Skip to content

Commit bff0be3

Browse files
committed
Add test case for #47287
1 parent f007e6f commit bff0be3

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

src/test/ui/parser/expr-as-stmt.fixed

+6
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,10 @@ fn qux(a: Option<u32>, b: Option<u32>) -> bool {
3131
if let Some(y) = a { true } else { false }
3232
}
3333

34+
fn moo(x: u32) -> bool {
35+
(match x {
36+
_ => 1,
37+
}) > 0 //~ ERROR ambiguous parse
38+
}
39+
3440
fn main() {}

src/test/ui/parser/expr-as-stmt.rs

+6
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,10 @@ fn qux(a: Option<u32>, b: Option<u32>) -> bool {
3131
if let Some(y) = a { true } else { false }
3232
}
3333

34+
fn moo(x: u32) -> bool {
35+
match x {
36+
_ => 1,
37+
} > 0 //~ ERROR ambiguous parse
38+
}
39+
3440
fn main() {}

src/test/ui/parser/expr-as-stmt.stderr

+13-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ LL | if let Some(x) = a { true } else { false }
3030
LL | &&
3131
| ^^
3232

33+
error: ambiguous parse
34+
--> $DIR/expr-as-stmt.rs:37:7
35+
|
36+
LL | } > 0
37+
| ^
38+
help: parenthesis are required to parse this as an expression
39+
|
40+
LL | (match x {
41+
LL | _ => 1,
42+
LL | }) > 0
43+
|
44+
3345
error[E0308]: mismatched types
3446
--> $DIR/expr-as-stmt.rs:7:6
3547
|
@@ -74,7 +86,7 @@ LL | { 3 } * 3
7486
| |
7587
| help: parenthesis are required to parse this as an expression: `({ 3 })`
7688

77-
error: aborting due to 9 previous errors
89+
error: aborting due to 10 previous errors
7890

7991
Some errors have detailed explanations: E0308, E0614.
8092
For more information about an error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)