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

False positive 'unnecessary parenthesis' with 'if let': #75300

Closed
Aaron1011 opened this issue Aug 8, 2020 · 1 comment
Closed

False positive 'unnecessary parenthesis' with 'if let': #75300

Aaron1011 opened this issue Aug 8, 2020 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. F-let_chains `#![feature(let_chains)]`

Comments

@Aaron1011
Copy link
Member

The following code:

fn main() {
    if let true = (true && false) {}
}

produces the following warning:

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

However, removing the parenthesis results in an error:

   Compiling playground v0.0.1 (/playground)
error[E0658]: `let` expressions in this position are experimental
 --> src/main.rs:2:8
  |
2 |     if let true = true && false {}
  |        ^^^^^^^^^^^^^^^
  |
  = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
  = help: add `#![feature(let_chains)]` to the crate attributes to enable

error: `let` expressions are not supported here
 --> src/main.rs:2:8
  |
2 |     if let true = true && false {}
  |        ^^^^^^^^^^^^^^^
  |
  = note: only supported directly in conditions of `if`- and `while`-expressions
  = note: as well as when nested within `&&` and parenthesis in those conditions
@Aaron1011 Aaron1011 added A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. F-let_chains `#![feature(let_chains)]` D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. labels Aug 8, 2020
@Aaron1011
Copy link
Member Author

Closing as duplicate of #60336

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. F-let_chains `#![feature(let_chains)]`
Projects
None yet
Development

No branches or pull requests

1 participant