Skip to content

Commit 9495776

Browse files
committed
test: allow assert_op_expr in macro_argument_binding and use it directly
Add `assert_op_expr` to the rule's `allow_extra` list: the macro evaluates each operand exactly once, so it carries no drop-or-duplicate hazard, unlike the `debug_assert_op*` pair already in `deny_extra`. With the exemption in place, pass the position expressions to `assert_op_expr!` directly instead of binding them to locals first. https://claude.ai/code/session_01Nj3xEp1eoDKRp1MUCxNQRQ
1 parent d1e6b8b commit 9495776

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

dylint.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ prefix = [
2626

2727
["perfectionist::macro_argument_binding"]
2828
deny_extra = ["debug_assert_op", "debug_assert_op_expr"]
29+
allow_extra = ["assert_op_expr"]
2930

3031
["perfectionist::single_letter_closure_param"]
3132
extra_trivial_callback_methods = ["sort_reflection_by"]

tests/json.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
pub mod _utils;
55
pub use _utils::*;
66

7-
use assert_cmp::assert_op;
7+
use assert_cmp::assert_op_expr;
88
use command_extra::CommandExtra;
99
use parallel_disk_usage::{
1010
bytes_format::BytesFormat,
@@ -252,12 +252,8 @@ fn json_input_no_sort() {
252252
// `--no-sort` preserves the ascending input order `a, b, c`, whereas the
253253
// default sorts by descending size, so their relative positions flip.
254254
let position = |text: &str, name: &str| text.find(name).expect("entry must be present");
255-
let actual_a = position(&actual, "a");
256-
let actual_c = position(&actual, "c");
257-
assert_op!(actual_a > actual_c);
258-
let sorted_a = position(&sorted, "a");
259-
let sorted_c = position(&sorted, "c");
260-
assert_op!(sorted_a < sorted_c);
255+
assert_op_expr!(position(&actual, "a"), >, position(&actual, "c"));
256+
assert_op_expr!(position(&sorted, "a"), <, position(&sorted, "c"));
261257
}
262258

263259
#[test]

0 commit comments

Comments
 (0)