Skip to content

Commit 5df6af4

Browse files
committed
Update tests to show diagnostics
1 parent 25a4f76 commit 5df6af4

8 files changed

+129
-20
lines changed

src/test/run-pass/ctfe/references.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn main() {
3131
#[allow(unreachable_patterns)]
3232
match &43 {
3333
&42 => panic!(),
34-
BOO => panic!(), // pattern is unreachable
34+
BOO => panic!(),
3535
_ => println!("d"),
3636
}
3737
}

src/test/ui/pattern/const-pat-ice.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// failure-status: 101
2+
3+
// This is a repro test for an ICE in our pattern handling of constants.
4+
5+
const FOO: &&&u32 = &&&42;
6+
7+
fn main() {
8+
match unimplemented!() {
9+
&&&42 => {},
10+
FOO => {},
11+
_ => {},
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
// compile-pass
1+
#![deny(unreachable_patterns)]
22

33
fn main() {
44
let s = &[0x00; 4][..]; //Slice of any value
55
const MAGIC_TEST: &[u32] = &[4, 5, 6, 7]; //Const slice to pattern match with
66
match s {
77
MAGIC_TEST => (),
88
[0x00, 0x00, 0x00, 0x00] => (),
9-
[4, 5, 6, 7] => (), // this should warn
9+
[4, 5, 6, 7] => (), //~ ERROR unreachable pattern
1010
_ => (),
1111
}
1212
match s {
1313
[0x00, 0x00, 0x00, 0x00] => (),
1414
MAGIC_TEST => (),
15-
[4, 5, 6, 7] => (), // this should warn
15+
[4, 5, 6, 7] => (), //~ ERROR unreachable pattern
1616
_ => (),
1717
}
1818
match s {
1919
[0x00, 0x00, 0x00, 0x00] => (),
2020
[4, 5, 6, 7] => (),
21-
MAGIC_TEST => (), // this should warn
21+
MAGIC_TEST => (), // FIXME(oli-obk): this should warn, but currently does not
2222
_ => (),
2323
}
2424
const FOO: [u32; 1] = [4];
2525
match [99] {
2626
[0x00] => (),
2727
[4] => (),
28-
FOO => (), // this should warn
28+
FOO => (), //~ ERROR unreachable pattern
2929
_ => (),
3030
}
3131
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
error: unreachable pattern
2+
--> $DIR/slice-pattern-const-2.rs:9:9
3+
|
4+
LL | [4, 5, 6, 7] => (), //~ ERROR unreachable pattern
5+
| ^^^^^^^^^^^^
6+
|
7+
note: lint level defined here
8+
--> $DIR/slice-pattern-const-2.rs:1:9
9+
|
10+
LL | #![deny(unreachable_patterns)]
11+
| ^^^^^^^^^^^^^^^^^^^^
12+
13+
error: unreachable pattern
14+
--> $DIR/slice-pattern-const-2.rs:15:9
15+
|
16+
LL | [4, 5, 6, 7] => (), //~ ERROR unreachable pattern
17+
| ^^^^^^^^^^^^
18+
19+
error: unreachable pattern
20+
--> $DIR/slice-pattern-const-2.rs:28:9
21+
|
22+
LL | FOO => (), //~ ERROR unreachable pattern
23+
| ^^^
24+
25+
error: aborting due to 3 previous errors
26+
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
// compile-pass
1+
#![deny(unreachable_patterns)]
22

33
fn main() {
44
let s = &["0x00"; 4][..]; //Slice of any value
55
const MAGIC_TEST: &[&str] = &["4", "5", "6", "7"]; //Const slice to pattern match with
66
match s {
77
MAGIC_TEST => (),
88
["0x00", "0x00", "0x00", "0x00"] => (),
9-
["4", "5", "6", "7"] => (), // this should warn
9+
["4", "5", "6", "7"] => (), // FIXME(oli-obk): this should warn, but currently does not
1010
_ => (),
1111
}
1212
match s {
1313
["0x00", "0x00", "0x00", "0x00"] => (),
1414
MAGIC_TEST => (),
15-
["4", "5", "6", "7"] => (), // this should warn
15+
["4", "5", "6", "7"] => (), // FIXME(oli-obk): this should warn, but currently does not
1616
_ => (),
1717
}
1818
match s {
1919
["0x00", "0x00", "0x00", "0x00"] => (),
2020
["4", "5", "6", "7"] => (),
21-
MAGIC_TEST => (), // this should warn
21+
MAGIC_TEST => (), // FIXME(oli-obk): this should warn, but currently does not
2222
_ => (),
2323
}
2424
const FOO: [&str; 1] = ["boo"];
2525
match ["baa"] {
2626
["0x00"] => (),
2727
["boo"] => (),
28-
FOO => (), // this should warn
28+
FOO => (), //~ ERROR unreachable pattern
2929
_ => (),
3030
}
3131
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error: unreachable pattern
2+
--> $DIR/slice-pattern-const-3.rs:28:9
3+
|
4+
LL | FOO => (), //~ ERROR unreachable pattern
5+
| ^^^
6+
|
7+
note: lint level defined here
8+
--> $DIR/slice-pattern-const-3.rs:1:9
9+
|
10+
LL | #![deny(unreachable_patterns)]
11+
| ^^^^^^^^^^^^^^^^^^^^
12+
13+
error: aborting due to previous error
14+
+9-9
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
1-
//compile-pass
1+
#![deny(unreachable_patterns)]
22

33
fn main() {
44
let s = &[0x00; 4][..]; //Slice of any value
55
const MAGIC_TEST: &[u8] = b"TEST"; //Const slice to pattern match with
66
match s {
77
MAGIC_TEST => (),
88
[0x00, 0x00, 0x00, 0x00] => (),
9-
[84, 69, 83, 84] => (), // this should warn
9+
[84, 69, 83, 84] => (), //~ ERROR unreachable pattern
1010
_ => (),
1111
}
1212
match s {
1313
[0x00, 0x00, 0x00, 0x00] => (),
1414
MAGIC_TEST => (),
15-
[84, 69, 83, 84] => (), // this should warn
15+
[84, 69, 83, 84] => (), //~ ERROR unreachable pattern
1616
_ => (),
1717
}
1818
match s {
1919
[0x00, 0x00, 0x00, 0x00] => (),
2020
[84, 69, 83, 84] => (),
21-
MAGIC_TEST => (), // this should warn
21+
MAGIC_TEST => (), //~ ERROR unreachable pattern
2222
_ => (),
2323
}
2424
const FOO: [u8; 1] = [4];
2525
match [99] {
2626
[0x00] => (),
2727
[4] => (),
28-
FOO => (), // this should warn
28+
FOO => (), //~ ERROR unreachable pattern
2929
_ => (),
3030
}
3131
const BAR: &[u8; 1] = &[4];
3232
match &[99] {
3333
[0x00] => (),
3434
[4] => (),
35-
BAR => (), // this should warn
35+
BAR => (), //~ ERROR unreachable pattern
3636
b"a" => (),
3737
_ => (),
3838
}
3939

4040
const BOO: &[u8; 0] = &[];
4141
match &[] {
4242
[] => (),
43-
BOO => (), // this should warn
44-
b"" => (),
45-
_ => (),
43+
BOO => (), //~ ERROR unreachable pattern
44+
b"" => (), //~ ERROR unreachable pattern
45+
_ => (), //~ ERROR unreachable pattern
4646
}
4747
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
error: unreachable pattern
2+
--> $DIR/slice-pattern-const.rs:9:9
3+
|
4+
LL | [84, 69, 83, 84] => (), //~ ERROR unreachable pattern
5+
| ^^^^^^^^^^^^^^^^
6+
|
7+
note: lint level defined here
8+
--> $DIR/slice-pattern-const.rs:1:9
9+
|
10+
LL | #![deny(unreachable_patterns)]
11+
| ^^^^^^^^^^^^^^^^^^^^
12+
13+
error: unreachable pattern
14+
--> $DIR/slice-pattern-const.rs:15:9
15+
|
16+
LL | [84, 69, 83, 84] => (), //~ ERROR unreachable pattern
17+
| ^^^^^^^^^^^^^^^^
18+
19+
error: unreachable pattern
20+
--> $DIR/slice-pattern-const.rs:21:9
21+
|
22+
LL | MAGIC_TEST => (), //~ ERROR unreachable pattern
23+
| ^^^^^^^^^^
24+
25+
error: unreachable pattern
26+
--> $DIR/slice-pattern-const.rs:28:9
27+
|
28+
LL | FOO => (), //~ ERROR unreachable pattern
29+
| ^^^
30+
31+
error: unreachable pattern
32+
--> $DIR/slice-pattern-const.rs:35:9
33+
|
34+
LL | BAR => (), //~ ERROR unreachable pattern
35+
| ^^^
36+
37+
error: unreachable pattern
38+
--> $DIR/slice-pattern-const.rs:43:9
39+
|
40+
LL | BOO => (), //~ ERROR unreachable pattern
41+
| ^^^
42+
43+
error: unreachable pattern
44+
--> $DIR/slice-pattern-const.rs:44:9
45+
|
46+
LL | b"" => (), //~ ERROR unreachable pattern
47+
| ^^^
48+
49+
error: unreachable pattern
50+
--> $DIR/slice-pattern-const.rs:45:9
51+
|
52+
LL | _ => (), //~ ERROR unreachable pattern
53+
| ^
54+
55+
error: aborting due to 8 previous errors
56+

0 commit comments

Comments
 (0)