@@ -8,9 +8,6 @@ use rustc_middle::mir::interpret::Scalar;
88use rustc_middle:: mir:: visit:: { NonUseContext , PlaceContext , Visitor } ;
99use rustc_middle:: mir:: * ;
1010use 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 } ;
1411use rustc_target:: abi:: { Size , FIRST_VARIANT } ;
1512use rustc_target:: spec:: abi:: Abi ;
1613
@@ -51,12 +48,6 @@ impl<'tcx> MirPass<'tcx> for Validator {
5148 Reveal :: All => tcx. param_env_reveal_all_normalized ( def_id) ,
5249 } ;
5350
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-
6051 let can_unwind = if mir_phase <= MirPhase :: Runtime ( RuntimePhase :: Initial ) {
6152 // In this case `AbortUnwindingCalls` haven't yet been executed.
6253 true
@@ -83,7 +74,6 @@ impl<'tcx> MirPass<'tcx> for Validator {
8374 mir_phase,
8475 unwind_edge_count : 0 ,
8576 reachable_blocks : traversal:: reachable_as_bitset ( body) ,
86- storage_liveness,
8777 place_cache : FxHashSet :: default ( ) ,
8878 value_cache : FxHashSet :: default ( ) ,
8979 can_unwind,
@@ -116,7 +106,6 @@ struct CfgChecker<'a, 'tcx> {
116106 mir_phase : MirPhase ,
117107 unwind_edge_count : usize ,
118108 reachable_blocks : BitSet < BasicBlock > ,
119- storage_liveness : ResultsCursor < ' a , ' tcx , MaybeStorageLive < ' static > > ,
120109 place_cache : FxHashSet < PlaceRef < ' tcx > > ,
121110 value_cache : FxHashSet < u128 > ,
122111 // If `false`, then the MIR must not contain `UnwindAction::Continue` or
@@ -294,28 +283,13 @@ impl<'a, 'tcx> CfgChecker<'a, 'tcx> {
294283}
295284
296285impl < ' 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 ) {
298287 if self . body . local_decls . get ( local) . is_none ( ) {
299288 self . fail (
300289 location,
301290 format ! ( "local {local:?} has no corresponding declaration in `body.local_decls`" ) ,
302291 ) ;
303292 }
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- }
319293 }
320294
321295 fn visit_statement ( & mut self , statement : & Statement < ' tcx > , location : Location ) {
@@ -367,26 +341,8 @@ impl<'a, 'tcx> Visitor<'tcx> for CfgChecker<'a, 'tcx> {
367341 self . fail ( location, format ! ( "explicit `{kind:?}` is forbidden" ) ) ;
368342 }
369343 }
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 ( _)
390346 | StatementKind :: Intrinsic ( _)
391347 | StatementKind :: Coverage ( _)
392348 | StatementKind :: ConstEvalCounter
0 commit comments