11use crate :: borrow_check:: location:: LocationTable ;
22use crate :: borrow_check:: nll:: region_infer:: values:: { self , PointIndex , RegionValueElements } ;
3- use crate :: borrow_check:: nll:: type_check:: liveness:: liveness_map:: { LiveVar , NllLivenessMap } ;
3+ use crate :: borrow_check:: nll:: type_check:: liveness:: liveness_map:: NllLivenessMap ;
44use crate :: borrow_check:: nll:: type_check:: liveness:: local_use_map:: LocalUseMap ;
55use crate :: borrow_check:: nll:: type_check:: NormalizeLocation ;
66use crate :: borrow_check:: nll:: type_check:: TypeChecker ;
77use crate :: dataflow:: move_paths:: indexes:: MovePathIndex ;
88use crate :: dataflow:: move_paths:: MoveData ;
99use crate :: dataflow:: { FlowAtLocation , FlowsAtLocation , MaybeInitializedPlaces } ;
10- use crate :: util:: liveness:: LiveVariableMap ;
1110use rustc:: infer:: canonical:: QueryRegionConstraint ;
1211use rustc:: mir:: { BasicBlock , ConstraintCategory , Local , Location , Mir } ;
1312use rustc:: traits:: query:: dropck_outlives:: DropckOutlivesResult ;
@@ -56,12 +55,12 @@ pub(super) fn trace(
5655 elements,
5756 local_use_map,
5857 move_data,
59- liveness_map,
6058 drop_data : FxHashMap :: default ( ) ,
6159 location_table,
6260 } ;
6361
64- LivenessResults :: new ( cx) . compute_for_all_locals ( ) ;
62+ let live_locals: Vec < Local > = liveness_map. to_local . clone ( ) . into_iter ( ) . collect ( ) ;
63+ LivenessResults :: new ( cx) . compute_for_all_locals ( live_locals) ;
6564}
6665
6766/// Contextual state for the type-liveness generator.
9594 /// dropped.
9695 local_use_map : & ' me LocalUseMap < ' me > ,
9796
98- /// Map tracking which variables need liveness computation.
99- liveness_map : & ' me NllLivenessMap ,
100-
10197 /// Maps between a MIR Location and a LocationIndex
10298 location_table : & ' me LocationTable ,
10399}
@@ -148,15 +144,12 @@ impl LivenessResults<'me, 'typeck, 'flow, 'gcx, 'tcx> {
148144 }
149145 }
150146
151- fn compute_for_all_locals ( & mut self ) {
152- for live_local in self . cx . liveness_map . to_local . indices ( ) {
153- let local = self . cx . liveness_map . from_live_var ( live_local) ;
154- debug ! ( "local={:?} live_local={:?}" , local, live_local) ;
155-
147+ fn compute_for_all_locals ( & mut self , live_locals : Vec < Local > ) {
148+ for local in live_locals {
156149 self . reset_local_state ( ) ;
157- self . add_defs_for ( live_local ) ;
158- self . compute_use_live_points_for ( live_local ) ;
159- self . compute_drop_live_points_for ( live_local ) ;
150+ self . add_defs_for ( local ) ;
151+ self . compute_use_live_points_for ( local ) ;
152+ self . compute_drop_live_points_for ( local ) ;
160153
161154 let local_ty = self . cx . mir . local_decls [ local] . ty ;
162155
@@ -185,23 +178,23 @@ impl LivenessResults<'me, 'typeck, 'flow, 'gcx, 'tcx> {
185178 }
186179
187180 /// Adds the definitions of `local` into `self.defs`.
188- fn add_defs_for ( & mut self , live_local : LiveVar ) {
189- for def in self . cx . local_use_map . defs ( live_local ) {
181+ fn add_defs_for ( & mut self , local : Local ) {
182+ for def in self . cx . local_use_map . defs ( local ) {
190183 debug ! ( "- defined at {:?}" , def) ;
191184 self . defs . insert ( def) ;
192185 }
193186 }
194187
195188 /// Computes all points where local is "use live" -- meaning its
196189 /// current value may be used later (except by a drop). This is
197- /// done by walking backwards from each use of `live_local ` until we
190+ /// done by walking backwards from each use of `local ` until we
198191 /// find a `def` of local.
199192 ///
200- /// Requires `add_defs_for(live_local )` to have been executed.
201- fn compute_use_live_points_for ( & mut self , live_local : LiveVar ) {
202- debug ! ( "compute_use_live_points_for(live_local ={:?})" , live_local ) ;
193+ /// Requires `add_defs_for(local )` to have been executed.
194+ fn compute_use_live_points_for ( & mut self , local : Local ) {
195+ debug ! ( "compute_use_live_points_for(local ={:?})" , local ) ;
203196
204- self . stack . extend ( self . cx . local_use_map . uses ( live_local ) ) ;
197+ self . stack . extend ( self . cx . local_use_map . uses ( local ) ) ;
205198 while let Some ( p) = self . stack . pop ( ) {
206199 if self . defs . contains ( p) {
207200 continue ;
@@ -224,15 +217,14 @@ impl LivenessResults<'me, 'typeck, 'flow, 'gcx, 'tcx> {
224217 ///
225218 /// Requires `compute_use_live_points_for` and `add_defs_for` to
226219 /// have been executed.
227- fn compute_drop_live_points_for ( & mut self , live_local : LiveVar ) {
228- debug ! ( "compute_drop_live_points_for(live_local ={:?})" , live_local ) ;
220+ fn compute_drop_live_points_for ( & mut self , local : Local ) {
221+ debug ! ( "compute_drop_live_points_for(local ={:?})" , local ) ;
229222
230- let local = self . cx . liveness_map . from_live_var ( live_local) ;
231223 let mpi = self . cx . move_data . rev_lookup . find_local ( local) ;
232224 debug ! ( "compute_drop_live_points_for: mpi = {:?}" , mpi) ;
233225
234226 // Find the drops where `local` is initialized.
235- for drop_point in self . cx . local_use_map . drops ( live_local ) {
227+ for drop_point in self . cx . local_use_map . drops ( local ) {
236228 let location = self . cx . elements . to_location ( drop_point) ;
237229 debug_assert_eq ! ( self . cx. mir. terminator_loc( location. block) , location, ) ;
238230
0 commit comments