@@ -206,7 +206,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
206
206
}
207
207
208
208
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 )
210
210
. ty ;
211
211
let needs_note = match ty. kind {
212
212
ty:: Closure ( id, _) => {
@@ -222,7 +222,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
222
222
let mpi = self . move_data . moves [ move_out_indices[ 0 ] ] . path ;
223
223
let place = & self . move_data . move_paths [ mpi] . place ;
224
224
225
- let ty = place. ty ( self . body , self . infcx . tcx ) . ty ;
225
+ let ty = place. ty ( self . body_cache . body ( ) , self . infcx . tcx ) . ty ;
226
226
let opt_name =
227
227
self . describe_place_with_options ( place. as_ref ( ) , IncludingDowncast ( true ) ) ;
228
228
let note_msg = match opt_name {
@@ -314,7 +314,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
314
314
None ,
315
315
) . add_explanation_to_diagnostic (
316
316
self . infcx . tcx ,
317
- self . body ,
317
+ & self . body_cache ,
318
318
& self . local_names ,
319
319
& mut err,
320
320
"" ,
@@ -356,7 +356,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
356
356
self . explain_why_borrow_contains_point ( location, borrow, None )
357
357
. add_explanation_to_diagnostic (
358
358
self . infcx . tcx ,
359
- self . body ,
359
+ & self . body_cache ,
360
360
& self . local_names ,
361
361
& mut err,
362
362
"" ,
@@ -578,7 +578,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
578
578
579
579
explanation. add_explanation_to_diagnostic (
580
580
self . infcx . tcx ,
581
- self . body ,
581
+ & self . body_cache ,
582
582
& self . local_names ,
583
583
& mut err,
584
584
first_borrow_desc,
@@ -619,7 +619,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
619
619
// Define a small closure that we can use to check if the type of a place
620
620
// is a union.
621
621
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 ;
623
623
ty. ty_adt_def ( ) . filter ( |adt| adt. is_union ( ) ) . map ( |_| ty)
624
624
} ;
625
625
let describe_place = |place| self . describe_place ( place) . unwrap_or_else ( || "_" . to_owned ( ) ) ;
@@ -738,7 +738,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
738
738
739
739
assert ! ( root_place. projection. is_empty( ) ) ;
740
740
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 ,
742
742
_ => drop_span,
743
743
} ;
744
744
@@ -965,7 +965,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
965
965
} else {
966
966
explanation. add_explanation_to_diagnostic (
967
967
self . infcx . tcx ,
968
- self . body ,
968
+ & self . body_cache ,
969
969
& self . local_names ,
970
970
& mut err,
971
971
"" ,
@@ -991,7 +991,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
991
991
) ;
992
992
993
993
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 ) ;
995
995
}
996
996
997
997
err
@@ -1051,7 +1051,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1051
1051
1052
1052
explanation. add_explanation_to_diagnostic (
1053
1053
self . infcx . tcx ,
1054
- self . body ,
1054
+ & self . body_cache ,
1055
1055
& self . local_names ,
1056
1056
& mut err,
1057
1057
"" ,
@@ -1138,7 +1138,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1138
1138
}
1139
1139
explanation. add_explanation_to_diagnostic (
1140
1140
self . infcx . tcx ,
1141
- self . body ,
1141
+ & self . body_cache ,
1142
1142
& self . local_names ,
1143
1143
& mut err,
1144
1144
"" ,
@@ -1174,15 +1174,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1174
1174
} ;
1175
1175
1176
1176
// 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 {
1178
1178
"reference to"
1179
1179
} else {
1180
1180
"value referencing"
1181
1181
} ;
1182
1182
1183
1183
let ( place_desc, note) = if let Some ( place_desc) = opt_place_desc {
1184
1184
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) {
1186
1186
LocalKind :: ReturnPointer
1187
1187
| LocalKind :: Temp => bug ! ( "temporary or return pointer with a name" ) ,
1188
1188
LocalKind :: Var => "local variable " ,
@@ -1215,7 +1215,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1215
1215
} else {
1216
1216
bug ! ( "try_report_cannot_return_reference_to_local: not a local" )
1217
1217
} ;
1218
- match self . body . local_kind ( * local) {
1218
+ match self . body_cache . local_kind ( * local) {
1219
1219
LocalKind :: ReturnPointer | LocalKind :: Temp => (
1220
1220
"temporary value" . to_string ( ) ,
1221
1221
"temporary value created here" . to_string ( ) ,
@@ -1372,10 +1372,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1372
1372
}
1373
1373
1374
1374
fn get_moved_indexes ( & mut self , location : Location , mpi : MovePathIndex ) -> Vec < MoveSite > {
1375
- let body = self . body ;
1376
-
1377
1375
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| {
1379
1377
let is_back_edge = location. dominates ( predecessor, & self . dominators ) ;
1380
1378
( predecessor, is_back_edge)
1381
1379
} ) ) ;
@@ -1394,7 +1392,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1394
1392
}
1395
1393
1396
1394
// check for moves
1397
- let stmt_kind = body [ location. block ]
1395
+ let stmt_kind = self . body_cache [ location. block ]
1398
1396
. statements
1399
1397
. get ( location. statement_index )
1400
1398
. map ( |s| & s. kind ) ;
@@ -1449,7 +1447,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1449
1447
let mut any_match = false ;
1450
1448
drop_flag_effects:: for_location_inits (
1451
1449
self . infcx . tcx ,
1452
- self . body ,
1450
+ & self . body_cache ,
1453
1451
self . move_data ,
1454
1452
location,
1455
1453
|m| {
@@ -1462,7 +1460,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1462
1460
continue ' dfs;
1463
1461
}
1464
1462
1465
- stack. extend ( body . predecessor_locations ( location) . map ( |predecessor| {
1463
+ stack. extend ( self . body_cache . predecessor_locations ( location) . map ( |predecessor| {
1466
1464
let back_edge = location. dominates ( predecessor, & self . dominators ) ;
1467
1465
( predecessor, is_back_edge || back_edge)
1468
1466
} ) ) ;
@@ -1514,7 +1512,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1514
1512
self . explain_why_borrow_contains_point ( location, loan, None )
1515
1513
. add_explanation_to_diagnostic (
1516
1514
self . infcx . tcx ,
1517
- self . body ,
1515
+ & self . body_cache ,
1518
1516
& self . local_names ,
1519
1517
& mut err,
1520
1518
"" ,
@@ -1539,8 +1537,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1539
1537
) {
1540
1538
let ( from_arg, local_decl, local_name) = match err_place. as_local ( ) {
1541
1539
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] ) ,
1544
1542
self . local_names [ local] ,
1545
1543
) ,
1546
1544
None => ( false , None , None ) ,
@@ -1625,15 +1623,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1625
1623
StorageDeadOrDrop :: LocalStorageDead
1626
1624
| StorageDeadOrDrop :: BoxedStorageDead => {
1627
1625
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( ) ,
1629
1627
"Drop of value behind a reference or raw pointer"
1630
1628
) ;
1631
1629
StorageDeadOrDrop :: BoxedStorageDead
1632
1630
}
1633
1631
StorageDeadOrDrop :: Destructor ( _) => base_access,
1634
1632
} ,
1635
1633
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 ;
1637
1635
match base_ty. kind {
1638
1636
ty:: Adt ( def, _) if def. has_dtor ( tcx) => {
1639
1637
// Report the outermost adt with a destructor
@@ -1721,22 +1719,22 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1721
1719
location
1722
1720
) ;
1723
1721
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 )
1725
1723
{
1726
1724
debug ! (
1727
1725
"annotate_argument_and_return_for_borrow: reservation={:?}" ,
1728
1726
reservation
1729
1727
) ;
1730
1728
// Check that the initial assignment of the reserve location is into a temporary.
1731
1729
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,
1733
1731
_ => return None ,
1734
1732
} ;
1735
1733
1736
1734
// Next, look through the rest of the block, checking if we are assigning the
1737
1735
// `target` (that is, the place that contains our borrow) to anything.
1738
1736
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 ..] {
1740
1738
debug ! (
1741
1739
"annotate_argument_and_return_for_borrow: target={:?} stmt={:?}" ,
1742
1740
target, stmt
@@ -1861,7 +1859,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1861
1859
}
1862
1860
1863
1861
// 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 ( ) ;
1865
1863
debug ! (
1866
1864
"annotate_argument_and_return_for_borrow: target={:?} terminator={:?}" ,
1867
1865
target, terminator
0 commit comments