Closed
Description
I tried this code:
pub fn foo() -> i32 {
let x = 1;
(match x {
_ => x,
} as i32)
}
This generates a warning about unused parentheses:
warning: unnecessary parentheses around block return value
--> src/lib.rs:3:5
|
3 | / (match x {
4 | | _ => x
5 | | } as i32)
| |_____________^
|
= note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
|
3 ~ match x {
4 + _ => x
5 + } as i32
|
However, applying the suggestion causes it to fail to compile:
error: expected expression, found `as`
--> src/lib.rs:5:7
|
5 | } as i32
| ^^ expected expression
|
help: parentheses are required to parse this as an expression
|
3 ~ (match x {
4 | _ => x,
5 ~ }) as i32
|
Found in the 2021 crater run for:
Meta
rustc --version --verbose
:
rustc 1.56.0-nightly (5eacec9ec 2021-08-28)
binary: rustc
commit-hash: 5eacec9ec7e112a0de1011519a57c45586d58414
commit-date: 2021-08-28
host: x86_64-apple-darwin
release: 1.56.0-nightly
LLVM version: 13.0.0