@@ -88,6 +88,24 @@ impl<'tcx> MutVisitor<'tcx> for RenameLocalVisitor {
8888 * local = self . to ;
8989 }
9090 }
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+ }
91109}
92110
93111struct DerefArgVisitor ;
@@ -110,7 +128,13 @@ impl<'tcx> MutVisitor<'tcx> for DerefArgVisitor {
110128 projection : Box :: new ( [ ProjectionElem :: Deref ] ) ,
111129 } ) ;
112130 } 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+ }
114138 }
115139 }
116140}
@@ -137,7 +161,13 @@ impl<'tcx> MutVisitor<'tcx> for PinArgVisitor<'tcx> {
137161 projection : Box :: new ( [ ProjectionElem :: Field ( Field :: new ( 0 ) , self . ref_gen_ty ) ] ) ,
138162 } ) ;
139163 } 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+ }
141171 }
142172 }
143173}
@@ -247,17 +277,25 @@ impl MutVisitor<'tcx> for TransformVisitor<'tcx> {
247277 assert_eq ! ( self . remap. get( local) , None ) ;
248278 }
249279
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+ ) {
254286 if let PlaceBase :: Local ( l) = place. base {
255287 // Replace an Local in the remap with a generator struct access
256288 if let Some ( & ( ty, variant_index, idx) ) = self . remap . get ( & l) {
257289 replace_base ( place, self . make_field ( variant_index, idx, ty) ) ;
258290 }
259291 } 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+ }
261299 }
262300 }
263301
0 commit comments