Closed
Description
Given the following code: link
fn main() {
let x = Some(123);
if let Some(y) = x else {
return;
};
}
The current output is:
Compiling playground v0.0.1 (/playground)
error: this `if` expression is missing a block after the condition
--> src/main.rs:3:5
|
3 | if let Some(y) = x else {
| ^^
|
help: add a block here
--> src/main.rs:3:23
|
3 | if let Some(y) = x else {
| ^
error: could not compile `playground` due to previous error
Ideally the output should suggest removing the additional if
keyword in front of the let else
. This mistake can occur due to muscle memory as if
, if let
, let else
and in the future let chains
are somewhat similar syntactically. Thanks.
@rustbot label +D-confusing +F-let-else
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: The lexing & parsing of Rust source code to an ASTDiagnostics: Confusing error or lint that should be reworked.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Issues related to let-else statements (RFC 3137)Relevant to the compiler team, which will review and decide on the PR/issue.