Skip to content

Commit cf74c74

Browse files
committed
lint: enable clippy restriction lints, disable redundant dylint rule
Enable `clippy::clone_on_ref_ptr`, `clippy::if_then_some_else_none`, and `clippy::unnecessary_lazy_evaluations` as warnings, which the existing `cargo clippy -- -D warnings` invocation in `test.sh` promotes to hard errors in CI. Disable `perfectionist::arc_rc_clone` in `dylint.toml` because `clippy::clone_on_ref_ptr` now covers the same ground in the default lint pass. Apply the single resulting code fix in `App::run`, replacing an `if`/`else` that produced `Some(1)`/`None` with `.then(|| ...)`.
1 parent 8c00d3e commit cf74c74

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ zero-copy-pads = "0.2.0"
9191
[lints.rust]
9292
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(dylint_lib, values("perfectionist"))'] }
9393

94+
[lints.clippy]
95+
clone_on_ref_ptr = "warn"
96+
if_then_some_else_none = "warn"
97+
unnecessary_lazy_evaluations = "warn"
98+
9499
[dev-dependencies]
95100
build-fs-tree = "0.8.1"
96101
command-extra = "1.0.0"

dylint.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ libraries = [
33
{ git = "https://github.com/KSXGitHub/perfectionist", tag = "0.0.0-rc.14" },
44
]
55

6+
[perfectionist]
7+
disable = [
8+
{ name = "arc_rc_clone", reason = "`arc_rc_clone` is enforced by `clippy::clone_on_ref_ptr` instead" },
9+
]
10+
611
["perfectionist::derive_ordering"]
712
style = "prefix_then_alphabetical"
813
prefix = [

src/app.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,11 @@ impl App {
144144
let threads = match self.args.threads {
145145
Threads::Auto => {
146146
let disks = Disks::new_with_refreshed_list();
147-
if any_path_is_in_hdd::<Disk, hdd::RealFs>(&self.args.files, &disks) {
147+
any_path_is_in_hdd::<Disk, hdd::RealFs>(&self.args.files, &disks).then(|| {
148148
eprintln!("warning: HDD detected, the thread limit will be set to 1");
149149
eprintln!("hint: You can pass --threads=max disable this behavior");
150-
Some(1)
151-
} else {
152-
None
153-
}
150+
1
151+
})
154152
}
155153
Threads::Max => None,
156154
Threads::Fixed(threads) => Some(threads.get()),

0 commit comments

Comments
 (0)