@@ -1331,34 +1331,44 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
1331
1331
if first_cycle {
1332
1332
first_cycle = false ;
1333
1333
} else {
1334
- while let Some ( & ( stack_depth, node_id, info) ) = added_goals. peek ( ) {
1335
- if let Some ( existing_entry) = self . stack . get ( stack_depth) {
1336
- let provisional_result = provisional_results. get ( & stack_depth) . copied ( ) ;
1337
- // Issue: changing the provisional result means we must not rebase, but instead
1338
- // invalidate.
1339
- if existing_entry. node_id == node_id
1340
- && provisional_result == existing_entry. provisional_result
1341
- {
1342
- debug_assert_eq ! ( existing_entry. input, info. input) ;
1343
- debug_assert_eq ! (
1344
- existing_entry. step_kind_from_parent,
1345
- info. step_kind_from_parent
1346
- ) ;
1347
- let _ = added_goals. next ( ) . unwrap ( ) ;
1348
- } else {
1349
- truncate_stack (
1350
- & mut self . stack ,
1351
- & mut self . provisional_cache ,
1352
- StackDepth :: from_usize ( stack_depth. as_usize ( ) ) ,
1353
- ) ;
1354
- break ;
1355
- }
1356
- } else {
1357
- if only_evaluated_leaf {
1358
- break ;
1334
+ if added_goals. peek ( ) . is_none ( ) {
1335
+ if self . stack . len ( ) > current_stack_len {
1336
+ truncate_stack (
1337
+ & mut self . stack ,
1338
+ & mut self . provisional_cache ,
1339
+ StackDepth :: from_usize ( current_stack_len) ,
1340
+ ) ;
1341
+ }
1342
+ } else {
1343
+ while let Some ( & ( stack_depth, node_id, info) ) = added_goals. peek ( ) {
1344
+ if let Some ( existing_entry) = self . stack . get ( stack_depth) {
1345
+ let provisional_result = provisional_results. get ( & stack_depth) . copied ( ) ;
1346
+ // Issue: changing the provisional result means we must not rebase, but instead
1347
+ // invalidate.
1348
+ if existing_entry. node_id == node_id
1349
+ && provisional_result == existing_entry. provisional_result
1350
+ {
1351
+ debug_assert_eq ! ( existing_entry. input, info. input) ;
1352
+ debug_assert_eq ! (
1353
+ existing_entry. step_kind_from_parent,
1354
+ info. step_kind_from_parent
1355
+ ) ;
1356
+ let _ = added_goals. next ( ) . unwrap ( ) ;
1357
+ } else {
1358
+ truncate_stack (
1359
+ & mut self . stack ,
1360
+ & mut self . provisional_cache ,
1361
+ stack_depth,
1362
+ ) ;
1363
+ break ;
1364
+ }
1359
1365
} else {
1360
- debug ! ( parent = ?info. input, cycle = ?added_goals. last( ) . unwrap( ) , "reevaluated parent, skip cycle" ) ;
1361
- continue ' outer;
1366
+ if only_evaluated_leaf {
1367
+ break ;
1368
+ } else {
1369
+ debug ! ( parent = ?info. input, cycle = ?added_goals. last( ) . unwrap( ) , "reevaluated parent, skip cycle" ) ;
1370
+ continue ' outer;
1371
+ }
1362
1372
}
1363
1373
}
1364
1374
}
0 commit comments