Skip to content

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

Closed
@dtolnay

Description

@dtolnay
#![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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions