Skip linting unused braces for FunctionArg and MethodArg context for 2024 later - #154373
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 comment has been minimized.
This comment has been minimized.
|
@rustbot ready |
|
r? compiler |
| ast::ExprKind::Array(exprs) | ast::ExprKind::Tup(exprs) => { | ||
| exprs.iter().all(|expr| Self::is_arg_block_without_temp_scope_change(expr)) | ||
| } | ||
| _ => false, |
There was a problem hiding this comment.
exhaustively list them all and add almost all others to the "ok" list:
- unary,unsafebindercast,includebytes
- binary, index, range,
- constblock, path,inlineasm, offsetof
- if,while,forloop,loop,match,block
- gen, closure, tryblock, try
- use, await, break, ret, continue, yield, yeet
- assign, assignop,
- struct, repeat
14cc286 to
2e43946
Compare
This comment has been minimized.
This comment has been minimized.
2e43946 to
88aa4a9
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
88aa4a9 to
8e30f04
Compare
|
@rustbot ready |
…d-braces-temp-scope-lite, r=oli-obk Skip linting unused braces for FunctionArg and MethodArg context for 2024 later Fixes rust-lang#154247 `unused_braces` is 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 `hir` related 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.
…d-braces-temp-scope-lite, r=oli-obk Skip linting unused braces for FunctionArg and MethodArg context for 2024 later Fixes rust-lang#154247 `unused_braces` is 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 `hir` related 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.
|
💔 I suspect this PR failed tests as part of a rollup After fixing the problem, consider running a try job for the failed job before re-approving. Link to failure: https://github.com/rust-lang/rust/actions/runs/30368814940/job/90307165557?pr=160081 |
|
This pull request was unapproved. This PR was contained in a rollup (#160081), which was unapproved. |
This comment has been minimized.
This comment has been minimized.
8e30f04 to
ad89677
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. |
|
fixed the conflict. |
…d-braces-temp-scope-lite, r=oli-obk Skip linting unused braces for FunctionArg and MethodArg context for 2024 later Fixes rust-lang#154247 `unused_braces` is 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 `hir` related 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.
…d-braces-temp-scope-lite, r=oli-obk Skip linting unused braces for FunctionArg and MethodArg context for 2024 later Fixes rust-lang#154247 `unused_braces` is 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 `hir` related 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.
…uwer Rollup of 10 pull requests Successful merges: - #162126 (Rename various resolving functions for consistency, and document them) - #162520 (Refactor `HygieneEncodeContext`) - #154373 (Skip linting unused braces for FunctionArg and MethodArg context for 2024 later ) - #160023 (Refactor the way cg_ssa handles indirect returns (returns via `sret`) — Take 2) - #161482 (Use attribute parser for `#[non_exhaustive]` attribute check) - #161867 (deeper `rustc_builtin_macros` cleanups) - #162099 (small refactor of doc attribute arguments warnings) - #162541 (split `macroless_generic_const_args` in two) - #162549 (The fuchsia team maintains `riscv64gc-unknown-fuchsia`) - #162577 (Fix `i686-pc-windows-msvc` platform support docs and target spec metadata)
…d-braces-temp-scope-lite, r=oli-obk Skip linting unused braces for FunctionArg and MethodArg context for 2024 later Fixes rust-lang#154247 `unused_braces` is 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 `hir` related 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.
…uwer Rollup of 11 pull requests Successful merges: - #162520 (Refactor `HygieneEncodeContext`) - #154373 (Skip linting unused braces for FunctionArg and MethodArg context for 2024 later ) - #160023 (Refactor the way cg_ssa handles indirect returns (returns via `sret`) — Take 2) - #160860 (Implement arbitrary casts in custom mir) - #161482 (Use attribute parser for `#[non_exhaustive]` attribute check) - #161867 (deeper `rustc_builtin_macros` cleanups) - #162099 (small refactor of doc attribute arguments warnings) - #162541 (split `macroless_generic_const_args` in two) - #162549 (The fuchsia team maintains `riscv64gc-unknown-fuchsia`) - #162577 (Fix `i686-pc-windows-msvc` platform support docs and target spec metadata) - #162624 (regression test for opaque field projection in closure capture)
Rollup merge of #154373 - chenyukang:yukang-fix-154247-unused-braces-temp-scope-lite, r=oli-obk Skip linting unused braces for FunctionArg and MethodArg context for 2024 later Fixes #154247 `unused_braces` is 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 `hir` related 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.
|
Note This PR was benchmarked as part of triage of its containing rollup: triage URL. Finished benchmarking commit (00df995): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis perf run didn't have relevant results for this metric. Max RSS (memory usage)Results (secondary 4.9%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesThis perf run didn't have relevant results for this metric. Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: missing data |
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.