Update tests to show diagnostics

This commit is contained in:
Oliver Scherer 2018-12-13 12:54:49 +01:00
parent 25a4f76d63
commit 5df6af49a7
8 changed files with 129 additions and 20 deletions

View file

@ -31,7 +31,7 @@ fn main() {
#[allow(unreachable_patterns)]
match &43 {
&42 => panic!(),
BOO => panic!(), // pattern is unreachable
BOO => panic!(),
_ => println!("d"),
}
}

View file

@ -0,0 +1,13 @@
// 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 => {},
_ => {},
}
}

View file

@ -1,4 +1,4 @@
// compile-pass
#![deny(unreachable_patterns)]
fn main() {
let s = &[0x00; 4][..]; //Slice of any value
@ -6,26 +6,26 @@ fn main() {
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
_ => (),
}
}

View file

@ -0,0 +1,26 @@
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

View file

@ -1,4 +1,4 @@
// compile-pass
#![deny(unreachable_patterns)]
fn main() {
let s = &["0x00"; 4][..]; //Slice of any value
@ -6,26 +6,26 @@ fn main() {
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
_ => (),
}
}

View file

@ -0,0 +1,14 @@
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

View file

@ -1,4 +1,4 @@
//compile-pass
#![deny(unreachable_patterns)]
fn main() {
let s = &[0x00; 4][..]; //Slice of any value
@ -6,33 +6,33 @@ fn main() {
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" => (),
_ => (),
}
@ -40,8 +40,8 @@ fn main() {
const BOO: &[u8; 0] = &[];
match &[] {
[] => (),
BOO => (), // this should warn
b"" => (),
_ => (),
BOO => (), //~ ERROR unreachable pattern
b"" => (), //~ ERROR unreachable pattern
_ => (), //~ ERROR unreachable pattern
}
}

View file

@ -0,0 +1,56 @@
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