@@ -584,15 +584,16 @@ impl<O: ForestObligation> ObligationForest<O> {
584
584
// function call.
585
585
if let NodeState :: Success ( waiting) = node. state . get ( ) {
586
586
if !self . is_still_waiting ( waiting) {
587
- self . find_cycles_from_node ( & mut stack, processor, index) ;
587
+ self . find_cycles_from_node ( & mut stack, processor, index, index ) ;
588
588
}
589
589
}
590
590
}
591
591
592
592
debug_assert ! ( stack. is_empty( ) ) ;
593
593
}
594
594
595
- fn find_cycles_from_node < P > ( & self , stack : & mut Vec < usize > , processor : & mut P , index : usize )
595
+ fn find_cycles_from_node < P > ( & self , stack : & mut Vec < usize > , processor : & mut P , min_index : usize ,
596
+ index : usize )
596
597
where P : ObligationProcessor < Obligation =O >
597
598
{
598
599
let node = & self . nodes [ index] ;
@@ -601,8 +602,11 @@ impl<O: ForestObligation> ObligationForest<O> {
601
602
match stack. iter ( ) . rposition ( |& n| n == index) {
602
603
None => {
603
604
stack. push ( index) ;
604
- for & index in node. dependents . iter ( ) {
605
- self . find_cycles_from_node ( stack, processor, index) ;
605
+ for & dep_index in node. dependents . iter ( ) {
606
+ // The index check avoids re-considering a node.
607
+ if dep_index >= min_index {
608
+ self . find_cycles_from_node ( stack, processor, min_index, dep_index) ;
609
+ }
606
610
}
607
611
stack. pop ( ) ;
608
612
}
0 commit comments