@@ -3,6 +3,7 @@ use std::marker::PhantomData;
33use  rustc_data_structures:: obligation_forest:: { 
44    Error ,  ForestObligation ,  ObligationForest ,  ObligationProcessor ,  Outcome ,  ProcessResult , 
55} ; 
6+ use  rustc_hir:: def_id:: LocalDefId ; 
67use  rustc_infer:: infer:: DefineOpaqueTypes ; 
78use  rustc_infer:: traits:: { 
89    FromSolverError ,  PolyTraitObligation ,  PredicateObligations ,  ProjectionCacheKey ,  SelectionError , 
@@ -12,8 +13,10 @@ use rustc_middle::bug;
1213use  rustc_middle:: ty:: abstract_const:: NotConstEvaluatable ; 
1314use  rustc_middle:: ty:: error:: { ExpectedFound ,  TypeError } ; 
1415use  rustc_middle:: ty:: { 
15-     self ,  Binder ,  Const ,  GenericArgsRef ,  TypeVisitableExt ,  TypingMode ,  may_use_unstable_feature, 
16+     self ,  Binder ,  Const ,  GenericArgsRef ,  TypeVisitable ,  TypeVisitableExt ,  TypingMode , 
17+     may_use_unstable_feature, 
1618} ; 
19+ use  rustc_span:: DUMMY_SP ; 
1720use  thin_vec:: { ThinVec ,  thin_vec} ; 
1821use  tracing:: { debug,  debug_span,  instrument} ; 
1922
@@ -26,6 +29,7 @@ use super::{
2629} ; 
2730use  crate :: error_reporting:: InferCtxtErrorExt ; 
2831use  crate :: infer:: { InferCtxt ,  TyOrConstInferVar } ; 
32+ use  crate :: solve:: StalledOnCoroutines ; 
2933use  crate :: traits:: normalize:: normalize_with_depth_to; 
3034use  crate :: traits:: project:: { PolyProjectionObligation ,  ProjectionCacheKeyExt  as  _} ; 
3135use  crate :: traits:: query:: evaluate_obligation:: InferCtxtExt ; 
@@ -168,15 +172,33 @@ where
168172        & mut  self , 
169173        infcx :  & InferCtxt < ' tcx > , 
170174    )  -> PredicateObligations < ' tcx >  { 
171-         let  mut  processor =
172-             DrainProcessor  {  removed_predicates :  PredicateObligations :: new ( ) ,  infcx } ; 
175+         let  stalled_coroutines = match  infcx. typing_mode ( )  { 
176+             TypingMode :: Analysis  {  defining_opaque_types_and_generators }  => { 
177+                 defining_opaque_types_and_generators
178+             } 
179+             TypingMode :: Coherence 
180+             | TypingMode :: Borrowck  {  defining_opaque_types :  _ } 
181+             | TypingMode :: PostBorrowckAnalysis  {  defined_opaque_types :  _ } 
182+             | TypingMode :: PostAnalysis  => return  Default :: default ( ) , 
183+         } ; 
184+ 
185+         if  stalled_coroutines. is_empty ( )  { 
186+             return  Default :: default ( ) ; 
187+         } 
188+ 
189+         let  mut  processor = DrainProcessor  { 
190+             infcx, 
191+             removed_predicates :  PredicateObligations :: new ( ) , 
192+             stalled_coroutines, 
193+         } ; 
173194        let  outcome:  Outcome < _ ,  _ >  = self . predicates . process_obligations ( & mut  processor) ; 
174195        assert ! ( outcome. errors. is_empty( ) ) ; 
175196        return  processor. removed_predicates ; 
176197
177198        struct  DrainProcessor < ' a ,  ' tcx >  { 
178199            infcx :  & ' a  InferCtxt < ' tcx > , 
179200            removed_predicates :  PredicateObligations < ' tcx > , 
201+             stalled_coroutines :  & ' tcx  ty:: List < LocalDefId > , 
180202        } 
181203
182204        impl < ' tcx >  ObligationProcessor  for  DrainProcessor < ' _ ,  ' tcx >  { 
@@ -185,10 +207,14 @@ where
185207            type  OUT  = Outcome < Self :: Obligation ,  Self :: Error > ; 
186208
187209            fn  needs_process_obligation ( & self ,  pending_obligation :  & Self :: Obligation )  -> bool  { 
188-                 pending_obligation
189-                     . stalled_on 
190-                     . iter ( ) 
191-                     . any ( |& var| self . infcx . ty_or_const_infer_var_changed ( var) ) 
210+                 self . infcx 
211+                     . resolve_vars_if_possible ( pending_obligation. obligation . predicate ) 
212+                     . visit_with ( & mut  StalledOnCoroutines  { 
213+                         stalled_coroutines :  self . stalled_coroutines , 
214+                         span :  DUMMY_SP , 
215+                         cache :  Default :: default ( ) , 
216+                     } ) 
217+                     . is_break ( ) 
192218            } 
193219
194220            fn  process_obligation ( 
0 commit comments