@@ -112,11 +112,12 @@ impl<'tcx> MutVisitor<'tcx> for RenameLocalVisitor<'tcx> {
112
112
}
113
113
}
114
114
115
- struct DerefArgVisitor < ' tcx > {
115
+ struct SelfArgVisitor < ' tcx > {
116
+ elem : ProjectionElem < Local , Ty < ' tcx > > ,
116
117
tcx : TyCtxt < ' tcx > ,
117
118
}
118
119
119
- impl < ' tcx > MutVisitor < ' tcx > for DerefArgVisitor < ' tcx > {
120
+ impl < ' tcx > MutVisitor < ' tcx > for SelfArgVisitor < ' tcx > {
120
121
fn tcx ( & self ) -> TyCtxt < ' tcx > {
121
122
self . tcx
122
123
}
@@ -129,49 +130,7 @@ impl<'tcx> MutVisitor<'tcx> for DerefArgVisitor<'tcx> {
129
130
if place. local == SELF_ARG {
130
131
replace_base (
131
132
place,
132
- Place {
133
- local : SELF_ARG ,
134
- projection : self . tcx ( ) . mk_place_elems ( & [ ProjectionElem :: Deref ] ) ,
135
- } ,
136
- self . tcx ,
137
- ) ;
138
- } else {
139
- self . visit_local ( & mut place. local , context, location) ;
140
-
141
- for elem in place. projection . iter ( ) {
142
- if let PlaceElem :: Index ( local) = elem {
143
- assert_ne ! ( local, SELF_ARG ) ;
144
- }
145
- }
146
- }
147
- }
148
- }
149
-
150
- struct PinArgVisitor < ' tcx > {
151
- ref_coroutine_ty : Ty < ' tcx > ,
152
- tcx : TyCtxt < ' tcx > ,
153
- }
154
-
155
- impl < ' tcx > MutVisitor < ' tcx > for PinArgVisitor < ' tcx > {
156
- fn tcx ( & self ) -> TyCtxt < ' tcx > {
157
- self . tcx
158
- }
159
-
160
- fn visit_local ( & mut self , local : & mut Local , _: PlaceContext , _: Location ) {
161
- assert_ne ! ( * local, SELF_ARG ) ;
162
- }
163
-
164
- fn visit_place ( & mut self , place : & mut Place < ' tcx > , context : PlaceContext , location : Location ) {
165
- if place. local == SELF_ARG {
166
- replace_base (
167
- place,
168
- Place {
169
- local : SELF_ARG ,
170
- projection : self . tcx ( ) . mk_place_elems ( & [ ProjectionElem :: Field (
171
- FieldIdx :: ZERO ,
172
- self . ref_coroutine_ty ,
173
- ) ] ) ,
174
- } ,
133
+ Place { local : SELF_ARG , projection : self . tcx ( ) . mk_place_elems ( & [ self . elem ] ) } ,
175
134
self . tcx ,
176
135
) ;
177
136
} else {
@@ -568,7 +527,7 @@ fn make_coroutine_state_argument_indirect<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Bo
568
527
body. local_decls . raw [ 1 ] . ty = ref_coroutine_ty;
569
528
570
529
// Add a deref to accesses of the coroutine state
571
- DerefArgVisitor { tcx } . visit_body ( body) ;
530
+ SelfArgVisitor { tcx, elem : ProjectionElem :: Deref } . visit_body ( body) ;
572
531
}
573
532
574
533
fn make_coroutine_state_argument_pinned < ' tcx > ( tcx : TyCtxt < ' tcx > , body : & mut Body < ' tcx > ) {
@@ -583,7 +542,8 @@ fn make_coroutine_state_argument_pinned<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body
583
542
body. local_decls . raw [ 1 ] . ty = pin_ref_coroutine_ty;
584
543
585
544
// Add the Pin field access to accesses of the coroutine state
586
- PinArgVisitor { ref_coroutine_ty, tcx } . visit_body ( body) ;
545
+ SelfArgVisitor { tcx, elem : ProjectionElem :: Field ( FieldIdx :: ZERO , ref_coroutine_ty) }
546
+ . visit_body ( body) ;
587
547
}
588
548
589
549
/// Allocates a new local and replaces all references of `local` with it. Returns the new local.
0 commit comments