Skip to content

Commit 9a5a342

Browse files
committed
Prepare erase_regions MutVisitor to have projections interned
1 parent e45e339 commit 9a5a342

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/librustc_mir/transform/erase_regions.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use rustc::ty::subst::SubstsRef;
88
use rustc::ty::{self, Ty, TyCtxt};
99
use rustc::mir::*;
10-
use rustc::mir::visit::{MutVisitor, TyContext};
10+
use rustc::mir::visit::{MutVisitor, PlaceContext, TyContext};
1111
use crate::transform::{MirPass, MirSource};
1212

1313
struct EraseRegionsVisitor<'tcx> {
@@ -38,6 +38,25 @@ impl MutVisitor<'tcx> for EraseRegionsVisitor<'tcx> {
3838
fn visit_substs(&mut self, substs: &mut SubstsRef<'tcx>, _: Location) {
3939
*substs = self.tcx.erase_regions(substs);
4040
}
41+
42+
fn visit_place(
43+
&mut self,
44+
place: &mut Place<'tcx>,
45+
context: PlaceContext,
46+
location: Location,
47+
) {
48+
self.visit_place_base(&mut place.base, context, location);
49+
50+
let new_projection: Vec<_> = place.projection.iter().map(|elem|
51+
if let PlaceElem::Field(field, ty) = elem {
52+
PlaceElem::Field(*field, self.tcx.erase_regions(ty))
53+
} else {
54+
elem.clone()
55+
}
56+
).collect();
57+
58+
place.projection = new_projection.into_boxed_slice();
59+
}
4160
}
4261

4362
pub struct EraseRegions;

0 commit comments

Comments
 (0)