-
Couldn't load subscription status.
- Fork 13.9k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTD-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.F-let_elseIssues related to let-else statements (RFC 3137)Issues related to let-else statements (RFC 3137)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
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
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTD-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.F-let_elseIssues related to let-else statements (RFC 3137)Issues related to let-else statements (RFC 3137)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.