Code
fn main() {
if let true = true || false {}
}
Current output
error: expected expression, found `let` statement
--> src/main.rs:6:8
|
6 | if let true = true || false {}
| ^^^^^^^^^^^^^^^
|
= note: only supported directly in conditions of `if` and `while` expressions
note: `||` operators are not supported in let chain expressions
--> src/main.rs:6:24
|
6 | if let true = true || false {}
| ^^
Desired output
error: `||` in an `if` expression with `let` is not allowed
--> src/main.rs:2:17
|
2 | if let true = true || false {}
| ^^
|
Rationale and extra context
The current error message has several confusing factors:
- The primary error message
expected expression, found `let` statement which is confusing. I suppose this is technically correct (let is not allowed in an if with a ||), but muddles the problem. There's also the confusion of using the term `let` statement`, where the term "statement" is confusing here.
- The note
only supported directly in conditions of `if` and `while` expressions is confusing, since we are in an if expression.
- The final note of
note: `||` operators are not supported in let chain expressions shows the actual problem, but it is lost in a sea of other text.
Other cases
Rust Version
rustc 1.88.0-nightly (df35ff6c3 2025-04-23)
binary: rustc
commit-hash: df35ff6c354f1f1fbf430b84e7dea37dfe997f34
commit-date: 2025-04-23
host: aarch64-apple-darwin
release: 1.88.0-nightly
LLVM version: 20.1.2
Anything else?
No response
Code
Current output
Desired output
Rationale and extra context
The current error message has several confusing factors:
expected expression, found `let` statementwhich is confusing. I suppose this is technically correct (letis not allowed in anifwith a||), but muddles the problem. There's also the confusion of using the term`let` statement`, where the term "statement"is confusing here.only supported directly in conditions of `if` and `while` expressionsis confusing, since we are in anifexpression.note: `||` operators are not supported in let chain expressionsshows the actual problem, but it is lost in a sea of other text.Other cases
Rust Version
Anything else?
No response