Skip to content

Commit f35a7eb

Browse files
committed
Prepare simplify MutVisitor to have projections interned
1 parent 4203f49 commit f35a7eb

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/librustc_mir/transform/simplify.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,27 @@ impl<'tcx> MutVisitor<'tcx> for LocalUpdater {
366366
});
367367
self.super_basic_block_data(block, data);
368368
}
369+
369370
fn visit_local(&mut self, l: &mut Local, _: PlaceContext, _: Location) {
370371
*l = self.map[*l].unwrap();
371372
}
373+
374+
fn visit_place(
375+
&mut self,
376+
place: &mut Place<'tcx>,
377+
context: PlaceContext,
378+
location: Location,
379+
) {
380+
self.visit_place_base(&mut place.base, context, location);
381+
382+
let new_projection: Vec<_> = place.projection.iter().map(|elem|
383+
if let PlaceElem::Index(local) = elem {
384+
PlaceElem::Index(self.map[*local].unwrap())
385+
} else {
386+
elem.clone()
387+
}
388+
).collect();
389+
390+
place.projection = new_projection.into_boxed_slice();
391+
}
372392
}

0 commit comments

Comments
 (0)