Skip to content

Commit b509577

Browse files
committed
Prepare renumber MutVisitor to have projections interned
1 parent f35a7eb commit b509577

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/librustc_mir/borrow_check/nll/renumber.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc::ty::subst::SubstsRef;
22
use rustc::ty::{self, Ty, TypeFoldable};
3-
use rustc::mir::{Location, Body, Promoted};
4-
use rustc::mir::visit::{MutVisitor, TyContext};
3+
use rustc::mir::{Body, Location, Place, PlaceElem, Promoted};
4+
use rustc::mir::visit::{MutVisitor, PlaceContext, TyContext};
55
use rustc::infer::{InferCtxt, NLLRegionVariableOrigin};
66
use rustc_index::vec::IndexVec;
77

@@ -62,6 +62,25 @@ impl<'a, 'tcx> MutVisitor<'tcx> for NLLVisitor<'a, 'tcx> {
6262
debug!("visit_ty: ty={:?}", ty);
6363
}
6464

65+
fn visit_place(
66+
&mut self,
67+
place: &mut Place<'tcx>,
68+
context: PlaceContext,
69+
location: Location,
70+
) {
71+
self.visit_place_base(&mut place.base, context, location);
72+
73+
let new_projection: Vec<_> = place.projection.iter().map(|elem|
74+
if let PlaceElem::Field(field, ty) = elem {
75+
PlaceElem::Field(*field, self.renumber_regions(ty))
76+
} else {
77+
elem.clone()
78+
}
79+
).collect();
80+
81+
place.projection = new_projection.into_boxed_slice();
82+
}
83+
6584
fn visit_substs(&mut self, substs: &mut SubstsRef<'tcx>, location: Location) {
6685
debug!("visit_substs(substs={:?}, location={:?})", substs, location);
6786

0 commit comments

Comments
 (0)