-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
unused_parens lint suggestion also removes attributes on inner expression with feature(stmt_expr_attributes). #129833
Copy link
Copy link
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-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.F-stmt_expr_attributes`#![feature(stmt_expr_attributes)]``#![feature(stmt_expr_attributes)]`L-unused_parensLint: unused_parensLint: unused_parensT-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.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.This issue requires a nightly compiler in some way. When possible, use a F-* label instead.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-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.F-stmt_expr_attributes`#![feature(stmt_expr_attributes)]``#![feature(stmt_expr_attributes)]`L-unused_parensLint: unused_parensLint: unused_parensT-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.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.This issue requires a nightly compiler in some way. When possible, use a F-* label instead.
Type
Fields
Give feedbackNo fields configured for issues without a type.
I tried this code:
I expected to see this happen: The
unused_parenswarning fires on all three lines offoo, and the suggestions should only suggest removing the parentheses, not the attribute also.Instead, this happened: The
unused_parensfires on the first and last lines offoo, and the suggestion also removes the#[inline].No
unused_parenswarning fires on the second line(#[inline] || println!("Hello!"));(but this is probably a separate issue, unrelated to attributes; it happens even when the attribute is removed; maybeunused_must_useoverrides it or something).Meta
rustc --version --verbose:Requires use of
#![feature(stmt_expr_attributes)], otherwise the#[inline]is not legal in that position (though note that theunused_parenswarning and suggestion is the same on stable, there's just anerror[E0658]: attributes on expressions are experimentalfirst).The issue is not specific to closures and
#[inline], but that was the simplest example of a reasonable attribute-on-expression I thought of.@rustbot label +A-diagnostics +requires-nightly