1
1
use crate :: borrow_check:: location:: LocationTable ;
2
2
use 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 ;
4
4
use crate :: borrow_check:: nll:: type_check:: liveness:: local_use_map:: LocalUseMap ;
5
5
use crate :: borrow_check:: nll:: type_check:: NormalizeLocation ;
6
6
use crate :: borrow_check:: nll:: type_check:: TypeChecker ;
7
7
use crate :: dataflow:: move_paths:: indexes:: MovePathIndex ;
8
8
use crate :: dataflow:: move_paths:: MoveData ;
9
9
use crate :: dataflow:: { FlowAtLocation , FlowsAtLocation , MaybeInitializedPlaces } ;
10
- use crate :: util:: liveness:: LiveVariableMap ;
11
10
use rustc:: infer:: canonical:: QueryRegionConstraint ;
12
11
use rustc:: mir:: { BasicBlock , ConstraintCategory , Local , Location , Mir } ;
13
12
use rustc:: traits:: query:: dropck_outlives:: DropckOutlivesResult ;
@@ -56,12 +55,12 @@ pub(super) fn trace(
56
55
elements,
57
56
local_use_map,
58
57
move_data,
59
- liveness_map,
60
58
drop_data : FxHashMap :: default ( ) ,
61
59
location_table,
62
60
} ;
63
61
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) ;
65
64
}
66
65
67
66
/// Contextual state for the type-liveness generator.
95
94
/// dropped.
96
95
local_use_map : & ' me LocalUseMap < ' me > ,
97
96
98
- /// Map tracking which variables need liveness computation.
99
- liveness_map : & ' me NllLivenessMap ,
100
-
101
97
/// Maps between a MIR Location and a LocationIndex
102
98
location_table : & ' me LocationTable ,
103
99
}
@@ -148,15 +144,12 @@ impl LivenessResults<'me, 'typeck, 'flow, 'gcx, 'tcx> {
148
144
}
149
145
}
150
146
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 {
156
149
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 ) ;
160
153
161
154
let local_ty = self . cx . mir . local_decls [ local] . ty ;
162
155
@@ -185,23 +178,23 @@ impl LivenessResults<'me, 'typeck, 'flow, 'gcx, 'tcx> {
185
178
}
186
179
187
180
/// 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 ) {
190
183
debug ! ( "- defined at {:?}" , def) ;
191
184
self . defs . insert ( def) ;
192
185
}
193
186
}
194
187
195
188
/// Computes all points where local is "use live" -- meaning its
196
189
/// 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
198
191
/// find a `def` of local.
199
192
///
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 ) ;
203
196
204
- self . stack . extend ( self . cx . local_use_map . uses ( live_local ) ) ;
197
+ self . stack . extend ( self . cx . local_use_map . uses ( local ) ) ;
205
198
while let Some ( p) = self . stack . pop ( ) {
206
199
if self . defs . contains ( p) {
207
200
continue ;
@@ -224,15 +217,14 @@ impl LivenessResults<'me, 'typeck, 'flow, 'gcx, 'tcx> {
224
217
///
225
218
/// Requires `compute_use_live_points_for` and `add_defs_for` to
226
219
/// 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 ) ;
229
222
230
- let local = self . cx . liveness_map . from_live_var ( live_local) ;
231
223
let mpi = self . cx . move_data . rev_lookup . find_local ( local) ;
232
224
debug ! ( "compute_drop_live_points_for: mpi = {:?}" , mpi) ;
233
225
234
226
// 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 ) {
236
228
let location = self . cx . elements . to_location ( drop_point) ;
237
229
debug_assert_eq ! ( self . cx. mir. terminator_loc( location. block) , location, ) ;
238
230
0 commit comments