@@ -275,11 +275,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
275
275
"report_move_out_while_borrowed: location={:?} place={:?} span={:?} borrow={:?}" ,
276
276
location, place, span, borrow
277
277
) ;
278
- let value_msg = match self . describe_place ( place) {
278
+ let value_msg = match self . describe_place ( place. as_place_ref ( ) ) {
279
279
Some ( name) => format ! ( "`{}`" , name) ,
280
280
None => "value" . to_owned ( ) ,
281
281
} ;
282
- let borrow_msg = match self . describe_place ( & borrow. borrowed_place ) {
282
+ let borrow_msg = match self . describe_place ( borrow. borrowed_place . as_place_ref ( ) ) {
283
283
Some ( name) => format ! ( "`{}`" , name) ,
284
284
None => "value" . to_owned ( ) ,
285
285
} ;
@@ -292,7 +292,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
292
292
293
293
let mut err = self . cannot_move_when_borrowed (
294
294
span,
295
- & self . describe_place ( place) . unwrap_or_else ( || "_" . to_owned ( ) ) ,
295
+ & self . describe_place ( place. as_place_ref ( ) ) . unwrap_or_else ( || "_" . to_owned ( ) ) ,
296
296
) ;
297
297
err. span_label ( borrow_span, format ! ( "borrow of {} occurs here" , borrow_msg) ) ;
298
298
err. span_label ( span, format ! ( "move out of {} occurs here" , value_msg) ) ;
@@ -331,15 +331,16 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
331
331
332
332
let mut err = self . cannot_use_when_mutably_borrowed (
333
333
span,
334
- & self . describe_place ( place) . unwrap_or_else ( || "_" . to_owned ( ) ) ,
334
+ & self . describe_place ( place. as_place_ref ( ) ) . unwrap_or_else ( || "_" . to_owned ( ) ) ,
335
335
borrow_span,
336
- & self . describe_place ( & borrow. borrowed_place )
336
+ & self . describe_place ( borrow. borrowed_place . as_place_ref ( ) )
337
337
. unwrap_or_else ( || "_" . to_owned ( ) ) ,
338
338
) ;
339
339
340
340
borrow_spans. var_span_label ( & mut err, {
341
341
let place = & borrow. borrowed_place ;
342
- let desc_place = self . describe_place ( place) . unwrap_or_else ( || "_" . to_owned ( ) ) ;
342
+ let desc_place =
343
+ self . describe_place ( place. as_place_ref ( ) ) . unwrap_or_else ( || "_" . to_owned ( ) ) ;
343
344
344
345
format ! ( "borrow occurs due to use of `{}`{}" , desc_place, borrow_spans. describe( ) )
345
346
} ) ;
@@ -516,7 +517,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
516
517
) ;
517
518
} else {
518
519
let borrow_place = & issued_borrow. borrowed_place ;
519
- let borrow_place_desc = self . describe_place ( borrow_place)
520
+ let borrow_place_desc = self . describe_place ( borrow_place. as_place_ref ( ) )
520
521
. unwrap_or_else ( || "_" . to_owned ( ) ) ;
521
522
issued_spans. var_span_label (
522
523
& mut err,
@@ -615,9 +616,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
615
616
while let Some ( box Projection { base : base_proj, elem } ) = current {
616
617
match elem {
617
618
ProjectionElem :: Field ( field, _) if union_ty ( base, base_proj) . is_some ( ) => {
618
- return Some ( ( Place {
619
- base : base. clone ( ) ,
620
- projection : base_proj. clone ( ) ,
619
+ return Some ( ( PlaceRef {
620
+ base : base,
621
+ projection : base_proj,
621
622
} , field) ) ;
622
623
} ,
623
624
_ => current = base_proj,
@@ -639,18 +640,18 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
639
640
if let ProjectionElem :: Field ( field, _) = elem {
640
641
if let Some ( union_ty) = union_ty ( base, proj_base) {
641
642
if field != target_field
642
- && * base == target_base. base
643
- && * proj_base == target_base. projection {
643
+ && base == target_base. base
644
+ && proj_base == target_base. projection {
644
645
// FIXME when we avoid clone reuse describe_place closure
645
- let describe_base_place = self . describe_place ( & Place {
646
- base : base. clone ( ) ,
647
- projection : proj_base. clone ( ) ,
646
+ let describe_base_place = self . describe_place ( PlaceRef {
647
+ base : base,
648
+ projection : proj_base,
648
649
} ) . unwrap_or_else ( || "_" . to_owned ( ) ) ;
649
650
650
651
return Some ( (
651
652
describe_base_place,
652
- describe_place ( first_borrowed_place) ,
653
- describe_place ( second_borrowed_place) ,
653
+ describe_place ( first_borrowed_place. as_place_ref ( ) ) ,
654
+ describe_place ( second_borrowed_place. as_place_ref ( ) ) ,
654
655
union_ty. to_string ( ) ,
655
656
) ) ;
656
657
}
@@ -665,7 +666,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
665
666
// If we didn't find a field access into a union, or both places match, then
666
667
// only return the description of the first place.
667
668
(
668
- describe_place ( first_borrowed_place) ,
669
+ describe_place ( first_borrowed_place. as_place_ref ( ) ) ,
669
670
"" . to_string ( ) ,
670
671
"" . to_string ( ) ,
671
672
"" . to_string ( ) ,
@@ -743,7 +744,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
743
744
}
744
745
}
745
746
746
- let place_desc = self . describe_place ( & borrow. borrowed_place ) ;
747
+ let place_desc = self . describe_place ( borrow. borrowed_place . as_place_ref ( ) ) ;
747
748
748
749
let kind_place = kind. filter ( |_| place_desc. is_some ( ) ) . map ( |k| ( k, place_span. 0 ) ) ;
749
750
let explanation = self . explain_why_borrow_contains_point ( location, & borrow, kind_place) ;
@@ -950,12 +951,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
950
951
951
952
let mut err = self . cannot_borrow_across_destructor ( borrow_span) ;
952
953
953
- let what_was_dropped = match self . describe_place ( place) {
954
+ let what_was_dropped = match self . describe_place ( place. as_place_ref ( ) ) {
954
955
Some ( name) => format ! ( "`{}`" , name. as_str( ) ) ,
955
956
None => String :: from ( "temporary value" ) ,
956
957
} ;
957
958
958
- let label = match self . describe_place ( & borrow. borrowed_place ) {
959
+ let label = match self . describe_place ( borrow. borrowed_place . as_place_ref ( ) ) {
959
960
Some ( borrowed) => format ! (
960
961
"here, drop of {D} needs exclusive access to `{B}`, \
961
962
because the type `{T}` implements the `Drop` trait",
@@ -1389,7 +1390,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1389
1390
let mut err = self . cannot_mutate_in_match_guard (
1390
1391
span,
1391
1392
loan_span,
1392
- & self . describe_place ( place) . unwrap_or_else ( || "_" . to_owned ( ) ) ,
1393
+ & self . describe_place ( place. as_place_ref ( ) ) . unwrap_or_else ( || "_" . to_owned ( ) ) ,
1393
1394
"assign" ,
1394
1395
) ;
1395
1396
loan_spans. var_span_label (
@@ -1405,7 +1406,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1405
1406
let mut err = self . cannot_assign_to_borrowed (
1406
1407
span,
1407
1408
loan_span,
1408
- & self . describe_place ( place) . unwrap_or_else ( || "_" . to_owned ( ) ) ,
1409
+ & self . describe_place ( place. as_place_ref ( ) ) . unwrap_or_else ( || "_" . to_owned ( ) ) ,
1409
1410
) ;
1410
1411
1411
1412
loan_spans. var_span_label (
@@ -1465,8 +1466,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1465
1466
is_user_variable : None ,
1466
1467
..
1467
1468
} )
1468
- | None => ( self . describe_place ( place) , assigned_span) ,
1469
- Some ( decl) => ( self . describe_place ( err_place) , decl. source_info . span ) ,
1469
+ | None => ( self . describe_place ( place. as_place_ref ( ) ) , assigned_span) ,
1470
+ Some ( decl) => ( self . describe_place ( err_place. as_place_ref ( ) ) , decl. source_info . span ) ,
1470
1471
} ;
1471
1472
1472
1473
let mut err = self . cannot_reassign_immutable (
0 commit comments