Rollup merge of #65056 - spastorino:place-mut-visitor-adjusts, r=oli-obk
Make visit projection iterative r? @oli-obk /cc @nikomatsakis
This commit is contained in:
commit
4a25c3c1ec
3 changed files with 111 additions and 88 deletions
|
@ -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) {
|
||||
|
@ -725,9 +734,19 @@ macro_rules! make_mir_visitor {
|
|||
projection: & $($mutability)? [PlaceElem<'tcx>],
|
||||
context: PlaceContext,
|
||||
location: Location) {
|
||||
if let [proj_base @ .., elem] = projection {
|
||||
self.visit_projection(base, proj_base, context, location);
|
||||
let mut cursor = projection;
|
||||
while let [proj_base @ .., elem] = cursor {
|
||||
cursor = proj_base;
|
||||
self.visit_projection_elem(base, cursor, elem, context, location);
|
||||
}
|
||||
}
|
||||
|
||||
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));
|
||||
|
@ -748,7 +767,6 @@ macro_rules! make_mir_visitor {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn super_local_decl(&mut self,
|
||||
local: Local,
|
||||
|
|
|
@ -404,25 +404,25 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
|
|||
self.super_assign(dest, rvalue, location);
|
||||
}
|
||||
|
||||
fn visit_projection(
|
||||
fn visit_projection_elem(
|
||||
&mut self,
|
||||
place_base: &PlaceBase<'tcx>,
|
||||
proj: &[PlaceElem<'tcx>],
|
||||
proj_base: &[PlaceElem<'tcx>],
|
||||
elem: &PlaceElem<'tcx>,
|
||||
context: PlaceContext,
|
||||
location: Location,
|
||||
) {
|
||||
trace!(
|
||||
"visit_place_projection: proj={:?} context={:?} location={:?}",
|
||||
proj,
|
||||
"visit_projection_elem: place_base={:?} proj_base={:?} elem={:?} \
|
||||
context={:?} location={:?}",
|
||||
place_base,
|
||||
proj_base,
|
||||
elem,
|
||||
context,
|
||||
location,
|
||||
);
|
||||
self.super_projection(place_base, proj, context, location);
|
||||
|
||||
let (elem, proj_base) = match proj.split_last() {
|
||||
Some(x) => x,
|
||||
None => return,
|
||||
};
|
||||
self.super_projection_elem(place_base, proj_base, elem, context, location);
|
||||
|
||||
match elem {
|
||||
ProjectionElem::Deref => {
|
||||
|
|
|
@ -1156,20 +1156,26 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn visit_projection(
|
||||
fn visit_projection_elem(
|
||||
&mut self,
|
||||
place_base: &PlaceBase<'tcx>,
|
||||
proj: &[PlaceElem<'tcx>],
|
||||
proj_base: &[PlaceElem<'tcx>],
|
||||
elem: &PlaceElem<'tcx>,
|
||||
context: PlaceContext,
|
||||
location: Location,
|
||||
) {
|
||||
debug!(
|
||||
"visit_place_projection: proj={:?} context={:?} location={:?}",
|
||||
proj, context, location,
|
||||
"visit_projection_elem: place_base={:?} proj_base={:?} elem={:?} \
|
||||
context={:?} location={:?}",
|
||||
place_base,
|
||||
proj_base,
|
||||
elem,
|
||||
context,
|
||||
location,
|
||||
);
|
||||
self.super_projection(place_base, proj, context, location);
|
||||
|
||||
if let [proj_base @ .., elem] = proj {
|
||||
self.super_projection_elem(place_base, proj_base, elem, context, location);
|
||||
|
||||
match elem {
|
||||
ProjectionElem::Deref => {
|
||||
if context.is_mutating_use() {
|
||||
|
@ -1234,7 +1240,6 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_operand(&mut self, operand: &Operand<'tcx>, location: Location) {
|
||||
debug!("visit_operand: operand={:?} location={:?}", operand, location);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue