@@ -638,8 +638,13 @@ impl Map {
638
638
///
639
639
/// This is currently the only way to create a [`Map`]. The way in which the tracked places are
640
640
/// chosen is an implementation detail and may not be relied upon (other than that their type
641
- /// are scalars).
642
- pub fn new < ' tcx > ( tcx : TyCtxt < ' tcx > , body : & Body < ' tcx > , value_limit : Option < usize > ) -> Self {
641
+ /// are scalars and pass the filter).
642
+ pub fn from_filter < ' tcx > (
643
+ tcx : TyCtxt < ' tcx > ,
644
+ body : & Body < ' tcx > ,
645
+ filter : impl Fn ( Local ) -> bool ,
646
+ value_limit : Option < usize > ,
647
+ ) -> Self {
643
648
let mut map = Self {
644
649
locals : IndexVec :: new ( ) ,
645
650
projections : FxHashMap :: default ( ) ,
@@ -648,8 +653,7 @@ impl Map {
648
653
inner_values : IndexVec :: new ( ) ,
649
654
inner_values_buffer : Vec :: new ( ) ,
650
655
} ;
651
- let exclude = excluded_locals ( body) ;
652
- map. register ( tcx, body, exclude, value_limit) ;
656
+ map. register ( tcx, body, filter, value_limit) ;
653
657
debug ! ( "registered {} places ({} nodes in total)" , map. value_count, map. places. len( ) ) ;
654
658
map
655
659
}
@@ -659,7 +663,7 @@ impl Map {
659
663
& mut self ,
660
664
tcx : TyCtxt < ' tcx > ,
661
665
body : & Body < ' tcx > ,
662
- exclude : BitSet < Local > ,
666
+ filter : impl Fn ( Local ) -> bool ,
663
667
value_limit : Option < usize > ,
664
668
) {
665
669
let mut worklist = VecDeque :: with_capacity ( value_limit. unwrap_or ( body. local_decls . len ( ) ) ) ;
@@ -668,7 +672,7 @@ impl Map {
668
672
// Start by constructing the places for each bare local.
669
673
self . locals = IndexVec :: from_elem ( None , & body. local_decls ) ;
670
674
for ( local, decl) in body. local_decls . iter_enumerated ( ) {
671
- if exclude . contains ( local) {
675
+ if ! filter ( local) {
672
676
continue ;
673
677
}
674
678
0 commit comments