about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSantiago Pastorino <spastorino@gmail.com>2019-07-19 22:11:57 +0200
committerSantiago Pastorino <spastorino@gmail.com>2019-07-20 05:08:39 +0200
commit7b456df4aba82ca62166f05e6c4608664dfb9223 (patch)
treee8a94ba6bd73ad495de701fc2a31ac84f77ce52d
parent17a465cb85c6bde2eca91aa0d5b13d6d993d7f76 (diff)
downloadrust-7b456df4aba82ca62166f05e6c4608664dfb9223.tar.gz
rust-7b456df4aba82ca62166f05e6c4608664dfb9223.zip
Avoid cloning Place in is_stable
-rw-r--r--src/librustc_mir/transform/add_retag.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/librustc_mir/transform/add_retag.rs b/src/librustc_mir/transform/add_retag.rs
index 0e534d9b757..887f93c6478 100644
--- a/src/librustc_mir/transform/add_retag.rs
+++ b/src/librustc_mir/transform/add_retag.rs
@@ -15,7 +15,7 @@ pub struct AddRetag;
 /// (Concurrent accesses by other threads are no problem as these are anyway non-atomic
 /// copies.  Data races are UB.)
 fn is_stable(
-    place: &Place<'_>,
+    place: PlaceRef<'_, '_>,
 ) -> bool {
     if let Some(proj) = &place.projection {
         match proj.elem {
@@ -32,9 +32,9 @@ fn is_stable(
             ProjectionElem::ConstantIndex { .. } |
             ProjectionElem::Subslice { .. } |
             ProjectionElem::Downcast { .. } =>
-                is_stable(&Place {
-                    base: place.base.clone(),
-                    projection: proj.base.clone(),
+                is_stable(PlaceRef {
+                    base: place.base,
+                    projection: &proj.base,
                 }),
         }
     } else {
@@ -79,7 +79,8 @@ impl MirPass for AddRetag {
         let needs_retag = |place: &Place<'tcx>| {
             // FIXME: Instead of giving up for unstable places, we should introduce
             // a temporary and retag on that.
-            is_stable(place) && may_have_reference(place.ty(&*local_decls, tcx).ty, tcx)
+            is_stable(place.as_place_ref())
+                && may_have_reference(place.ty(&*local_decls, tcx).ty, tcx)
         };
 
         // PART 1