Skip to content

Commit

Permalink
Auto merge of #124610 - nnethercote:typenum, r=<try>
Browse files Browse the repository at this point in the history
Speed up fast rejection

r? `@ghost`
  • Loading branch information
bors committed May 2, 2024
2 parents fcc06c8 + e0fd8dd commit 1e6d65e
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions compiler/rustc_middle/src/ty/fast_reject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ pub struct DeepRejectCtxt {
}

impl DeepRejectCtxt {
#[inline]
pub fn args_may_unify<'tcx>(
self,
obligation_args: GenericArgsRef<'tcx>,
Expand Down Expand Up @@ -329,21 +330,22 @@ impl DeepRejectCtxt {
}
}

#[inline(always)]
pub fn consts_may_unify(self, obligation_ct: ty::Const<'_>, impl_ct: ty::Const<'_>) -> bool {
match impl_ct.kind() {
let k = impl_ct.kind();
let impl_val = match k {
ty::ConstKind::Expr(_)
| ty::ConstKind::Param(_)
| ty::ConstKind::Unevaluated(_)
| ty::ConstKind::Error(_) => {
return true;
}
ty::ConstKind::Value(_) => {}
ty::ConstKind::Value(impl_val) => impl_val,
ty::ConstKind::Infer(_) | ty::ConstKind::Bound(..) | ty::ConstKind::Placeholder(_) => {
bug!("unexpected impl arg: {:?}", impl_ct)
}
}
};

let k = impl_ct.kind();
match obligation_ct.kind() {
ty::ConstKind::Param(_) => match self.treat_obligation_params {
TreatParams::ForLookup => false,
Expand All @@ -358,10 +360,7 @@ impl DeepRejectCtxt {
ty::ConstKind::Expr(_) | ty::ConstKind::Unevaluated(_) | ty::ConstKind::Error(_) => {
true
}
ty::ConstKind::Value(obl) => match k {
ty::ConstKind::Value(imp) => obl == imp,
_ => true,
},
ty::ConstKind::Value(obl_val) => obl_val == impl_val,

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

Expand Down

0 comments on commit 1e6d65e

Please sign in to comment.