Skip to content

Commit 29ff7f0

Browse files
committed
Tweak consts_may_unify.
`ConstKind::Value` is the only variant where control flow leaves the first match on `impl_ct.kind()`, so there is no need for a second match on the same expression later on.
1 parent 4f81879 commit 29ff7f0

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

compiler/rustc_middle/src/ty/fast_reject.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -330,20 +330,20 @@ impl DeepRejectCtxt {
330330
}
331331

332332
pub fn consts_may_unify(self, obligation_ct: ty::Const<'_>, impl_ct: ty::Const<'_>) -> bool {
333-
match impl_ct.kind() {
333+
let k = impl_ct.kind();
334+
let impl_val = match k {
334335
ty::ConstKind::Expr(_)
335336
| ty::ConstKind::Param(_)
336337
| ty::ConstKind::Unevaluated(_)
337338
| ty::ConstKind::Error(_) => {
338339
return true;
339340
}
340-
ty::ConstKind::Value(_) => {}
341+
ty::ConstKind::Value(impl_val) => impl_val,
341342
ty::ConstKind::Infer(_) | ty::ConstKind::Bound(..) | ty::ConstKind::Placeholder(_) => {
342343
bug!("unexpected impl arg: {:?}", impl_ct)
343344
}
344-
}
345+
};
345346

346-
let k = impl_ct.kind();
347347
match obligation_ct.kind() {
348348
ty::ConstKind::Param(_) => match self.treat_obligation_params {
349349
TreatParams::ForLookup => false,
@@ -358,10 +358,7 @@ impl DeepRejectCtxt {
358358
ty::ConstKind::Expr(_) | ty::ConstKind::Unevaluated(_) | ty::ConstKind::Error(_) => {
359359
true
360360
}
361-
ty::ConstKind::Value(obl) => match k {
362-
ty::ConstKind::Value(imp) => obl == imp,
363-
_ => true,
364-
},
361+
ty::ConstKind::Value(obl_val) => obl_val == impl_val,
365362

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

0 commit comments

Comments
 (0)