@@ -1192,6 +1192,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1192
1192
ImplCandidate ( def_id) if tcx. constness ( def_id) == hir:: Constness :: Const => { }
1193
1193
// const param
1194
1194
ParamCandidate ( trait_pred) if trait_pred. is_const_if_const ( ) => { }
1195
+ // const projection
1196
+ ProjectionCandidate ( _, ty:: BoundConstness :: ConstIfConst ) => { }
1195
1197
// auto trait impl
1196
1198
AutoImplCandidate ( ..) => { }
1197
1199
// generator, this will raise error in other places
@@ -1399,7 +1401,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1399
1401
fn match_projection_obligation_against_definition_bounds (
1400
1402
& mut self ,
1401
1403
obligation : & TraitObligation < ' tcx > ,
1402
- ) -> smallvec:: SmallVec < [ usize ; 2 ] > {
1404
+ ) -> smallvec:: SmallVec < [ ( usize , ty :: BoundConstness ) ; 2 ] > {
1403
1405
let poly_trait_predicate = self . infcx ( ) . resolve_vars_if_possible ( obligation. predicate ) ;
1404
1406
let placeholder_trait_predicate =
1405
1407
self . infcx ( ) . replace_bound_vars_with_placeholders ( poly_trait_predicate) ;
@@ -1447,7 +1449,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1447
1449
_ => false ,
1448
1450
}
1449
1451
} ) {
1450
- return Some ( idx) ;
1452
+ return Some ( ( idx, pred . constness ) ) ;
1451
1453
}
1452
1454
}
1453
1455
None
@@ -1683,9 +1685,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1683
1685
| BuiltinCandidate { .. }
1684
1686
| TraitAliasCandidate ( ..)
1685
1687
| ObjectCandidate ( _)
1686
- | ProjectionCandidate ( _ ) ,
1688
+ | ProjectionCandidate ( .. ) ,
1687
1689
) => !is_global ( cand) ,
1688
- ( ObjectCandidate ( _) | ProjectionCandidate ( _ ) , ParamCandidate ( ref cand) ) => {
1690
+ ( ObjectCandidate ( _) | ProjectionCandidate ( .. ) , ParamCandidate ( ref cand) ) => {
1689
1691
// Prefer these to a global where-clause bound
1690
1692
// (see issue #50825).
1691
1693
is_global ( cand)
@@ -1707,20 +1709,20 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1707
1709
is_global ( cand) && other. evaluation . must_apply_modulo_regions ( )
1708
1710
}
1709
1711
1710
- ( ProjectionCandidate ( i) , ProjectionCandidate ( j) )
1712
+ ( ProjectionCandidate ( i, _ ) , ProjectionCandidate ( j, _ ) )
1711
1713
| ( ObjectCandidate ( i) , ObjectCandidate ( j) ) => {
1712
1714
// Arbitrarily pick the lower numbered candidate for backwards
1713
1715
// compatibility reasons. Don't let this affect inference.
1714
1716
i < j && !needs_infer
1715
1717
}
1716
- ( ObjectCandidate ( _) , ProjectionCandidate ( _ ) )
1717
- | ( ProjectionCandidate ( _ ) , ObjectCandidate ( _) ) => {
1718
+ ( ObjectCandidate ( _) , ProjectionCandidate ( .. ) )
1719
+ | ( ProjectionCandidate ( .. ) , ObjectCandidate ( _) ) => {
1718
1720
bug ! ( "Have both object and projection candidate" )
1719
1721
}
1720
1722
1721
1723
// Arbitrarily give projection and object candidates priority.
1722
1724
(
1723
- ObjectCandidate ( _) | ProjectionCandidate ( _ ) ,
1725
+ ObjectCandidate ( _) | ProjectionCandidate ( .. ) ,
1724
1726
ImplCandidate ( ..)
1725
1727
| ClosureCandidate
1726
1728
| GeneratorCandidate
@@ -1742,7 +1744,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1742
1744
| TraitUpcastingUnsizeCandidate ( _)
1743
1745
| BuiltinCandidate { .. }
1744
1746
| TraitAliasCandidate ( ..) ,
1745
- ObjectCandidate ( _) | ProjectionCandidate ( _ ) ,
1747
+ ObjectCandidate ( _) | ProjectionCandidate ( .. ) ,
1746
1748
) => false ,
1747
1749
1748
1750
( & ImplCandidate ( other_def) , & ImplCandidate ( victim_def) ) => {
0 commit comments