Skip to content

Commit 71a6b66

Browse files
committed
chore(deps): bump perfectionist to 8925331 and adopt deny/allow config
8925331 redesigns `macro_argument_binding` from "flag every macro with a non-trivial top-level argument" to a curated `AllowAndDeny` mode: only invocations on the built-in deny list (`debug_assert`, `debug_assert_eq`, `debug_assert_ne`) plus user `deny_extra` trigger the rule, and the built-in allow list silences common once-only macros (`format`, `vec`, `assert`, …). The trivial- expression grammar also gains a pure-getter postfix walker so `vec.len()`, `s.is_empty()`, `opt.as_ref()`, and the rest of the built-in zero-arg list stay trivial. Adopt the new config knobs: - `deny_extra = ["debug_assert_op", "debug_assert_op_expr"]` enrolls the `assert-cmp` family alongside the std `debug_assert*` macros so non-trivial arguments still get caught despite their conditional `cfg(debug_assertions)` expansion. - `allow_extra = ["bump", "visualize", "test_case"]` catalogues the three remaining project-defined macros that expand each top-level argument exactly once. The combination eliminates two suppressions that were necessary under PR 52's head (`93cb529`): - `src/visualizer/methods/tree_table.rs` — `intermediate_table .len()` is now trivial via the built-in pure-getter list. - `tests/bytes_format.rs` — `test_case!` is in `allow_extra`, so the rule no longer fires on its `name -> value in system == expected` DSL invocations. The crate-root suppression and the `register_tool(perfectionist)` it required are gone. The late-pass anchoring bug #419 is mechanistically unchanged: `src/rules/macro_argument_binding/late.rs` is byte-identical between `93cb529` and `8925331`. The new `allow_extra` / `deny_extra` mechanism sidesteps #419 in practice for user-defined macros (config-level allow needs no `#[expect]`), but the underlying anchoring bug for item-position macro expansions still exists. https://claude.ai/code/session_01CoRidYHvni9nKNgxMPXmfQ
1 parent d948bd5 commit 71a6b66

3 files changed

Lines changed: 22 additions & 18 deletions

File tree

dylint.toml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[workspace.metadata.dylint]
22
libraries = [
3-
{ git = "https://github.com/KSXGitHub/perfectionist", rev = "93cb529c15ae9e0ac8ef093efee58219b8d68cb7" },
3+
{ git = "https://github.com/KSXGitHub/perfectionist", rev = "892533129e44ef48f7be468a9804ff36325f70fa" },
44
]
55

66
["perfectionist::derive_ordering"]
@@ -38,6 +38,27 @@ prefix = [
3838
"LowerHex", "UpperHex", "Octal",
3939
]
4040

41+
["perfectionist::macro_argument_binding"]
42+
# `assert_cmp::debug_assert_op!` and `debug_assert_op_expr!` expand
43+
# conditionally on `cfg(debug_assertions)`, so they share the
44+
# argument-evaluation hazard the built-in deny list catches for
45+
# `debug_assert*`. Catalogue them so the rule still flags genuinely
46+
# side-effecting arguments while accepting the pure-getter calls
47+
# (`vec.len()`) that the trivial-method classifier already recognises.
48+
deny_extra = ["debug_assert_op", "debug_assert_op_expr"]
49+
# Project-defined and third-party macros that expand each top-level
50+
# argument exactly once. Adding them to the allow list silences the
51+
# blanket "unknown macro" flag the default `AllowAndDeny` mode
52+
# applies to uncatalogued invocations.
53+
allow_extra = [
54+
# `src/reporter/progress_and_error_reporter.rs::report`.
55+
"bump",
56+
# `src/app.rs::App::run`.
57+
"visualize",
58+
# `tests/bytes_format.rs`.
59+
"test_case",
60+
]
61+
4162
["perfectionist::single_letter_closure_param"]
4263
# Treat project-specific and third-party comparison-style helpers as if
4364
# they were standard `sort_by`-shaped methods, so the idiomatic

src/visualizer/methods/tree_table.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,6 @@ impl TreeColumnWidth {
4141

4242
pub(super) type TreeTable<Name, NodeData> = Table<TreeRow<Name, NodeData>, TreeColumnWidth>;
4343

44-
#[cfg_attr(
45-
dylint_lib = "perfectionist",
46-
expect(
47-
perfectionist::macro_argument_binding,
48-
reason = "`Vec::len` is a pure `O(1)` read; the `debug_assert_op_expr!` invocation below intentionally keeps the call inside the assertion so it runs only in debug builds, and binding it to a `let` would lift the call into release builds for no benefit",
49-
)
50-
)]
5144
pub(super) fn render_tree<'a, Name, Size>(
5245
visualizer: Visualizer<'a, Name, Size>,
5346
initial_table: InitialTable<&'a Name, Size>,

tests/bytes_format.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
#![cfg_attr(dylint_lib = "perfectionist", feature(register_tool))]
2-
#![cfg_attr(dylint_lib = "perfectionist", register_tool(perfectionist))]
3-
#![cfg_attr(
4-
dylint_lib = "perfectionist",
5-
expect(
6-
perfectionist::macro_argument_binding,
7-
reason = "the `test_case!` macro uses a `name -> value in system == expected` DSL whose `->` and `in` separators are not yet recognised by the rule's non-expression marker list (PR #52 added `=`, `+=`, and bare operators but not these). See #416. The crate-root scope is forced by an upstream late-pass anchoring quirk: violations in module-level item-position macro expansions resolve to the crate root, where finer-scoped `#[expect]` cannot reach them (#419).",
8-
)
9-
)]
10-
111
use parallel_disk_usage::bytes_format::BytesFormat;
122
use pretty_assertions::assert_eq;
133

0 commit comments

Comments
 (0)