1- use rustc_data_structures:: fx:: { FxIndexMap , FxIndexSet } ;
1+ use rustc_data_structures:: fx:: { FxHashMap , FxIndexMap , FxIndexSet } ;
22use rustc_index:: bit_set:: DenseBitSet ;
33use rustc_index:: interval:: IntervalSet ;
44use rustc_infer:: infer:: canonical:: QueryRegionConstraints ;
@@ -8,7 +8,7 @@ use rustc_middle::traits::query::DropckOutlivesResult;
88use rustc_middle:: ty:: relate:: Relate ;
99use rustc_middle:: ty:: { Ty , TyCtxt , TypeVisitable , TypeVisitableExt } ;
1010use rustc_mir_dataflow:: impls:: { FilteringMovePathIndexMapper , MaybeInitializedPlaces2 } ;
11- use rustc_mir_dataflow:: move_paths:: { HasMoveData , MoveData , MovePathIndex } ;
11+ use rustc_mir_dataflow:: move_paths:: { HasMoveData , MoveData , MovePathIndex , SparseMovePathIndex } ;
1212use rustc_mir_dataflow:: points:: { DenseLocationMap , PointIndex } ;
1313use rustc_mir_dataflow:: { Analysis , ResultsCursor , on_all_children_bits} ;
1414use rustc_span:: { DUMMY_SP , ErrorGuaranteed , Span } ;
@@ -46,7 +46,8 @@ pub(super) fn trace<'tcx>(
4646) {
4747 let local_use_map = & LocalUseMap :: build ( & relevant_live_locals, location_map, typeck. body ) ;
4848
49- let mut dense_mpis = smallvec:: SmallVec :: new ( ) ;
49+ let mut dense_mpis = FxHashMap :: default ( ) ;
50+ // let mut dense_mpis = smallvec::SmallVec::new();
5051 for & local in relevant_live_locals. iter ( ) {
5152 let Some ( mpi) = move_data. rev_lookup . find_local ( local) else { unreachable ! ( ) } ;
5253
@@ -56,7 +57,10 @@ pub(super) fn trace<'tcx>(
5657 }
5758
5859 on_all_children_bits ( move_data, mpi, |child| {
59- dense_mpis. push ( child) ;
60+ // dense_mpis.push(child);
61+ let dense_idx = dense_mpis. len ( ) ;
62+ let sparse_idx = SparseMovePathIndex :: from_u32 ( dense_idx. try_into ( ) . unwrap ( ) ) ;
63+ dense_mpis. insert ( child, sparse_idx) ;
6064 } ) ;
6165 }
6266
@@ -105,7 +109,8 @@ struct LivenessContext<'a, 'typeck, 'tcx> {
105109 /// dropped.
106110 local_use_map : & ' a LocalUseMap ,
107111
108- dense_mpis : smallvec:: SmallVec < [ MovePathIndex ; 1 ] > ,
112+ // dense_mpis: smallvec::SmallVec<[MovePathIndex; 1]>,
113+ dense_mpis : FxHashMap < MovePathIndex , SparseMovePathIndex > ,
109114}
110115
111116struct DropData < ' tcx > {
@@ -566,8 +571,9 @@ impl<'a, 'typeck, 'tcx> LivenessContext<'a, 'typeck, 'tcx> {
566571 // let mapper = sparse_bitset;
567572
568573 // let timer = std::time::Instant::now();
574+ let x = std:: mem:: take ( & mut self . dense_mpis ) ;
569575 let flow_inits = MaybeInitializedPlaces2 :: new ( tcx, body, self . move_data )
570- . filter_move_paths ( & self . dense_mpis )
576+ . filter_move_paths ( x )
571577 // .with_mapper(mapper)
572578 . iterate_to_fixpoint ( tcx, body, Some ( "borrowck" ) )
573579 . into_results_cursor ( body) ;
0 commit comments