@@ -492,7 +492,7 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
492
492
// Special-case reborrows to be more like a copy of a reference.
493
493
match * rvalue {
494
494
Rvalue :: Ref ( _, kind, place) => {
495
- if let Some ( place_ref ) = place_as_reborrow ( self . tcx , self . body , place) {
495
+ if let Some ( reborrowed_place_ref ) = place_as_reborrow ( self . tcx , self . body , place) {
496
496
let ctx = match kind {
497
497
BorrowKind :: Shared => {
498
498
PlaceContext :: NonMutatingUse ( NonMutatingUseContext :: SharedBorrow )
@@ -507,21 +507,31 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
507
507
PlaceContext :: MutatingUse ( MutatingUseContext :: Borrow )
508
508
}
509
509
} ;
510
- self . visit_local ( & place. local , ctx, location) ;
511
- self . visit_projection ( place. local , place_ref. projection , ctx, location) ;
510
+ self . visit_local ( & reborrowed_place_ref. local , ctx, location) ;
511
+ self . visit_projection (
512
+ reborrowed_place_ref. local ,
513
+ reborrowed_place_ref. projection ,
514
+ ctx,
515
+ location,
516
+ ) ;
512
517
return ;
513
518
}
514
519
}
515
520
Rvalue :: AddressOf ( mutbl, place) => {
516
- if let Some ( place_ref ) = place_as_reborrow ( self . tcx , self . body , place) {
521
+ if let Some ( reborrowed_place_ref ) = place_as_reborrow ( self . tcx , self . body , place) {
517
522
let ctx = match mutbl {
518
523
Mutability :: Not => {
519
524
PlaceContext :: NonMutatingUse ( NonMutatingUseContext :: AddressOf )
520
525
}
521
526
Mutability :: Mut => PlaceContext :: MutatingUse ( MutatingUseContext :: AddressOf ) ,
522
527
} ;
523
- self . visit_local ( & place. local , ctx, location) ;
524
- self . visit_projection ( place. local , place_ref. projection , ctx, location) ;
528
+ self . visit_local ( & reborrowed_place_ref. local , ctx, location) ;
529
+ self . visit_projection (
530
+ reborrowed_place_ref. local ,
531
+ reborrowed_place_ref. projection ,
532
+ ctx,
533
+ location,
534
+ ) ;
525
535
return ;
526
536
}
527
537
}
0 commit comments