@@ -10,8 +10,8 @@ use rustc_infer::traits::{
10
10
FromSolverError , PredicateObligation , PredicateObligations , TraitEngine ,
11
11
} ;
12
12
use rustc_middle:: ty:: {
13
- self , DelayedSet , Ty , TyCtxt , TypeSuperVisitable , TypeVisitable , TypeVisitableExt , TypeVisitor ,
14
- TypingMode ,
13
+ self , DelayedSet , Ty , TyCtxt , TyVid , TypeSuperVisitable , TypeVisitable , TypeVisitableExt ,
14
+ TypeVisitor , TypingMode ,
15
15
} ;
16
16
use rustc_next_trait_solver:: delegate:: SolverDelegate as _;
17
17
use rustc_next_trait_solver:: solve:: {
@@ -85,8 +85,27 @@ impl<'tcx> ObligationStorage<'tcx> {
85
85
obligations. extend ( self . overflowed . iter ( ) . cloned ( ) ) ;
86
86
obligations
87
87
}
88
+ fn clone_pending_potentially_referencing_sub_root (
89
+ & self ,
90
+ vid : TyVid ,
91
+ ) -> PredicateObligations < ' tcx > {
92
+ let mut obligations: PredicateObligations < ' tcx > = self
93
+ . pending
94
+ . iter ( )
95
+ . filter ( |( _, stalled_on) | {
96
+ if let Some ( stalled_on) = stalled_on {
97
+ stalled_on. sub_roots . iter ( ) . any ( |& r| r == vid)
98
+ } else {
99
+ true
100
+ }
101
+ } )
102
+ . map ( |( o, _) | o. clone ( ) )
103
+ . collect ( ) ;
104
+ obligations. extend ( self . overflowed . iter ( ) . cloned ( ) ) ;
105
+ obligations
106
+ }
88
107
89
- fn drain_pending (
108
+ fn drain_pending_ignoring_overflowed (
90
109
& mut self ,
91
110
cond : impl Fn ( & PredicateObligation < ' tcx > ) -> bool ,
92
111
) -> PendingObligations < ' tcx > {
@@ -184,7 +203,9 @@ where
184
203
let mut errors = Vec :: new ( ) ;
185
204
loop {
186
205
let mut any_changed = false ;
187
- for ( mut obligation, stalled_on) in self . obligations . drain_pending ( |_| true ) {
206
+ for ( mut obligation, stalled_on) in
207
+ self . obligations . drain_pending_ignoring_overflowed ( |_| true )
208
+ {
188
209
if !infcx. tcx . recursion_limit ( ) . value_within_limit ( obligation. recursion_depth ) {
189
210
self . obligations . on_fulfillment_overflow ( infcx) ;
190
211
// Only return true errors that we have accumulated while processing.
@@ -277,6 +298,12 @@ where
277
298
fn pending_obligations ( & self ) -> PredicateObligations < ' tcx > {
278
299
self . obligations . clone_pending ( )
279
300
}
301
+ fn pending_obligations_potentially_referencing_sub_root (
302
+ & self ,
303
+ vid : ty:: TyVid ,
304
+ ) -> PredicateObligations < ' tcx > {
305
+ self . obligations . clone_pending_potentially_referencing_sub_root ( vid)
306
+ }
280
307
281
308
fn drain_stalled_obligations_for_coroutines (
282
309
& mut self ,
@@ -297,7 +324,7 @@ where
297
324
}
298
325
299
326
self . obligations
300
- . drain_pending ( |obl| {
327
+ . drain_pending_ignoring_overflowed ( |obl| {
301
328
infcx. probe ( |_| {
302
329
infcx
303
330
. visit_proof_tree (
0 commit comments