@@ -11,7 +11,6 @@ use rustc_mir_dataflow::{Analysis, ResultsCursor};
1111use std:: borrow:: Cow ;
1212
1313pub fn lint_body < ' tcx > ( tcx : TyCtxt < ' tcx > , body : & Body < ' tcx > , when : String ) {
14- let reachable_blocks = traversal:: reachable_as_bitset ( body) ;
1514 let always_live_locals = & always_storage_live_locals ( body) ;
1615
1716 let maybe_storage_live = MaybeStorageLive :: new ( Cow :: Borrowed ( always_live_locals) )
@@ -24,17 +23,18 @@ pub fn lint_body<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, when: String) {
2423 . iterate_to_fixpoint ( )
2524 . into_results_cursor ( body) ;
2625
27- Lint {
26+ let mut lint = Lint {
2827 tcx,
2928 when,
3029 body,
3130 is_fn_like : tcx. def_kind ( body. source . def_id ( ) ) . is_fn_like ( ) ,
3231 always_live_locals,
33- reachable_blocks,
3432 maybe_storage_live,
3533 maybe_storage_dead,
34+ } ;
35+ for ( bb, data) in traversal:: reachable ( body) {
36+ lint. visit_basic_block_data ( bb, data) ;
3637 }
37- . visit_body ( body) ;
3838}
3939
4040struct Lint < ' a , ' tcx > {
@@ -43,7 +43,6 @@ struct Lint<'a, 'tcx> {
4343 body : & ' a Body < ' tcx > ,
4444 is_fn_like : bool ,
4545 always_live_locals : & ' a BitSet < Local > ,
46- reachable_blocks : BitSet < BasicBlock > ,
4746 maybe_storage_live : ResultsCursor < ' a , ' tcx , MaybeStorageLive < ' a > > ,
4847 maybe_storage_dead : ResultsCursor < ' a , ' tcx , MaybeStorageDead < ' a > > ,
4948}
@@ -67,7 +66,7 @@ impl<'a, 'tcx> Lint<'a, 'tcx> {
6766
6867impl < ' a , ' tcx > Visitor < ' tcx > for Lint < ' a , ' tcx > {
6968 fn visit_local ( & mut self , local : Local , context : PlaceContext , location : Location ) {
70- if self . reachable_blocks . contains ( location . block ) && context. is_use ( ) {
69+ if context. is_use ( ) {
7170 self . maybe_storage_dead . seek_after_primary_effect ( location) ;
7271 if self . maybe_storage_dead . get ( ) . contains ( local) {
7372 self . fail ( location, format ! ( "use of local {local:?}, which has no storage here" ) ) ;
@@ -78,14 +77,12 @@ impl<'a, 'tcx> Visitor<'tcx> for Lint<'a, 'tcx> {
7877 fn visit_statement ( & mut self , statement : & Statement < ' tcx > , location : Location ) {
7978 match statement. kind {
8079 StatementKind :: StorageLive ( local) => {
81- if self . reachable_blocks . contains ( location. block ) {
82- self . maybe_storage_live . seek_before_primary_effect ( location) ;
83- if self . maybe_storage_live . get ( ) . contains ( local) {
84- self . fail (
85- location,
86- format ! ( "StorageLive({local:?}) which already has storage here" ) ,
87- ) ;
88- }
80+ self . maybe_storage_live . seek_before_primary_effect ( location) ;
81+ if self . maybe_storage_live . get ( ) . contains ( local) {
82+ self . fail (
83+ location,
84+ format ! ( "StorageLive({local:?}) which already has storage here" ) ,
85+ ) ;
8986 }
9087 }
9188 _ => { }
@@ -97,7 +94,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Lint<'a, 'tcx> {
9794 fn visit_terminator ( & mut self , terminator : & Terminator < ' tcx > , location : Location ) {
9895 match terminator. kind {
9996 TerminatorKind :: Return => {
100- if self . is_fn_like && self . reachable_blocks . contains ( location . block ) {
97+ if self . is_fn_like {
10198 self . maybe_storage_live . seek_after_primary_effect ( location) ;
10299 for local in self . maybe_storage_live . get ( ) . iter ( ) {
103100 if !self . always_live_locals . contains ( local) {
0 commit comments