Skip to content

Commit 8d28099

Browse files
committed
Add more test cases for block-no-opening-brace
1 parent 8ed95d1 commit 8d28099

File tree

2 files changed

+48
-12
lines changed

2 files changed

+48
-12
lines changed

tests/ui/parser/block-no-opening-brace.rs

+27-9
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,46 @@
44

55
fn main() {}
66

7-
fn f1() {
7+
fn in_loop() {
88
loop
99
let x = 0; //~ ERROR expected `{`, found keyword `let`
1010
drop(0);
11-
}
11+
}
1212

13-
fn f2() {
13+
fn in_while() {
1414
while true
1515
let x = 0; //~ ERROR expected `{`, found keyword `let`
16-
}
16+
}
1717

18-
fn f3() {
18+
fn in_for() {
1919
for x in 0..1
2020
let x = 0; //~ ERROR expected `{`, found keyword `let`
21-
}
21+
}
22+
2223

23-
fn f4() {
24+
// FIXME
25+
fn in_try() {
2426
try //~ ERROR expected expression, found reserved keyword `try`
2527
let x = 0;
26-
}
28+
}
2729

28-
fn f5() {
30+
// FIXME(#80931)
31+
fn in_async() {
2932
async
3033
let x = 0; //~ ERROR expected one of `move`, `|`, or `||`, found keyword `let`
34+
}
35+
36+
// FIXME(#78168)
37+
fn in_const() {
38+
let x = const 2; //~ ERROR expected expression, found keyword `const`
39+
}
40+
41+
// FIXME(#78168)
42+
fn in_const_in_match() {
43+
let x = 2;
44+
match x {
45+
const 2 => {}
46+
//~^ ERROR expected identifier, found keyword `const`
47+
//~| ERROR expected one of `=>`, `if`, or `|`, found `2`
3148
}
49+
}

tests/ui/parser/block-no-opening-brace.stderr

+21-3
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,36 @@ LL | { let x = 0; }
3838
| + +
3939

4040
error: expected expression, found reserved keyword `try`
41-
--> $DIR/block-no-opening-brace.rs:24:5
41+
--> $DIR/block-no-opening-brace.rs:26:5
4242
|
4343
LL | try
4444
| ^^^ expected expression
4545

4646
error: expected one of `move`, `|`, or `||`, found keyword `let`
47-
--> $DIR/block-no-opening-brace.rs:30:9
47+
--> $DIR/block-no-opening-brace.rs:33:9
4848
|
4949
LL | async
5050
| - expected one of `move`, `|`, or `||`
5151
LL | let x = 0;
5252
| ^^^ unexpected token
5353

54-
error: aborting due to 5 previous errors
54+
error: expected expression, found keyword `const`
55+
--> $DIR/block-no-opening-brace.rs:38:13
56+
|
57+
LL | let x = const 2;
58+
| ^^^^^ expected expression
59+
60+
error: expected identifier, found keyword `const`
61+
--> $DIR/block-no-opening-brace.rs:45:9
62+
|
63+
LL | const 2 => {}
64+
| ^^^^^ expected identifier, found keyword
65+
66+
error: expected one of `=>`, `if`, or `|`, found `2`
67+
--> $DIR/block-no-opening-brace.rs:45:15
68+
|
69+
LL | const 2 => {}
70+
| ^ expected one of `=>`, `if`, or `|`
71+
72+
error: aborting due to 8 previous errors
5573

0 commit comments

Comments
 (0)