Prepare simplify MutVisitor to have projections interned

This commit is contained in:
Santiago Pastorino 2019-10-07 17:58:28 -03:00
parent e069e9ccac
commit 591cc9aede
No known key found for this signature in database
GPG key ID: 88C941CDA1D46432

View file

@ -366,7 +366,27 @@ impl<'tcx> MutVisitor<'tcx> for LocalUpdater {
});
self.super_basic_block_data(block, data);
}
fn visit_local(&mut self, l: &mut Local, _: PlaceContext, _: Location) {
*l = self.map[*l].unwrap();
}
fn visit_place(
&mut self,
place: &mut Place<'tcx>,
context: PlaceContext,
location: Location,
) {
self.visit_place_base(&mut place.base, context, location);
let new_projection: Vec<_> = place.projection.iter().map(|elem|
if let PlaceElem::Index(local) = elem {
PlaceElem::Index(self.map[*local].unwrap())
} else {
elem.clone()
}
).collect();
place.projection = new_projection.into_boxed_slice();
}
}