Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

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

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-lint 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-lint 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint 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.

2 participants