about summary refs log tree commit diff
path: root/tests/ui/pattern/usefulness/slice-patterns-reachability.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/pattern/usefulness/slice-patterns-reachability.rs')
-rw-r--r--tests/ui/pattern/usefulness/slice-patterns-reachability.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/ui/pattern/usefulness/slice-patterns-reachability.rs b/tests/ui/pattern/usefulness/slice-patterns-reachability.rs
new file mode 100644
index 00000000000..7c747b5e0b9
--- /dev/null
+++ b/tests/ui/pattern/usefulness/slice-patterns-reachability.rs
@@ -0,0 +1,25 @@
+#![deny(unreachable_patterns)]
+
+fn main() {
+    let s: &[bool] = &[];
+
+    match s {
+        [true, ..] => {}
+        [true, ..] => {} //~ ERROR unreachable pattern
+        [true] => {} //~ ERROR unreachable pattern
+        [..] => {}
+    }
+    match s {
+        [.., true] => {}
+        [.., true] => {} //~ ERROR unreachable pattern
+        [true] => {} //~ ERROR unreachable pattern
+        [..] => {}
+    }
+    match s {
+        [false, .., true] => {}
+        [false, .., true] => {} //~ ERROR unreachable pattern
+        [false, true] => {} //~ ERROR unreachable pattern
+        [false] => {}
+        [..] => {}
+    }
+}