about summary refs log tree commit diff
path: root/src/test/ui/binding/match-byte-array-patterns.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/binding/match-byte-array-patterns.rs')
-rw-r--r--src/test/ui/binding/match-byte-array-patterns.rs45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/test/ui/binding/match-byte-array-patterns.rs b/src/test/ui/binding/match-byte-array-patterns.rs
new file mode 100644
index 00000000000..e87745705da
--- /dev/null
+++ b/src/test/ui/binding/match-byte-array-patterns.rs
@@ -0,0 +1,45 @@
+// run-pass
+#![feature(slice_patterns)]
+
+fn main() {
+    let buf = &[0u8; 4];
+    match buf {
+        &[0, 1, 0, 0] => unimplemented!(),
+        b"true" => unimplemented!(),
+        _ => {}
+    }
+
+    match buf {
+        b"true" => unimplemented!(),
+        &[0, 1, 0, 0] => unimplemented!(),
+        _ => {}
+    }
+
+    match buf {
+        b"true" => unimplemented!(),
+        &[0, x, 0, 0] => assert_eq!(x, 0),
+        _ => unimplemented!(),
+    }
+
+    let buf: &[u8] = buf;
+
+    match buf {
+        &[0, 1, 0, 0] => unimplemented!(),
+        &[_] => unimplemented!(),
+        &[_, _, _, _, _, ..] => unimplemented!(),
+        b"true" => unimplemented!(),
+        _ => {}
+    }
+
+    match buf {
+        b"true" => unimplemented!(),
+        &[0, 1, 0, 0] => unimplemented!(),
+        _ => {}
+    }
+
+    match buf {
+        b"true" => unimplemented!(),
+        &[0, x, 0, 0] => assert_eq!(x, 0),
+        _ => unimplemented!(),
+    }
+}