]> git.lizzy.rs Git - rust.git/commitdiff
make `super_projection` take a `PlaceRef`
authorHenry Boisdequin <65845077+henryboisdequin@users.noreply.github.com>
Sat, 20 Feb 2021 11:16:05 +0000 (16:46 +0530)
committerHenry Boisdequin <65845077+henryboisdequin@users.noreply.github.com>
Sat, 20 Feb 2021 11:26:08 +0000 (16:56 +0530)
compiler/rustc_middle/src/mir/visit.rs
compiler/rustc_mir/src/transform/simplify.rs

index 66dd278b578402773ed65dad641fca77670a37cf..9530efaedbce44e2b5a1ce2aeec6f8cc00871ddc 100644 (file)
@@ -1002,7 +1002,7 @@ fn visit_projection(
             context: PlaceContext,
             location: Location,
         ) {
-            self.super_projection(place_ref.local, place_ref.projection, context, location);
+            self.super_projection(place_ref, context, location);
         }
 
         fn visit_projection_elem(
@@ -1037,15 +1037,15 @@ fn super_place(&mut self, place: &Place<'tcx>, context: PlaceContext, location:
 
         fn super_projection(
             &mut self,
-            local: Local,
-            projection: &[PlaceElem<'tcx>],
+            place_ref: PlaceRef<'tcx>,
             context: PlaceContext,
             location: Location,
         ) {
-            let mut cursor = projection;
+            // 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(local, cursor, elem, context, location);
+                self.visit_projection_elem(place_ref.local, cursor, elem, context, location);
             }
         }
 
index 289231e52cb41baf65c40823b75eb58f6e2f9d59..d9abfec85c9e7643e4d68ad0118d05781dfc5b18 100644 (file)
@@ -414,8 +414,7 @@ fn visit_lhs(&mut self, place: &Place<'tcx>, location: Location) {
         } else {
             // A definition. Although, it still might use other locals for indexing.
             self.super_projection(
-                place.local,
-                &place.projection,
+                place.as_ref(),
                 PlaceContext::MutatingUse(MutatingUseContext::Projection),
                 location,
             );