@@ -7,7 +7,7 @@ use crate::dataflow::indexes::MovePathIndex;
77use crate :: dataflow:: move_paths:: MoveData ;
88use crate :: dataflow:: { FlowAtLocation , FlowsAtLocation , MaybeInitializedPlaces } ;
99use rustc:: infer:: canonical:: QueryRegionConstraints ;
10- use rustc:: mir:: { BasicBlock , Body , ConstraintCategory , Local , Location } ;
10+ use rustc:: mir:: { BasicBlock , ConstraintCategory , Local , Location , ReadOnlyBodyCache } ;
1111use rustc:: traits:: query:: dropck_outlives:: DropckOutlivesResult ;
1212use rustc:: traits:: query:: type_op:: outlives:: DropckOutlives ;
1313use rustc:: traits:: query:: type_op:: TypeOp ;
@@ -32,7 +32,7 @@ use std::rc::Rc;
3232/// this respects `#[may_dangle]` annotations).
3333pub ( super ) fn trace (
3434 typeck : & mut TypeChecker < ' _ , ' tcx > ,
35- body : & Body < ' tcx > ,
35+ body_cache : & ReadOnlyBodyCache < ' _ , ' tcx > ,
3636 elements : & Rc < RegionValueElements > ,
3737 flow_inits : & mut FlowAtLocation < ' tcx , MaybeInitializedPlaces < ' _ , ' tcx > > ,
3838 move_data : & MoveData < ' tcx > ,
@@ -41,11 +41,11 @@ pub(super) fn trace(
4141) {
4242 debug ! ( "trace()" ) ;
4343
44- let local_use_map = & LocalUseMap :: build ( & live_locals, elements, body ) ;
44+ let local_use_map = & LocalUseMap :: build ( & live_locals, elements, & body_cache ) ;
4545
4646 let cx = LivenessContext {
4747 typeck,
48- body ,
48+ body_cache ,
4949 flow_inits,
5050 elements,
5151 local_use_map,
@@ -71,7 +71,7 @@ struct LivenessContext<'me, 'typeck, 'flow, 'tcx> {
7171 elements : & ' me RegionValueElements ,
7272
7373 /// MIR we are analyzing.
74- body : & ' me Body < ' tcx > ,
74+ body_cache : & ' me ReadOnlyBodyCache < ' me , ' tcx > ,
7575
7676 /// Mapping to/from the various indices used for initialization tracking.
7777 move_data : & ' me MoveData < ' tcx > ,
@@ -135,7 +135,7 @@ impl LivenessResults<'me, 'typeck, 'flow, 'tcx> {
135135 self . compute_use_live_points_for ( local) ;
136136 self . compute_drop_live_points_for ( local) ;
137137
138- let local_ty = self . cx . body . local_decls [ local] . ty ;
138+ let local_ty = self . cx . body_cache . local_decls [ local] . ty ;
139139
140140 if !self . use_live_at . is_empty ( ) {
141141 self . cx . add_use_live_facts_for ( local_ty, & self . use_live_at ) ;
@@ -165,7 +165,7 @@ impl LivenessResults<'me, 'typeck, 'flow, 'tcx> {
165165
166166 for ( local, location) in drop_used {
167167 if !live_locals. contains ( & local) {
168- let local_ty = self . cx . body . local_decls [ local] . ty ;
168+ let local_ty = self . cx . body_cache . local_decls [ local] . ty ;
169169 if local_ty. has_free_regions ( ) {
170170 self . cx . add_drop_live_facts_for (
171171 local,
@@ -211,7 +211,7 @@ impl LivenessResults<'me, 'typeck, 'flow, 'tcx> {
211211 }
212212
213213 if self . use_live_at . insert ( p) {
214- self . cx . elements . push_predecessors ( self . cx . body , p, & mut self . stack )
214+ self . cx . elements . push_predecessors ( & self . cx . body_cache , p, & mut self . stack )
215215 }
216216 }
217217 }
@@ -234,7 +234,7 @@ impl LivenessResults<'me, 'typeck, 'flow, 'tcx> {
234234 // Find the drops where `local` is initialized.
235235 for drop_point in self . cx . local_use_map . drops ( local) {
236236 let location = self . cx . elements . to_location ( drop_point) ;
237- debug_assert_eq ! ( self . cx. body . terminator_loc( location. block) , location, ) ;
237+ debug_assert_eq ! ( self . cx. body_cache . terminator_loc( location. block) , location, ) ;
238238
239239 if self . cx . initialized_at_terminator ( location. block , mpi) {
240240 if self . drop_live_at . insert ( drop_point) {
@@ -280,7 +280,7 @@ impl LivenessResults<'me, 'typeck, 'flow, 'tcx> {
280280 // block. One of them may be either a definition or use
281281 // live point.
282282 let term_location = self . cx . elements . to_location ( term_point) ;
283- debug_assert_eq ! ( self . cx. body . terminator_loc( term_location. block) , term_location, ) ;
283+ debug_assert_eq ! ( self . cx. body_cache . terminator_loc( term_location. block) , term_location, ) ;
284284 let block = term_location. block ;
285285 let entry_point = self . cx . elements . entry_point ( term_location. block ) ;
286286 for p in ( entry_point..term_point) . rev ( ) {
@@ -302,7 +302,7 @@ impl LivenessResults<'me, 'typeck, 'flow, 'tcx> {
302302 }
303303 }
304304
305- for & pred_block in self . cx . body . predecessors_for ( block) . iter ( ) {
305+ for & pred_block in self . cx . body_cache . predecessors_for ( block) . iter ( ) {
306306 debug ! ( "compute_drop_live_points_for_block: pred_block = {:?}" , pred_block, ) ;
307307
308308 // Check whether the variable is (at least partially)
@@ -328,7 +328,7 @@ impl LivenessResults<'me, 'typeck, 'flow, 'tcx> {
328328 continue ;
329329 }
330330
331- let pred_term_loc = self . cx . body . terminator_loc ( pred_block) ;
331+ let pred_term_loc = self . cx . body_cache . terminator_loc ( pred_block) ;
332332 let pred_term_point = self . cx . elements . point_from_location ( pred_term_loc) ;
333333
334334 // If the terminator of this predecessor either *assigns*
@@ -399,7 +399,7 @@ impl LivenessContext<'_, '_, '_, 'tcx> {
399399 // the effects of all statements. This is the only way to get
400400 // "just ahead" of a terminator.
401401 self . flow_inits . reset_to_entry_of ( block) ;
402- for statement_index in 0 ..self . body [ block] . statements . len ( ) {
402+ for statement_index in 0 ..self . body_cache [ block] . statements . len ( ) {
403403 let location = Location { block, statement_index } ;
404404 self . flow_inits . reconstruct_statement_effect ( location) ;
405405 self . flow_inits . apply_local_effect ( location) ;
@@ -471,7 +471,7 @@ impl LivenessContext<'_, '_, '_, 'tcx> {
471471
472472 drop_data. dropck_result . report_overflows (
473473 self . typeck . infcx . tcx ,
474- self . body . source_info ( * drop_locations. first ( ) . unwrap ( ) ) . span ,
474+ self . body_cache . source_info ( * drop_locations. first ( ) . unwrap ( ) ) . span ,
475475 dropped_ty,
476476 ) ;
477477
0 commit comments