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

Regression: false negative in unused_braces lint for braces around macro call #106899

Closed
dtolnay opened this issue Jan 15, 2023 · 0 comments · Fixed by #106900
Closed

Regression: false negative in unused_braces lint for braces around macro call #106899

dtolnay opened this issue Jan 15, 2023 · 0 comments · Fixed by #106900
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@dtolnay
Copy link
Member

dtolnay commented Jan 15, 2023

#![allow(unreachable_code)]
#![deny(unused_braces)]

fn main() {
    return { println!("!") };
}
$ rustc +nightly-2023-01-14 src/main.rs  # correct behavior
error: unnecessary braces around `return` value
 --> src/main.rs:5:12
  |
5 |     return { println!("!") };
  |            ^^             ^^
  |
note: the lint level is defined here
 --> src/main.rs:2:9
  |
2 | #![deny(unused_braces)]
  |         ^^^^^^^^^^^^^
help: remove these braces
  |
5 -     return { println!("!") };
5 +     return println!("!");
  |
$ rustc +nightly-2023-01-15 src/main.rs  # incorrect: no lint

The false negative bisects to #106866, so pretty obviously #106563. FYI @clubby789 @TaKO8Ki

From skimming #106545, that's an issue about const generics. It doesn't seem like the PR was supposed to have affected unused_braces situations outside of const generics position.

@dtolnay dtolnay added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels Jan 15, 2023
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jan 15, 2023
@dtolnay dtolnay added A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed regression-untriaged Untriaged performance or correctness regression. labels Jan 15, 2023
dtolnay added a commit to dtolnay/rust-quiz that referenced this issue Jan 15, 2023
@bors bors closed this as completed in 5321ad5 Jan 16, 2023
@apiraino apiraino removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants