about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/mir-opt/const_prop/return_place.rs6
-rw-r--r--src/test/mir-opt/uniform_array_move_out.rs56
-rw-r--r--src/test/ui/borrowck/borrowck-move-out-from-array-no-overlap.rs69
-rw-r--r--src/test/ui/borrowck/borrowck-move-out-from-array-use-no-overlap.rs69
-rw-r--r--src/test/ui/borrowck/borrowck-move-out-from-array-use.rs99
-rw-r--r--src/test/ui/borrowck/borrowck-move-out-from-array-use.stderr143
-rw-r--r--src/test/ui/borrowck/borrowck-move-out-from-array.rs69
-rw-r--r--src/test/ui/borrowck/borrowck-move-out-from-array.stderr100
-rw-r--r--src/test/ui/borrowck/borrowck-slice-pattern-element-loan-array-no-overlap.rs66
-rw-r--r--src/test/ui/borrowck/borrowck-slice-pattern-element-loan-array.rs60
-rw-r--r--src/test/ui/borrowck/borrowck-slice-pattern-element-loan-array.stderr86
-rw-r--r--src/test/ui/borrowck/borrowck-slice-pattern-element-loan-slice-no-overlap.rs61
-rw-r--r--src/test/ui/borrowck/borrowck-slice-pattern-element-loan-slice.rs (renamed from src/test/ui/borrowck/borrowck-slice-pattern-element-loan.rs)46
-rw-r--r--src/test/ui/borrowck/borrowck-slice-pattern-element-loan-slice.stderr (renamed from src/test/ui/borrowck/borrowck-slice-pattern-element-loan.stderr)24
-rw-r--r--src/test/ui/drop/dynamic-drop.rs32
15 files changed, 854 insertions, 132 deletions
diff --git a/src/test/mir-opt/const_prop/return_place.rs b/src/test/mir-opt/const_prop/return_place.rs
index cc9951b554d..ea7c1e7ccd0 100644
--- a/src/test/mir-opt/const_prop/return_place.rs
+++ b/src/test/mir-opt/const_prop/return_place.rs
@@ -21,9 +21,6 @@ fn main() {
 //         _0 = move (_1.0: u32);
 //         return;
 //     }
-//     bb2 (cleanup): {
-//         resume;
-//     }
 // }
 // END rustc.add.ConstProp.before.mir
 // START rustc.add.ConstProp.after.mir
@@ -38,9 +35,6 @@ fn main() {
 //         _0 = const 4u32;
 //         return;
 //     }
-//     bb2 (cleanup): {
-//         resume;
-//     }
 // }
 // END rustc.add.ConstProp.after.mir
 // START rustc.add.PreCodegen.before.mir
diff --git a/src/test/mir-opt/uniform_array_move_out.rs b/src/test/mir-opt/uniform_array_move_out.rs
index c249154c71e..f2e1864096e 100644
--- a/src/test/mir-opt/uniform_array_move_out.rs
+++ b/src/test/mir-opt/uniform_array_move_out.rs
@@ -18,58 +18,12 @@ fn main() {
 
 // END RUST SOURCE
 
-// START rustc.move_out_from_end.UniformArrayMoveOut.before.mir
-//     StorageLive(_6);
-//      _6 = move _1[-1 of 1];
-//      _0 = ();
-// END rustc.move_out_from_end.UniformArrayMoveOut.before.mir
-
-// START rustc.move_out_from_end.UniformArrayMoveOut.after.mir
-//     StorageLive(_6);
+// START rustc.move_out_from_end.mir_map.0.mir
 //      _6 = move _1[1 of 2];
-//      nop;
 //      _0 = ();
-// END rustc.move_out_from_end.UniformArrayMoveOut.after.mir
-
-// START rustc.move_out_by_subslice.UniformArrayMoveOut.before.mir
-//     StorageLive(_6);
-//      _6 = move _1[0:];
-// END rustc.move_out_by_subslice.UniformArrayMoveOut.before.mir
-
-// START rustc.move_out_by_subslice.UniformArrayMoveOut.after.mir
-//     StorageLive(_6);
-//     StorageLive(_7);
-//     _7 = move _1[0 of 2];
-//     StorageLive(_8);
-//     _8 = move _1[1 of 2];
-//     _6 = [move _7, move _8];
-//     StorageDead(_7);
-//     StorageDead(_8);
-//     nop;
-//     _0 = ();
-// END rustc.move_out_by_subslice.UniformArrayMoveOut.after.mir
-
-// START rustc.move_out_by_subslice.RestoreSubsliceArrayMoveOut.before.mir
-//     StorageLive(_6);
-//     StorageLive(_7);
-//     _7 = move _1[0 of 2];
-//     StorageLive(_8);
-//     _8 = move _1[1 of 2];
-//     _6 = [move _7, move _8];
-//     StorageDead(_7);
-//     StorageDead(_8);
-//     _0 = ();
-// END rustc.move_out_by_subslice.RestoreSubsliceArrayMoveOut.before.mir
+// END rustc.move_out_from_end.mir_map.0.mir
 
-// START rustc.move_out_by_subslice.RestoreSubsliceArrayMoveOut.after.mir
-//     StorageLive(_6);
-//     nop;
-//     nop;
-//     nop;
-//     nop;
-//     _6 = move _1[0:];
-//     nop;
-//     nop;
-//     nop;
+// START rustc.move_out_by_subslice.mir_map.0.mir
+//     _6 = move _1[0..2];
 //     _0 = ();
-// END rustc.move_out_by_subslice.RestoreSubsliceArrayMoveOut.after.mir
+// END rustc.move_out_by_subslice.mir_map.0.mir
diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array-no-overlap.rs b/src/test/ui/borrowck/borrowck-move-out-from-array-no-overlap.rs
new file mode 100644
index 00000000000..8f274cf73cb
--- /dev/null
+++ b/src/test/ui/borrowck/borrowck-move-out-from-array-no-overlap.rs
@@ -0,0 +1,69 @@
+// check-pass
+
+#![feature(slice_patterns)]
+
+fn array() -> [(String, String); 3] {
+    Default::default()
+}
+
+// Const Index + Const Index
+
+fn move_out_from_begin_and_one_from_end() {
+    let a = array();
+    let [_, _, _x] = a;
+    let [.., _y, _] = a;
+}
+
+fn move_out_from_begin_field_and_end_field() {
+    let a = array();
+    let [_, _, (_x, _)] = a;
+    let [.., (_, _y)] = a;
+}
+
+// Const Index + Slice
+
+fn move_out_by_const_index_and_subslice() {
+    let a = array();
+    let [_x, _, _] = a;
+    let [_, _y @ ..] = a;
+}
+
+fn move_out_by_const_index_end_and_subslice() {
+    let a = array();
+    let [.., _x] = a;
+    let [_y @ .., _] = a;
+}
+
+fn move_out_by_const_index_field_and_subslice() {
+    let a = array();
+    let [(_x, _), _, _] = a;
+    let [_, _y @ ..] = a;
+}
+
+fn move_out_by_const_index_end_field_and_subslice() {
+    let a = array();
+    let [.., (_x, _)] = a;
+    let [_y @ .., _] = a;
+}
+
+fn move_out_by_const_subslice_and_index_field() {
+    let a = array();
+    let [_, _y @ ..] = a;
+    let [(_x, _), _, _] = a;
+}
+
+fn move_out_by_const_subslice_and_end_index_field() {
+    let a = array();
+    let [_y @ .., _] = a;
+    let [.., (_x, _)] = a;
+}
+
+// Slice + Slice
+
+fn move_out_by_subslice_and_subslice() {
+    let a = array();
+    let [x @ .., _, _] = a;
+    let [_, _y @ ..] = a;
+}
+
+fn main() {}
diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array-use-no-overlap.rs b/src/test/ui/borrowck/borrowck-move-out-from-array-use-no-overlap.rs
new file mode 100644
index 00000000000..57ce2417570
--- /dev/null
+++ b/src/test/ui/borrowck/borrowck-move-out-from-array-use-no-overlap.rs
@@ -0,0 +1,69 @@
+// check-pass
+
+#![feature(slice_patterns)]
+
+fn array() -> [(String, String); 3] {
+    Default::default()
+}
+
+// Const Index + Const Index
+
+fn move_out_from_begin_and_one_from_end() {
+    let a = array();
+    let [_, _, _x] = a;
+    let [.., ref _y, _] = a;
+}
+
+fn move_out_from_begin_field_and_end_field() {
+    let a = array();
+    let [_, _, (_x, _)] = a;
+    let [.., (_, ref _y)] = a;
+}
+
+// Const Index + Slice
+
+fn move_out_by_const_index_and_subslice() {
+    let a = array();
+    let [_x, _, _] = a;
+    let [_, ref _y @ ..] = a;
+}
+
+fn move_out_by_const_index_end_and_subslice() {
+    let a = array();
+    let [.., _x] = a;
+    let [ref _y @ .., _] = a;
+}
+
+fn move_out_by_const_index_field_and_subslice() {
+    let a = array();
+    let [(_x, _), _, _] = a;
+    let [_, ref _y @ ..] = a;
+}
+
+fn move_out_by_const_index_end_field_and_subslice() {
+    let a = array();
+    let [.., (_x, _)] = a;
+    let [ref _y @ .., _] = a;
+}
+
+fn move_out_by_const_subslice_and_index_field() {
+    let a = array();
+    let [_, _y @ ..] = a;
+    let [(ref _x, _), _, _] = a;
+}
+
+fn move_out_by_const_subslice_and_end_index_field() {
+    let a = array();
+    let [_y @ .., _] = a;
+    let [.., (ref _x, _)] = a;
+}
+
+// Slice + Slice
+
+fn move_out_by_subslice_and_subslice() {
+    let a = array();
+    let [x @ .., _, _] = a;
+    let [_, ref _y @ ..] = a;
+}
+
+fn main() {}
diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array-use.rs b/src/test/ui/borrowck/borrowck-move-out-from-array-use.rs
new file mode 100644
index 00000000000..778beefbf2c
--- /dev/null
+++ b/src/test/ui/borrowck/borrowck-move-out-from-array-use.rs
@@ -0,0 +1,99 @@
+#![feature(slice_patterns)]
+
+fn array() -> [(String, String); 3] {
+    Default::default()
+}
+
+// Const Index + Const Index
+
+fn move_out_from_begin_and_end() {
+    let a = array();
+    let [_, _, _x] = a;
+    let [.., ref _y] = a; //~ ERROR [E0382]
+}
+
+fn move_out_from_begin_field_and_end() {
+    let a = array();
+    let [_, _, (_x, _)] = a;
+    let [.., ref _y] = a; //~ ERROR [E0382]
+}
+
+fn move_out_from_begin_field_and_end_field() {
+    let a = array();
+    let [_, _, (_x, _)] = a;
+    let [.., (ref _y, _)] = a; //~ ERROR [E0382]
+}
+
+// Const Index + Slice
+
+fn move_out_by_const_index_and_subslice() {
+    let a = array();
+    let [_x, _, _] = a;
+    let [ref _y @ .., _, _] = a; //~ ERROR [E0382]
+}
+
+fn move_out_by_const_index_end_and_subslice() {
+    let a = array();
+    let [.., _x] = a;
+    let [_, _, ref _y @ ..] = a; //~ ERROR [E0382]
+}
+
+fn move_out_by_const_index_field_and_subslice() {
+    let a = array();
+    let [(_x, _), _, _] = a;
+    let [ref _y @ .., _, _] = a; //~ ERROR [E0382]
+}
+
+fn move_out_by_const_index_end_field_and_subslice() {
+    let a = array();
+    let [.., (_x, _)] = a;
+    let [_, _, ref _y @ ..] = a; //~ ERROR [E0382]
+}
+
+fn move_out_by_subslice_and_const_index_field() {
+    let a = array();
+    let [_y @ .., _, _] = a;
+    let [(ref _x, _), _, _] = a; //~ ERROR [E0382]
+}
+
+fn move_out_by_subslice_and_const_index_end_field() {
+    let a = array();
+    let [_, _, _y @ ..] = a;
+    let [.., (ref _x, _)] = a; //~ ERROR [E0382]
+}
+
+// Slice + Slice
+
+fn move_out_by_subslice_and_subslice() {
+    let a = array();
+    let [x @ .., _] = a;
+    let [_, ref _y @ ..] = a; //~ ERROR [E0382]
+}
+
+// Move + Assign
+
+fn move_out_and_assign_end() {
+    let mut a = array();
+    let [_, _, _x] = a;
+    a[2] = Default::default(); //~ ERROR [E0382]
+}
+
+fn move_out_and_assign_end_field() {
+    let mut a = array();
+    let [_, _, (_x, _)] = a;
+    a[2].1 = Default::default(); //~ ERROR [E0382]
+}
+
+fn move_out_slice_and_assign_end() {
+    let mut a = array();
+    let [_, _, _x @ ..] = a;
+    a[0] = Default::default(); //~ ERROR [E0382]
+}
+
+fn move_out_slice_and_assign_end_field() {
+    let mut a = array();
+    let [_, _, _x @ ..] = a;
+    a[0].1 = Default::default(); //~ ERROR [E0382]
+}
+
+fn main() {}
diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array-use.stderr b/src/test/ui/borrowck/borrowck-move-out-from-array-use.stderr
new file mode 100644
index 00000000000..2a7b89132c1
--- /dev/null
+++ b/src/test/ui/borrowck/borrowck-move-out-from-array-use.stderr
@@ -0,0 +1,143 @@
+error[E0382]: borrow of moved value: `a[..]`
+  --> $DIR/borrowck-move-out-from-array-use.rs:12:14
+   |
+LL |     let [_, _, _x] = a;
+   |                -- value moved here
+LL |     let [.., ref _y] = a;
+   |              ^^^^^^ value borrowed here after move
+   |
+   = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait
+
+error[E0382]: borrow of moved value: `a[..]`
+  --> $DIR/borrowck-move-out-from-array-use.rs:18:14
+   |
+LL |     let [_, _, (_x, _)] = a;
+   |                 -- value moved here
+LL |     let [.., ref _y] = a;
+   |              ^^^^^^ value borrowed here after partial move
+   |
+   = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait
+
+error[E0382]: borrow of moved value: `a[..].0`
+  --> $DIR/borrowck-move-out-from-array-use.rs:24:15
+   |
+LL |     let [_, _, (_x, _)] = a;
+   |                 -- value moved here
+LL |     let [.., (ref _y, _)] = a;
+   |               ^^^^^^ value borrowed here after move
+   |
+   = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait
+
+error[E0382]: borrow of moved value: `a`
+  --> $DIR/borrowck-move-out-from-array-use.rs:32:10
+   |
+LL |     let [_x, _, _] = a;
+   |          -- value moved here
+LL |     let [ref _y @ .., _, _] = a;
+   |          ^^^^^^^^^^^ value borrowed here after partial move
+   |
+   = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait
+
+error[E0382]: borrow of moved value: `a`
+  --> $DIR/borrowck-move-out-from-array-use.rs:38:16
+   |
+LL |     let [.., _x] = a;
+   |              -- value moved here
+LL |     let [_, _, ref _y @ ..] = a;
+   |                ^^^^^^^^^^^ value borrowed here after partial move
+   |
+   = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait
+
+error[E0382]: borrow of moved value: `a`
+  --> $DIR/borrowck-move-out-from-array-use.rs:44:10
+   |
+LL |     let [(_x, _), _, _] = a;
+   |           -- value moved here
+LL |     let [ref _y @ .., _, _] = a;
+   |          ^^^^^^^^^^^ value borrowed here after partial move
+   |
+   = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait
+
+error[E0382]: borrow of moved value: `a`
+  --> $DIR/borrowck-move-out-from-array-use.rs:50:16
+   |
+LL |     let [.., (_x, _)] = a;
+   |               -- value moved here
+LL |     let [_, _, ref _y @ ..] = a;
+   |                ^^^^^^^^^^^ value borrowed here after partial move
+   |
+   = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait
+
+error[E0382]: borrow of moved value: `a[..]`
+  --> $DIR/borrowck-move-out-from-array-use.rs:56:11
+   |
+LL |     let [_y @ .., _, _] = a;
+   |          ------- value moved here
+LL |     let [(ref _x, _), _, _] = a;
+   |           ^^^^^^ value borrowed here after move
+   |
+   = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait
+
+error[E0382]: borrow of moved value: `a[..]`
+  --> $DIR/borrowck-move-out-from-array-use.rs:62:15
+   |
+LL |     let [_, _, _y @ ..] = a;
+   |                ------- value moved here
+LL |     let [.., (ref _x, _)] = a;
+   |               ^^^^^^ value borrowed here after move
+   |
+   = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait
+
+error[E0382]: borrow of moved value: `a`
+  --> $DIR/borrowck-move-out-from-array-use.rs:70:13
+   |
+LL |     let [x @ .., _] = a;
+   |          ------ value moved here
+LL |     let [_, ref _y @ ..] = a;
+   |             ^^^^^^^^^^^ value borrowed here after partial move
+   |
+   = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait
+
+error[E0382]: use of moved value: `a`
+  --> $DIR/borrowck-move-out-from-array-use.rs:78:5
+   |
+LL |     let [_, _, _x] = a;
+   |                -- value moved here
+LL |     a[2] = Default::default();
+   |     ^^^^ value used here after partial move
+   |
+   = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait
+
+error[E0382]: use of moved value: `a`
+  --> $DIR/borrowck-move-out-from-array-use.rs:84:5
+   |
+LL |     let [_, _, (_x, _)] = a;
+   |                 -- value moved here
+LL |     a[2].1 = Default::default();
+   |     ^^^^ value used here after partial move
+   |
+   = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait
+
+error[E0382]: use of moved value: `a`
+  --> $DIR/borrowck-move-out-from-array-use.rs:90:5
+   |
+LL |     let [_, _, _x @ ..] = a;
+   |                ------- value moved here
+LL |     a[0] = Default::default();
+   |     ^^^^ value used here after partial move
+   |
+   = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait
+
+error[E0382]: use of moved value: `a`
+  --> $DIR/borrowck-move-out-from-array-use.rs:96:5
+   |
+LL |     let [_, _, _x @ ..] = a;
+   |                ------- value moved here
+LL |     a[0].1 = Default::default();
+   |     ^^^^ value used here after partial move
+   |
+   = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait
+
+error: aborting due to 14 previous errors
+
+For more information about this error, try `rustc --explain E0382`.
diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array.rs b/src/test/ui/borrowck/borrowck-move-out-from-array.rs
index ee6abf407a3..f9d3f6f2c07 100644
--- a/src/test/ui/borrowck/borrowck-move-out-from-array.rs
+++ b/src/test/ui/borrowck/borrowck-move-out-from-array.rs
@@ -1,16 +1,73 @@
-#![feature(box_syntax)]
 #![feature(slice_patterns)]
 
+fn array() -> [(String, String); 3] {
+    Default::default()
+}
+
+// Const Index + Const Index
+
 fn move_out_from_begin_and_end() {
-    let a = [box 1, box 2];
-    let [_, _x] = a;
+    let a = array();
+    let [_, _, _x] = a;
+    let [.., _y] = a; //~ ERROR [E0382]
+}
+
+fn move_out_from_begin_field_and_end() {
+    let a = array();
+    let [_, _, (_x, _)] = a;
     let [.., _y] = a; //~ ERROR [E0382]
 }
 
+fn move_out_from_begin_field_and_end_field() {
+    let a = array();
+    let [_, _, (_x, _)] = a;
+    let [.., (_y, _)] = a; //~ ERROR [E0382]
+}
+
+// Const Index + Slice
+
 fn move_out_by_const_index_and_subslice() {
-    let a = [box 1, box 2];
-    let [_x, _] = a;
-    let [_y @ ..] = a; //~ ERROR [E0382]
+    let a = array();
+    let [_x, _, _] = a;
+    let [_y @ .., _, _] = a; //~ ERROR [E0382]
+}
+
+fn move_out_by_const_index_end_and_subslice() {
+    let a = array();
+    let [.., _x] = a;
+    let [_, _, _y @ ..] = a; //~ ERROR [E0382]
+}
+
+fn move_out_by_const_index_field_and_subslice() {
+    let a = array();
+    let [(_x, _), _, _] = a;
+    let [_y @ .., _, _] = a; //~ ERROR [E0382]
+}
+
+fn move_out_by_const_index_end_field_and_subslice() {
+    let a = array();
+    let [.., (_x, _)] = a;
+    let [_, _, _y @ ..] = a; //~ ERROR [E0382]
+}
+
+fn move_out_by_subslice_and_const_index_field() {
+    let a = array();
+    let [_y @ .., _, _] = a;
+    let [(_x, _), _, _] = a; //~ ERROR [E0382]
+}
+
+fn move_out_by_subslice_and_const_index_end_field() {
+    let a = array();
+    let [_, _, _y @ ..] = a;
+    let [.., (_x, _)] = a; //~ ERROR [E0382]
+}
+
+// Slice + Slice
+
+fn move_out_by_subslice_and_subslice() {
+    let a = array();
+    let [x @ .., _] = a;
+    let [_, _y @ ..] = a; //~ ERROR [E0382]
 }
 
 fn main() {}
diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array.stderr b/src/test/ui/borrowck/borrowck-move-out-from-array.stderr
index b34c03e6def..08134a2a323 100644
--- a/src/test/ui/borrowck/borrowck-move-out-from-array.stderr
+++ b/src/test/ui/borrowck/borrowck-move-out-from-array.stderr
@@ -1,23 +1,103 @@
 error[E0382]: use of moved value: `a[..]`
-  --> $DIR/borrowck-move-out-from-array.rs:7:14
+  --> $DIR/borrowck-move-out-from-array.rs:12:14
    |
-LL |     let [_, _x] = a;
-   |             -- value moved here
+LL |     let [_, _, _x] = a;
+   |                -- value moved here
 LL |     let [.., _y] = a;
    |              ^^ value used here after move
    |
-   = note: move occurs because `a[..]` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait
+   = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait
 
 error[E0382]: use of moved value: `a[..]`
-  --> $DIR/borrowck-move-out-from-array.rs:13:10
+  --> $DIR/borrowck-move-out-from-array.rs:18:14
    |
-LL |     let [_x, _] = a;
+LL |     let [_, _, (_x, _)] = a;
+   |                 -- value moved here
+LL |     let [.., _y] = a;
+   |              ^^ value used here after partial move
+   |
+   = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait
+
+error[E0382]: use of moved value: `a[..].0`
+  --> $DIR/borrowck-move-out-from-array.rs:24:15
+   |
+LL |     let [_, _, (_x, _)] = a;
+   |                 -- value moved here
+LL |     let [.., (_y, _)] = a;
+   |               ^^ value used here after move
+   |
+   = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait
+
+error[E0382]: use of moved value: `a`
+  --> $DIR/borrowck-move-out-from-array.rs:32:10
+   |
+LL |     let [_x, _, _] = a;
    |          -- value moved here
-LL |     let [_y @ ..] = a;
-   |          ^^^^^^^ value used here after move
+LL |     let [_y @ .., _, _] = a;
+   |          ^^^^^^^ value used here after partial move
+   |
+   = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait
+
+error[E0382]: use of moved value: `a`
+  --> $DIR/borrowck-move-out-from-array.rs:38:16
+   |
+LL |     let [.., _x] = a;
+   |              -- value moved here
+LL |     let [_, _, _y @ ..] = a;
+   |                ^^^^^^^ value used here after partial move
+   |
+   = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait
+
+error[E0382]: use of moved value: `a`
+  --> $DIR/borrowck-move-out-from-array.rs:44:10
+   |
+LL |     let [(_x, _), _, _] = a;
+   |           -- value moved here
+LL |     let [_y @ .., _, _] = a;
+   |          ^^^^^^^ value used here after partial move
+   |
+   = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait
+
+error[E0382]: use of moved value: `a`
+  --> $DIR/borrowck-move-out-from-array.rs:50:16
+   |
+LL |     let [.., (_x, _)] = a;
+   |               -- value moved here
+LL |     let [_, _, _y @ ..] = a;
+   |                ^^^^^^^ value used here after partial move
+   |
+   = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait
+
+error[E0382]: use of moved value: `a[..].0`
+  --> $DIR/borrowck-move-out-from-array.rs:56:11
+   |
+LL |     let [_y @ .., _, _] = a;
+   |          ------- value moved here
+LL |     let [(_x, _), _, _] = a;
+   |           ^^ value used here after move
+   |
+   = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait
+
+error[E0382]: use of moved value: `a[..].0`
+  --> $DIR/borrowck-move-out-from-array.rs:62:15
+   |
+LL |     let [_, _, _y @ ..] = a;
+   |                ------- value moved here
+LL |     let [.., (_x, _)] = a;
+   |               ^^ value used here after move
+   |
+   = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait
+
+error[E0382]: use of moved value: `a`
+  --> $DIR/borrowck-move-out-from-array.rs:70:13
+   |
+LL |     let [x @ .., _] = a;
+   |          ------ value moved here
+LL |     let [_, _y @ ..] = a;
+   |             ^^^^^^^ value used here after partial move
    |
-   = note: move occurs because `a[..]` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait
+   = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait
 
-error: aborting due to 2 previous errors
+error: aborting due to 10 previous errors
 
 For more information about this error, try `rustc --explain E0382`.
diff --git a/src/test/ui/borrowck/borrowck-slice-pattern-element-loan-array-no-overlap.rs b/src/test/ui/borrowck/borrowck-slice-pattern-element-loan-array-no-overlap.rs
new file mode 100644
index 00000000000..7d91a212647
--- /dev/null
+++ b/src/test/ui/borrowck/borrowck-slice-pattern-element-loan-array-no-overlap.rs
@@ -0,0 +1,66 @@
+// check-pass
+
+#![feature(slice_patterns)]
+
+fn nop(_s: &[& i32]) {}
+fn nop_subslice(_s: &[i32]) {}
+
+fn const_index_ok(s: &mut [i32; 4]) {
+    let [ref first, ref second, _, ref fourth, ..] = *s;
+    let [_, _, ref mut third, ..] = *s;
+    nop(&[first, second, third, fourth]);
+}
+
+fn const_index_from_end_ok(s: &mut [i32; 4]) {
+    let [.., ref fourth, ref third, _, ref first] = *s;
+    let [.., ref mut second, _] = *s;
+    nop(&[first, second, third, fourth]);
+}
+
+fn const_index_mixed(s: &mut [i32; 6]) {
+    let [.., _, ref from_end4, ref from_end3, _, ref from_end1] = *s;
+
+    let [ref mut from_begin0, ..] = *s;
+    nop(&[from_begin0, from_end1, from_end3, from_end4]);
+    let [_, ref mut from_begin1, ..] = *s;
+    nop(&[from_begin1, from_end1, from_end3, from_end4]);
+
+    let [ref from_begin0, ref from_begin1, _, ref from_begin3, _, ..] = *s;
+
+    let [.., ref mut from_end1] = *s;
+    nop(&[from_begin0, from_begin1, from_begin3, from_end1]);
+    let [.., ref mut from_end2, _] = *s;
+    nop(&[from_begin0, from_begin1, from_begin3, from_end2]);
+    let [.., ref mut from_end4, _, _, _] = *s;
+    nop(&[from_begin0, from_begin1, from_begin3, from_end4]);
+}
+
+fn const_index_and_subslice_ok(s: &mut [i32; 4]) {
+    let [ref first, ref second, ..] = *s;
+    let [_, _, ref mut tail @ ..] = *s;
+    nop(&[first, second]);
+    nop_subslice(tail);
+}
+
+fn const_index_and_subslice_from_end_ok(s: &mut [i32; 4]) {
+    let [.., ref second, ref first] = *s;
+    let [ref mut tail @ .., _, _] = *s;
+    nop(&[first, second]);
+    nop_subslice(tail);
+}
+
+fn subslices(s: &mut [i32; 4]) {
+    let [_, _, ref s1 @ ..] = *s;
+    let [ref mut s2 @ .., _, _] = *s;
+    nop_subslice(s1);
+    nop_subslice(s2);
+}
+
+fn main() {
+    let mut v = [1,2,3,4];
+    const_index_ok(&mut v);
+    const_index_from_end_ok(&mut v);
+    const_index_and_subslice_ok(&mut v);
+    const_index_and_subslice_from_end_ok(&mut v);
+    subslices(&mut v);
+}
diff --git a/src/test/ui/borrowck/borrowck-slice-pattern-element-loan-array.rs b/src/test/ui/borrowck/borrowck-slice-pattern-element-loan-array.rs
new file mode 100644
index 00000000000..f03a2ab8fa8
--- /dev/null
+++ b/src/test/ui/borrowck/borrowck-slice-pattern-element-loan-array.rs
@@ -0,0 +1,60 @@
+#![feature(slice_patterns)]
+
+fn nop(_s: &[& i32]) {}
+fn nop_subslice(_s: &[i32]) {}
+
+fn const_index_err(s: &mut [i32; 4]) {
+    let [ref first, ref second, ..] = *s;
+    let [_, ref mut  second2, ref mut third, ..] = *s; //~ERROR
+    nop(&[first, second, second2, third]);
+}
+
+fn const_index_from_end_err(s: &mut [i32; 4]) {
+    let [.., ref fourth, ref third, _, ref first] = *s;
+    let [.., ref mut third2, _, _] = *s; //~ERROR
+    nop(&[first, third, third2, fourth]);
+}
+
+fn const_index_mixed(s: &mut [i32; 6]) {
+    let [.., _, ref from_end4, ref from_end3, _, ref from_end1] = *s;
+
+    let [_, _, ref mut from_begin2, ..] = *s; //~ERROR
+    nop(&[from_begin2, from_end1, from_end3, from_end4]);
+    let [_, _, _, ref mut from_begin3, ..] = *s; //~ERROR
+    nop(&[from_begin3, from_end1, from_end3, from_end4]);
+
+    let [ref from_begin0, ref from_begin1, _, ref from_begin3, _, ..] = *s;
+
+    let [.., ref mut from_end3, _,  _] = *s; //~ERROR
+    nop(&[from_begin0, from_begin1, from_begin3, from_end3]);
+}
+
+fn const_index_and_subslice_err(s: &mut [i32; 4]) {
+    let [ref first, ref second, ..] = *s;
+    let [_, ref mut tail @ ..] = *s; //~ERROR
+    nop(&[first, second]);
+    nop_subslice(tail);
+}
+
+fn const_index_and_subslice_from_end_err(s: &mut [i32; 4]) {
+    let [.., ref second, ref first] = *s;
+    let [ref mut tail @ .., _] = *s; //~ERROR
+    nop(&[first, second]);
+    nop_subslice(tail);
+}
+
+fn subslices_overlap(s: &mut [i32; 4]) {
+    let [_,  ref s1 @ ..] = *s;
+    let [ref mut s2 @ .., _, _] = *s; //~ERROR
+    nop_subslice(s1);
+    nop_subslice(s2);
+}
+
+fn main() {
+    let mut v = [1,2,3,4];
+    const_index_err(&mut v);
+    const_index_from_end_err(&mut v);
+    const_index_and_subslice_err(&mut v);
+    const_index_and_subslice_from_end_err(&mut v);
+    subslices_overlap(&mut v);
+}
diff --git a/src/test/ui/borrowck/borrowck-slice-pattern-element-loan-array.stderr b/src/test/ui/borrowck/borrowck-slice-pattern-element-loan-array.stderr
new file mode 100644
index 00000000000..e50e7eb3e22
--- /dev/null
+++ b/src/test/ui/borrowck/borrowck-slice-pattern-element-loan-array.stderr
@@ -0,0 +1,86 @@
+error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable
+  --> $DIR/borrowck-slice-pattern-element-loan-array.rs:8:13
+   |
+LL |     let [ref first, ref second, ..] = *s;
+   |                     ---------- immutable borrow occurs here
+LL |     let [_, ref mut  second2, ref mut third, ..] = *s;
+   |             ^^^^^^^^^^^^^^^^ mutable borrow occurs here
+LL |     nop(&[first, second, second2, third]);
+   |                  ------ immutable borrow later used here
+
+error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable
+  --> $DIR/borrowck-slice-pattern-element-loan-array.rs:14:14
+   |
+LL |     let [.., ref fourth, ref third, _, ref first] = *s;
+   |                          --------- immutable borrow occurs here
+LL |     let [.., ref mut third2, _, _] = *s;
+   |              ^^^^^^^^^^^^^^ mutable borrow occurs here
+LL |     nop(&[first, third, third2, fourth]);
+   |                  ----- immutable borrow later used here
+
+error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable
+  --> $DIR/borrowck-slice-pattern-element-loan-array.rs:21:16
+   |
+LL |     let [.., _, ref from_end4, ref from_end3, _, ref from_end1] = *s;
+   |                 ------------- immutable borrow occurs here
+LL | 
+LL |     let [_, _, ref mut from_begin2, ..] = *s;
+   |                ^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
+LL |     nop(&[from_begin2, from_end1, from_end3, from_end4]);
+   |                                              --------- immutable borrow later used here
+
+error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable
+  --> $DIR/borrowck-slice-pattern-element-loan-array.rs:23:19
+   |
+LL |     let [.., _, ref from_end4, ref from_end3, _, ref from_end1] = *s;
+   |                                ------------- immutable borrow occurs here
+...
+LL |     let [_, _, _, ref mut from_begin3, ..] = *s;
+   |                   ^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
+LL |     nop(&[from_begin3, from_end1, from_end3, from_end4]);
+   |                                   --------- immutable borrow later used here
+
+error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable
+  --> $DIR/borrowck-slice-pattern-element-loan-array.rs:28:14
+   |
+LL |     let [ref from_begin0, ref from_begin1, _, ref from_begin3, _, ..] = *s;
+   |                                               --------------- immutable borrow occurs here
+LL | 
+LL |     let [.., ref mut from_end3, _,  _] = *s;
+   |              ^^^^^^^^^^^^^^^^^ mutable borrow occurs here
+LL |     nop(&[from_begin0, from_begin1, from_begin3, from_end3]);
+   |                                     ----------- immutable borrow later used here
+
+error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable
+  --> $DIR/borrowck-slice-pattern-element-loan-array.rs:34:13
+   |
+LL |     let [ref first, ref second, ..] = *s;
+   |                     ---------- immutable borrow occurs here
+LL |     let [_, ref mut tail @ ..] = *s;
+   |             ^^^^^^^^^^^^^^^^^ mutable borrow occurs here
+LL |     nop(&[first, second]);
+   |                  ------ immutable borrow later used here
+
+error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable
+  --> $DIR/borrowck-slice-pattern-element-loan-array.rs:41:10
+   |
+LL |     let [.., ref second, ref first] = *s;
+   |              ---------- immutable borrow occurs here
+LL |     let [ref mut tail @ .., _] = *s;
+   |          ^^^^^^^^^^^^^^^^^ mutable borrow occurs here
+LL |     nop(&[first, second]);
+   |                  ------ immutable borrow later used here
+
+error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable
+  --> $DIR/borrowck-slice-pattern-element-loan-array.rs:48:10
+   |
+LL |     let [_,  ref s1 @ ..] = *s;
+   |              ----------- immutable borrow occurs here
+LL |     let [ref mut s2 @ .., _, _] = *s;
+   |          ^^^^^^^^^^^^^^^ mutable borrow occurs here
+LL |     nop_subslice(s1);
+   |                  -- immutable borrow later used here
+
+error: aborting due to 8 previous errors
+
+For more information about this error, try `rustc --explain E0502`.
diff --git a/src/test/ui/borrowck/borrowck-slice-pattern-element-loan-slice-no-overlap.rs b/src/test/ui/borrowck/borrowck-slice-pattern-element-loan-slice-no-overlap.rs
new file mode 100644
index 00000000000..e69071f8772
--- /dev/null
+++ b/src/test/ui/borrowck/borrowck-slice-pattern-element-loan-slice-no-overlap.rs
@@ -0,0 +1,61 @@
+// check-pass
+
+#![feature(slice_patterns)]
+
+fn nop(_s: &[& i32]) {}
+fn nop_subslice(_s: &[i32]) {}
+
+fn const_index_ok(s: &mut [i32]) {
+    if let [ref first, ref second, _, ref fourth, ..] = *s {
+        if let [_, _, ref mut third, ..] = *s {
+            nop(&[first, second, third, fourth]);
+        }
+    }
+}
+
+fn const_index_from_end_ok(s: &mut [i32]) {
+    if let [.., ref fourth, ref third, _, ref first] = *s {
+        if let [.., ref mut second, _] = *s {
+            nop(&[first, second, third, fourth]);
+        }
+    }
+}
+
+fn const_index_mixed(s: &mut [i32]) {
+    if let [.., _, ref from_end4, ref from_end3, _, ref from_end1] = *s {
+        if let [ref mut from_begin0, ..] = *s {
+            nop(&[from_begin0, from_end1, from_end3, from_end4]);
+        }
+    }
+    if let [ref from_begin0, ref from_begin1, _, ref from_begin3, _, ..] = *s {
+        if let [.., ref mut from_end1] = *s {
+            nop(&[from_begin0, from_begin1, from_begin3, from_end1]);
+        }
+    }
+}
+
+fn const_index_and_subslice_ok(s: &mut [i32]) {
+    if let [ref first, ref second, ..] = *s {
+        if let [_, _, ref mut tail @ ..] = *s {
+            nop(&[first, second]);
+            nop_subslice(tail);
+        }
+    }
+}
+
+fn const_index_and_subslice_from_end_ok(s: &mut [i32]) {
+    if let [.., ref second, ref first] = *s {
+        if let [ref mut tail @ .., _, _] = *s {
+            nop(&[first, second]);
+            nop_subslice(tail);
+        }
+    }
+}
+
+fn main() {
+    let mut v = [1,2,3,4];
+    const_index_ok(&mut v);
+    const_index_from_end_ok(&mut v);
+    const_index_and_subslice_ok(&mut v);
+    const_index_and_subslice_from_end_ok(&mut v);
+}
diff --git a/src/test/ui/borrowck/borrowck-slice-pattern-element-loan.rs b/src/test/ui/borrowck/borrowck-slice-pattern-element-loan-slice.rs
index a6b54f9537d..2ef98741dc3 100644
--- a/src/test/ui/borrowck/borrowck-slice-pattern-element-loan.rs
+++ b/src/test/ui/borrowck/borrowck-slice-pattern-element-loan-slice.rs
@@ -1,18 +1,8 @@
-//compile-flags: -Z borrowck=mir
-
 #![feature(slice_patterns)]
 
 fn nop(_s: &[& i32]) {}
 fn nop_subslice(_s: &[i32]) {}
 
-fn const_index_ok(s: &mut [i32]) {
-    if let [ref first, ref second, _, ref fourth, ..] = *s {
-        if let [_, _, ref mut third, ..] = *s {
-            nop(&[first, second, third, fourth]);
-        }
-    }
-}
-
 fn const_index_err(s: &mut [i32]) {
     if let [ref first, ref second, ..] = *s {
         if let [_, ref mut  second2, ref mut third, ..] = *s { //~ERROR
@@ -21,14 +11,6 @@ fn const_index_err(s: &mut [i32]) {
     }
 }
 
-fn const_index_from_end_ok(s: &mut [i32]) {
-    if let [.., ref fourth, ref third, _, ref first] = *s {
-        if let [.., ref mut second, _] = *s {
-            nop(&[first, second, third, fourth]);
-        }
-    }
-}
-
 fn const_index_from_end_err(s: &mut [i32]) {
     if let [.., ref fourth, ref third, _, ref first] = *s {
         if let [.., ref mut third2, _, _] = *s { //~ERROR
@@ -39,9 +21,6 @@ fn const_index_from_end_err(s: &mut [i32]) {
 
 fn const_index_mixed(s: &mut [i32]) {
     if let [.., _, ref from_end4, ref from_end3, _, ref from_end1] = *s {
-        if let [ref mut from_begin0, ..] = *s {
-            nop(&[from_begin0, from_end1, from_end3, from_end4]);
-        }
         if let [_, ref mut from_begin1, ..] = *s { //~ERROR
             nop(&[from_begin1, from_end1, from_end3, from_end4]);
         }
@@ -53,9 +32,6 @@ fn const_index_mixed(s: &mut [i32]) {
         }
     }
     if let [ref from_begin0, ref from_begin1, _, ref from_begin3, _, ..] = *s {
-        if let [.., ref mut from_end1] = *s {
-            nop(&[from_begin0, from_begin1, from_begin3, from_end1]);
-        }
         if let [.., ref mut from_end2, _] = *s { //~ERROR
             nop(&[from_begin0, from_begin1, from_begin3, from_end2]);
         }
@@ -68,15 +44,6 @@ fn const_index_mixed(s: &mut [i32]) {
     }
 }
 
-fn const_index_and_subslice_ok(s: &mut [i32]) {
-    if let [ref first, ref second, ..] = *s {
-        if let [_, _, ref mut tail @ ..] = *s {
-            nop(&[first, second]);
-            nop_subslice(tail);
-        }
-    }
-}
-
 fn const_index_and_subslice_err(s: &mut [i32]) {
     if let [ref first, ref second, ..] = *s {
         if let [_, ref mut tail @ ..] = *s { //~ERROR
@@ -86,15 +53,6 @@ fn const_index_and_subslice_err(s: &mut [i32]) {
     }
 }
 
-fn const_index_and_subslice_from_end_ok(s: &mut [i32]) {
-    if let [.., ref second, ref first] = *s {
-        if let [ref mut tail @ .., _, _] = *s {
-            nop(&[first, second]);
-            nop_subslice(tail);
-        }
-    }
-}
-
 fn const_index_and_subslice_from_end_err(s: &mut [i32]) {
     if let [.., ref second, ref first] = *s {
         if let [ref mut tail @ .., _] = *s { //~ERROR
@@ -115,13 +73,9 @@ fn subslices(s: &mut [i32]) {
 
 fn main() {
     let mut v = [1,2,3,4];
-    const_index_ok(&mut v);
     const_index_err(&mut v);
-    const_index_from_end_ok(&mut v);
     const_index_from_end_err(&mut v);
-    const_index_and_subslice_ok(&mut v);
     const_index_and_subslice_err(&mut v);
-    const_index_and_subslice_from_end_ok(&mut v);
     const_index_and_subslice_from_end_err(&mut v);
     subslices(&mut v);
 }
diff --git a/src/test/ui/borrowck/borrowck-slice-pattern-element-loan.stderr b/src/test/ui/borrowck/borrowck-slice-pattern-element-loan-slice.stderr
index 2c019f44611..b6f5ac64b20 100644
--- a/src/test/ui/borrowck/borrowck-slice-pattern-element-loan.stderr
+++ b/src/test/ui/borrowck/borrowck-slice-pattern-element-loan-slice.stderr
@@ -1,5 +1,5 @@
 error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable
-  --> $DIR/borrowck-slice-pattern-element-loan.rs:18:20
+  --> $DIR/borrowck-slice-pattern-element-loan-slice.rs:8:20
    |
 LL |     if let [ref first, ref second, ..] = *s {
    |                        ---------- immutable borrow occurs here
@@ -9,7 +9,7 @@ LL |             nop(&[first, second, second2, third]);
    |                          ------ immutable borrow later used here
 
 error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable
-  --> $DIR/borrowck-slice-pattern-element-loan.rs:34:21
+  --> $DIR/borrowck-slice-pattern-element-loan-slice.rs:16:21
    |
 LL |     if let [.., ref fourth, ref third, _, ref first] = *s {
    |                             --------- immutable borrow occurs here
@@ -19,18 +19,17 @@ LL |             nop(&[first, third, third2, fourth]);
    |                          ----- immutable borrow later used here
 
 error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable
-  --> $DIR/borrowck-slice-pattern-element-loan.rs:45:20
+  --> $DIR/borrowck-slice-pattern-element-loan-slice.rs:24:20
    |
 LL |     if let [.., _, ref from_end4, ref from_end3, _, ref from_end1] = *s {
    |                    ------------- immutable borrow occurs here
-...
 LL |         if let [_, ref mut from_begin1, ..] = *s {
    |                    ^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
 LL |             nop(&[from_begin1, from_end1, from_end3, from_end4]);
    |                                                      --------- immutable borrow later used here
 
 error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable
-  --> $DIR/borrowck-slice-pattern-element-loan.rs:48:23
+  --> $DIR/borrowck-slice-pattern-element-loan-slice.rs:27:23
    |
 LL |     if let [.., _, ref from_end4, ref from_end3, _, ref from_end1] = *s {
    |                                   ------------- immutable borrow occurs here
@@ -41,7 +40,7 @@ LL |             nop(&[from_begin2, from_end1, from_end3, from_end4]);
    |                                           --------- immutable borrow later used here
 
 error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable
-  --> $DIR/borrowck-slice-pattern-element-loan.rs:51:26
+  --> $DIR/borrowck-slice-pattern-element-loan-slice.rs:30:26
    |
 LL |     if let [.., _, ref from_end4, ref from_end3, _, ref from_end1] = *s {
    |                                   ------------- immutable borrow occurs here
@@ -52,18 +51,17 @@ LL |             nop(&[from_begin3, from_end1, from_end3, from_end4]);
    |                                           --------- immutable borrow later used here
 
 error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable
-  --> $DIR/borrowck-slice-pattern-element-loan.rs:59:21
+  --> $DIR/borrowck-slice-pattern-element-loan-slice.rs:35:21
    |
 LL |     if let [ref from_begin0, ref from_begin1, _, ref from_begin3, _, ..] = *s {
    |                                                  --------------- immutable borrow occurs here
-...
 LL |         if let [.., ref mut from_end2, _] = *s {
    |                     ^^^^^^^^^^^^^^^^^ mutable borrow occurs here
 LL |             nop(&[from_begin0, from_begin1, from_begin3, from_end2]);
    |                                             ----------- immutable borrow later used here
 
 error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable
-  --> $DIR/borrowck-slice-pattern-element-loan.rs:62:21
+  --> $DIR/borrowck-slice-pattern-element-loan-slice.rs:38:21
    |
 LL |     if let [ref from_begin0, ref from_begin1, _, ref from_begin3, _, ..] = *s {
    |                                                  --------------- immutable borrow occurs here
@@ -74,7 +72,7 @@ LL |             nop(&[from_begin0, from_begin1, from_begin3, from_end3]);
    |                                             ----------- immutable borrow later used here
 
 error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable
-  --> $DIR/borrowck-slice-pattern-element-loan.rs:65:21
+  --> $DIR/borrowck-slice-pattern-element-loan-slice.rs:41:21
    |
 LL |     if let [ref from_begin0, ref from_begin1, _, ref from_begin3, _, ..] = *s {
    |                              --------------- immutable borrow occurs here
@@ -85,7 +83,7 @@ LL |             nop(&[from_begin0, from_begin1, from_begin3, from_end4]);
    |                                ----------- immutable borrow later used here
 
 error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable
-  --> $DIR/borrowck-slice-pattern-element-loan.rs:82:20
+  --> $DIR/borrowck-slice-pattern-element-loan-slice.rs:49:20
    |
 LL |     if let [ref first, ref second, ..] = *s {
    |                        ---------- immutable borrow occurs here
@@ -95,7 +93,7 @@ LL |             nop(&[first, second]);
    |                          ------ immutable borrow later used here
 
 error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable
-  --> $DIR/borrowck-slice-pattern-element-loan.rs:100:17
+  --> $DIR/borrowck-slice-pattern-element-loan-slice.rs:58:17
    |
 LL |     if let [.., ref second, ref first] = *s {
    |                 ---------- immutable borrow occurs here
@@ -105,7 +103,7 @@ LL |             nop(&[first, second]);
    |                          ------ immutable borrow later used here
 
 error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable
-  --> $DIR/borrowck-slice-pattern-element-loan.rs:109:17
+  --> $DIR/borrowck-slice-pattern-element-loan-slice.rs:67:17
    |
 LL |     if let [_, _, _, ref s1 @ ..] = *s {
    |                      ----------- immutable borrow occurs here
diff --git a/src/test/ui/drop/dynamic-drop.rs b/src/test/ui/drop/dynamic-drop.rs
index 29dcbfe9609..0f0ec0ba460 100644
--- a/src/test/ui/drop/dynamic-drop.rs
+++ b/src/test/ui/drop/dynamic-drop.rs
@@ -269,6 +269,28 @@ fn subslice_pattern_reassign(a: &Allocator) {
     let[_, _y @ ..] = ar;
 }
 
+fn index_field_mixed_ends(a: &Allocator) {
+    let ar = [(a.alloc(), a.alloc()), (a.alloc(), a.alloc())];
+    let[(_x, _), ..] = ar;
+    let[(_, _y), _] = ar;
+    let[_, (_, _w)] = ar;
+    let[.., (_z, _)] = ar;
+}
+
+fn subslice_mixed_min_lengths(a: &Allocator, c: i32) {
+    let ar = [(a.alloc(), a.alloc()), (a.alloc(), a.alloc())];
+    match c {
+        0 => { let[_x, ..] = ar; }
+        1 => { let[_x, _, ..] = ar; }
+        2 => { let[_x, _] = ar; }
+        3 => { let[(_x, _), _, ..] = ar; }
+        4 => { let[.., (_x, _)] = ar; }
+        5 => { let[.., (_x, _), _] = ar; }
+        6 => { let [_y @ ..] = ar; }
+        _ => { let [_y @ .., _] = ar; }
+    }
+}
+
 fn panic_after_return(a: &Allocator) -> Ptr<'_> {
     // Panic in the drop of `p` or `q` can leak
     let exceptions = vec![8, 9];
@@ -422,6 +444,16 @@ fn main() {
     run_test(|a| slice_pattern_reassign(a));
     run_test(|a| subslice_pattern_reassign(a));
 
+    run_test(|a| index_field_mixed_ends(a));
+    run_test(|a| subslice_mixed_min_lengths(a, 0));
+    run_test(|a| subslice_mixed_min_lengths(a, 1));
+    run_test(|a| subslice_mixed_min_lengths(a, 2));
+    run_test(|a| subslice_mixed_min_lengths(a, 3));
+    run_test(|a| subslice_mixed_min_lengths(a, 4));
+    run_test(|a| subslice_mixed_min_lengths(a, 5));
+    run_test(|a| subslice_mixed_min_lengths(a, 6));
+    run_test(|a| subslice_mixed_min_lengths(a, 7));
+
     run_test(|a| {
         panic_after_return(a);
     });