@@ -353,9 +353,9 @@ impl<O: ForestObligation> ObligationForest<O> {
353
353
/// Converts all remaining obligations to the given error.
354
354
pub fn to_errors < E : Clone > ( & mut self , error : E ) -> Vec < Error < O , E > > {
355
355
let mut errors = vec ! [ ] ;
356
- for ( i , node) in self . nodes . iter ( ) . enumerate ( ) {
356
+ for ( index , node) in self . nodes . iter ( ) . enumerate ( ) {
357
357
if let NodeState :: Pending = node. state . get ( ) {
358
- let backtrace = self . error_at ( i ) ;
358
+ let backtrace = self . error_at ( index ) ;
359
359
errors. push ( Error {
360
360
error : error. clone ( ) ,
361
361
backtrace,
@@ -399,10 +399,10 @@ impl<O: ForestObligation> ObligationForest<O> {
399
399
let mut errors = vec ! [ ] ;
400
400
let mut stalled = true ;
401
401
402
- for i in 0 ..self . nodes . len ( ) {
403
- let node = & mut self . nodes [ i ] ;
402
+ for index in 0 ..self . nodes . len ( ) {
403
+ let node = & mut self . nodes [ index ] ;
404
404
405
- debug ! ( "process_obligations: node {} == {:?}" , i , node) ;
405
+ debug ! ( "process_obligations: node {} == {:?}" , index , node) ;
406
406
407
407
// `processor.process_obligation` can modify the predicate within
408
408
// `node.obligation`, and that predicate is the key used for
@@ -414,7 +414,7 @@ impl<O: ForestObligation> ObligationForest<O> {
414
414
_ => continue
415
415
} ;
416
416
417
- debug ! ( "process_obligations: node {} got result {:?}" , i , result) ;
417
+ debug ! ( "process_obligations: node {} got result {:?}" , index , result) ;
418
418
419
419
match result {
420
420
ProcessResult :: Unchanged => {
@@ -428,18 +428,18 @@ impl<O: ForestObligation> ObligationForest<O> {
428
428
for child in children {
429
429
let st = self . register_obligation_at (
430
430
child,
431
- Some ( i )
431
+ Some ( index )
432
432
) ;
433
433
if let Err ( ( ) ) = st {
434
434
// Error already reported - propagate it
435
435
// to our node.
436
- self . error_at ( i ) ;
436
+ self . error_at ( index ) ;
437
437
}
438
438
}
439
439
}
440
440
ProcessResult :: Error ( err) => {
441
441
stalled = false ;
442
- let backtrace = self . error_at ( i ) ;
442
+ let backtrace = self . error_at ( index ) ;
443
443
errors. push ( Error {
444
444
error : err,
445
445
backtrace,
@@ -483,14 +483,14 @@ impl<O: ForestObligation> ObligationForest<O> {
483
483
484
484
debug ! ( "process_cycles()" ) ;
485
485
486
- for ( i , node) in self . nodes . iter ( ) . enumerate ( ) {
486
+ for ( index , node) in self . nodes . iter ( ) . enumerate ( ) {
487
487
// For rustc-benchmarks/inflate-0.1.0 this state test is extremely
488
488
// hot and the state is almost always `Pending` or `Waiting`. It's
489
489
// a win to handle the no-op cases immediately to avoid the cost of
490
490
// the function call.
491
491
match node. state . get ( ) {
492
492
NodeState :: Waiting | NodeState :: Pending | NodeState :: Done | NodeState :: Error => { } ,
493
- _ => self . find_cycles_from_node ( & mut stack, processor, i ) ,
493
+ _ => self . find_cycles_from_node ( & mut stack, processor, index ) ,
494
494
}
495
495
}
496
496
@@ -500,19 +500,19 @@ impl<O: ForestObligation> ObligationForest<O> {
500
500
self . scratch . replace ( stack) ;
501
501
}
502
502
503
- fn find_cycles_from_node < P > ( & self , stack : & mut Vec < usize > , processor : & mut P , i : usize )
503
+ fn find_cycles_from_node < P > ( & self , stack : & mut Vec < usize > , processor : & mut P , index : usize )
504
504
where P : ObligationProcessor < Obligation =O >
505
505
{
506
- let node = & self . nodes [ i ] ;
506
+ let node = & self . nodes [ index ] ;
507
507
match node. state . get ( ) {
508
508
NodeState :: OnDfsStack => {
509
- let i = stack. iter ( ) . rposition ( |n| * n == i ) . unwrap ( ) ;
510
- processor. process_backedge ( stack[ i ..] . iter ( ) . map ( GetObligation ( & self . nodes ) ) ,
509
+ let index = stack. iter ( ) . rposition ( |& n| n == index ) . unwrap ( ) ;
510
+ processor. process_backedge ( stack[ index ..] . iter ( ) . map ( GetObligation ( & self . nodes ) ) ,
511
511
PhantomData ) ;
512
512
}
513
513
NodeState :: Success => {
514
514
node. state . set ( NodeState :: OnDfsStack ) ;
515
- stack. push ( i ) ;
515
+ stack. push ( index ) ;
516
516
for & index in node. dependents . iter ( ) {
517
517
self . find_cycles_from_node ( stack, processor, index) ;
518
518
}
@@ -531,28 +531,28 @@ impl<O: ForestObligation> ObligationForest<O> {
531
531
532
532
/// Returns a vector of obligations for `p` and all of its
533
533
/// ancestors, putting them into the error state in the process.
534
- fn error_at ( & self , mut i : usize ) -> Vec < O > {
534
+ fn error_at ( & self , mut index : usize ) -> Vec < O > {
535
535
let mut error_stack = self . scratch . replace ( vec ! [ ] ) ;
536
536
let mut trace = vec ! [ ] ;
537
537
538
538
loop {
539
- let node = & self . nodes [ i ] ;
539
+ let node = & self . nodes [ index ] ;
540
540
node. state . set ( NodeState :: Error ) ;
541
541
trace. push ( node. obligation . clone ( ) ) ;
542
542
if node. has_parent {
543
543
// The first dependent is the parent, which is treated
544
544
// specially.
545
545
error_stack. extend ( node. dependents . iter ( ) . skip ( 1 ) ) ;
546
- i = node. dependents [ 0 ] ;
546
+ index = node. dependents [ 0 ] ;
547
547
} else {
548
548
// No parent; treat all dependents non-specially.
549
549
error_stack. extend ( node. dependents . iter ( ) ) ;
550
550
break ;
551
551
}
552
552
}
553
553
554
- while let Some ( i ) = error_stack. pop ( ) {
555
- let node = & self . nodes [ i ] ;
554
+ while let Some ( index ) = error_stack. pop ( ) {
555
+ let node = & self . nodes [ index ] ;
556
556
match node. state . get ( ) {
557
557
NodeState :: Error => continue ,
558
558
_ => node. state . set ( NodeState :: Error ) ,
@@ -568,8 +568,8 @@ impl<O: ForestObligation> ObligationForest<O> {
568
568
// This always-inlined function is for the hot call site.
569
569
#[ inline( always) ]
570
570
fn inlined_mark_neighbors_as_waiting_from ( & self , node : & Node < O > ) {
571
- for & dependent in node. dependents . iter ( ) {
572
- self . mark_as_waiting_from ( & self . nodes [ dependent ] ) ;
571
+ for & index in node. dependents . iter ( ) {
572
+ self . mark_as_waiting_from ( & self . nodes [ index ] ) ;
573
573
}
574
574
}
575
575
@@ -622,16 +622,16 @@ impl<O: ForestObligation> ObligationForest<O> {
622
622
// Now move all popped nodes to the end. Try to keep the order.
623
623
//
624
624
// LOOP INVARIANT:
625
- // self.nodes[0..i - dead_nodes] are the first remaining nodes
626
- // self.nodes[i - dead_nodes..i ] are all dead
627
- // self.nodes[i ..] are unchanged
628
- for i in 0 ..self . nodes . len ( ) {
629
- let node = & self . nodes [ i ] ;
625
+ // self.nodes[0..index - dead_nodes] are the first remaining nodes
626
+ // self.nodes[index - dead_nodes..index ] are all dead
627
+ // self.nodes[index ..] are unchanged
628
+ for index in 0 ..self . nodes . len ( ) {
629
+ let node = & self . nodes [ index ] ;
630
630
match node. state . get ( ) {
631
631
NodeState :: Pending | NodeState :: Waiting => {
632
632
if dead_nodes > 0 {
633
- self . nodes . swap ( i , i - dead_nodes) ;
634
- node_rewrites[ i ] -= dead_nodes;
633
+ self . nodes . swap ( index , index - dead_nodes) ;
634
+ node_rewrites[ index ] -= dead_nodes;
635
635
}
636
636
}
637
637
NodeState :: Done => {
@@ -646,17 +646,17 @@ impl<O: ForestObligation> ObligationForest<O> {
646
646
} else {
647
647
self . done_cache . insert ( node. obligation . as_predicate ( ) . clone ( ) ) ;
648
648
}
649
- node_rewrites[ i ] = nodes_len;
649
+ node_rewrites[ index ] = nodes_len;
650
650
dead_nodes += 1 ;
651
651
}
652
652
NodeState :: Error => {
653
653
// We *intentionally* remove the node from the cache at this point. Otherwise
654
654
// tests must come up with a different type on every type error they
655
655
// check against.
656
656
self . waiting_cache . remove ( node. obligation . as_predicate ( ) ) ;
657
- node_rewrites[ i ] = nodes_len;
657
+ node_rewrites[ index ] = nodes_len;
658
658
dead_nodes += 1 ;
659
- self . insert_into_error_cache ( i ) ;
659
+ self . insert_into_error_cache ( index ) ;
660
660
}
661
661
NodeState :: OnDfsStack | NodeState :: Success => unreachable ! ( )
662
662
}
@@ -697,30 +697,30 @@ impl<O: ForestObligation> ObligationForest<O> {
697
697
let nodes_len = node_rewrites. len ( ) ;
698
698
699
699
for node in & mut self . nodes {
700
- let mut i = 0 ;
701
- while i < node. dependents . len ( ) {
702
- let new_i = node_rewrites[ node. dependents [ i ] ] ;
703
- if new_i >= nodes_len {
704
- node. dependents . swap_remove ( i ) ;
705
- if i == 0 && node. has_parent {
700
+ let mut index = 0 ;
701
+ while index < node. dependents . len ( ) {
702
+ let new_index = node_rewrites[ node. dependents [ index ] ] ;
703
+ if new_index >= nodes_len {
704
+ node. dependents . swap_remove ( index ) ;
705
+ if index == 0 && node. has_parent {
706
706
// We just removed the parent.
707
707
node. has_parent = false ;
708
708
}
709
709
} else {
710
- node. dependents [ i ] = new_i ;
711
- i += 1 ;
710
+ node. dependents [ index ] = new_index ;
711
+ index += 1 ;
712
712
}
713
713
}
714
714
}
715
715
716
716
// This updating of `self.waiting_cache` is necessary because the
717
717
// removal of nodes within `compress` can fail. See above.
718
718
self . waiting_cache . retain ( |_predicate, index| {
719
- let new_i = node_rewrites[ * index] ;
720
- if new_i >= nodes_len {
719
+ let new_index = node_rewrites[ * index] ;
720
+ if new_index >= nodes_len {
721
721
false
722
722
} else {
723
- * index = new_i ;
723
+ * index = new_index ;
724
724
true
725
725
}
726
726
} ) ;
0 commit comments