-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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 ASTC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.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
Hi,
As I understand, chaining inequality operators like <
, >
, <=
and >=
is not allowed. Yet trying to do so will ask you to add parenthesies:
fn main() {
let x = 2;
if 1 <= x <= 3 {
println!("yes");
} else {
println!("no");
}
}
Gives:
error: chained comparison operators require parentheses
--> src/main.rs:4:10
|
4 | if 1 <= x <= 3 {
| ^^^^^^^
error[E0308]: mismatched types
--> src/main.rs:4:18
|
4 | if 1 <= x <= 3 {
| ^ expected bool, found integer
|
= note: expected type `bool`
found type `{integer}`
The first error is false advice in the context of <=
. It would have been ok for ==
though.
Thanks :)
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 ASTC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.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.