@@ -386,7 +386,6 @@ impl<O: ForestObligation> ObligationForest<O> {
386
386
387
387
fn insert_into_error_cache ( & mut self , node_index : usize ) {
388
388
let node = & self . nodes [ node_index] ;
389
-
390
389
self . error_cache
391
390
. entry ( node. obligation_tree_id )
392
391
. or_default ( )
@@ -407,11 +406,12 @@ impl<O: ForestObligation> ObligationForest<O> {
407
406
let mut stalled = true ;
408
407
409
408
for i in 0 ..self . nodes . len ( ) {
410
- debug ! ( "process_obligations: node {} == {:?}" , i, self . nodes[ i] ) ;
409
+ let node = & mut self . nodes [ i] ;
410
+
411
+ debug ! ( "process_obligations: node {} == {:?}" , i, node) ;
411
412
412
- let result = match self . nodes [ i] {
413
- Node { ref state, ref mut obligation, .. } if state. get ( ) == NodeState :: Pending =>
414
- processor. process_obligation ( obligation) ,
413
+ let result = match node. state . get ( ) {
414
+ NodeState :: Pending => processor. process_obligation ( & mut node. obligation ) ,
415
415
_ => continue
416
416
} ;
417
417
@@ -424,7 +424,7 @@ impl<O: ForestObligation> ObligationForest<O> {
424
424
ProcessResult :: Changed ( children) => {
425
425
// We are not (yet) stalled.
426
426
stalled = false ;
427
- self . nodes [ i ] . state . set ( NodeState :: Success ) ;
427
+ node . state . set ( NodeState :: Success ) ;
428
428
429
429
for child in children {
430
430
let st = self . register_obligation_at (
@@ -491,8 +491,7 @@ impl<O: ForestObligation> ObligationForest<O> {
491
491
// hot and the state is almost always `Pending` or `Waiting`. It's
492
492
// a win to handle the no-op cases immediately to avoid the cost of
493
493
// the function call.
494
- let state = self . nodes [ i] . state . get ( ) ;
495
- match state {
494
+ match self . nodes [ i] . state . get ( ) {
496
495
NodeState :: Waiting | NodeState :: Pending | NodeState :: Done | NodeState :: Error => { } ,
497
496
_ => self . find_cycles_from_node ( & mut stack, processor, i) ,
498
497
}
@@ -508,8 +507,7 @@ impl<O: ForestObligation> ObligationForest<O> {
508
507
where P : ObligationProcessor < Obligation =O >
509
508
{
510
509
let node = & self . nodes [ i] ;
511
- let state = node. state . get ( ) ;
512
- match state {
510
+ match node. state . get ( ) {
513
511
NodeState :: OnDfsStack => {
514
512
let i = stack. iter ( ) . rposition ( |n| * n == i) . unwrap ( ) ;
515
513
processor. process_backedge ( stack[ i..] . iter ( ) . map ( GetObligation ( & self . nodes ) ) ,
@@ -557,7 +555,7 @@ impl<O: ForestObligation> ObligationForest<O> {
557
555
let node = & self . nodes [ i] ;
558
556
match node. state . get ( ) {
559
557
NodeState :: Error => continue ,
560
- _ => self . nodes [ i ] . state . set ( NodeState :: Error ) ,
558
+ _ => node . state . set ( NodeState :: Error ) ,
561
559
}
562
560
563
561
error_stack. extend (
@@ -630,7 +628,8 @@ impl<O: ForestObligation> ObligationForest<O> {
630
628
// self.nodes[i - dead_nodes..i] are all dead
631
629
// self.nodes[i..] are unchanged
632
630
for i in 0 ..self . nodes . len ( ) {
633
- match self . nodes [ i] . state . get ( ) {
631
+ let node = & self . nodes [ i] ;
632
+ match node. state . get ( ) {
634
633
NodeState :: Pending | NodeState :: Waiting => {
635
634
if dead_nodes > 0 {
636
635
self . nodes . swap ( i, i - dead_nodes) ;
@@ -640,11 +639,11 @@ impl<O: ForestObligation> ObligationForest<O> {
640
639
NodeState :: Done => {
641
640
// Avoid cloning the key (predicate) in case it exists in the waiting cache
642
641
if let Some ( ( predicate, _) ) = self . waiting_cache
643
- . remove_entry ( self . nodes [ i ] . obligation . as_predicate ( ) )
642
+ . remove_entry ( node . obligation . as_predicate ( ) )
644
643
{
645
644
self . done_cache . insert ( predicate) ;
646
645
} else {
647
- self . done_cache . insert ( self . nodes [ i ] . obligation . as_predicate ( ) . clone ( ) ) ;
646
+ self . done_cache . insert ( node . obligation . as_predicate ( ) . clone ( ) ) ;
648
647
}
649
648
node_rewrites[ i] = nodes_len;
650
649
dead_nodes += 1 ;
@@ -653,7 +652,7 @@ impl<O: ForestObligation> ObligationForest<O> {
653
652
// We *intentionally* remove the node from the cache at this point. Otherwise
654
653
// tests must come up with a different type on every type error they
655
654
// check against.
656
- self . waiting_cache . remove ( self . nodes [ i ] . obligation . as_predicate ( ) ) ;
655
+ self . waiting_cache . remove ( node . obligation . as_predicate ( ) ) ;
657
656
node_rewrites[ i] = nodes_len;
658
657
dead_nodes += 1 ;
659
658
self . insert_into_error_cache ( i) ;
0 commit comments