Skip to content

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

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
Tracked by #53667
Centril opened this issue Apr 27, 2019 · 1 comment · Fixed by #77931
Closed
Tracked by #53667

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

Centril opened this issue Apr 27, 2019 · 1 comment · Fixed by #77931
Assignees
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. F-let_chains `#![feature(let_chains)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Centril
Copy link
Contributor

Centril commented Apr 27, 2019

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.

@Centril Centril added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Apr 27, 2019
@Centril Centril self-assigned this Apr 27, 2019
@Centril
Copy link
Contributor Author

Centril commented Apr 27, 2019

This is a rather obscure bug which no one seems to have hit thus far... I only found it due to working on let_chains. I'll fix the issue as part of this work.

@Centril Centril added the F-let_chains `#![feature(let_chains)]` label Oct 10, 2019
@Aaron1011 Aaron1011 added the D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. label Aug 8, 2020
@bors bors closed this as completed in 378ca5e Oct 20, 2020
@fmease fmease added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. and removed A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. labels Dec 21, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. F-let_chains `#![feature(let_chains)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants