@@ -115,8 +115,14 @@ impl<'tcx> MutVisitor<'tcx> for RenameLocalVisitor<'tcx> {
115115}
116116
117117struct SelfArgVisitor < ' tcx > {
118- elem : ProjectionElem < Local , Ty < ' tcx > > ,
119118 tcx : TyCtxt < ' tcx > ,
119+ new_base : Place < ' tcx > ,
120+ }
121+
122+ impl < ' tcx > SelfArgVisitor < ' tcx > {
123+ fn new ( tcx : TyCtxt < ' tcx > , elem : ProjectionElem < Local , Ty < ' tcx > > ) -> Self {
124+ Self { tcx, new_base : Place { local : SELF_ARG , projection : tcx. mk_place_elems ( & [ elem] ) } }
125+ }
120126}
121127
122128impl < ' tcx > MutVisitor < ' tcx > for SelfArgVisitor < ' tcx > {
@@ -130,11 +136,7 @@ impl<'tcx> MutVisitor<'tcx> for SelfArgVisitor<'tcx> {
130136
131137 fn visit_place ( & mut self , place : & mut Place < ' tcx > , context : PlaceContext , location : Location ) {
132138 if place. local == SELF_ARG {
133- replace_base (
134- place,
135- Place { local : SELF_ARG , projection : self . tcx ( ) . mk_place_elems ( & [ self . elem ] ) } ,
136- self . tcx ,
137- ) ;
139+ replace_base ( place, self . new_base , self . tcx ) ;
138140 } else {
139141 self . visit_local ( & mut place. local , context, location) ;
140142
@@ -475,7 +477,7 @@ fn make_coroutine_state_argument_indirect<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Bo
475477 body. local_decls . raw [ 1 ] . ty = ref_coroutine_ty;
476478
477479 // Add a deref to accesses of the coroutine state
478- SelfArgVisitor { tcx, elem : ProjectionElem :: Deref } . visit_body ( body) ;
480+ SelfArgVisitor :: new ( tcx, ProjectionElem :: Deref ) . visit_body ( body) ;
479481}
480482
481483fn make_coroutine_state_argument_pinned < ' tcx > ( tcx : TyCtxt < ' tcx > , body : & mut Body < ' tcx > ) {
@@ -490,7 +492,7 @@ fn make_coroutine_state_argument_pinned<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body
490492 body. local_decls . raw [ 1 ] . ty = pin_ref_coroutine_ty;
491493
492494 // Add the Pin field access to accesses of the coroutine state
493- SelfArgVisitor { tcx, elem : ProjectionElem :: Field ( FieldIdx :: ZERO , ref_coroutine_ty) }
495+ SelfArgVisitor :: new ( tcx, ProjectionElem :: Field ( FieldIdx :: ZERO , ref_coroutine_ty) )
494496 . visit_body ( body) ;
495497}
496498
0 commit comments