@@ -1192,6 +1192,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
11921192 ImplCandidate ( def_id) if tcx. constness ( def_id) == hir:: Constness :: Const => { }
11931193 // const param
11941194 ParamCandidate ( trait_pred) if trait_pred. is_const_if_const ( ) => { }
1195+ // const projection
1196+ ProjectionCandidate ( _, ty:: BoundConstness :: ConstIfConst ) => { }
11951197 // auto trait impl
11961198 AutoImplCandidate ( ..) => { }
11971199 // generator, this will raise error in other places
@@ -1399,7 +1401,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
13991401 fn match_projection_obligation_against_definition_bounds (
14001402 & mut self ,
14011403 obligation : & TraitObligation < ' tcx > ,
1402- ) -> smallvec:: SmallVec < [ usize ; 2 ] > {
1404+ ) -> smallvec:: SmallVec < [ ( usize , ty :: BoundConstness ) ; 2 ] > {
14031405 let poly_trait_predicate = self . infcx ( ) . resolve_vars_if_possible ( obligation. predicate ) ;
14041406 let placeholder_trait_predicate =
14051407 self . infcx ( ) . replace_bound_vars_with_placeholders ( poly_trait_predicate) ;
@@ -1447,7 +1449,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
14471449 _ => false ,
14481450 }
14491451 } ) {
1450- return Some ( idx) ;
1452+ return Some ( ( idx, pred . constness ) ) ;
14511453 }
14521454 }
14531455 None
@@ -1683,9 +1685,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
16831685 | BuiltinCandidate { .. }
16841686 | TraitAliasCandidate ( ..)
16851687 | ObjectCandidate ( _)
1686- | ProjectionCandidate ( _ ) ,
1688+ | ProjectionCandidate ( .. ) ,
16871689 ) => !is_global ( cand) ,
1688- ( ObjectCandidate ( _) | ProjectionCandidate ( _ ) , ParamCandidate ( ref cand) ) => {
1690+ ( ObjectCandidate ( _) | ProjectionCandidate ( .. ) , ParamCandidate ( ref cand) ) => {
16891691 // Prefer these to a global where-clause bound
16901692 // (see issue #50825).
16911693 is_global ( cand)
@@ -1707,20 +1709,20 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
17071709 is_global ( cand) && other. evaluation . must_apply_modulo_regions ( )
17081710 }
17091711
1710- ( ProjectionCandidate ( i) , ProjectionCandidate ( j) )
1712+ ( ProjectionCandidate ( i, _ ) , ProjectionCandidate ( j, _ ) )
17111713 | ( ObjectCandidate ( i) , ObjectCandidate ( j) ) => {
17121714 // Arbitrarily pick the lower numbered candidate for backwards
17131715 // compatibility reasons. Don't let this affect inference.
17141716 i < j && !needs_infer
17151717 }
1716- ( ObjectCandidate ( _) , ProjectionCandidate ( _ ) )
1717- | ( ProjectionCandidate ( _ ) , ObjectCandidate ( _) ) => {
1718+ ( ObjectCandidate ( _) , ProjectionCandidate ( .. ) )
1719+ | ( ProjectionCandidate ( .. ) , ObjectCandidate ( _) ) => {
17181720 bug ! ( "Have both object and projection candidate" )
17191721 }
17201722
17211723 // Arbitrarily give projection and object candidates priority.
17221724 (
1723- ObjectCandidate ( _) | ProjectionCandidate ( _ ) ,
1725+ ObjectCandidate ( _) | ProjectionCandidate ( .. ) ,
17241726 ImplCandidate ( ..)
17251727 | ClosureCandidate
17261728 | GeneratorCandidate
@@ -1742,7 +1744,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
17421744 | TraitUpcastingUnsizeCandidate ( _)
17431745 | BuiltinCandidate { .. }
17441746 | TraitAliasCandidate ( ..) ,
1745- ObjectCandidate ( _) | ProjectionCandidate ( _ ) ,
1747+ ObjectCandidate ( _) | ProjectionCandidate ( .. ) ,
17461748 ) => false ,
17471749
17481750 ( & ImplCandidate ( other_def) , & ImplCandidate ( victim_def) ) => {
0 commit comments