about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc_mir/borrow_check/error_reporting.rs76
-rw-r--r--src/test/ui/borrowck/borrowck-describe-lvalue.rs2
-rw-r--r--src/test/ui/borrowck/borrowck-vec-pattern-move-tail.rs2
-rw-r--r--src/test/ui/nll/drop-no-may-dangle.rs4
-rw-r--r--src/test/ui/use/use-after-move-self.rs2
5 files changed, 34 insertions, 52 deletions
diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs
index b072e464a29..6a5b5d172bb 100644
--- a/src/librustc_mir/borrow_check/error_reporting.rs
+++ b/src/librustc_mir/borrow_check/error_reporting.rs
@@ -181,38 +181,36 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
                 );
             }
 
-            if let Some(ty) = self.retrieve_type_for_place(used_place) {
-                let needs_note = match ty.sty {
-                    ty::Closure(id, _) => {
-                        let tables = self.infcx.tcx.typeck_tables_of(id);
-                        let node_id = self.infcx.tcx.hir().as_local_node_id(id).unwrap();
-                        let hir_id = self.infcx.tcx.hir().node_to_hir_id(node_id);
-
-                        tables.closure_kind_origins().get(hir_id).is_none()
-                    }
-                    _ => true,
-                };
+            let ty = used_place.ty(self.mir, self.infcx.tcx).to_ty(self.infcx.tcx);
+            let needs_note = match ty.sty {
+                ty::Closure(id, _) => {
+                    let tables = self.infcx.tcx.typeck_tables_of(id);
+                    let node_id = self.infcx.tcx.hir().as_local_node_id(id).unwrap();
+                    let hir_id = self.infcx.tcx.hir().node_to_hir_id(node_id);
 
-                if needs_note {
-                    let mpi = self.move_data.moves[move_out_indices[0]].path;
-                    let place = &self.move_data.move_paths[mpi].place;
-
-                    if let Some(ty) = self.retrieve_type_for_place(place) {
-                        let note_msg = match self.describe_place_with_options(
-                            place,
-                            IncludingDowncast(true),
-                        ) {
-                            Some(name) => format!("`{}`", name),
-                            None => "value".to_owned(),
-                        };
-
-                        err.note(&format!(
-                            "move occurs because {} has type `{}`, \
-                             which does not implement the `Copy` trait",
-                            note_msg, ty
-                        ));
-                    }
+                    tables.closure_kind_origins().get(hir_id).is_none()
                 }
+                _ => true,
+            };
+
+            if needs_note {
+                let mpi = self.move_data.moves[move_out_indices[0]].path;
+                let place = &self.move_data.move_paths[mpi].place;
+
+                let ty = place.ty(self.mir, self.infcx.tcx).to_ty(self.infcx.tcx);
+                let note_msg = match self.describe_place_with_options(
+                    place,
+                    IncludingDowncast(true),
+                ) {
+                    Some(name) => format!("`{}`", name),
+                    None => "value".to_owned(),
+                };
+
+                err.note(&format!(
+                    "move occurs because {} has type `{}`, \
+                     which does not implement the `Copy` trait",
+                    note_msg, ty
+                ));
             }
 
             if let Some((_, mut old_err)) = self.move_error_reported
@@ -1558,7 +1556,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
                         )?;
                         buf.push_str("[");
                         if self.append_local_to_string(index, buf).is_err() {
-                            buf.push_str("..");
+                            buf.push_str("_");
                         }
                         buf.push_str("]");
                     }
@@ -1663,22 +1661,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
         }
     }
 
-    /// Retrieve type of a place for the current MIR representation
-    fn retrieve_type_for_place(&self, place: &Place<'tcx>) -> Option<ty::Ty> {
-        match place {
-            Place::Local(local) => {
-                let local = &self.mir.local_decls[*local];
-                Some(local.ty)
-            }
-            Place::Promoted(ref prom) => Some(prom.1),
-            Place::Static(ref st) => Some(st.ty),
-            Place::Projection(ref proj) => match proj.elem {
-                ProjectionElem::Field(_, ty) => Some(ty),
-                _ => None,
-            },
-        }
-    }
-
     /// Check if a place is a thread-local static.
     pub fn is_place_thread_local(&self, place: &Place<'tcx>) -> bool {
         if let Place::Static(statik) = place {
diff --git a/src/test/ui/borrowck/borrowck-describe-lvalue.rs b/src/test/ui/borrowck/borrowck-describe-lvalue.rs
index 00ce234d6d5..eb622ac10ad 100644
--- a/src/test/ui/borrowck/borrowck-describe-lvalue.rs
+++ b/src/test/ui/borrowck/borrowck-describe-lvalue.rs
@@ -260,7 +260,7 @@ fn main() {
         let x = &mut v;
         v[0].y;
         //[ast]~^ ERROR cannot use `v[..].y` because it was mutably borrowed
-        //[mir]~^^ ERROR cannot use `v[..].y` because it was mutably borrowed
+        //[mir]~^^ ERROR cannot use `v[_].y` because it was mutably borrowed
         //[mir]~| ERROR cannot use `*v` because it was mutably borrowed
         drop(x);
     }
diff --git a/src/test/ui/borrowck/borrowck-vec-pattern-move-tail.rs b/src/test/ui/borrowck/borrowck-vec-pattern-move-tail.rs
index 540f9333bc0..e14ecd90d56 100644
--- a/src/test/ui/borrowck/borrowck-vec-pattern-move-tail.rs
+++ b/src/test/ui/borrowck/borrowck-vec-pattern-move-tail.rs
@@ -15,7 +15,7 @@ fn main() {
     println!("t[0]: {}", t[0]);
     a[2] = 0; //[ast]~ ERROR cannot assign to `a[..]` because it is borrowed
               //[cmp]~^ ERROR cannot assign to `a[..]` because it is borrowed (Ast)
-              //[cmp]~| ERROR cannot assign to `a[..]` because it is borrowed (Mir)
+              //[cmp]~| ERROR cannot assign to `a[_]` because it is borrowed (Mir)
     println!("t[0]: {}", t[0]);
     t[0];
 }
diff --git a/src/test/ui/nll/drop-no-may-dangle.rs b/src/test/ui/nll/drop-no-may-dangle.rs
index e3659a2f2f6..23f7f6c265e 100644
--- a/src/test/ui/nll/drop-no-may-dangle.rs
+++ b/src/test/ui/nll/drop-no-may-dangle.rs
@@ -17,10 +17,10 @@ fn main() {
         use_x(*p.value);
     } else {
         use_x(22);
-        v[0] += 1; //~ ERROR cannot assign to `v[..]` because it is borrowed
+        v[0] += 1; //~ ERROR cannot assign to `v[_]` because it is borrowed
     }
 
-    v[0] += 1; //~ ERROR cannot assign to `v[..]` because it is borrowed
+    v[0] += 1; //~ ERROR cannot assign to `v[_]` because it is borrowed
 }
 
 struct WrapMayNotDangle<T> {
diff --git a/src/test/ui/use/use-after-move-self.rs b/src/test/ui/use/use-after-move-self.rs
index 1337d61a6d8..a6f6c45573d 100644
--- a/src/test/ui/use/use-after-move-self.rs
+++ b/src/test/ui/use/use-after-move-self.rs
@@ -7,7 +7,7 @@ struct S {
 impl S {
     pub fn foo(self) -> isize {
         self.bar();
-        return *self.x;  //~ ERROR use of moved value: `*self.x`
+        return *self.x;  //~ ERROR use of moved value: `self`
     }
 
     pub fn bar(self) {}