Skip to content

unnecessary_parens false positive when calling function from match #90456

Closed
@monoclex

Description

@monoclex

Rust Information

rustc --version: rustc 1.55.0-nightly (gentoo)
rustfmt --version: rustfmt 1.4.37-nightly ( )
cargo --version: cargo 1.55.0-nightly
rust-analyzer version: v0.3.794 preview (nightly mode is enabled)

Repro

pub enum Repro {
    A(i64),
    B(i64),
}

fn make(a: bool, data: i64) -> Repro {
    (match a {
        true => Repro::A,
        false => Repro::B,
    }(data))
}

Issue

When I write my code as suggested, I get a warning for putting parenthesis around this match statement:

the warning

However, upon doing what the warning says, I am then greeted with a compiler error (the error persists if I put the parenthesis next to the closing brace of the match statement, as expected)

the compiler error

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions