1
1
use crate :: dataflow;
2
- use crate :: dataflow:: impls:: { MaybeInitializedPlaces , MaybeUninitializedPlaces } ;
3
2
use crate :: dataflow:: move_paths:: { LookupResult , MoveData , MovePathIndex } ;
4
3
use crate :: dataflow:: on_lookup_result_bits;
5
4
use crate :: dataflow:: MoveDataParamEnv ;
6
5
use crate :: dataflow:: { on_all_children_bits, on_all_drop_children_bits} ;
7
6
use crate :: dataflow:: { Analysis , ResultsCursor } ;
7
+ use crate :: dataflow:: { MaybeInitializedPlaces , MaybeUninitializedPlaces } ;
8
8
use crate :: transform:: { MirPass , MirSource } ;
9
9
use crate :: util:: elaborate_drops:: { elaborate_drop, DropFlagState , Unwind } ;
10
10
use crate :: util:: elaborate_drops:: { DropElaborator , DropFlagMode , DropStyle } ;
@@ -48,7 +48,6 @@ impl<'tcx> MirPass<'tcx> for ElaborateDrops {
48
48
. into_results_cursor ( body) ;
49
49
50
50
let uninits = MaybeUninitializedPlaces :: new ( tcx, body, & env)
51
- . mark_inactive_variants_as_uninit ( )
52
51
. into_engine ( tcx, body, def_id)
53
52
. dead_unwinds ( & dead_unwinds)
54
53
. iterate_to_fixpoint ( )
@@ -86,27 +85,27 @@ fn find_dead_unwinds<'tcx>(
86
85
. iterate_to_fixpoint ( )
87
86
. into_results_cursor ( body) ;
88
87
for ( bb, bb_data) in body. basic_blocks ( ) . iter_enumerated ( ) {
89
- let place = match bb_data. terminator ( ) . kind {
90
- TerminatorKind :: Drop { ref place , unwind : Some ( _) , .. }
91
- | TerminatorKind :: DropAndReplace { ref place , unwind : Some ( _) , .. } => place ,
88
+ let location = match bb_data. terminator ( ) . kind {
89
+ TerminatorKind :: Drop { ref location , unwind : Some ( _) , .. }
90
+ | TerminatorKind :: DropAndReplace { ref location , unwind : Some ( _) , .. } => location ,
92
91
_ => continue ,
93
92
} ;
94
93
95
94
debug ! ( "find_dead_unwinds @ {:?}: {:?}" , bb, bb_data) ;
96
95
97
- let path = match env. move_data . rev_lookup . find ( place . as_ref ( ) ) {
96
+ let path = match env. move_data . rev_lookup . find ( location . as_ref ( ) ) {
98
97
LookupResult :: Exact ( e) => e,
99
98
LookupResult :: Parent ( ..) => {
100
99
debug ! ( "find_dead_unwinds: has parent; skipping" ) ;
101
100
continue ;
102
101
}
103
102
} ;
104
103
105
- flow_inits. seek_before_primary_effect ( body. terminator_loc ( bb) ) ;
104
+ flow_inits. seek_before ( body. terminator_loc ( bb) ) ;
106
105
debug ! (
107
106
"find_dead_unwinds @ {:?}: path({:?})={:?}; init_data={:?}" ,
108
107
bb,
109
- place ,
108
+ location ,
110
109
path,
111
110
flow_inits. get( )
112
111
) ;
@@ -132,8 +131,8 @@ struct InitializationData<'mir, 'tcx> {
132
131
133
132
impl InitializationData < ' _ , ' _ > {
134
133
fn seek_before ( & mut self , loc : Location ) {
135
- self . inits . seek_before_primary_effect ( loc) ;
136
- self . uninits . seek_before_primary_effect ( loc) ;
134
+ self . inits . seek_before ( loc) ;
135
+ self . uninits . seek_before ( loc) ;
137
136
}
138
137
139
138
fn maybe_live_dead ( & self , path : MovePathIndex ) -> ( bool , bool ) {
@@ -214,31 +213,31 @@ impl<'a, 'b, 'tcx> DropElaborator<'a, 'tcx> for Elaborator<'a, 'b, 'tcx> {
214
213
215
214
fn field_subpath ( & self , path : Self :: Path , field : Field ) -> Option < Self :: Path > {
216
215
dataflow:: move_path_children_matching ( self . ctxt . move_data ( ) , path, |e| match e {
217
- ProjectionElem :: Field ( idx, _) => idx == field,
216
+ ProjectionElem :: Field ( idx, _) => * idx == field,
218
217
_ => false ,
219
218
} )
220
219
}
221
220
222
- fn array_subpath ( & self , path : Self :: Path , index : u32 , size : u32 ) -> Option < Self :: Path > {
221
+ fn array_subpath ( & self , path : Self :: Path , index : u64 , size : u64 ) -> Option < Self :: Path > {
223
222
dataflow:: move_path_children_matching ( self . ctxt . move_data ( ) , path, |e| match e {
224
223
ProjectionElem :: ConstantIndex { offset, min_length, from_end } => {
225
- debug_assert ! ( size == min_length, "min_length should be exact for arrays" ) ;
224
+ debug_assert ! ( size == * min_length as u64 , "min_length should be exact for arrays" ) ;
226
225
assert ! ( !from_end, "from_end should not be used for array element ConstantIndex" ) ;
227
- offset == index
226
+ * offset == index
228
227
}
229
228
_ => false ,
230
229
} )
231
230
}
232
231
233
232
fn deref_subpath ( & self , path : Self :: Path ) -> Option < Self :: Path > {
234
233
dataflow:: move_path_children_matching ( self . ctxt . move_data ( ) , path, |e| {
235
- e == ProjectionElem :: Deref
234
+ * e == ProjectionElem :: Deref
236
235
} )
237
236
}
238
237
239
238
fn downcast_subpath ( & self , path : Self :: Path , variant : VariantIdx ) -> Option < Self :: Path > {
240
239
dataflow:: move_path_children_matching ( self . ctxt . move_data ( ) , path, |e| match e {
241
- ProjectionElem :: Downcast ( _, idx) => idx == variant,
240
+ ProjectionElem :: Downcast ( _, idx) => * idx == variant,
242
241
_ => false ,
243
242
} )
244
243
}
@@ -295,16 +294,16 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
295
294
fn collect_drop_flags ( & mut self ) {
296
295
for ( bb, data) in self . body . basic_blocks ( ) . iter_enumerated ( ) {
297
296
let terminator = data. terminator ( ) ;
298
- let place = match terminator. kind {
299
- TerminatorKind :: Drop { ref place , .. }
300
- | TerminatorKind :: DropAndReplace { ref place , .. } => place ,
297
+ let location = match terminator. kind {
298
+ TerminatorKind :: Drop { ref location , .. }
299
+ | TerminatorKind :: DropAndReplace { ref location , .. } => location ,
301
300
_ => continue ,
302
301
} ;
303
302
304
303
self . init_data . seek_before ( self . body . terminator_loc ( bb) ) ;
305
304
306
- let path = self . move_data ( ) . rev_lookup . find ( place . as_ref ( ) ) ;
307
- debug ! ( "collect_drop_flags: {:?}, place {:?} ({:?})" , bb, place , path) ;
305
+ let path = self . move_data ( ) . rev_lookup . find ( location . as_ref ( ) ) ;
306
+ debug ! ( "collect_drop_flags: {:?}, place {:?} ({:?})" , bb, location , path) ;
308
307
309
308
let path = match path {
310
309
LookupResult :: Exact ( e) => e,
@@ -316,7 +315,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
316
315
terminator. source_info. span,
317
316
"drop of untracked, uninitialized value {:?}, place {:?} ({:?})" ,
318
317
bb,
319
- place ,
318
+ location ,
320
319
path
321
320
) ;
322
321
}
@@ -329,7 +328,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
329
328
debug ! (
330
329
"collect_drop_flags: collecting {:?} from {:?}@{:?} - {:?}" ,
331
330
child,
332
- place ,
331
+ location ,
333
332
path,
334
333
( maybe_live, maybe_dead)
335
334
) ;
@@ -347,13 +346,13 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
347
346
348
347
let resume_block = self . patch . resume_block ( ) ;
349
348
match terminator. kind {
350
- TerminatorKind :: Drop { place , target, unwind } => {
349
+ TerminatorKind :: Drop { location , target, unwind } => {
351
350
self . init_data . seek_before ( loc) ;
352
- match self . move_data ( ) . rev_lookup . find ( place . as_ref ( ) ) {
351
+ match self . move_data ( ) . rev_lookup . find ( location . as_ref ( ) ) {
353
352
LookupResult :: Exact ( path) => elaborate_drop (
354
353
& mut Elaborator { ctxt : self } ,
355
354
terminator. source_info ,
356
- place ,
355
+ location ,
357
356
path,
358
357
target,
359
358
if data. is_cleanup {
@@ -372,10 +371,10 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
372
371
}
373
372
}
374
373
}
375
- TerminatorKind :: DropAndReplace { place , ref value, target, unwind } => {
374
+ TerminatorKind :: DropAndReplace { location , ref value, target, unwind } => {
376
375
assert ! ( !data. is_cleanup) ;
377
376
378
- self . elaborate_replace ( loc, place , value, target, unwind) ;
377
+ self . elaborate_replace ( loc, location , value, target, unwind) ;
379
378
}
380
379
_ => continue ,
381
380
}
@@ -397,7 +396,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
397
396
fn elaborate_replace (
398
397
& mut self ,
399
398
loc : Location ,
400
- place : Place < ' tcx > ,
399
+ location : Place < ' tcx > ,
401
400
value : & Operand < ' tcx > ,
402
401
target : BasicBlock ,
403
402
unwind : Option < BasicBlock > ,
@@ -408,7 +407,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
408
407
assert ! ( !data. is_cleanup, "DropAndReplace in unwind path not supported" ) ;
409
408
410
409
let assign = Statement {
411
- kind : StatementKind :: Assign ( box ( place , Rvalue :: Use ( value. clone ( ) ) ) ) ,
410
+ kind : StatementKind :: Assign ( box ( location , Rvalue :: Use ( value. clone ( ) ) ) ) ,
412
411
source_info : terminator. source_info ,
413
412
} ;
414
413
@@ -428,14 +427,14 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
428
427
is_cleanup : false ,
429
428
} ) ;
430
429
431
- match self . move_data ( ) . rev_lookup . find ( place . as_ref ( ) ) {
430
+ match self . move_data ( ) . rev_lookup . find ( location . as_ref ( ) ) {
432
431
LookupResult :: Exact ( path) => {
433
432
debug ! ( "elaborate_drop_and_replace({:?}) - tracked {:?}" , terminator, path) ;
434
433
self . init_data . seek_before ( loc) ;
435
434
elaborate_drop (
436
435
& mut Elaborator { ctxt : self } ,
437
436
terminator. source_info ,
438
- place ,
437
+ location ,
439
438
path,
440
439
target,
441
440
Unwind :: To ( unwind) ,
@@ -460,7 +459,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
460
459
debug ! ( "elaborate_drop_and_replace({:?}) - untracked {:?}" , terminator, parent) ;
461
460
self . patch . patch_terminator (
462
461
bb,
463
- TerminatorKind :: Drop { place , target, unwind : Some ( unwind) } ,
462
+ TerminatorKind :: Drop { location , target, unwind : Some ( unwind) } ,
464
463
) ;
465
464
}
466
465
}
0 commit comments