@@ -300,17 +300,7 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
300
300
// We update both the head of this cycle to rerun its evaluation until
301
301
// we reach a fixpoint and all other cycle participants to make sure that
302
302
// their result does not get moved to the global cache.
303
- fn tag_cycle_participants (
304
- stack : & mut IndexVec < StackDepth , StackEntry < X > > ,
305
- usage_kind : Option < UsageKind > ,
306
- head : StackDepth ,
307
- ) {
308
- if let Some ( usage_kind) = usage_kind {
309
- stack[ head] . has_been_used =
310
- Some ( stack[ head] . has_been_used . map_or ( usage_kind, |prev| prev. merge ( usage_kind) ) ) ;
311
- }
312
- debug_assert ! ( stack[ head] . has_been_used. is_some( ) ) ;
313
-
303
+ fn tag_cycle_participants ( stack : & mut IndexVec < StackDepth , StackEntry < X > > , head : StackDepth ) {
314
304
// The current root of these cycles. Note that this may not be the final
315
305
// root in case a later goal depends on a goal higher up the stack.
316
306
let mut current_root = head;
@@ -403,7 +393,8 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
403
393
// We have a nested goal which is already in the provisional cache, use
404
394
// its result. We do not provide any usage kind as that should have been
405
395
// already set correctly while computing the cache entry.
406
- Self :: tag_cycle_participants ( & mut self . stack , None , entry. head ) ;
396
+ debug_assert ! ( self . stack[ entry. head] . has_been_used. is_some( ) ) ;
397
+ Self :: tag_cycle_participants ( & mut self . stack , entry. head ) ;
407
398
return entry. result ;
408
399
} else if let Some ( stack_depth) = cache_entry. stack_depth {
409
400
debug ! ( "encountered cycle with depth {stack_depth:?}" ) ;
@@ -416,11 +407,13 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
416
407
let is_coinductive_cycle = Self :: stack_coinductive_from ( cx, & self . stack , stack_depth) ;
417
408
let cycle_kind =
418
409
if is_coinductive_cycle { CycleKind :: Coinductive } else { CycleKind :: Inductive } ;
419
- Self :: tag_cycle_participants (
420
- & mut self . stack ,
421
- Some ( UsageKind :: Single ( cycle_kind) ) ,
422
- stack_depth,
410
+ let usage_kind = UsageKind :: Single ( cycle_kind) ;
411
+ self . stack [ stack_depth] . has_been_used = Some (
412
+ self . stack [ stack_depth]
413
+ . has_been_used
414
+ . map_or ( usage_kind, |prev| prev. merge ( usage_kind) ) ,
423
415
) ;
416
+ Self :: tag_cycle_participants ( & mut self . stack , stack_depth) ;
424
417
425
418
// Return the provisional result or, if we're in the first iteration,
426
419
// start with no constraints.
0 commit comments