]> git.lizzy.rs Git - rust.git/commitdiff
Avoid cloning Place in classify_drop_access_kind
authorSantiago Pastorino <spastorino@gmail.com>
Fri, 19 Jul 2019 17:36:47 +0000 (19:36 +0200)
committerSantiago Pastorino <spastorino@gmail.com>
Sat, 20 Jul 2019 03:08:39 +0000 (05:08 +0200)
src/librustc_mir/borrow_check/conflict_errors.rs

index 83ae87bc166717db378fc2caaec3ad6acedd72f5..95fc22dc5eb766c6636314341cf97e829745c07e 100644 (file)
@@ -730,7 +730,7 @@ pub(super) fn report_borrowed_value_does_not_live_long_enough(
             }, borrow_span));
 
         if let StorageDeadOrDrop::Destructor(dropped_ty) =
-            self.classify_drop_access_kind(&borrow.borrowed_place)
+            self.classify_drop_access_kind(borrow.borrowed_place.as_place_ref())
         {
             // If a borrow of path `B` conflicts with drop of `D` (and
             // we're not in the uninteresting case where `B` is a
@@ -1505,16 +1505,16 @@ pub(super) fn report_illegal_reassignment(
         err.buffer(&mut self.errors_buffer);
     }
 
-    fn classify_drop_access_kind(&self, place: &Place<'tcx>) -> StorageDeadOrDrop<'tcx> {
+    fn classify_drop_access_kind(&self, place: PlaceRef<'cx, 'tcx>) -> StorageDeadOrDrop<'tcx> {
         let tcx = self.infcx.tcx;
         match place.projection {
             None => {
                 StorageDeadOrDrop::LocalStorageDead
             }
             Some(box Projection { ref base, ref elem }) => {
-                let base_access = self.classify_drop_access_kind(&Place {
-                    base: place.base.clone(),
-                    projection: base.clone(),
+                let base_access = self.classify_drop_access_kind(PlaceRef {
+                    base: place.base,
+                    projection: base,
                 });
                 match elem {
                     ProjectionElem::Deref => match base_access {