@@ -666,7 +666,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
666
666
) ;
667
667
} else if !suggested {
668
668
// Can't show anything else useful, try to find similar impls.
669
- let impl_candidates = self . find_similar_impl_candidates ( trait_ref ) ;
669
+ let impl_candidates = self . find_similar_impl_candidates ( trait_predicate ) ;
670
670
if !self . report_similar_impl_candidates (
671
671
impl_candidates,
672
672
trait_ref,
@@ -701,7 +701,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
701
701
{
702
702
let trait_ref = trait_pred. to_poly_trait_ref ( ) ;
703
703
let impl_candidates =
704
- self . find_similar_impl_candidates ( trait_ref ) ;
704
+ self . find_similar_impl_candidates ( trait_pred ) ;
705
705
self . report_similar_impl_candidates (
706
706
impl_candidates,
707
707
trait_ref,
@@ -1325,7 +1325,7 @@ trait InferCtxtPrivExt<'hir, 'tcx> {
1325
1325
1326
1326
fn find_similar_impl_candidates (
1327
1327
& self ,
1328
- trait_ref : ty:: PolyTraitRef < ' tcx > ,
1328
+ trait_pred : ty:: PolyTraitPredicate < ' tcx > ,
1329
1329
) -> Vec < ImplCandidate < ' tcx > > ;
1330
1330
1331
1331
fn report_similar_impl_candidates (
@@ -1694,18 +1694,22 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
1694
1694
1695
1695
fn find_similar_impl_candidates (
1696
1696
& self ,
1697
- trait_ref : ty:: PolyTraitRef < ' tcx > ,
1697
+ trait_pred : ty:: PolyTraitPredicate < ' tcx > ,
1698
1698
) -> Vec < ImplCandidate < ' tcx > > {
1699
1699
self . tcx
1700
- . all_impls ( trait_ref . def_id ( ) )
1700
+ . all_impls ( trait_pred . def_id ( ) )
1701
1701
. filter_map ( |def_id| {
1702
- if self . tcx . impl_polarity ( def_id) == ty:: ImplPolarity :: Negative {
1702
+ if self . tcx . impl_polarity ( def_id) == ty:: ImplPolarity :: Negative
1703
+ || !trait_pred
1704
+ . skip_binder ( )
1705
+ . is_constness_satisfied_by ( self . tcx . constness ( def_id) )
1706
+ {
1703
1707
return None ;
1704
1708
}
1705
1709
1706
1710
let imp = self . tcx . impl_trait_ref ( def_id) . unwrap ( ) ;
1707
1711
1708
- self . fuzzy_match_tys ( trait_ref . skip_binder ( ) . self_ty ( ) , imp. self_ty ( ) , false )
1712
+ self . fuzzy_match_tys ( trait_pred . skip_binder ( ) . self_ty ( ) , imp. self_ty ( ) , false )
1709
1713
. map ( |similarity| ImplCandidate { trait_ref : imp, similarity } )
1710
1714
} )
1711
1715
. collect ( )
0 commit comments