Skip to content

Misleading unnecessary braces warning #104141

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

Closed
bugadani opened this issue Nov 8, 2022 · 0 comments · Fixed by #105515
Closed

Misleading unnecessary braces warning #104141

bugadani opened this issue Nov 8, 2022 · 0 comments · Fixed by #105515
Labels
A-const-generics Area: const generics (parameters and arguments) A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@bugadani
Copy link
Contributor

bugadani commented Nov 8, 2022

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")}>();
}
@bugadani bugadani added the C-bug Category: This is a bug. label Nov 8, 2022
@estebank estebank added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-const-generics Area: const generics (parameters and arguments) labels Dec 9, 2022
@bors bors closed this as completed in b8d71fc Dec 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. 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.

2 participants