#[allow(unreachable_patterns)]
match &43 {
&42 => panic!(),
- BOO => panic!(), // pattern is unreachable
+ BOO => panic!(),
_ => println!("d"),
}
}
--- /dev/null
+// failure-status: 101
+
+// This is a repro test for an ICE in our pattern handling of constants.
+
+const FOO: &&&u32 = &&&42;
+
+fn main() {
+ match unimplemented!() {
+ &&&42 => {},
+ FOO => {},
+ _ => {},
+ }
+}
-// compile-pass
+#![deny(unreachable_patterns)]
fn main() {
let s = &[0x00; 4][..]; //Slice of any value
match s {
MAGIC_TEST => (),
[0x00, 0x00, 0x00, 0x00] => (),
- [4, 5, 6, 7] => (), // this should warn
+ [4, 5, 6, 7] => (), //~ ERROR unreachable pattern
_ => (),
}
match s {
[0x00, 0x00, 0x00, 0x00] => (),
MAGIC_TEST => (),
- [4, 5, 6, 7] => (), // this should warn
+ [4, 5, 6, 7] => (), //~ ERROR unreachable pattern
_ => (),
}
match s {
[0x00, 0x00, 0x00, 0x00] => (),
[4, 5, 6, 7] => (),
- MAGIC_TEST => (), // this should warn
+ MAGIC_TEST => (), // FIXME(oli-obk): this should warn, but currently does not
_ => (),
}
const FOO: [u32; 1] = [4];
match [99] {
[0x00] => (),
[4] => (),
- FOO => (), // this should warn
+ FOO => (), //~ ERROR unreachable pattern
_ => (),
}
}
--- /dev/null
+error: unreachable pattern
+ --> $DIR/slice-pattern-const-2.rs:9:9
+ |
+LL | [4, 5, 6, 7] => (), //~ ERROR unreachable pattern
+ | ^^^^^^^^^^^^
+ |
+note: lint level defined here
+ --> $DIR/slice-pattern-const-2.rs:1:9
+ |
+LL | #![deny(unreachable_patterns)]
+ | ^^^^^^^^^^^^^^^^^^^^
+
+error: unreachable pattern
+ --> $DIR/slice-pattern-const-2.rs:15:9
+ |
+LL | [4, 5, 6, 7] => (), //~ ERROR unreachable pattern
+ | ^^^^^^^^^^^^
+
+error: unreachable pattern
+ --> $DIR/slice-pattern-const-2.rs:28:9
+ |
+LL | FOO => (), //~ ERROR unreachable pattern
+ | ^^^
+
+error: aborting due to 3 previous errors
+
-// compile-pass
+#![deny(unreachable_patterns)]
fn main() {
let s = &["0x00"; 4][..]; //Slice of any value
match s {
MAGIC_TEST => (),
["0x00", "0x00", "0x00", "0x00"] => (),
- ["4", "5", "6", "7"] => (), // this should warn
+ ["4", "5", "6", "7"] => (), // FIXME(oli-obk): this should warn, but currently does not
_ => (),
}
match s {
["0x00", "0x00", "0x00", "0x00"] => (),
MAGIC_TEST => (),
- ["4", "5", "6", "7"] => (), // this should warn
+ ["4", "5", "6", "7"] => (), // FIXME(oli-obk): this should warn, but currently does not
_ => (),
}
match s {
["0x00", "0x00", "0x00", "0x00"] => (),
["4", "5", "6", "7"] => (),
- MAGIC_TEST => (), // this should warn
+ MAGIC_TEST => (), // FIXME(oli-obk): this should warn, but currently does not
_ => (),
}
const FOO: [&str; 1] = ["boo"];
match ["baa"] {
["0x00"] => (),
["boo"] => (),
- FOO => (), // this should warn
+ FOO => (), //~ ERROR unreachable pattern
_ => (),
}
}
--- /dev/null
+error: unreachable pattern
+ --> $DIR/slice-pattern-const-3.rs:28:9
+ |
+LL | FOO => (), //~ ERROR unreachable pattern
+ | ^^^
+ |
+note: lint level defined here
+ --> $DIR/slice-pattern-const-3.rs:1:9
+ |
+LL | #![deny(unreachable_patterns)]
+ | ^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
-//compile-pass
+#![deny(unreachable_patterns)]
fn main() {
let s = &[0x00; 4][..]; //Slice of any value
match s {
MAGIC_TEST => (),
[0x00, 0x00, 0x00, 0x00] => (),
- [84, 69, 83, 84] => (), // this should warn
+ [84, 69, 83, 84] => (), //~ ERROR unreachable pattern
_ => (),
}
match s {
[0x00, 0x00, 0x00, 0x00] => (),
MAGIC_TEST => (),
- [84, 69, 83, 84] => (), // this should warn
+ [84, 69, 83, 84] => (), //~ ERROR unreachable pattern
_ => (),
}
match s {
[0x00, 0x00, 0x00, 0x00] => (),
[84, 69, 83, 84] => (),
- MAGIC_TEST => (), // this should warn
+ MAGIC_TEST => (), //~ ERROR unreachable pattern
_ => (),
}
const FOO: [u8; 1] = [4];
match [99] {
[0x00] => (),
[4] => (),
- FOO => (), // this should warn
+ FOO => (), //~ ERROR unreachable pattern
_ => (),
}
const BAR: &[u8; 1] = &[4];
match &[99] {
[0x00] => (),
[4] => (),
- BAR => (), // this should warn
+ BAR => (), //~ ERROR unreachable pattern
b"a" => (),
_ => (),
}
const BOO: &[u8; 0] = &[];
match &[] {
[] => (),
- BOO => (), // this should warn
- b"" => (),
- _ => (),
+ BOO => (), //~ ERROR unreachable pattern
+ b"" => (), //~ ERROR unreachable pattern
+ _ => (), //~ ERROR unreachable pattern
}
}
--- /dev/null
+error: unreachable pattern
+ --> $DIR/slice-pattern-const.rs:9:9
+ |
+LL | [84, 69, 83, 84] => (), //~ ERROR unreachable pattern
+ | ^^^^^^^^^^^^^^^^
+ |
+note: lint level defined here
+ --> $DIR/slice-pattern-const.rs:1:9
+ |
+LL | #![deny(unreachable_patterns)]
+ | ^^^^^^^^^^^^^^^^^^^^
+
+error: unreachable pattern
+ --> $DIR/slice-pattern-const.rs:15:9
+ |
+LL | [84, 69, 83, 84] => (), //~ ERROR unreachable pattern
+ | ^^^^^^^^^^^^^^^^
+
+error: unreachable pattern
+ --> $DIR/slice-pattern-const.rs:21:9
+ |
+LL | MAGIC_TEST => (), //~ ERROR unreachable pattern
+ | ^^^^^^^^^^
+
+error: unreachable pattern
+ --> $DIR/slice-pattern-const.rs:28:9
+ |
+LL | FOO => (), //~ ERROR unreachable pattern
+ | ^^^
+
+error: unreachable pattern
+ --> $DIR/slice-pattern-const.rs:35:9
+ |
+LL | BAR => (), //~ ERROR unreachable pattern
+ | ^^^
+
+error: unreachable pattern
+ --> $DIR/slice-pattern-const.rs:43:9
+ |
+LL | BOO => (), //~ ERROR unreachable pattern
+ | ^^^
+
+error: unreachable pattern
+ --> $DIR/slice-pattern-const.rs:44:9
+ |
+LL | b"" => (), //~ ERROR unreachable pattern
+ | ^^^
+
+error: unreachable pattern
+ --> $DIR/slice-pattern-const.rs:45:9
+ |
+LL | _ => (), //~ ERROR unreachable pattern
+ | ^
+
+error: aborting due to 8 previous errors
+