@@ -75,46 +75,46 @@ impl<'a, 'tcx> BottomValue for MaybeStorageLive<'a, 'tcx> {
7575/// Dataflow analysis that determines whether each local requires storage at a
7676/// given location; i.e. whether its storage can go away without being observed.
7777pub struct RequiresStorage < ' mir , ' tcx > {
78- body : & ' mir Body < ' tcx > ,
78+ body_cache : & ' mir ReadOnlyBodyCache < ' mir , ' tcx > ,
7979 borrowed_locals :
8080 RefCell < DataflowResultsRefCursor < ' mir , ' tcx , HaveBeenBorrowedLocals < ' mir , ' tcx > > > ,
8181}
8282
8383impl < ' mir , ' tcx : ' mir > RequiresStorage < ' mir , ' tcx > {
8484 pub fn new (
85- body : & ' mir Body < ' tcx > ,
85+ body_cache : & ' mir ReadOnlyBodyCache < ' mir , ' tcx > ,
8686 borrowed_locals : & ' mir DataflowResults < ' tcx , HaveBeenBorrowedLocals < ' mir , ' tcx > > ,
8787 ) -> Self {
8888 RequiresStorage {
89- body ,
90- borrowed_locals : RefCell :: new ( DataflowResultsCursor :: new ( borrowed_locals, body ) ) ,
89+ body_cache ,
90+ borrowed_locals : RefCell :: new ( DataflowResultsCursor :: new ( borrowed_locals, body_cache ) ) ,
9191 }
9292 }
9393
9494 pub fn body ( & self ) -> & Body < ' tcx > {
95- self . body
95+ & self . body_cache
9696 }
9797}
9898
9999impl < ' mir , ' tcx > BitDenotation < ' tcx > for RequiresStorage < ' mir , ' tcx > {
100100 type Idx = Local ;
101101 fn name ( ) -> & ' static str { "requires_storage" }
102102 fn bits_per_block ( & self ) -> usize {
103- self . body . local_decls . len ( )
103+ self . body_cache . local_decls . len ( )
104104 }
105105
106106 fn start_block_effect ( & self , _sets : & mut BitSet < Local > ) {
107107 // Nothing is live on function entry (generators only have a self
108108 // argument, and we don't care about that)
109- assert_eq ! ( 1 , self . body . arg_count) ;
109+ assert_eq ! ( 1 , self . body_cache . arg_count) ;
110110 }
111111
112112 fn before_statement_effect ( & self , sets : & mut GenKillSet < Self :: Idx > , loc : Location ) {
113113 // If we borrow or assign to a place then it needs storage for that
114114 // statement.
115115 self . check_for_borrow ( sets, loc) ;
116116
117- let stmt = & self . body [ loc. block ] . statements [ loc. statement_index ] ;
117+ let stmt = & self . body_cache [ loc. block ] . statements [ loc. statement_index ] ;
118118 match stmt. kind {
119119 StatementKind :: StorageDead ( l) => sets. kill ( l) ,
120120 StatementKind :: Assign ( box( ref place, _) )
@@ -146,7 +146,7 @@ impl<'mir, 'tcx> BitDenotation<'tcx> for RequiresStorage<'mir, 'tcx> {
146146 if let TerminatorKind :: Call {
147147 destination : Some ( ( Place { base : PlaceBase :: Local ( local) , .. } , _) ) ,
148148 ..
149- } = self . body [ loc. block ] . terminator ( ) . kind {
149+ } = self . body_cache [ loc. block ] . terminator ( ) . kind {
150150 sets. gen ( local) ;
151151 }
152152 }
@@ -159,7 +159,7 @@ impl<'mir, 'tcx> BitDenotation<'tcx> for RequiresStorage<'mir, 'tcx> {
159159 if let TerminatorKind :: Call {
160160 destination : Some ( ( ref place, _) ) ,
161161 ..
162- } = self . body [ loc. block ] . terminator ( ) . kind {
162+ } = self . body_cache [ loc. block ] . terminator ( ) . kind {
163163 if let Some ( local) = place. as_local ( ) {
164164 sets. kill ( local) ;
165165 }
@@ -187,7 +187,7 @@ impl<'mir, 'tcx> RequiresStorage<'mir, 'tcx> {
187187 sets,
188188 borrowed_locals : & self . borrowed_locals ,
189189 } ;
190- visitor. visit_location ( self . body , loc) ;
190+ visitor. visit_location ( & self . body_cache , loc) ;
191191 }
192192
193193 /// Gen locals that are newly borrowed. This includes borrowing any part of
0 commit comments