@@ -1089,10 +1089,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
10891089 ImplCandidate ( def_id)
10901090 if tcx. impl_constness ( def_id) == hir:: Constness :: Const => { }
10911091 // const param
1092- ParamCandidate ( (
1093- ty:: ConstnessAnd { constness : ty:: BoundConstness :: ConstIfConst , .. } ,
1094- _,
1095- ) ) => { }
1092+ ParamCandidate ( trait_pred)
1093+ if trait_pred. skip_binder ( ) . constness
1094+ == ty:: BoundConstness :: ConstIfConst => { }
10961095 // auto trait impl
10971096 AutoImplCandidate ( ..) => { }
10981097 // generator, this will raise error in other places
@@ -1474,7 +1473,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
14741473 // Check if a bound would previously have been removed when normalizing
14751474 // the param_env so that it can be given the lowest priority. See
14761475 // #50825 for the motivation for this.
1477- let is_global = |cand : & ty:: PolyTraitRef < ' tcx > | {
1476+ let is_global = |cand : & ty:: PolyTraitPredicate < ' tcx > | {
14781477 cand. is_global ( self . infcx . tcx ) && !cand. has_late_bound_regions ( )
14791478 } ;
14801479
@@ -1507,25 +1506,22 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
15071506 | ConstDropCandidate ,
15081507 ) => false ,
15091508
1510- (
1511- ParamCandidate ( ( other, other_polarity) ) ,
1512- ParamCandidate ( ( victim, victim_polarity) ) ,
1513- ) => {
1514- let same_except_bound_vars = other. value . skip_binder ( )
1515- == victim. value . skip_binder ( )
1516- && other. constness == victim. constness
1517- && other_polarity == victim_polarity
1518- && !other. value . skip_binder ( ) . has_escaping_bound_vars ( ) ;
1509+ ( ParamCandidate ( other) , ParamCandidate ( victim) ) => {
1510+ let same_except_bound_vars = other. skip_binder ( ) . trait_ref
1511+ == victim. skip_binder ( ) . trait_ref
1512+ && other. skip_binder ( ) . constness == victim. skip_binder ( ) . constness
1513+ && other. skip_binder ( ) . polarity == victim. skip_binder ( ) . polarity
1514+ && !other. skip_binder ( ) . trait_ref . has_escaping_bound_vars ( ) ;
15191515 if same_except_bound_vars {
15201516 // See issue #84398. In short, we can generate multiple ParamCandidates which are
15211517 // the same except for unused bound vars. Just pick the one with the fewest bound vars
15221518 // or the current one if tied (they should both evaluate to the same answer). This is
15231519 // probably best characterized as a "hack", since we might prefer to just do our
15241520 // best to *not* create essentially duplicate candidates in the first place.
1525- other. value . bound_vars ( ) . len ( ) <= victim. value . bound_vars ( ) . len ( )
1526- } else if other. value == victim. value
1527- && victim. constness == ty:: BoundConstness :: NotConst
1528- && other_polarity == victim_polarity
1521+ other. bound_vars ( ) . len ( ) <= victim. bound_vars ( ) . len ( )
1522+ } else if other. skip_binder ( ) . trait_ref == victim. skip_binder ( ) . trait_ref
1523+ && victim. skip_binder ( ) . constness == ty:: BoundConstness :: NotConst
1524+ && other . skip_binder ( ) . polarity == victim . skip_binder ( ) . polarity
15291525 {
15301526 // Drop otherwise equivalent non-const candidates in favor of const candidates.
15311527 true
@@ -1555,11 +1551,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
15551551 | TraitAliasCandidate ( ..)
15561552 | ObjectCandidate ( _)
15571553 | ProjectionCandidate ( _) ,
1558- ) => !is_global ( & cand. 0 . value ) ,
1554+ ) => !is_global ( cand) ,
15591555 ( ObjectCandidate ( _) | ProjectionCandidate ( _) , ParamCandidate ( ref cand) ) => {
15601556 // Prefer these to a global where-clause bound
15611557 // (see issue #50825).
1562- is_global ( & cand. 0 . value )
1558+ is_global ( cand)
15631559 }
15641560 (
15651561 ImplCandidate ( _)
@@ -1575,7 +1571,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
15751571 ) => {
15761572 // Prefer these to a global where-clause bound
15771573 // (see issue #50825).
1578- is_global ( & cand. 0 . value ) && other. evaluation . must_apply_modulo_regions ( )
1574+ is_global ( cand) && other. evaluation . must_apply_modulo_regions ( )
15791575 }
15801576
15811577 ( ProjectionCandidate ( i) , ProjectionCandidate ( j) )
0 commit comments