about summary refs log tree commit diff
path: root/src/test/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui')
-rw-r--r--src/test/ui/pattern/usefulness/65413-constants-and-slices-exhaustiveness.rs15
-rw-r--r--src/test/ui/pattern/usefulness/65413-constants-and-slices-exhaustiveness.stderr14
-rw-r--r--src/test/ui/pattern/usefulness/slice-pattern-const.rs7
-rw-r--r--src/test/ui/pattern/usefulness/slice-pattern-const.stderr8
-rw-r--r--src/test/ui/pattern/usefulness/slice-patterns-exhaustiveness.rs22
-rw-r--r--src/test/ui/pattern/usefulness/slice-patterns-exhaustiveness.stderr26
-rw-r--r--src/test/ui/pattern/usefulness/slice-patterns-reachability.rs2
7 files changed, 91 insertions, 3 deletions
diff --git a/src/test/ui/pattern/usefulness/65413-constants-and-slices-exhaustiveness.rs b/src/test/ui/pattern/usefulness/65413-constants-and-slices-exhaustiveness.rs
new file mode 100644
index 00000000000..cca4173e3ef
--- /dev/null
+++ b/src/test/ui/pattern/usefulness/65413-constants-and-slices-exhaustiveness.rs
@@ -0,0 +1,15 @@
+#![feature(slice_patterns)]
+#![deny(unreachable_patterns)]
+
+const C0: &'static [u8] = b"\x00";
+
+fn main() {
+    let x: &[u8] = &[0];
+    match x {
+        &[] => {}
+        &[1..=255] => {}
+        // this shouldn't be unreachable
+        C0 => {} //~ unreachable pattern
+        &[_, _, ..] => {}
+    }
+}
diff --git a/src/test/ui/pattern/usefulness/65413-constants-and-slices-exhaustiveness.stderr b/src/test/ui/pattern/usefulness/65413-constants-and-slices-exhaustiveness.stderr
new file mode 100644
index 00000000000..74421b4085c
--- /dev/null
+++ b/src/test/ui/pattern/usefulness/65413-constants-and-slices-exhaustiveness.stderr
@@ -0,0 +1,14 @@
+error: unreachable pattern
+  --> $DIR/65413-constants-and-slices-exhaustiveness.rs:12:9
+   |
+LL |         C0 => {}
+   |         ^^
+   |
+note: lint level defined here
+  --> $DIR/65413-constants-and-slices-exhaustiveness.rs:2:9
+   |
+LL | #![deny(unreachable_patterns)]
+   |         ^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/pattern/usefulness/slice-pattern-const.rs b/src/test/ui/pattern/usefulness/slice-pattern-const.rs
index f0a04513f91..89195d5b11e 100644
--- a/src/test/ui/pattern/usefulness/slice-pattern-const.rs
+++ b/src/test/ui/pattern/usefulness/slice-pattern-const.rs
@@ -44,4 +44,11 @@ fn main() {
         b"" => (), //~ ERROR unreachable pattern
         _ => (), //~ ERROR unreachable pattern
     }
+
+    const CONST1: &[bool; 1] = &[true];
+    match &[false] {
+        CONST1 => {}
+        [true] => {} //~ ERROR unreachable pattern
+        [false] => {}
+    }
 }
diff --git a/src/test/ui/pattern/usefulness/slice-pattern-const.stderr b/src/test/ui/pattern/usefulness/slice-pattern-const.stderr
index 2dd10a0478a..d274d6d7c67 100644
--- a/src/test/ui/pattern/usefulness/slice-pattern-const.stderr
+++ b/src/test/ui/pattern/usefulness/slice-pattern-const.stderr
@@ -52,5 +52,11 @@ error: unreachable pattern
 LL |         _ => (),
    |         ^
 
-error: aborting due to 8 previous errors
+error: unreachable pattern
+  --> $DIR/slice-pattern-const.rs:51:9
+   |
+LL |         [true] => {}
+   |         ^^^^^^
+
+error: aborting due to 9 previous errors
 
diff --git a/src/test/ui/pattern/usefulness/slice-patterns-exhaustiveness.rs b/src/test/ui/pattern/usefulness/slice-patterns-exhaustiveness.rs
index eb3dfac950f..88a47fc074f 100644
--- a/src/test/ui/pattern/usefulness/slice-patterns-exhaustiveness.rs
+++ b/src/test/ui/pattern/usefulness/slice-patterns-exhaustiveness.rs
@@ -82,4 +82,26 @@ fn main() {
         [_, _] => {}
         [false, .., false] => {}
     }
+
+    const CONST: &[bool] = &[true];
+    match s {
+    //~^ ERROR `&[..]` not covered
+        CONST => {}
+    }
+    match s {
+    //~^ ERROR `&[true]` not covered
+        [] => {},
+        [false] => {},
+        CONST => {},
+        [_, _, ..] => {}
+    }
+    const CONST1: &[bool; 1] = &[true];
+    match s1 {
+    //~^ ERROR `&[..]` not covered
+        CONST1 => {}
+    }
+    match s1 {
+        CONST1 => {}
+        [false] => {}
+    }
 }
diff --git a/src/test/ui/pattern/usefulness/slice-patterns-exhaustiveness.stderr b/src/test/ui/pattern/usefulness/slice-patterns-exhaustiveness.stderr
index ebadedccfea..2295de02ed5 100644
--- a/src/test/ui/pattern/usefulness/slice-patterns-exhaustiveness.stderr
+++ b/src/test/ui/pattern/usefulness/slice-patterns-exhaustiveness.stderr
@@ -102,6 +102,30 @@ LL |     match s {
    |
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
-error: aborting due to 13 previous errors
+error[E0004]: non-exhaustive patterns: `&[..]` not covered
+  --> $DIR/slice-patterns-exhaustiveness.rs:87:11
+   |
+LL |     match s {
+   |           ^ pattern `&[..]` not covered
+   |
+   = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
+
+error[E0004]: non-exhaustive patterns: `&[true]` not covered
+  --> $DIR/slice-patterns-exhaustiveness.rs:91:11
+   |
+LL |     match s {
+   |           ^ pattern `&[true]` not covered
+   |
+   = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
+
+error[E0004]: non-exhaustive patterns: `&[..]` not covered
+  --> $DIR/slice-patterns-exhaustiveness.rs:99:11
+   |
+LL |     match s1 {
+   |           ^^ pattern `&[..]` not covered
+   |
+   = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
+
+error: aborting due to 16 previous errors
 
 For more information about this error, try `rustc --explain E0004`.
diff --git a/src/test/ui/pattern/usefulness/slice-patterns-reachability.rs b/src/test/ui/pattern/usefulness/slice-patterns-reachability.rs
index 35d9dc91aee..cd229a0fcbe 100644
--- a/src/test/ui/pattern/usefulness/slice-patterns-reachability.rs
+++ b/src/test/ui/pattern/usefulness/slice-patterns-reachability.rs
@@ -2,7 +2,7 @@
 #![deny(unreachable_patterns)]
 
 fn main() {
-    let s: &[bool] = &[true; 0];
+    let s: &[bool] = &[];
 
     match s {
         [true, ..] => {}