Skip to content

Commit 5f57fee

Browse files
committed
parser: multiple-pattern-typo: cover more or-pattern places.
1 parent d34ee76 commit 5f57fee

File tree

2 files changed

+73
-2
lines changed

2 files changed

+73
-2
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,40 @@
1+
#![feature(or_patterns)]
2+
//~^ WARN the feature `or_patterns` is incomplete and may cause the compiler to crash
3+
14
fn main() {
25
let x = 3;
6+
37
match x {
48
1 | 2 || 3 => (), //~ ERROR unexpected token `||` after pattern
59
_ => (),
610
}
11+
12+
match x {
13+
(1 | 2 || 3) => (), //~ ERROR unexpected token `||` after pattern
14+
_ => (),
15+
}
16+
17+
match (x,) {
18+
(1 | 2 || 3,) => (), //~ ERROR unexpected token `||` after pattern
19+
_ => (),
20+
}
21+
22+
struct TS(u8);
23+
24+
match TS(x) {
25+
TS(1 | 2 || 3) => (), //~ ERROR unexpected token `||` after pattern
26+
_ => (),
27+
}
28+
29+
struct NS { f: u8 }
30+
31+
match (NS { f: x }) {
32+
NS { f: 1 | 2 || 3 } => (), //~ ERROR unexpected token `||` after pattern
33+
_ => (),
34+
}
35+
36+
match [x] {
37+
[1 | 2 || 3] => (), //~ ERROR unexpected token `||` after pattern
38+
_ => (),
39+
}
740
}
Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,46 @@
11
error: unexpected token `||` after pattern
2-
--> $DIR/multiple-pattern-typo.rs:4:15
2+
--> $DIR/multiple-pattern-typo.rs:8:15
33
|
44
LL | 1 | 2 || 3 => (),
55
| ^^ help: use a single `|` to specify multiple patterns: `|`
66

7-
error: aborting due to previous error
7+
error: unexpected token `||` after pattern
8+
--> $DIR/multiple-pattern-typo.rs:13:16
9+
|
10+
LL | (1 | 2 || 3) => (),
11+
| ^^ help: use a single `|` to specify multiple patterns: `|`
12+
13+
error: unexpected token `||` after pattern
14+
--> $DIR/multiple-pattern-typo.rs:18:16
15+
|
16+
LL | (1 | 2 || 3,) => (),
17+
| ^^ help: use a single `|` to specify multiple patterns: `|`
18+
19+
error: unexpected token `||` after pattern
20+
--> $DIR/multiple-pattern-typo.rs:25:18
21+
|
22+
LL | TS(1 | 2 || 3) => (),
23+
| ^^ help: use a single `|` to specify multiple patterns: `|`
24+
25+
error: unexpected token `||` after pattern
26+
--> $DIR/multiple-pattern-typo.rs:32:23
27+
|
28+
LL | NS { f: 1 | 2 || 3 } => (),
29+
| ^^ help: use a single `|` to specify multiple patterns: `|`
30+
31+
error: unexpected token `||` after pattern
32+
--> $DIR/multiple-pattern-typo.rs:37:16
33+
|
34+
LL | [1 | 2 || 3] => (),
35+
| ^^ help: use a single `|` to specify multiple patterns: `|`
36+
37+
warning: the feature `or_patterns` is incomplete and may cause the compiler to crash
38+
--> $DIR/multiple-pattern-typo.rs:1:12
39+
|
40+
LL | #![feature(or_patterns)]
41+
| ^^^^^^^^^^^
42+
|
43+
= note: `#[warn(incomplete_features)]` on by default
44+
45+
error: aborting due to 6 previous errors
846

0 commit comments

Comments
 (0)