Skip to content

unnecessary_parens false positive when calling function from match #5057

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

Closed
monoclex opened this issue Oct 31, 2021 · 3 comments
Closed

unnecessary_parens false positive when calling function from match #5057

monoclex opened this issue Oct 31, 2021 · 3 comments

Comments

@monoclex
Copy link

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

Misc

Apologies if this is in the wrong repository. Not sure if it should go to clippy, or to rust as this seems like some sort of parser oversight.

@monoclex monoclex changed the title unnecessary_parens false positive when calling function unnecessary_parens false positive when calling function from match Oct 31, 2021
@karyon
Copy link
Contributor

karyon commented Oct 31, 2021

Both the warning and the error come from rustc (the rust compiler), so I would suggest you open a bug report there. This repo here is rustfmt, a tool that auto-formats your code :)

(The error is interesting! I don't really understand what's going on there. If you create a rustc bug report, please link it, I'm curious about the result!)

@karyon karyon closed this as completed Oct 31, 2021
@monoclex
Copy link
Author

Ah, my bad for reporting it here — here's the link to the issue on the rustc repo since you're interested rust-lang/rust#90456

@karyon
Copy link
Contributor

karyon commented Nov 1, 2021

no worries, and thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants