about summary refs log tree commit diff
path: root/src/test/ui/pattern/usefulness/match-byte-array-patterns.rs
diff options
context:
space:
mode:
authorNadrieril <nadrieril@gmail.com>2019-09-28 16:05:38 +0200
committerNadrieril <nadrieril@gmail.com>2019-10-27 21:20:26 +0000
commit09f9947ebc68a8199c3dff8607a41571c48cc377 (patch)
treefb81c258de9902ea813c24c5ca08bcce9817a4bb /src/test/ui/pattern/usefulness/match-byte-array-patterns.rs
parent0f677c65e867d93a47ccbaeaf6e6725cde8c5ff6 (diff)
downloadrust-09f9947ebc68a8199c3dff8607a41571c48cc377.tar.gz
rust-09f9947ebc68a8199c3dff8607a41571c48cc377.zip
Gather together usefulness tests
I took most tests that were testing only for match exhaustiveness,
pattern refutability or match arm reachability, and put them in
the same test folder.
Diffstat (limited to 'src/test/ui/pattern/usefulness/match-byte-array-patterns.rs')
-rw-r--r--src/test/ui/pattern/usefulness/match-byte-array-patterns.rs56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/test/ui/pattern/usefulness/match-byte-array-patterns.rs b/src/test/ui/pattern/usefulness/match-byte-array-patterns.rs
new file mode 100644
index 00000000000..7541ea3e2e2
--- /dev/null
+++ b/src/test/ui/pattern/usefulness/match-byte-array-patterns.rs
@@ -0,0 +1,56 @@
+#![feature(slice_patterns)]
+#![deny(unreachable_patterns)]
+
+fn main() {
+    let buf = &[0, 1, 2, 3];
+
+    match buf {
+        b"AAAA" => {},
+        &[0x41, 0x41, 0x41, 0x41] => {} //~ ERROR unreachable pattern
+        _ => {}
+    }
+
+    match buf {
+        &[0x41, 0x41, 0x41, 0x41] => {}
+        b"AAAA" => {}, //~ ERROR unreachable pattern
+        _ => {}
+    }
+
+    match buf {
+        &[_, 0x41, 0x41, 0x41] => {},
+        b"AAAA" => {}, //~ ERROR unreachable pattern
+        _ => {}
+    }
+
+    match buf {
+        &[0x41, .., 0x41] => {}
+        b"AAAA" => {}, //~ ERROR unreachable pattern
+        _ => {}
+    }
+
+    let buf: &[u8] = buf;
+
+    match buf {
+        b"AAAA" => {},
+        &[0x41, 0x41, 0x41, 0x41] => {} //~ ERROR unreachable pattern
+        _ => {}
+    }
+
+    match buf {
+        &[0x41, 0x41, 0x41, 0x41] => {}
+        b"AAAA" => {}, //~ ERROR unreachable pattern
+        _ => {}
+    }
+
+    match buf {
+        &[_, 0x41, 0x41, 0x41] => {},
+        b"AAAA" => {}, //~ ERROR unreachable pattern
+        _ => {}
+    }
+
+    match buf {
+        &[0x41, .., 0x41] => {}
+        b"AAAA" => {}, //~ ERROR unreachable pattern
+        _ => {}
+    }
+}