about summary refs log tree commit diff
path: root/tests/ui/array-slice-vec/vec-matching-legal-tail-element-borrow.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/array-slice-vec/vec-matching-legal-tail-element-borrow.rs')
-rw-r--r--tests/ui/array-slice-vec/vec-matching-legal-tail-element-borrow.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/ui/array-slice-vec/vec-matching-legal-tail-element-borrow.rs b/tests/ui/array-slice-vec/vec-matching-legal-tail-element-borrow.rs
new file mode 100644
index 00000000000..ed34f074a92
--- /dev/null
+++ b/tests/ui/array-slice-vec/vec-matching-legal-tail-element-borrow.rs
@@ -0,0 +1,15 @@
+// run-pass
+
+#![allow(unused_variables)]
+
+pub fn main() {
+    let x = &[1, 2, 3, 4, 5];
+    let x: &[isize] = &[1, 2, 3, 4, 5];
+    if !x.is_empty() {
+        let el = match x {
+            &[1, ref tail @ ..] => &tail[0],
+            _ => unreachable!()
+        };
+        println!("{}", *el);
+    }
+}