@@ -3,6 +3,7 @@ use std::marker::PhantomData;
3
3
use rustc_data_structures:: obligation_forest:: {
4
4
Error , ForestObligation , ObligationForest , ObligationProcessor , Outcome , ProcessResult ,
5
5
} ;
6
+ use rustc_hir:: def_id:: LocalDefId ;
6
7
use rustc_infer:: infer:: DefineOpaqueTypes ;
7
8
use rustc_infer:: traits:: {
8
9
FromSolverError , PolyTraitObligation , PredicateObligations , ProjectionCacheKey , SelectionError ,
@@ -12,8 +13,10 @@ use rustc_middle::bug;
12
13
use rustc_middle:: ty:: abstract_const:: NotConstEvaluatable ;
13
14
use rustc_middle:: ty:: error:: { ExpectedFound , TypeError } ;
14
15
use 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,
16
18
} ;
19
+ use rustc_span:: DUMMY_SP ;
17
20
use thin_vec:: { ThinVec , thin_vec} ;
18
21
use tracing:: { debug, debug_span, instrument} ;
19
22
@@ -26,6 +29,7 @@ use super::{
26
29
} ;
27
30
use crate :: error_reporting:: InferCtxtErrorExt ;
28
31
use crate :: infer:: { InferCtxt , TyOrConstInferVar } ;
32
+ use crate :: solve:: StalledOnCoroutines ;
29
33
use crate :: traits:: normalize:: normalize_with_depth_to;
30
34
use crate :: traits:: project:: { PolyProjectionObligation , ProjectionCacheKeyExt as _} ;
31
35
use crate :: traits:: query:: evaluate_obligation:: InferCtxtExt ;
@@ -168,15 +172,33 @@ where
168
172
& mut self ,
169
173
infcx : & InferCtxt < ' tcx > ,
170
174
) -> 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
+ } ;
173
194
let outcome: Outcome < _ , _ > = self . predicates . process_obligations ( & mut processor) ;
174
195
assert ! ( outcome. errors. is_empty( ) ) ;
175
196
return processor. removed_predicates ;
176
197
177
198
struct DrainProcessor < ' a , ' tcx > {
178
199
infcx : & ' a InferCtxt < ' tcx > ,
179
200
removed_predicates : PredicateObligations < ' tcx > ,
201
+ stalled_coroutines : & ' tcx ty:: List < LocalDefId > ,
180
202
}
181
203
182
204
impl < ' tcx > ObligationProcessor for DrainProcessor < ' _ , ' tcx > {
@@ -185,10 +207,14 @@ where
185
207
type OUT = Outcome < Self :: Obligation , Self :: Error > ;
186
208
187
209
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 ( )
192
218
}
193
219
194
220
fn process_obligation (
0 commit comments