-
-
Notifications
You must be signed in to change notification settings - Fork 15k
unused_braces false positive with assignment to wildcard #116536
Copy link
Copy link
Open
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.L-unused_bracesLint: unused_bracesLint: unused_bracesT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.L-unused_bracesLint: unused_bracesLint: unused_bracesT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
This code:
Gives this warning:
However, the braces are not unnecessary.
_ = { e };does the same thing asdrop(e);, but_ = e;doesn't do anything (not even movee).You also can't just write
{ e };, that would trigger aunused_must_usewarning.I think the lint shouldn't trigger here.
There are also more complicated examples like this:
Where it isn't even possible to tell if the braces are unnecessary just based on the AST. But surely no-one writes code like that :)
Version
rustc 1.75.0-nightly (2023-10-07)@rustbot label: T-compiler A-lint