mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 01:04:03 +00:00
Prepare promote_consts MutVisitor to have projections interned
This commit is contained in:
parent
5de9cb0703
commit
e069e9ccac
@ -191,6 +191,10 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
|
||||
});
|
||||
}
|
||||
|
||||
fn is_temp_kind(&self, local: Local) -> bool {
|
||||
self.source.local_kind(local) == LocalKind::Temp
|
||||
}
|
||||
|
||||
/// Copies the initialization of this temp to the
|
||||
/// promoted MIR, recursing through temps.
|
||||
fn promote_temp(&mut self, temp: Local) -> Local {
|
||||
@ -396,10 +400,30 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Promoter<'a, 'tcx> {
|
||||
local: &mut Local,
|
||||
_: PlaceContext,
|
||||
_: Location) {
|
||||
if self.source.local_kind(*local) == LocalKind::Temp {
|
||||
if self.is_temp_kind(*local) {
|
||||
*local = self.promote_temp(*local);
|
||||
}
|
||||
}
|
||||
|
||||
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|
|
||||
match elem {
|
||||
PlaceElem::Index(local) if self.is_temp_kind(*local) => {
|
||||
PlaceElem::Index(self.promote_temp(*local))
|
||||
}
|
||||
_ => elem.clone(),
|
||||
}
|
||||
).collect();
|
||||
|
||||
place.projection = new_projection.into_boxed_slice();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn promote_candidates<'tcx>(
|
||||
|
Loading…
Reference in New Issue
Block a user