about summary refs log tree commit diff
path: root/tests/ui/borrowck/borrowck-vec-pattern-move-tail.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/borrowck/borrowck-vec-pattern-move-tail.rs')
-rw-r--r--tests/ui/borrowck/borrowck-vec-pattern-move-tail.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/ui/borrowck/borrowck-vec-pattern-move-tail.rs b/tests/ui/borrowck/borrowck-vec-pattern-move-tail.rs
new file mode 100644
index 00000000000..9b8ba2ea8ad
--- /dev/null
+++ b/tests/ui/borrowck/borrowck-vec-pattern-move-tail.rs
@@ -0,0 +1,11 @@
+fn main() {
+    let mut a = [1, 2, 3, 4];
+    let t = match a {
+        [1, 2, ref tail @ ..] => tail,
+        _ => unreachable!()
+    };
+    println!("t[0]: {}", t[0]);
+    a[2] = 0; //~ ERROR cannot assign to `a[_]` because it is borrowed
+    println!("t[0]: {}", t[0]);
+    t[0];
+}