@@ -88,6 +88,24 @@ impl<'tcx> MutVisitor<'tcx> for RenameLocalVisitor {
88
88
* local = self . to ;
89
89
}
90
90
}
91
+
92
+ fn visit_place ( & mut self ,
93
+ place : & mut Place < ' tcx > ,
94
+ context : PlaceContext ,
95
+ location : Location ) {
96
+ self . visit_place_base ( & mut place. base , context, location) ;
97
+
98
+ let new_projection: Vec < _ > = place. projection . iter ( ) . map ( |elem|
99
+ match elem {
100
+ PlaceElem :: Index ( local) if * local == self . from => {
101
+ PlaceElem :: Index ( self . to )
102
+ }
103
+ _ => elem. clone ( ) ,
104
+ }
105
+ ) . collect ( ) ;
106
+
107
+ place. projection = new_projection. into_boxed_slice ( ) ;
108
+ }
91
109
}
92
110
93
111
struct DerefArgVisitor ;
@@ -110,7 +128,13 @@ impl<'tcx> MutVisitor<'tcx> for DerefArgVisitor {
110
128
projection : Box :: new ( [ ProjectionElem :: Deref ] ) ,
111
129
} ) ;
112
130
} else {
113
- self . super_place ( place, context, location) ;
131
+ self . visit_place_base ( & mut place. base , context, location) ;
132
+
133
+ for elem in place. projection . iter ( ) {
134
+ if let PlaceElem :: Index ( local) = elem {
135
+ assert_ne ! ( * local, self_arg( ) ) ;
136
+ }
137
+ }
114
138
}
115
139
}
116
140
}
@@ -137,7 +161,13 @@ impl<'tcx> MutVisitor<'tcx> for PinArgVisitor<'tcx> {
137
161
projection : Box :: new ( [ ProjectionElem :: Field ( Field :: new ( 0 ) , self . ref_gen_ty ) ] ) ,
138
162
} ) ;
139
163
} else {
140
- self . super_place ( place, context, location) ;
164
+ self . visit_place_base ( & mut place. base , context, location) ;
165
+
166
+ for elem in place. projection . iter ( ) {
167
+ if let PlaceElem :: Index ( local) = elem {
168
+ assert_ne ! ( * local, self_arg( ) ) ;
169
+ }
170
+ }
141
171
}
142
172
}
143
173
}
@@ -247,17 +277,25 @@ impl MutVisitor<'tcx> for TransformVisitor<'tcx> {
247
277
assert_eq ! ( self . remap. get( local) , None ) ;
248
278
}
249
279
250
- fn visit_place ( & mut self ,
251
- place : & mut Place < ' tcx > ,
252
- context : PlaceContext ,
253
- location : Location ) {
280
+ fn visit_place (
281
+ & mut self ,
282
+ place : & mut Place < ' tcx > ,
283
+ context : PlaceContext ,
284
+ location : Location ,
285
+ ) {
254
286
if let PlaceBase :: Local ( l) = place. base {
255
287
// Replace an Local in the remap with a generator struct access
256
288
if let Some ( & ( ty, variant_index, idx) ) = self . remap . get ( & l) {
257
289
replace_base ( place, self . make_field ( variant_index, idx, ty) ) ;
258
290
}
259
291
} else {
260
- self . super_place ( place, context, location) ;
292
+ self . visit_place_base ( & mut place. base , context, location) ;
293
+
294
+ for elem in place. projection . iter ( ) {
295
+ if let PlaceElem :: Index ( local) = elem {
296
+ assert_ne ! ( * local, self_arg( ) ) ;
297
+ }
298
+ }
261
299
}
262
300
}
263
301
0 commit comments