Skip to content

Misleading unnecessary braces warning #104141

Closed
@bugadani

Description

@bugadani

Const generics, combined with the cfg! macro gives an "unnecessary braces" warning. However, removing the braces results in a compilation failure.

Example:

https://rust.godbolt.org/z/Kv8Eq5hzn

I expect no warning to be emitted for the following code:

pub fn foo<const BAR: bool> () {}

pub fn main() {
    // warning: unnecessary braces around const expression
    foo::<{cfg!(feature = "foo")}>();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-genericsArea: const generics (parameters and arguments)A-diagnosticsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions