8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
10
11
+ use borrow_check:: nll:: { NllLivenessMap , LocalWithRegion } ;
11
12
use borrow_check:: nll:: type_check:: AtLocation ;
12
13
use dataflow:: move_paths:: { HasMoveData , MoveData } ;
13
14
use dataflow:: MaybeInitializedPlaces ;
14
15
use dataflow:: { FlowAtLocation , FlowsAtLocation } ;
15
16
use rustc:: infer:: canonical:: QueryRegionConstraint ;
16
- use rustc:: mir:: Local ;
17
17
use rustc:: mir:: { BasicBlock , Location , Mir } ;
18
18
use rustc:: traits:: query:: dropck_outlives:: DropckOutlivesResult ;
19
19
use rustc:: traits:: query:: type_op:: outlives:: DropckOutlives ;
20
20
use rustc:: traits:: query:: type_op:: TypeOp ;
21
21
use rustc:: ty:: { Ty , TypeFoldable } ;
22
22
use rustc_data_structures:: fx:: FxHashMap ;
23
23
use std:: rc:: Rc ;
24
- use util:: liveness:: LivenessResults ;
24
+ use util:: liveness:: { LivenessResults , LiveVariableMap } ;
25
25
26
26
use super :: TypeChecker ;
27
27
@@ -36,7 +36,7 @@ use super::TypeChecker;
36
36
pub ( super ) fn generate < ' gcx , ' tcx > (
37
37
cx : & mut TypeChecker < ' _ , ' gcx , ' tcx > ,
38
38
mir : & Mir < ' tcx > ,
39
- liveness : & LivenessResults ,
39
+ liveness : & LivenessResults < LocalWithRegion > ,
40
40
flow_inits : & mut FlowAtLocation < MaybeInitializedPlaces < ' _ , ' gcx , ' tcx > > ,
41
41
move_data : & MoveData < ' tcx > ,
42
42
) {
@@ -47,6 +47,7 @@ pub(super) fn generate<'gcx, 'tcx>(
47
47
flow_inits,
48
48
move_data,
49
49
drop_data : FxHashMap ( ) ,
50
+ map : & NllLivenessMap :: compute ( mir) ,
50
51
} ;
51
52
52
53
for bb in mir. basic_blocks ( ) . indices ( ) {
@@ -63,10 +64,11 @@ where
63
64
{
64
65
cx : & ' gen mut TypeChecker < ' typeck , ' gcx , ' tcx > ,
65
66
mir : & ' gen Mir < ' tcx > ,
66
- liveness : & ' gen LivenessResults ,
67
+ liveness : & ' gen LivenessResults < LocalWithRegion > ,
67
68
flow_inits : & ' gen mut FlowAtLocation < MaybeInitializedPlaces < ' flow , ' gcx , ' tcx > > ,
68
69
move_data : & ' gen MoveData < ' tcx > ,
69
70
drop_data : FxHashMap < Ty < ' tcx > , DropData < ' tcx > > ,
71
+ map : & ' gen NllLivenessMap ,
70
72
}
71
73
72
74
struct DropData < ' tcx > {
@@ -84,17 +86,18 @@ impl<'gen, 'typeck, 'flow, 'gcx, 'tcx> TypeLivenessGenerator<'gen, 'typeck, 'flo
84
86
85
87
self . liveness
86
88
. regular
87
- . simulate_block ( self . mir , bb, |location, live_locals| {
89
+ . simulate_block ( self . mir , bb, self . map , |location, live_locals| {
88
90
for live_local in live_locals. iter ( ) {
89
- let live_local_ty = self . mir . local_decls [ live_local] . ty ;
91
+ let local = self . map . from_live_var ( live_local) ;
92
+ let live_local_ty = self . mir . local_decls [ local] . ty ;
90
93
Self :: push_type_live_constraint ( & mut self . cx , live_local_ty, location) ;
91
94
}
92
95
} ) ;
93
96
94
- let mut all_live_locals: Vec < ( Location , Vec < Local > ) > = vec ! [ ] ;
97
+ let mut all_live_locals: Vec < ( Location , Vec < LocalWithRegion > ) > = vec ! [ ] ;
95
98
self . liveness
96
99
. drop
97
- . simulate_block ( self . mir , bb, |location, live_locals| {
100
+ . simulate_block ( self . mir , bb, self . map , |location, live_locals| {
98
101
all_live_locals. push ( ( location, live_locals. iter ( ) . collect ( ) ) ) ;
99
102
} ) ;
100
103
debug ! (
@@ -121,15 +124,17 @@ impl<'gen, 'typeck, 'flow, 'gcx, 'tcx> TypeLivenessGenerator<'gen, 'typeck, 'flo
121
124
} ) ;
122
125
}
123
126
124
- let mpi = self . move_data . rev_lookup . find_local ( live_local) ;
127
+ let local = self . map . from_live_var ( live_local) ;
128
+ let mpi = self . move_data . rev_lookup . find_local ( local) ;
125
129
if let Some ( initialized_child) = self . flow_inits . has_any_child_of ( mpi) {
126
130
debug ! (
127
131
"add_liveness_constraints: mpi={:?} has initialized child {:?}" ,
128
132
self . move_data. move_paths[ mpi] ,
129
133
self . move_data. move_paths[ initialized_child]
130
134
) ;
131
135
132
- let live_local_ty = self . mir . local_decls [ live_local] . ty ;
136
+ let local = self . map . from_live_var ( live_local) ;
137
+ let live_local_ty = self . mir . local_decls [ local] . ty ;
133
138
self . add_drop_live_constraint ( live_local, live_local_ty, location) ;
134
139
}
135
140
}
@@ -190,7 +195,7 @@ impl<'gen, 'typeck, 'flow, 'gcx, 'tcx> TypeLivenessGenerator<'gen, 'typeck, 'flo
190
195
/// particular this takes `#[may_dangle]` into account.
191
196
fn add_drop_live_constraint (
192
197
& mut self ,
193
- dropped_local : Local ,
198
+ dropped_local : LocalWithRegion ,
194
199
dropped_ty : Ty < ' tcx > ,
195
200
location : Location ,
196
201
) {
0 commit comments