-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-verboseDiagnostics: Too much output caused by a single piece of incorrect code.Diagnostics: Too much output caused by a single piece of incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Follow-up to #82827, cc: @estebank
Given the following code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=7810898a8a0c0b5d421b4efbd58a4ff8
pub fn main() {
let x = Some(3);
if (let Some(y) = x) {
println!("{}", y)
} else {
println!("None")
}
}
The current output is:
error[E0658]: `let` expressions in this position are experimental
--> src/main.rs:3:7
|
3 | if (let Some(y) = x) {
| ^^^^^^^^^^^^^^^
|
= note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
= help: add `#![feature(let_chains)]` to the crate attributes to enable
= help: you can write `matches!(<expr>, <pattern>)` instead of `let <pattern> = <expr>`
error: invalid parentheses around `let` expression in `if let`
--> src/main.rs:3:6
|
3 | if (let Some(y) = x) {
| ^ ^
|
help: `if let` needs to be written without parentheses
|
3 | if let Some(y) = x {
| -- --
error: aborting due to 2 previous errors
Ideally the output should look like:
(Just the invalid parantheses error, and the let expressions in this position is experimental
error is silenced)
error: invalid parentheses around `let` expression in `if let`
--> src/main.rs:3:6
|
3 | if (let Some(y) = x) {
| ^ ^
|
help: `if let` needs to be written without parentheses
|
3 | if let Some(y) = x {
| -- --
error: aborting due to 2 previous errors
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-verboseDiagnostics: Too much output caused by a single piece of incorrect code.Diagnostics: Too much output caused by a single piece of incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.