Skip to content

Commit 9aaeda8

Browse files
committed
ci(test): enforce dylint warnings as errors
Pass RUSTFLAGS="-D warnings" to cargo dylint so any rule violation now fails the script, matching what cargo clippy already does. Suppress the two known macro_trailing_comma sites in tests/tree_builder.rs and tests/visualizer.rs via crate-level cfg_attr-gated attributes: * Gate everything on cfg(dylint_lib = "perfectionist") so the attributes only apply during dylint runs (the cfg is set by dylint's RUSTC wrapper). This keeps stable cargo check untouched and matches the user preference for narrow handling of unknown_tool, since perfectionist is registered as a tool only when dylint is active. * register_tool(perfectionist) under #![feature(register_tool)] makes rustc accept the perfectionist:: lint prefix on the nightly toolchain that dylint uses, avoiding E0710. * Use expect rather than allow for macro_trailing_comma per project preference, with an accompanying allow(unfulfilled_lint_expectations) because perfectionist appears to short-circuit when its lint is expected at crate scope, leaving the expect unfulfilled despite actual violations. * allow(unexpected_cfgs) covers the dylint_lib cfg name itself, which rustc does not learn from --check-cfg.
1 parent 58bee1d commit 9aaeda8

3 files changed

Lines changed: 44 additions & 1 deletion

File tree

test.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ unit() (
7575
run_if "${FMT:-true}" cargo fmt -- --check
7676
# Dylint inspects the source under all feature gates in a single pass, so it is
7777
# run once with `--all-features` rather than across every feature combination.
78-
run_if "${DYLINT:-false}" cargo dylint --all -- --all-features --all-targets
78+
run_if "${DYLINT:-false}" env RUSTFLAGS="-D warnings ${RUSTFLAGS:-}" \
79+
cargo dylint --all -- --all-features --all-targets
7980
unit "$@"
8081
unit --no-default-features "$@"
8182
unit --all-features "$@"

tests/tree_builder.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
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_trailing_comma,
7+
reason = "rustfmt collapses single-element multi-line vec! and removes the trailing comma; see https://github.com/KSXGitHub/perfectionist/issues"
8+
)
9+
)]
10+
#![cfg_attr(
11+
dylint_lib = "perfectionist",
12+
allow(
13+
unfulfilled_lint_expectations,
14+
reason = "perfectionist's macro_trailing_comma short-circuits when its lint is allowed/expected at crate scope, so #[expect] cannot be fulfilled even though violations exist"
15+
)
16+
)]
17+
#![allow(
18+
unexpected_cfgs,
19+
reason = "`dylint_lib` is set by dylint's compiler wrapper and is not in --check-cfg"
20+
)]
21+
122
use build_fs_tree::{FileSystemTree, dir, file};
223
use derive_more::From;
324
use parallel_disk_usage::{

tests/visualizer.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
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_trailing_comma,
7+
reason = "rustfmt collapses single-element multi-line vec! and removes the trailing comma; see https://github.com/KSXGitHub/perfectionist/issues"
8+
)
9+
)]
10+
#![cfg_attr(
11+
dylint_lib = "perfectionist",
12+
allow(
13+
unfulfilled_lint_expectations,
14+
reason = "perfectionist's macro_trailing_comma short-circuits when its lint is allowed/expected at crate scope, so #[expect] cannot be fulfilled even though violations exist"
15+
)
16+
)]
17+
#![allow(
18+
unexpected_cfgs,
19+
reason = "`dylint_lib` is set by dylint's compiler wrapper and is not in --check-cfg"
20+
)]
21+
122
use parallel_disk_usage::{
223
bytes_format::BytesFormat::*,
324
data_tree::DataTree,

0 commit comments

Comments
 (0)