Skip linting unused braces for FunctionArg and MethodArg context for 2024 later #154373
Skip linting unused braces for FunctionArg and MethodArg context for 2024 later #154373chenyukang wants to merge 1 commit intorust-lang:mainfrom
Conversation
|
r? @fmease rustbot has assigned @fmease. Use Why was this reviewer chosen?The reviewer was selected based on:
|
73c892b to
e120f17
Compare
This comment has been minimized.
This comment has been minimized.
| is_kw: bool, | ||
| ); | ||
|
|
||
| fn is_expr_simple_arg(expr: &ast::Expr) -> bool { |
There was a problem hiding this comment.
This is a very generic name for a very specific use case. "Simple argument" could mean vastly different things in different contexts. I think this should be renamed to something more specific.
| ast::ExprKind::Lit(_) | ast::ExprKind::Path(..) => true, | ||
| ast::ExprKind::Type(expr, _) => Self::is_expr_simple_arg(expr), |
There was a problem hiding this comment.
Surely more kinds of expressions qualify? Like possibly as-casting other "simple" exprs, arrays & tuples of other "simple" exprs and so on.
e120f17 to
14cc286
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@rustbot ready |
Fixes #154247
unused_bracesis a AST level lint, but in Rust 2024 braces around function and method arguments can affect temporary drop scope.I tried to find a more complete fix for it, but seems all too heavy, which involve AST visitor or need
hirrelated stuff.Instead of teaching this lint to reason about semantics, so it's better to stop linting those argument-position braces in 2024 later edition.