@@ -71,7 +71,9 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
71
71
goal : Goal < ' tcx , TraitPredicate < ' tcx > > ,
72
72
impl_def_id : DefId ,
73
73
) {
74
- let impl_trait_ref = acx. cx . tcx . bound_impl_trait_ref ( impl_def_id) . unwrap ( ) ;
74
+ let tcx = acx. cx . tcx ;
75
+
76
+ let impl_trait_ref = tcx. bound_impl_trait_ref ( impl_def_id) . unwrap ( ) ;
75
77
let drcx = DeepRejectCtxt { treat_obligation_params : TreatParams :: AsPlaceholder } ;
76
78
if iter:: zip ( goal. predicate . trait_ref . substs , impl_trait_ref. skip_binder ( ) . substs )
77
79
. any ( |( goal, imp) | !drcx. generic_args_may_unify ( goal, imp) )
@@ -81,7 +83,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
81
83
82
84
acx. infcx . probe ( |_| {
83
85
let impl_substs = acx. infcx . fresh_substs_for_item ( DUMMY_SP , impl_def_id) ;
84
- let impl_trait_ref = impl_trait_ref. subst ( acx . cx . tcx , impl_substs) ;
86
+ let impl_trait_ref = impl_trait_ref. subst ( tcx, impl_substs) ;
85
87
86
88
let Ok ( InferOk { obligations, .. } ) = acx
87
89
. infcx
@@ -92,8 +94,15 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
92
94
else {
93
95
return
94
96
} ;
95
-
96
- let nested_goals = obligations. into_iter ( ) . map ( |o| o. into ( ) ) . collect ( ) ;
97
+ let where_clause_bounds = tcx
98
+ . predicates_of ( impl_def_id)
99
+ . instantiate ( tcx, impl_substs)
100
+ . predicates
101
+ . into_iter ( )
102
+ . map ( |pred| goal. with ( tcx, pred) ) ;
103
+
104
+ let nested_goals =
105
+ obligations. into_iter ( ) . map ( |o| o. into ( ) ) . chain ( where_clause_bounds) . collect ( ) ;
97
106
98
107
let Ok ( certainty) = acx. cx . evaluate_all ( acx. infcx , nested_goals) else { return } ;
99
108
acx. try_insert_candidate ( CandidateSource :: Impl ( impl_def_id) , certainty) ;
0 commit comments