Skip to content

unused_parens incorrectly lints on if let true = (false && true) {} #60336

Closed
@Centril

Description

@Centril
warning: unnecessary parentheses around `if let` head expression
 --> src/lib.rs:2:19
  |
2 |     if let true = (false && true) {}
  |                   ^^^^^^^^^^^^^^^ help: remove these parentheses
  |
  = note: #[warn(unused_parens)] on by default

If we remove the parens we correctly get:

error: ambiguous use of `&&`
 --> src/lib.rs:2:19
  |
2 |     if let true = false && true {}
  |                   ^^^^^^^^^^^^^ help: consider adding parentheses: `(false && true)`
  |
  = note: this will be a error until the `let_chains` feature is stabilized
  = note: see rust-lang/rust#53668 for more information

cc #53667 #53668

The lint should take let_chains into account.

Metadata

Metadata

Assignees

Labels

A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.F-let_chains`#![feature(let_chains)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions