@@ -632,11 +632,11 @@ impl Map {
632
632
tcx : TyCtxt < ' tcx > ,
633
633
body : & Body < ' tcx > ,
634
634
filter : impl Fn ( Ty < ' tcx > ) -> bool ,
635
- place_limit : Option < usize > ,
635
+ value_limit : Option < usize > ,
636
636
) -> Self {
637
637
let mut map = Self :: new ( ) ;
638
638
let exclude = excluded_locals ( body) ;
639
- map. register_with_filter ( tcx, body, filter, exclude, place_limit ) ;
639
+ map. register_with_filter ( tcx, body, filter, exclude, value_limit ) ;
640
640
debug ! ( "registered {} places ({} nodes in total)" , map. value_count, map. places. len( ) ) ;
641
641
map
642
642
}
@@ -648,10 +648,11 @@ impl Map {
648
648
body : & Body < ' tcx > ,
649
649
filter : impl Fn ( Ty < ' tcx > ) -> bool ,
650
650
exclude : BitSet < Local > ,
651
- place_limit : Option < usize > ,
651
+ value_limit : Option < usize > ,
652
652
) {
653
- // We use this vector as stack, pushing and popping projections.
654
- let mut worklist = VecDeque :: with_capacity ( place_limit. unwrap_or ( body. local_decls . len ( ) ) ) ;
653
+ let mut worklist = VecDeque :: with_capacity ( value_limit. unwrap_or ( body. local_decls . len ( ) ) ) ;
654
+
655
+ // Start by constructing the places for each bare local.
655
656
self . locals = IndexVec :: from_elem ( None , & body. local_decls ) ;
656
657
for ( local, decl) in body. local_decls . iter_enumerated ( ) {
657
658
if exclude. contains ( local) {
@@ -668,8 +669,10 @@ impl Map {
668
669
}
669
670
670
671
// `place.elem1.elem2` with type `ty`.
672
+ // `elem1` is either `Some(Variant(i))` or `None`.
671
673
while let Some ( ( mut place, elem1, elem2, ty) ) = worklist. pop_front ( ) {
672
- if let Some ( place_limit) = place_limit && self . value_count >= place_limit {
674
+ // The user requires a bound on the number of created values.
675
+ if let Some ( value_limit) = value_limit && self . value_count >= value_limit {
673
676
break
674
677
}
675
678
@@ -688,6 +691,9 @@ impl Map {
688
691
self . register_children ( tcx, place, ty, & filter, & mut worklist) ;
689
692
}
690
693
694
+ // Pre-compute the tree of ValueIndex nested in each PlaceIndex.
695
+ // `inner_values_buffer[inner_values[place]]` is the set of all the values
696
+ // reachable by projecting `place`.
691
697
self . inner_values_buffer = Vec :: with_capacity ( self . value_count ) ;
692
698
self . inner_values = IndexVec :: from_elem ( 0 ..0 , & self . places ) ;
693
699
for local in body. local_decls . indices ( ) {
0 commit comments