@@ -481,12 +481,8 @@ impl<O: ForestObligation> ObligationForest<O> {
481
481
// For some benchmarks this state test is extremely
482
482
// hot. It's a win to handle the no-op cases immediately to avoid
483
483
// the cost of the function call.
484
- match node. state . get ( ) {
485
- // Match arms are in order of frequency. Pending, Success and
486
- // Waiting dominate; the others are rare.
487
- NodeState :: Pending => { } ,
488
- NodeState :: Success => self . find_cycles_from_node ( & mut stack, processor, index) ,
489
- NodeState :: Waiting | NodeState :: Done | NodeState :: Error => { } ,
484
+ if node. state . get ( ) == NodeState :: Success {
485
+ self . find_cycles_from_node ( & mut stack, processor, index) ;
490
486
}
491
487
}
492
488
@@ -499,34 +495,25 @@ impl<O: ForestObligation> ObligationForest<O> {
499
495
where P : ObligationProcessor < Obligation =O >
500
496
{
501
497
let node = & self . nodes [ index] ;
502
- match node. state . get ( ) {
503
- NodeState :: Success => {
504
- match stack. iter ( ) . rposition ( |& n| n == index) {
505
- None => {
506
- stack. push ( index) ;
507
- for & index in node. dependents . iter ( ) {
508
- self . find_cycles_from_node ( stack, processor, index) ;
509
- }
510
- stack. pop ( ) ;
511
- node. state . set ( NodeState :: Done ) ;
512
- }
513
- Some ( rpos) => {
514
- // Cycle detected.
515
- processor. process_backedge (
516
- stack[ rpos..] . iter ( ) . map ( GetObligation ( & self . nodes ) ) ,
517
- PhantomData
518
- ) ;
498
+ if node. state . get ( ) == NodeState :: Success {
499
+ match stack. iter ( ) . rposition ( |& n| n == index) {
500
+ None => {
501
+ stack. push ( index) ;
502
+ for & index in node. dependents . iter ( ) {
503
+ self . find_cycles_from_node ( stack, processor, index) ;
519
504
}
505
+ stack. pop ( ) ;
506
+ node. state . set ( NodeState :: Done ) ;
507
+ }
508
+ Some ( rpos) => {
509
+ // Cycle detected.
510
+ processor. process_backedge (
511
+ stack[ rpos..] . iter ( ) . map ( GetObligation ( & self . nodes ) ) ,
512
+ PhantomData
513
+ ) ;
520
514
}
521
515
}
522
- NodeState :: Waiting | NodeState :: Pending => {
523
- // This node is still reachable from some pending node. We
524
- // will get to it when they are all processed.
525
- }
526
- NodeState :: Done | NodeState :: Error => {
527
- // Already processed that node.
528
- }
529
- } ;
516
+ }
530
517
}
531
518
532
519
/// Returns a vector of obligations for `p` and all of its
@@ -553,12 +540,10 @@ impl<O: ForestObligation> ObligationForest<O> {
553
540
554
541
while let Some ( index) = error_stack. pop ( ) {
555
542
let node = & self . nodes [ index] ;
556
- match node. state . get ( ) {
557
- NodeState :: Error => continue ,
558
- _ => node. state . set ( NodeState :: Error ) ,
543
+ if node. state . get ( ) != NodeState :: Error {
544
+ node . state . set ( NodeState :: Error ) ;
545
+ error_stack . extend ( node. dependents . iter ( ) ) ;
559
546
}
560
-
561
- error_stack. extend ( node. dependents . iter ( ) ) ;
562
547
}
563
548
564
549
trace
0 commit comments