@@ -8,9 +8,6 @@ use rustc_middle::mir::interpret::Scalar;
8
8
use rustc_middle:: mir:: visit:: { NonUseContext , PlaceContext , Visitor } ;
9
9
use rustc_middle:: mir:: * ;
10
10
use rustc_middle:: ty:: { self , InstanceDef , ParamEnv , Ty , TyCtxt , TypeVisitableExt , Variance } ;
11
- use rustc_mir_dataflow:: impls:: MaybeStorageLive ;
12
- use rustc_mir_dataflow:: storage:: always_storage_live_locals;
13
- use rustc_mir_dataflow:: { Analysis , ResultsCursor } ;
14
11
use rustc_target:: abi:: { Size , FIRST_VARIANT } ;
15
12
use rustc_target:: spec:: abi:: Abi ;
16
13
@@ -51,12 +48,6 @@ impl<'tcx> MirPass<'tcx> for Validator {
51
48
Reveal :: All => tcx. param_env_reveal_all_normalized ( def_id) ,
52
49
} ;
53
50
54
- let always_live_locals = always_storage_live_locals ( body) ;
55
- let storage_liveness = MaybeStorageLive :: new ( std:: borrow:: Cow :: Owned ( always_live_locals) )
56
- . into_engine ( tcx, body)
57
- . iterate_to_fixpoint ( )
58
- . into_results_cursor ( body) ;
59
-
60
51
let can_unwind = if mir_phase <= MirPhase :: Runtime ( RuntimePhase :: Initial ) {
61
52
// In this case `AbortUnwindingCalls` haven't yet been executed.
62
53
true
@@ -83,7 +74,6 @@ impl<'tcx> MirPass<'tcx> for Validator {
83
74
mir_phase,
84
75
unwind_edge_count : 0 ,
85
76
reachable_blocks : traversal:: reachable_as_bitset ( body) ,
86
- storage_liveness,
87
77
place_cache : FxHashSet :: default ( ) ,
88
78
value_cache : FxHashSet :: default ( ) ,
89
79
can_unwind,
@@ -116,7 +106,6 @@ struct CfgChecker<'a, 'tcx> {
116
106
mir_phase : MirPhase ,
117
107
unwind_edge_count : usize ,
118
108
reachable_blocks : BitSet < BasicBlock > ,
119
- storage_liveness : ResultsCursor < ' a , ' tcx , MaybeStorageLive < ' static > > ,
120
109
place_cache : FxHashSet < PlaceRef < ' tcx > > ,
121
110
value_cache : FxHashSet < u128 > ,
122
111
// If `false`, then the MIR must not contain `UnwindAction::Continue` or
@@ -294,28 +283,13 @@ impl<'a, 'tcx> CfgChecker<'a, 'tcx> {
294
283
}
295
284
296
285
impl < ' a , ' tcx > Visitor < ' tcx > for CfgChecker < ' a , ' tcx > {
297
- fn visit_local ( & mut self , local : Local , context : PlaceContext , location : Location ) {
286
+ fn visit_local ( & mut self , local : Local , _context : PlaceContext , location : Location ) {
298
287
if self . body . local_decls . get ( local) . is_none ( ) {
299
288
self . fail (
300
289
location,
301
290
format ! ( "local {local:?} has no corresponding declaration in `body.local_decls`" ) ,
302
291
) ;
303
292
}
304
-
305
- if self . reachable_blocks . contains ( location. block ) && context. is_use ( ) {
306
- // We check that the local is live whenever it is used. Technically, violating this
307
- // restriction is only UB and not actually indicative of not well-formed MIR. This means
308
- // that an optimization which turns MIR that already has UB into MIR that fails this
309
- // check is not necessarily wrong. However, we have no such optimizations at the moment,
310
- // and so we include this check anyway to help us catch bugs. If you happen to write an
311
- // optimization that might cause this to incorrectly fire, feel free to remove this
312
- // check.
313
- self . storage_liveness . seek_after_primary_effect ( location) ;
314
- let locals_with_storage = self . storage_liveness . get ( ) ;
315
- if !locals_with_storage. contains ( local) {
316
- self . fail ( location, format ! ( "use of local {local:?}, which has no storage here" ) ) ;
317
- }
318
- }
319
293
}
320
294
321
295
fn visit_statement ( & mut self , statement : & Statement < ' tcx > , location : Location ) {
@@ -367,26 +341,8 @@ impl<'a, 'tcx> Visitor<'tcx> for CfgChecker<'a, 'tcx> {
367
341
self . fail ( location, format ! ( "explicit `{kind:?}` is forbidden" ) ) ;
368
342
}
369
343
}
370
- StatementKind :: StorageLive ( local) => {
371
- // We check that the local is not live when entering a `StorageLive` for it.
372
- // Technically, violating this restriction is only UB and not actually indicative
373
- // of not well-formed MIR. This means that an optimization which turns MIR that
374
- // already has UB into MIR that fails this check is not necessarily wrong. However,
375
- // we have no such optimizations at the moment, and so we include this check anyway
376
- // to help us catch bugs. If you happen to write an optimization that might cause
377
- // this to incorrectly fire, feel free to remove this check.
378
- if self . reachable_blocks . contains ( location. block ) {
379
- self . storage_liveness . seek_before_primary_effect ( location) ;
380
- let locals_with_storage = self . storage_liveness . get ( ) ;
381
- if locals_with_storage. contains ( * local) {
382
- self . fail (
383
- location,
384
- format ! ( "StorageLive({local:?}) which already has storage here" ) ,
385
- ) ;
386
- }
387
- }
388
- }
389
- StatementKind :: StorageDead ( _)
344
+ StatementKind :: StorageLive ( _)
345
+ | StatementKind :: StorageDead ( _)
390
346
| StatementKind :: Intrinsic ( _)
391
347
| StatementKind :: Coverage ( _)
392
348
| StatementKind :: ConstEvalCounter
0 commit comments