@@ -115,8 +115,14 @@ impl<'tcx> MutVisitor<'tcx> for RenameLocalVisitor<'tcx> {
115
115
}
116
116
117
117
struct SelfArgVisitor < ' tcx > {
118
- elem : ProjectionElem < Local , Ty < ' tcx > > ,
119
118
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
+ }
120
126
}
121
127
122
128
impl < ' tcx > MutVisitor < ' tcx > for SelfArgVisitor < ' tcx > {
@@ -130,11 +136,7 @@ impl<'tcx> MutVisitor<'tcx> for SelfArgVisitor<'tcx> {
130
136
131
137
fn visit_place ( & mut self , place : & mut Place < ' tcx > , context : PlaceContext , location : Location ) {
132
138
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 ) ;
138
140
} else {
139
141
self . visit_local ( & mut place. local , context, location) ;
140
142
@@ -475,7 +477,7 @@ fn make_coroutine_state_argument_indirect<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Bo
475
477
body. local_decls . raw [ 1 ] . ty = ref_coroutine_ty;
476
478
477
479
// 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) ;
479
481
}
480
482
481
483
fn 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
490
492
body. local_decls . raw [ 1 ] . ty = pin_ref_coroutine_ty;
491
493
492
494
// 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) )
494
496
. visit_body ( body) ;
495
497
}
496
498
0 commit comments