@@ -492,7 +492,7 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
492492 // Special-case reborrows to be more like a copy of a reference.
493493 match * rvalue {
494494 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) {
496496 let ctx = match kind {
497497 BorrowKind :: Shared => {
498498 PlaceContext :: NonMutatingUse ( NonMutatingUseContext :: SharedBorrow )
@@ -507,21 +507,31 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
507507 PlaceContext :: MutatingUse ( MutatingUseContext :: Borrow )
508508 }
509509 } ;
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+ ) ;
512517 return ;
513518 }
514519 }
515520 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) {
517522 let ctx = match mutbl {
518523 Mutability :: Not => {
519524 PlaceContext :: NonMutatingUse ( NonMutatingUseContext :: AddressOf )
520525 }
521526 Mutability :: Mut => PlaceContext :: MutatingUse ( MutatingUseContext :: AddressOf ) ,
522527 } ;
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+ ) ;
525535 return ;
526536 }
527537 }
0 commit comments