Skip to content

Misleading unnecessary braces warning #104141

Closed

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")}>();
}

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.
    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
    A-const-genericsArea: const generics (parameters and arguments)
    on Dec 9, 2022
  2. added a commit that references this issue on Dec 27, 2022
    b8d71fc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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