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 on unused_parens lint #26461

Closed
tomjakubowski opened this issue Jun 21, 2015 · 3 comments
Closed

false positive on unused_parens lint #26461

tomjakubowski opened this issue Jun 21, 2015 · 3 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@tomjakubowski
Copy link
Contributor

fn main() {
    if (return) {}
}

sez:

<anon>:2:8: 2:16 warning: unnecessary parentheses around `if` condition, #[warn(unused_parens)] on by default
<anon>:2     if (return) {}
                ^~~~~~~~

However, removing the parentheses makes the file have illegal syntax, because {} is part of the return expression (so the if is missing its arm).

@tomjakubowski
Copy link
Contributor Author

Also, by the way, it's very amusing to me that this is legal:

fn main() {
    if return { return } { return } else { return }
}

@steveklabnik steveklabnik added the A-diagnostics Area: Messages for errors, warnings, and lints label Jun 23, 2015
@samdoiron
Copy link

Triage: Warning still generated in nightly build. Seems to be an issue with contains_exterior_struct_lit not identifying return {} as an exterior expression.

@steveklabnik steveklabnik added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 9, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 22, 2017
@euclio
Copy link
Contributor

euclio commented Dec 4, 2018

Looks like this was fixed in #55166, and there's a test.

@oli-obk oli-obk closed this as completed Dec 5, 2018
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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants