@@ -151,9 +151,8 @@ pub struct ObligationForest<O: ForestObligation> {
151
151
/// comments in `process_obligation` for details.
152
152
active_cache : FxHashMap < O :: Predicate , usize > ,
153
153
154
- /// A scratch vector reused in various operations, to avoid allocating new
155
- /// vectors.
156
- scratch : RefCell < Vec < usize > > ,
154
+ /// A vector reused in compress(), to avoid allocating new vectors.
155
+ node_rewrites : RefCell < Vec < usize > > ,
157
156
158
157
obligation_tree_id_generator : ObligationTreeIdGenerator ,
159
158
@@ -275,7 +274,7 @@ impl<O: ForestObligation> ObligationForest<O> {
275
274
nodes : vec ! [ ] ,
276
275
done_cache : Default :: default ( ) ,
277
276
active_cache : Default :: default ( ) ,
278
- scratch : RefCell :: new ( vec ! [ ] ) ,
277
+ node_rewrites : RefCell :: new ( vec ! [ ] ) ,
279
278
obligation_tree_id_generator : ( 0 ..) . map ( ObligationTreeId ) ,
280
279
error_cache : Default :: default ( ) ,
281
280
}
@@ -472,8 +471,7 @@ impl<O: ForestObligation> ObligationForest<O> {
472
471
fn process_cycles < P > ( & self , processor : & mut P )
473
472
where P : ObligationProcessor < Obligation =O >
474
473
{
475
- let mut stack = self . scratch . replace ( vec ! [ ] ) ;
476
- debug_assert ! ( stack. is_empty( ) ) ;
474
+ let mut stack = vec ! [ ] ;
477
475
478
476
debug ! ( "process_cycles()" ) ;
479
477
@@ -493,7 +491,6 @@ impl<O: ForestObligation> ObligationForest<O> {
493
491
debug ! ( "process_cycles: complete" ) ;
494
492
495
493
debug_assert ! ( stack. is_empty( ) ) ;
496
- self . scratch . replace ( stack) ;
497
494
}
498
495
499
496
fn find_cycles_from_node < P > ( & self , stack : & mut Vec < usize > , processor : & mut P , index : usize )
@@ -533,7 +530,7 @@ impl<O: ForestObligation> ObligationForest<O> {
533
530
/// Returns a vector of obligations for `p` and all of its
534
531
/// ancestors, putting them into the error state in the process.
535
532
fn error_at ( & self , mut index : usize ) -> Vec < O > {
536
- let mut error_stack = self . scratch . replace ( vec ! [ ] ) ;
533
+ let mut error_stack: Vec < usize > = vec ! [ ] ;
537
534
let mut trace = vec ! [ ] ;
538
535
539
536
loop {
@@ -562,7 +559,6 @@ impl<O: ForestObligation> ObligationForest<O> {
562
559
error_stack. extend ( node. dependents . iter ( ) ) ;
563
560
}
564
561
565
- self . scratch . replace ( error_stack) ;
566
562
trace
567
563
}
568
564
@@ -617,7 +613,7 @@ impl<O: ForestObligation> ObligationForest<O> {
617
613
#[ inline( never) ]
618
614
fn compress ( & mut self , do_completed : DoCompleted ) -> Option < Vec < O > > {
619
615
let nodes_len = self . nodes . len ( ) ;
620
- let mut node_rewrites: Vec < _ > = self . scratch . replace ( vec ! [ ] ) ;
616
+ let mut node_rewrites: Vec < _ > = self . node_rewrites . replace ( vec ! [ ] ) ;
621
617
node_rewrites. extend ( 0 ..nodes_len) ;
622
618
let mut dead_nodes = 0 ;
623
619
@@ -667,7 +663,7 @@ impl<O: ForestObligation> ObligationForest<O> {
667
663
// No compression needed.
668
664
if dead_nodes == 0 {
669
665
node_rewrites. truncate ( 0 ) ;
670
- self . scratch . replace ( node_rewrites) ;
666
+ self . node_rewrites . replace ( node_rewrites) ;
671
667
return if do_completed == DoCompleted :: Yes { Some ( vec ! [ ] ) } else { None } ;
672
668
}
673
669
@@ -690,7 +686,7 @@ impl<O: ForestObligation> ObligationForest<O> {
690
686
self . apply_rewrites ( & node_rewrites) ;
691
687
692
688
node_rewrites. truncate ( 0 ) ;
693
- self . scratch . replace ( node_rewrites) ;
689
+ self . node_rewrites . replace ( node_rewrites) ;
694
690
695
691
successful
696
692
}
0 commit comments