@@ -206,7 +206,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
206206 }
207207
208208 let ty =
209- Place :: ty_from ( used_place. base , used_place. projection , self . body , self . infcx . tcx )
209+ Place :: ty_from ( used_place. base , used_place. projection , self . body_cache . body ( ) , self . infcx . tcx )
210210 . ty ;
211211 let needs_note = match ty. kind {
212212 ty:: Closure ( id, _) => {
@@ -222,7 +222,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
222222 let mpi = self . move_data . moves [ move_out_indices[ 0 ] ] . path ;
223223 let place = & self . move_data . move_paths [ mpi] . place ;
224224
225- let ty = place. ty ( self . body , self . infcx . tcx ) . ty ;
225+ let ty = place. ty ( self . body_cache . body ( ) , self . infcx . tcx ) . ty ;
226226 let opt_name =
227227 self . describe_place_with_options ( place. as_ref ( ) , IncludingDowncast ( true ) ) ;
228228 let note_msg = match opt_name {
@@ -314,7 +314,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
314314 None ,
315315 ) . add_explanation_to_diagnostic (
316316 self . infcx . tcx ,
317- self . body ,
317+ & self . body_cache ,
318318 & self . local_names ,
319319 & mut err,
320320 "" ,
@@ -356,7 +356,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
356356 self . explain_why_borrow_contains_point ( location, borrow, None )
357357 . add_explanation_to_diagnostic (
358358 self . infcx . tcx ,
359- self . body ,
359+ & self . body_cache ,
360360 & self . local_names ,
361361 & mut err,
362362 "" ,
@@ -578,7 +578,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
578578
579579 explanation. add_explanation_to_diagnostic (
580580 self . infcx . tcx ,
581- self . body ,
581+ & self . body_cache ,
582582 & self . local_names ,
583583 & mut err,
584584 first_borrow_desc,
@@ -619,7 +619,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
619619 // Define a small closure that we can use to check if the type of a place
620620 // is a union.
621621 let union_ty = |place_base, place_projection| {
622- let ty = Place :: ty_from ( place_base, place_projection, self . body , self . infcx . tcx ) . ty ;
622+ let ty = Place :: ty_from ( place_base, place_projection, self . body_cache . body ( ) , self . infcx . tcx ) . ty ;
623623 ty. ty_adt_def ( ) . filter ( |adt| adt. is_union ( ) ) . map ( |_| ty)
624624 } ;
625625 let describe_place = |place| self . describe_place ( place) . unwrap_or_else ( || "_" . to_owned ( ) ) ;
@@ -738,7 +738,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
738738
739739 assert ! ( root_place. projection. is_empty( ) ) ;
740740 let proper_span = match root_place. base {
741- PlaceBase :: Local ( local) => self . body . local_decls [ * local] . source_info . span ,
741+ PlaceBase :: Local ( local) => self . body_cache . local_decls [ * local] . source_info . span ,
742742 _ => drop_span,
743743 } ;
744744
@@ -965,7 +965,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
965965 } else {
966966 explanation. add_explanation_to_diagnostic (
967967 self . infcx . tcx ,
968- self . body ,
968+ & self . body_cache ,
969969 & self . local_names ,
970970 & mut err,
971971 "" ,
@@ -991,7 +991,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
991991 ) ;
992992
993993 explanation. add_explanation_to_diagnostic (
994- self . infcx . tcx , self . body , & self . local_names , & mut err, "" , None ) ;
994+ self . infcx . tcx , & self . body_cache , & self . local_names , & mut err, "" , None ) ;
995995 }
996996
997997 err
@@ -1051,7 +1051,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
10511051
10521052 explanation. add_explanation_to_diagnostic (
10531053 self . infcx . tcx ,
1054- self . body ,
1054+ & self . body_cache ,
10551055 & self . local_names ,
10561056 & mut err,
10571057 "" ,
@@ -1138,7 +1138,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11381138 }
11391139 explanation. add_explanation_to_diagnostic (
11401140 self . infcx . tcx ,
1141- self . body ,
1141+ & self . body_cache ,
11421142 & self . local_names ,
11431143 & mut err,
11441144 "" ,
@@ -1174,15 +1174,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11741174 } ;
11751175
11761176 // FIXME use a better heuristic than Spans
1177- let reference_desc = if return_span == self . body . source_info ( borrow. reserve_location ) . span {
1177+ let reference_desc = if return_span == self . body_cache . source_info ( borrow. reserve_location ) . span {
11781178 "reference to"
11791179 } else {
11801180 "value referencing"
11811181 } ;
11821182
11831183 let ( place_desc, note) = if let Some ( place_desc) = opt_place_desc {
11841184 let local_kind = if let Some ( local) = borrow. borrowed_place . as_local ( ) {
1185- match self . body . local_kind ( local) {
1185+ match self . body_cache . local_kind ( local) {
11861186 LocalKind :: ReturnPointer
11871187 | LocalKind :: Temp => bug ! ( "temporary or return pointer with a name" ) ,
11881188 LocalKind :: Var => "local variable " ,
@@ -1215,7 +1215,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
12151215 } else {
12161216 bug ! ( "try_report_cannot_return_reference_to_local: not a local" )
12171217 } ;
1218- match self . body . local_kind ( * local) {
1218+ match self . body_cache . local_kind ( * local) {
12191219 LocalKind :: ReturnPointer | LocalKind :: Temp => (
12201220 "temporary value" . to_string ( ) ,
12211221 "temporary value created here" . to_string ( ) ,
@@ -1372,10 +1372,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
13721372 }
13731373
13741374 fn get_moved_indexes ( & mut self , location : Location , mpi : MovePathIndex ) -> Vec < MoveSite > {
1375- let body = self . body ;
1376-
13771375 let mut stack = Vec :: new ( ) ;
1378- stack. extend ( body . predecessor_locations ( location) . map ( |predecessor| {
1376+ stack. extend ( self . body_cache . predecessor_locations ( location) . map ( |predecessor| {
13791377 let is_back_edge = location. dominates ( predecessor, & self . dominators ) ;
13801378 ( predecessor, is_back_edge)
13811379 } ) ) ;
@@ -1394,7 +1392,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
13941392 }
13951393
13961394 // check for moves
1397- let stmt_kind = body [ location. block ]
1395+ let stmt_kind = self . body_cache [ location. block ]
13981396 . statements
13991397 . get ( location. statement_index )
14001398 . map ( |s| & s. kind ) ;
@@ -1449,7 +1447,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
14491447 let mut any_match = false ;
14501448 drop_flag_effects:: for_location_inits (
14511449 self . infcx . tcx ,
1452- self . body ,
1450+ & self . body_cache ,
14531451 self . move_data ,
14541452 location,
14551453 |m| {
@@ -1462,7 +1460,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
14621460 continue ' dfs;
14631461 }
14641462
1465- stack. extend ( body . predecessor_locations ( location) . map ( |predecessor| {
1463+ stack. extend ( self . body_cache . predecessor_locations ( location) . map ( |predecessor| {
14661464 let back_edge = location. dominates ( predecessor, & self . dominators ) ;
14671465 ( predecessor, is_back_edge || back_edge)
14681466 } ) ) ;
@@ -1514,7 +1512,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
15141512 self . explain_why_borrow_contains_point ( location, loan, None )
15151513 . add_explanation_to_diagnostic (
15161514 self . infcx . tcx ,
1517- self . body ,
1515+ & self . body_cache ,
15181516 & self . local_names ,
15191517 & mut err,
15201518 "" ,
@@ -1539,8 +1537,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
15391537 ) {
15401538 let ( from_arg, local_decl, local_name) = match err_place. as_local ( ) {
15411539 Some ( local) => (
1542- self . body . local_kind ( local) == LocalKind :: Arg ,
1543- Some ( & self . body . local_decls [ local] ) ,
1540+ self . body_cache . local_kind ( local) == LocalKind :: Arg ,
1541+ Some ( & self . body_cache . local_decls [ local] ) ,
15441542 self . local_names [ local] ,
15451543 ) ,
15461544 None => ( false , None , None ) ,
@@ -1625,15 +1623,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
16251623 StorageDeadOrDrop :: LocalStorageDead
16261624 | StorageDeadOrDrop :: BoxedStorageDead => {
16271625 assert ! (
1628- Place :: ty_from( & place. base, proj_base, self . body, tcx) . ty. is_box( ) ,
1626+ Place :: ty_from( & place. base, proj_base, self . body_cache . body( ) , tcx) . ty. is_box( ) ,
16291627 "Drop of value behind a reference or raw pointer"
16301628 ) ;
16311629 StorageDeadOrDrop :: BoxedStorageDead
16321630 }
16331631 StorageDeadOrDrop :: Destructor ( _) => base_access,
16341632 } ,
16351633 ProjectionElem :: Field ( ..) | ProjectionElem :: Downcast ( ..) => {
1636- let base_ty = Place :: ty_from ( & place. base , proj_base, self . body , tcx) . ty ;
1634+ let base_ty = Place :: ty_from ( & place. base , proj_base, self . body_cache . body ( ) , tcx) . ty ;
16371635 match base_ty. kind {
16381636 ty:: Adt ( def, _) if def. has_dtor ( tcx) => {
16391637 // Report the outermost adt with a destructor
@@ -1721,22 +1719,22 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
17211719 location
17221720 ) ;
17231721 if let Some ( & Statement { kind : StatementKind :: Assign ( box( ref reservation, _) ) , ..} )
1724- = & self . body [ location. block ] . statements . get ( location. statement_index )
1722+ = & self . body_cache [ location. block ] . statements . get ( location. statement_index )
17251723 {
17261724 debug ! (
17271725 "annotate_argument_and_return_for_borrow: reservation={:?}" ,
17281726 reservation
17291727 ) ;
17301728 // Check that the initial assignment of the reserve location is into a temporary.
17311729 let mut target = match reservation. as_local ( ) {
1732- Some ( local) if self . body . local_kind ( local) == LocalKind :: Temp => local,
1730+ Some ( local) if self . body_cache . local_kind ( local) == LocalKind :: Temp => local,
17331731 _ => return None ,
17341732 } ;
17351733
17361734 // Next, look through the rest of the block, checking if we are assigning the
17371735 // `target` (that is, the place that contains our borrow) to anything.
17381736 let mut annotated_closure = None ;
1739- for stmt in & self . body [ location. block ] . statements [ location. statement_index + 1 ..] {
1737+ for stmt in & self . body_cache [ location. block ] . statements [ location. statement_index + 1 ..] {
17401738 debug ! (
17411739 "annotate_argument_and_return_for_borrow: target={:?} stmt={:?}" ,
17421740 target, stmt
@@ -1861,7 +1859,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
18611859 }
18621860
18631861 // Check the terminator if we didn't find anything in the statements.
1864- let terminator = & self . body [ location. block ] . terminator ( ) ;
1862+ let terminator = & self . body_cache [ location. block ] . terminator ( ) ;
18651863 debug ! (
18661864 "annotate_argument_and_return_for_borrow: target={:?} terminator={:?}" ,
18671865 target, terminator
0 commit comments