summaryrefslogtreecommitdiffstats
path: root/tests/ui/pattern/usefulness/slice-patterns-exhaustiveness.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
commit64d98f8ee037282c35007b64c2649055c56af1db (patch)
tree5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /tests/ui/pattern/usefulness/slice-patterns-exhaustiveness.rs
parentAdding debian version 1.67.1+dfsg1-1. (diff)
downloadrustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz
rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/pattern/usefulness/slice-patterns-exhaustiveness.rs')
-rw-r--r--tests/ui/pattern/usefulness/slice-patterns-exhaustiveness.rs129
1 files changed, 129 insertions, 0 deletions
diff --git a/tests/ui/pattern/usefulness/slice-patterns-exhaustiveness.rs b/tests/ui/pattern/usefulness/slice-patterns-exhaustiveness.rs
new file mode 100644
index 000000000..46e0da5be
--- /dev/null
+++ b/tests/ui/pattern/usefulness/slice-patterns-exhaustiveness.rs
@@ -0,0 +1,129 @@
+fn main() {
+ let s: &[bool] = &[true; 0];
+ let s1: &[bool; 1] = &[false; 1];
+ let s2: &[bool; 2] = &[false; 2];
+ let s3: &[bool; 3] = &[false; 3];
+ let s10: &[bool; 10] = &[false; 10];
+
+ match s2 {
+ //~^ ERROR `&[false, _]` not covered
+ [true, .., true] => {}
+ }
+ match s3 {
+ //~^ ERROR `&[false, ..]` not covered
+ [true, .., true] => {}
+ }
+ match s10 {
+ //~^ ERROR `&[false, ..]` not covered
+ [true, .., true] => {}
+ }
+
+ match s1 {
+ [true, ..] => {}
+ [.., false] => {}
+ }
+ match s2 {
+ //~^ ERROR `&[false, true]` not covered
+ [true, ..] => {}
+ [.., false] => {}
+ }
+ match s3 {
+ //~^ ERROR `&[false, .., true]` not covered
+ [true, ..] => {}
+ [.., false] => {}
+ }
+ match s {
+ //~^ ERROR `&[false, .., true]` not covered
+ [] => {}
+ [true, ..] => {}
+ [.., false] => {}
+ }
+
+ match s {
+ //~^ ERROR `&[_, ..]` not covered
+ [] => {}
+ }
+ match s {
+ //~^ ERROR `&[_, _, ..]` not covered
+ [] => {}
+ [_] => {}
+ }
+ match s {
+ //~^ ERROR `&[false, ..]` not covered
+ [] => {}
+ [true, ..] => {}
+ }
+ match s {
+ //~^ ERROR `&[false, _, ..]` not covered
+ [] => {}
+ [_] => {}
+ [true, ..] => {}
+ }
+ match s {
+ //~^ ERROR `&[_, .., false]` not covered
+ [] => {}
+ [_] => {}
+ [.., true] => {}
+ }
+
+ match s {
+ //~^ ERROR `&[_, _, .., true]` not covered
+ [] => {}
+ [_] => {}
+ [_, _] => {}
+ [.., false] => {}
+ }
+ match s {
+ //~^ ERROR `&[true, _, .., _]` not covered
+ [] => {}
+ [_] => {}
+ [_, _] => {}
+ [false, .., false] => {}
+ }
+
+ const CONST: &[bool] = &[true];
+ match s {
+ //~^ ERROR `&[]` and `&[_, _, ..]` not covered
+ &[true] => {}
+ }
+ match s {
+ //~^ ERROR `&[]` and `&[_, _, ..]` not covered
+ CONST => {}
+ }
+ match s {
+ //~^ ERROR `&[]` and `&[_, _, ..]` not covered
+ CONST => {}
+ &[false] => {}
+ }
+ match s {
+ //~^ ERROR `&[]` and `&[_, _, ..]` not covered
+ &[false] => {}
+ CONST => {}
+ }
+ match s {
+ //~^ ERROR `&[_, _, ..]` not covered
+ &[] => {}
+ CONST => {}
+ }
+ match s {
+ //~^ ERROR `&[false]` not covered
+ &[] => {}
+ CONST => {}
+ &[_, _, ..] => {}
+ }
+ match s {
+ [] => {}
+ [false] => {}
+ CONST => {}
+ [_, _, ..] => {}
+ }
+ const CONST1: &[bool; 1] = &[true];
+ match s1 {
+ //~^ ERROR `&[false]` not covered
+ CONST1 => {}
+ }
+ match s1 {
+ CONST1 => {}
+ [false] => {}
+ }
+}