diff --git a/compiler/rustc_middle/src/mir/visit.rs b/compiler/rustc_middle/src/mir/visit.rs index 1cfda71baf803..d285728ec0783 100644 --- a/compiler/rustc_middle/src/mir/visit.rs +++ b/compiler/rustc_middle/src/mir/visit.rs @@ -1118,11 +1118,9 @@ macro_rules! visit_place_fns { context: PlaceContext, location: Location, ) { - // FIXME: Use PlaceRef::iter_projections, once that exists. - let mut cursor = place_ref.projection; - while let &[ref proj_base @ .., elem] = cursor { - cursor = proj_base; - self.visit_projection_elem(place_ref.local, cursor, elem, context, location); + for (base, elem) in place_ref.iter_projections().rev() { + let base_proj = base.projection; + self.visit_projection_elem(place_ref.local, base_proj, elem, context, location); } }