Skip to content

chore(clippy): the lints newer toolchains enforce - #252

Open
bdelanghe wants to merge 1 commit into
mainfrom
fix/pi-sort-by-key
Open

chore(clippy): the lints newer toolchains enforce#252
bdelanghe wants to merge 1 commit into
mainfrom
fix/pi-sort-by-key

Conversation

@bdelanghe

@bdelanghe bdelanghe commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

rust-toolchain.toml pins 1.94.0 and CI installs exactly that, so nothing in this repo has ever been checked against a newer clippy. Anyone whose toolchain comes from somewhere else — nixpkgs currently ships 1.97 — gets eight errors on a clean tree, which makes just clippy useless to them.

Found while wiring up #250 (a devShell), where gate_clippy was the one gate that would not go green.

All mechanical, no behaviour change

lint sites change
unnecessary_sort_by 6 flipped comparator → sort_by_key with std::cmp::Reverse
needless_borrows_for_generic_args 2 drop a & in a println! argument that Display takes by reference anyway
crates/path-cli/src/cache.rs:135
crates/path-cli/src/cmd_import.rs:593,785
crates/path-cli/src/cmd_list.rs:378,398,550,571
crates/path-cli/src/sync/engine.rs:152
crates/toolpath-pi/src/reader.rs:359

Every sort keeps its ordering — all six were "newest first", and Reverse on a Copy key (SystemTime, Option<DateTime<Utc>>) expresses that directly rather than leaving the reader to work out which side of the comparison was swapped.

The 1.94.0 pin is untouched. This does not adopt a newer toolchain; it only removes the gap between the pinned one and later releases, so the tree is clean under both.

Verified under 1.97

cargo clippy --workspace -- -D warnings     clean
cargo fmt --all --check                     clean
cargo test -p path-cli --lib                418 passed, 0 failed
cargo test -p toolpath-pi --lib             133 passed, 0 failed

  1. Independent PR — no bundled or speculative changes
    • Verified: one concern — lints that newer clippy enforces. No behaviour change, no new lint allows, no toolchain bump.
  2. Changed codepaths verified — targeted unit and full integration tests
    • Verified: path-cli 418 and toolpath-pi 133 unit tests pass; clippy and fmt clean under 1.97
  3. Root cause identified — every failure traced to source
    • The pin means CI only ever exercises 1.94.0; unnecessary_sort_by and needless_borrows_for_generic_args tightened in later releases, so the gap only shows on a toolchain from elsewhere
  4. No duplication — refactoring preferred over copy/paste
    • Same rewrite applied uniformly at all six sort sites rather than special-casing any
  5. No unrelated changes — housekeeping isolated to its own branch

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

rust-toolchain.toml pins 1.94.0 and CI installs it, so nothing here has
ever been checked against a newer clippy. Anyone whose toolchain comes
from somewhere else — nixpkgs currently ships 1.97 — gets eight errors on
a clean tree, which makes `just clippy` useless to them.

All mechanical, no behaviour change:

  unnecessary_sort_by     six flipped comparators become sort_by_key with
                          Reverse. Same order, and the key form states the
                          intent instead of leaving the reader to work out
                          which side of the comparison was swapped.
  needless_borrows_for_   two `&` in println! arguments that Display would
  generic_args            take by reference anyway.

Verified under 1.97: clippy --workspace -D warnings clean, cargo fmt
clean, path-cli 418 and toolpath-pi 133 unit tests pass. The 1.94.0 pin
is unchanged — this only removes the gap between it and later releases.
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

🔍 Preview deployed: https://ba950533.toolpath.pages.dev

@bdelanghe
bdelanghe marked this pull request as ready for review September 1, 2026 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant