@@ -163,15 +163,15 @@ where
163
163
fn select_where_possible ( & mut self , infcx : & InferCtxt < ' tcx > ) -> Vec < E > {
164
164
assert_eq ! ( self . usable_in_snapshot, infcx. num_open_snapshots( ) ) ;
165
165
let mut errors = Vec :: new ( ) ;
166
- for i in 0 .. {
167
- if !infcx. tcx . recursion_limit ( ) . value_within_limit ( i) {
168
- self . obligations . on_fulfillment_overflow ( infcx) ;
169
- // Only return true errors that we have accumulated while processing.
170
- return errors;
171
- }
172
-
166
+ loop {
173
167
let mut has_changed = false ;
174
- for obligation in self . obligations . drain_pending ( |_| true ) {
168
+ for mut obligation in self . obligations . drain_pending ( |_| true ) {
169
+ if !infcx. tcx . recursion_limit ( ) . value_within_limit ( obligation. recursion_depth ) {
170
+ self . obligations . on_fulfillment_overflow ( infcx) ;
171
+ // Only return true errors that we have accumulated while processing.
172
+ return errors;
173
+ }
174
+
175
175
let goal = obligation. as_goal ( ) ;
176
176
let result = <& SolverDelegate < ' tcx > >:: from ( infcx)
177
177
. evaluate_root_goal ( goal, GenerateProofTree :: No , obligation. cause . span )
@@ -189,6 +189,13 @@ where
189
189
} ;
190
190
191
191
if changed == HasChanged :: Yes {
192
+ // We increment the recursion depth here to track the number of times
193
+ // this goal has resulted in inference progress. This doesn't precisely
194
+ // model the way that we track recursion depth in the old solver due
195
+ // to the fact that we only process root obligations, but it is a good
196
+ // approximation and should only result in fulfillment overflow in
197
+ // pathological cases.
198
+ obligation. recursion_depth += 1 ;
192
199
has_changed = true ;
193
200
}
194
201
0 commit comments