diff options
| author | Santiago Pastorino <spastorino@gmail.com> | 2019-10-07 18:15:19 -0300 |
|---|---|---|
| committer | Santiago Pastorino <spastorino@gmail.com> | 2019-10-17 22:06:55 -0400 |
| commit | bb7d6d1c70964d1d3efd5fb448538b7de50bbe3c (patch) | |
| tree | 7922760d2ac3099fbcb92a18d2b2d71090a2b2ff /src | |
| parent | 591cc9aede4aec9b8816b8489eb98c2f2a3bfe90 (diff) | |
Prepare renumber MutVisitor to have projections interned
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_mir/borrow_check/nll/renumber.rs | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/librustc_mir/borrow_check/nll/renumber.rs b/src/librustc_mir/borrow_check/nll/renumber.rs index 88ad1fb1295..6eb5735cb16 100644 --- a/src/librustc_mir/borrow_check/nll/renumber.rs +++ b/src/librustc_mir/borrow_check/nll/renumber.rs @@ -1,7 +1,7 @@ use rustc::ty::subst::SubstsRef; use rustc::ty::{self, Ty, TypeFoldable}; -use rustc::mir::{Location, Body, Promoted}; -use rustc::mir::visit::{MutVisitor, TyContext}; +use rustc::mir::{Body, Location, Place, PlaceElem, Promoted}; +use rustc::mir::visit::{MutVisitor, PlaceContext, TyContext}; use rustc::infer::{InferCtxt, NLLRegionVariableOrigin}; use rustc_index::vec::IndexVec; @@ -62,6 +62,25 @@ impl<'a, 'tcx> MutVisitor<'tcx> for NLLVisitor<'a, 'tcx> { debug!("visit_ty: ty={:?}", ty); } + 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::Field(field, ty) = elem { + PlaceElem::Field(*field, self.renumber_regions(ty)) + } else { + elem.clone() + } + ).collect(); + + place.projection = new_projection.into_boxed_slice(); + } + fn visit_substs(&mut self, substs: &mut SubstsRef<'tcx>, location: Location) { debug!("visit_substs(substs={:?}, location={:?})", substs, location); |
