@@ -91,13 +91,14 @@ struct Node<O> {
9191 obligation : O ,
9292 state : Cell < NodeState > ,
9393
94- /// Obligations that depend on this obligation for their
95- /// completion. They must all be in a non-pending state.
96- dependents : Vec < NodeIndex > ,
9794 /// The parent of a node - the original obligation of
9895 /// which it is a subobligation. Except for error reporting,
99- /// this is just another member of `dependents`.
96+ /// it is just like any member of `dependents`.
10097 parent : Option < NodeIndex > ,
98+
99+ /// Obligations that depend on this obligation for their
100+ /// completion. They must all be in a non-pending state.
101+ dependents : Vec < NodeIndex > ,
101102}
102103
103104/// The state of one node in some tree within the forest. This
@@ -383,10 +384,7 @@ impl<O: ForestObligation> ObligationForest<O> {
383384 NodeState :: Success => {
384385 node. state . set ( NodeState :: OnDfsStack ) ;
385386 stack. push ( index) ;
386- if let Some ( parent) = node. parent {
387- self . find_cycles_from_node ( stack, processor, parent. get ( ) ) ;
388- }
389- for dependent in & node. dependents {
387+ for dependent in node. parent . iter ( ) . chain ( node. dependents . iter ( ) ) {
390388 self . find_cycles_from_node ( stack, processor, dependent. get ( ) ) ;
391389 }
392390 stack. pop ( ) ;
@@ -430,7 +428,7 @@ impl<O: ForestObligation> ObligationForest<O> {
430428 }
431429
432430 error_stack. extend (
433- node. dependents . iter ( ) . cloned ( ) . chain ( node. parent ) . map ( |x| x. get ( ) )
431+ node. parent . iter ( ) . chain ( node. dependents . iter ( ) ) . map ( |x| x. get ( ) )
434432 ) ;
435433 }
436434
@@ -440,11 +438,7 @@ impl<O: ForestObligation> ObligationForest<O> {
440438
441439 #[ inline]
442440 fn mark_neighbors_as_waiting_from ( & self , node : & Node < O > ) {
443- if let Some ( parent) = node. parent {
444- self . mark_as_waiting_from ( & self . nodes [ parent. get ( ) ] ) ;
445- }
446-
447- for dependent in & node. dependents {
441+ for dependent in node. parent . iter ( ) . chain ( node. dependents . iter ( ) ) {
448442 self . mark_as_waiting_from ( & self . nodes [ dependent. get ( ) ] ) ;
449443 }
450444 }
@@ -591,8 +585,8 @@ impl<O> Node<O> {
591585 fn new ( parent : Option < NodeIndex > , obligation : O ) -> Node < O > {
592586 Node {
593587 obligation,
594- parent,
595588 state : Cell :: new ( NodeState :: Pending ) ,
589+ parent,
596590 dependents : vec ! [ ] ,
597591 }
598592 }
0 commit comments