Skip to content

Commit 1e6d65e

Browse files
committed
Auto merge of rust-lang#124610 - nnethercote:typenum, r=<try>
Speed up fast rejection r? `@ghost`
2 parents fcc06c8 + e0fd8dd commit 1e6d65e

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

compiler/rustc_middle/src/ty/fast_reject.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ pub struct DeepRejectCtxt {
167167
}
168168

169169
impl DeepRejectCtxt {
170+
#[inline]
170171
pub fn args_may_unify<'tcx>(
171172
self,
172173
obligation_args: GenericArgsRef<'tcx>,
@@ -329,21 +330,22 @@ impl DeepRejectCtxt {
329330
}
330331
}
331332

333+
#[inline(always)]
332334
pub fn consts_may_unify(self, obligation_ct: ty::Const<'_>, impl_ct: ty::Const<'_>) -> bool {
333-
match impl_ct.kind() {
335+
let k = impl_ct.kind();
336+
let impl_val = match k {
334337
ty::ConstKind::Expr(_)
335338
| ty::ConstKind::Param(_)
336339
| ty::ConstKind::Unevaluated(_)
337340
| ty::ConstKind::Error(_) => {
338341
return true;
339342
}
340-
ty::ConstKind::Value(_) => {}
343+
ty::ConstKind::Value(impl_val) => impl_val,
341344
ty::ConstKind::Infer(_) | ty::ConstKind::Bound(..) | ty::ConstKind::Placeholder(_) => {
342345
bug!("unexpected impl arg: {:?}", impl_ct)
343346
}
344-
}
347+
};
345348

346-
let k = impl_ct.kind();
347349
match obligation_ct.kind() {
348350
ty::ConstKind::Param(_) => match self.treat_obligation_params {
349351
TreatParams::ForLookup => false,
@@ -358,10 +360,7 @@ impl DeepRejectCtxt {
358360
ty::ConstKind::Expr(_) | ty::ConstKind::Unevaluated(_) | ty::ConstKind::Error(_) => {
359361
true
360362
}
361-
ty::ConstKind::Value(obl) => match k {
362-
ty::ConstKind::Value(imp) => obl == imp,
363-
_ => true,
364-
},
363+
ty::ConstKind::Value(obl_val) => obl_val == impl_val,
365364

366365
ty::ConstKind::Infer(_) => true,
367366

0 commit comments

Comments
 (0)