Skip to content

false positive for unused_parens in a let-else #131655

Closed
@its-the-shrimp

Description

@its-the-shrimp

Code

fn main() {
    macro_rules! x {
        () => { None::<i32> };
    }

    let Some(_x) = (x! {}) else { return };
}

Current output

warning: unnecessary parentheses around assigned value
 --> src/main.rs:6:20
  |
6 |     let Some(_x) = (x! {}) else { return };
  |                    ^     ^
  |
  = note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
  |
6 -     let Some(_x) = (x! {}) else { return };
6 +     let Some(_x) = x! {} else { return };
  |

warning: 1 warning emitted

Desired output

nothing

Rationale and extra context

No response

Other cases

No response

Rust Version

rustc 1.83.0-nightly (6b9676b 2024-10-12)
binary: rustc
commit-hash: 6b9676b
commit-date: 2024-10-12
host: aarch64-apple-darwin
release: 1.83.0-nightly
LLVM version: 19.1.1

Anything else?

This was an issue on a nightly from 7th of August as well

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.L-unused_parensLint: unused_parensT-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