-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Closed
Copy link
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 ASTA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.F-let_chains`#![feature(let_chains)]``#![feature(let_chains)]`P-lowLow priorityLow priorityT-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
fn foo(b: bool, x: Option<u32>) {
if b && if let Some(x) = x {}
}
fn main() {
if true && if true { true }
}
error: expected `{`, found `}`
--> src/main.rs:3:1
|
3 | }
| ^ expected `{`
|
note: the `if` expression is missing a block after this condition
--> src/main.rs:2:8
|
2 | if b && if let Some(x) = x {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: expected `{`, found `}`
--> src/main.rs:6:1
|
6 | }
| ^ expected `{`
|
note: the `if` expression is missing a block after this condition
--> src/main.rs:5:8
|
5 | if true && if true { true }
| ^^^^^^^^^^^^^^^^^^^^^^^^
We should detect that what was intended was
fn foo(b: bool, x: Option<u32>) {
if b && let Some(x) = x {}
}
fn main() {
if true && true { true }
}
fmease, camsteffen, jruderman and est31
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 ASTA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.F-let_chains`#![feature(let_chains)]``#![feature(let_chains)]`P-lowLow priorityLow priorityT-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.