@@ -15,7 +15,7 @@ use rustc_data_structures::bit_set::BitSet;
15
15
use rustc_data_structures:: graph:: dominators:: Dominators ;
16
16
use rustc_data_structures:: indexed_vec:: { Idx , IndexVec } ;
17
17
use rustc:: mir:: { self , Location , TerminatorKind } ;
18
- use rustc:: mir:: visit:: { Visitor , PlaceContext } ;
18
+ use rustc:: mir:: visit:: { Visitor , PlaceContext , MutatingUseContext , NonMutatingUseContext } ;
19
19
use rustc:: mir:: traversal;
20
20
use rustc:: ty;
21
21
use rustc:: ty:: layout:: LayoutOf ;
@@ -116,7 +116,11 @@ impl Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'll, 'tcx> {
116
116
self . not_ssa ( index) ;
117
117
}
118
118
} else {
119
- self . visit_place ( place, PlaceContext :: Store , location) ;
119
+ self . visit_place (
120
+ place,
121
+ PlaceContext :: MutatingUse ( MutatingUseContext :: Store ) ,
122
+ location
123
+ ) ;
120
124
}
121
125
122
126
self . visit_rvalue ( rvalue, location) ;
@@ -142,7 +146,11 @@ impl Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'll, 'tcx> {
142
146
// is not guaranteed to be statically dominated by the
143
147
// definition of x, so x must always be in an alloca.
144
148
if let mir:: Operand :: Move ( ref place) = args[ 0 ] {
145
- self . visit_place ( place, PlaceContext :: Drop , location) ;
149
+ self . visit_place (
150
+ place,
151
+ PlaceContext :: MutatingUse ( MutatingUseContext :: Drop ) ,
152
+ location
153
+ ) ;
146
154
}
147
155
}
148
156
}
@@ -160,7 +168,8 @@ impl Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'll, 'tcx> {
160
168
if let mir:: Place :: Projection ( ref proj) = * place {
161
169
// Allow uses of projections that are ZSTs or from scalar fields.
162
170
let is_consume = match context {
163
- PlaceContext :: Copy | PlaceContext :: Move => true ,
171
+ PlaceContext :: NonMutatingUse ( NonMutatingUseContext :: Copy ) |
172
+ PlaceContext :: NonMutatingUse ( NonMutatingUseContext :: Move ) => true ,
164
173
_ => false
165
174
} ;
166
175
if is_consume {
@@ -190,7 +199,11 @@ impl Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'll, 'tcx> {
190
199
191
200
// A deref projection only reads the pointer, never needs the place.
192
201
if let mir:: ProjectionElem :: Deref = proj. elem {
193
- return self . visit_place ( & proj. base , PlaceContext :: Copy , location) ;
202
+ return self . visit_place (
203
+ & proj. base ,
204
+ PlaceContext :: NonMutatingUse ( NonMutatingUseContext :: Copy ) ,
205
+ location
206
+ ) ;
194
207
}
195
208
}
196
209
@@ -202,16 +215,14 @@ impl Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'll, 'tcx> {
202
215
context : PlaceContext < ' tcx > ,
203
216
location : Location ) {
204
217
match context {
205
- PlaceContext :: Call => {
218
+ PlaceContext :: MutatingUse ( MutatingUseContext :: Call ) => {
206
219
self . assign ( local, location) ;
207
220
}
208
221
209
- PlaceContext :: StorageLive |
210
- PlaceContext :: StorageDead |
211
- PlaceContext :: Validate => { }
222
+ PlaceContext :: NonUse ( _) => { }
212
223
213
- PlaceContext :: Copy |
214
- PlaceContext :: Move => {
224
+ PlaceContext :: NonMutatingUse ( NonMutatingUseContext :: Copy ) |
225
+ PlaceContext :: NonMutatingUse ( NonMutatingUseContext :: Move ) => {
215
226
// Reads from uninitialized variables (e.g. in dead code, after
216
227
// optimizations) require locals to be in (uninitialized) memory.
217
228
// NB: there can be uninitialized reads of a local visited after
@@ -227,15 +238,19 @@ impl Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'll, 'tcx> {
227
238
}
228
239
}
229
240
230
- PlaceContext :: Inspect |
231
- PlaceContext :: Store |
232
- PlaceContext :: AsmOutput |
233
- PlaceContext :: Borrow { .. } |
234
- PlaceContext :: Projection ( ..) => {
241
+ PlaceContext :: NonMutatingUse ( NonMutatingUseContext :: Inspect ) |
242
+ PlaceContext :: MutatingUse ( MutatingUseContext :: Store ) |
243
+ PlaceContext :: MutatingUse ( MutatingUseContext :: AsmOutput ) |
244
+ PlaceContext :: MutatingUse ( MutatingUseContext :: Borrow ( ..) ) |
245
+ PlaceContext :: MutatingUse ( MutatingUseContext :: Projection ) |
246
+ PlaceContext :: NonMutatingUse ( NonMutatingUseContext :: SharedBorrow ( ..) ) |
247
+ PlaceContext :: NonMutatingUse ( NonMutatingUseContext :: UniqueBorrow ( ..) ) |
248
+ PlaceContext :: NonMutatingUse ( NonMutatingUseContext :: ShallowBorrow ( ..) ) |
249
+ PlaceContext :: NonMutatingUse ( NonMutatingUseContext :: Projection ) => {
235
250
self . not_ssa ( local) ;
236
251
}
237
252
238
- PlaceContext :: Drop => {
253
+ PlaceContext :: MutatingUse ( MutatingUseContext :: Drop ) => {
239
254
let ty = mir:: Place :: Local ( local) . ty ( self . fx . mir , self . fx . cx . tcx ) ;
240
255
let ty = self . fx . monomorphize ( & ty. to_ty ( self . fx . cx . tcx ) ) ;
241
256
0 commit comments