Skip to content

Commit

Permalink
Add visit_projection_elem method to visitors
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino committed Oct 3, 2019
1 parent f2023ac commit a8d70d1
Showing 1 changed file with 35 additions and 18 deletions.
53 changes: 35 additions & 18 deletions src/librustc/mir/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,15 @@ macro_rules! make_mir_visitor {
self.super_projection(base, projection, context, location);
}

fn visit_projection_elem(&mut self,
base: & $($mutability)? PlaceBase<'tcx>,
proj_base: & $($mutability)? [PlaceElem<'tcx>],
elem: & $($mutability)? PlaceElem<'tcx>,
context: PlaceContext,
location: Location) {
self.super_projection_elem(base, proj_base, elem, context, location);
}

fn visit_constant(&mut self,
constant: & $($mutability)? Constant<'tcx>,
location: Location) {
Expand Down Expand Up @@ -727,25 +736,33 @@ macro_rules! make_mir_visitor {
location: Location) {
if let [proj_base @ .., elem] = projection {
self.visit_projection(base, proj_base, context, location);
self.visit_projection_elem(base, proj_base, elem, context, location);
}
}

match elem {
ProjectionElem::Field(_field, ty) => {
self.visit_ty(ty, TyContext::Location(location));
}
ProjectionElem::Index(local) => {
self.visit_local(
local,
PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy),
location
);
}
ProjectionElem::Deref |
ProjectionElem::Subslice { from: _, to: _ } |
ProjectionElem::ConstantIndex { offset: _,
min_length: _,
from_end: _ } |
ProjectionElem::Downcast(_, _) => {
}
fn super_projection_elem(&mut self,
_base: & $($mutability)? PlaceBase<'tcx>,
_proj_base: & $($mutability)? [PlaceElem<'tcx>],
elem: & $($mutability)? PlaceElem<'tcx>,
_context: PlaceContext,
location: Location) {
match elem {
ProjectionElem::Field(_field, ty) => {
self.visit_ty(ty, TyContext::Location(location));
}
ProjectionElem::Index(local) => {
self.visit_local(
local,
PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy),
location
);
}
ProjectionElem::Deref |
ProjectionElem::Subslice { from: _, to: _ } |
ProjectionElem::ConstantIndex { offset: _,
min_length: _,
from_end: _ } |
ProjectionElem::Downcast(_, _) => {
}
}
}
Expand Down

0 comments on commit a8d70d1

Please sign in to comment.