]> git.lizzy.rs Git - rust.git/commitdiff
Use the correct type for cannot move error
authormatthewjasper <mjjasper1@gmail.com>
Mon, 13 Nov 2017 22:40:22 +0000 (22:40 +0000)
committermatthewjasper <mjjasper1@gmail.com>
Mon, 13 Nov 2017 22:40:22 +0000 (22:40 +0000)
src/librustc_mir/borrow_check.rs
src/librustc_mir/dataflow/move_paths/builder.rs
src/librustc_mir/dataflow/move_paths/mod.rs
src/test/compile-fail/E0508.rs

index d2524b306cfed6a22c8b2f1fb6aeacaedcc4b376..9b116630bfce9c079cc8279f9448e48c1ffb6d3f 100644 (file)
@@ -95,9 +95,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
                         tcx.cannot_move_out_of(span, "borrowed_content", origin),
                     IllegalMoveOriginKind::InteriorOfTypeWithDestructor { container_ty: ty } =>
                         tcx.cannot_move_out_of_interior_of_drop(span, ty, origin),
-                    IllegalMoveOriginKind::InteriorOfSlice { elem_ty: ty, is_index } =>
-                        tcx.cannot_move_out_of_interior_noncopy(span, ty, is_index, origin),
-                    IllegalMoveOriginKind::InteriorOfArray { elem_ty: ty, is_index } =>
+                    IllegalMoveOriginKind::InteriorOfSliceOrArray { ty, is_index } =>
                         tcx.cannot_move_out_of_interior_noncopy(span, ty, is_index, origin),
                 };
                 err.emit();
index 79ea745125c5332569172eb9a8aa81573a3bdfa7..f333dd4d2a1783c2d74dd643bf44d01b27120697 100644 (file)
@@ -137,21 +137,21 @@ fn move_path_for_projection(&mut self,
             // move out of union - always move the entire union
             ty::TyAdt(adt, _) if adt.is_union() =>
                 return Err(MoveError::UnionMove { path: base }),
-            ty::TySlice(elem_ty) =>
+            ty::TySlice(_) =>
                 return Err(MoveError::cannot_move_out_of(
                     mir.source_info(self.loc).span,
-                    InteriorOfSlice {
-                        elem_ty, is_index: match proj.elem {
+                    InteriorOfSliceOrArray {
+                        ty: lv_ty, is_index: match proj.elem {
                             ProjectionElem::Index(..) => true,
                             _ => false
                         },
                     })),
-            ty::TyArray(elem_ty, _num_elems) => match proj.elem {
+            ty::TyArray(..) => match proj.elem {
                 ProjectionElem::Index(..) =>
                     return Err(MoveError::cannot_move_out_of(
                         mir.source_info(self.loc).span,
-                        InteriorOfArray {
-                            elem_ty, is_index: true
+                        InteriorOfSliceOrArray {
+                            ty: lv_ty, is_index: true
                         })),
                 _ => {
                     // FIXME: still badly broken
index 5bfecd01aaa822c809175a865355d2fa56628daf..73218c9815024225d8be4eec876796c4f5e50a83 100644 (file)
@@ -239,8 +239,7 @@ pub(crate) enum IllegalMoveOriginKind<'tcx> {
     Static,
     BorrowedContent,
     InteriorOfTypeWithDestructor { container_ty: ty::Ty<'tcx> },
-    InteriorOfSlice { elem_ty: ty::Ty<'tcx>, is_index: bool, },
-    InteriorOfArray { elem_ty: ty::Ty<'tcx>, is_index: bool, },
+    InteriorOfSliceOrArray { ty: ty::Ty<'tcx>, is_index: bool, },
 }
 
 #[derive(Debug)]
index a72c29cc3a59e55f7f14058b630b206bf78b31bf..d75f92580cc1d2fc9e6d5e4d490970827e285c84 100644 (file)
@@ -8,9 +8,14 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// revisions: ast mir
+//[mir]compile-flags: -Zborrowck-mir
+
 struct NonCopy;
 
 fn main() {
     let array = [NonCopy; 1];
-    let _value = array[0]; //~ ERROR E0508
+    let _value = array[0];  //[ast]~ ERROR E0508
+                            //[mir]~^ ERROR (Ast) [E0508]
+                            //[mir]~| ERROR (Mir) [E0508]
 }