@@ -71,7 +71,9 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
7171 goal : Goal < ' tcx , TraitPredicate < ' tcx > > ,
7272 impl_def_id : DefId ,
7373 ) {
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 ( ) ;
7577 let drcx = DeepRejectCtxt { treat_obligation_params : TreatParams :: AsPlaceholder } ;
7678 if iter:: zip ( goal. predicate . trait_ref . substs , impl_trait_ref. skip_binder ( ) . substs )
7779 . any ( |( goal, imp) | !drcx. generic_args_may_unify ( goal, imp) )
@@ -81,7 +83,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
8183
8284 acx. infcx . probe ( |_| {
8385 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) ;
8587
8688 let Ok ( InferOk { obligations, .. } ) = acx
8789 . infcx
@@ -92,8 +94,15 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
9294 else {
9395 return
9496 } ;
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 ( ) ;
97106
98107 let Ok ( certainty) = acx. cx . evaluate_all ( acx. infcx , nested_goals) else { return } ;
99108 acx. try_insert_candidate ( CandidateSource :: Impl ( impl_def_id) , certainty) ;
0 commit comments