summaryrefslogtreecommitdiffstats
path: root/tests/ui/consts/references.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/consts/references.rs')
-rw-r--r--tests/ui/consts/references.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/ui/consts/references.rs b/tests/ui/consts/references.rs
new file mode 100644
index 000000000..d0af47a8e
--- /dev/null
+++ b/tests/ui/consts/references.rs
@@ -0,0 +1,27 @@
+// run-pass
+
+const FOO: &[u8] = b"foo";
+const BAR: &[u8] = &[1, 2, 3];
+
+const BOO: &i32 = &42;
+
+fn main() {
+ match &[1u8, 2, 3] as &[u8] {
+ FOO => panic!("a"),
+ BAR => println!("b"),
+ _ => panic!("c"),
+ }
+
+ match b"foo" as &[u8] {
+ FOO => println!("a"),
+ BAR => panic!("b"),
+ _ => panic!("c"),
+ }
+
+ #[allow(unreachable_patterns)]
+ match &43 {
+ &42 => panic!(),
+ BOO => panic!(),
+ _ => println!("d"),
+ }
+}