From b4022e84e62113703adff92500414d01d808e991 Mon Sep 17 00:00:00 2001 From: Robert DeLanghe <1240090+bdelanghe@users.noreply.github.com> Date: Tue, 1 Sep 2026 14:26:56 -0400 Subject: [PATCH] chore(clippy): the lints newer toolchains enforce MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- crates/path-cli/src/cache.rs | 2 +- crates/path-cli/src/cmd_import.rs | 4 ++-- crates/path-cli/src/cmd_list.rs | 8 ++++---- crates/path-cli/src/sync/engine.rs | 2 +- crates/toolpath-pi/src/reader.rs | 6 +++++- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/crates/path-cli/src/cache.rs b/crates/path-cli/src/cache.rs index 2b2432e4..5be698f3 100644 --- a/crates/path-cli/src/cache.rs +++ b/crates/path-cli/src/cache.rs @@ -132,7 +132,7 @@ pub(crate) fn list_cached() -> Result> { modified: meta.modified().unwrap_or(std::time::SystemTime::UNIX_EPOCH), }); } - out.sort_by(|a, b| b.modified.cmp(&a.modified)); + out.sort_by_key(|e| std::cmp::Reverse(e.modified)); Ok(out) } diff --git a/crates/path-cli/src/cmd_import.rs b/crates/path-cli/src/cmd_import.rs index 7dce75be..5927e129 100644 --- a/crates/path-cli/src/cmd_import.rs +++ b/crates/path-cli/src/cmd_import.rs @@ -590,7 +590,7 @@ fn pick_claude_global( metas.extend(ms); } } - metas.sort_by(|a, b| b.last_activity.cmp(&a.last_activity)); + metas.sort_by_key(|m| std::cmp::Reverse(m.last_activity)); if metas.is_empty() { return Ok(None); } @@ -782,7 +782,7 @@ fn pick_gemini_global( metas.extend(ms); } } - metas.sort_by(|a, b| b.last_activity.cmp(&a.last_activity)); + metas.sort_by_key(|m| std::cmp::Reverse(m.last_activity)); if metas.is_empty() { return Ok(None); } diff --git a/crates/path-cli/src/cmd_list.rs b/crates/path-cli/src/cmd_list.rs index 59e59cca..489d0319 100644 --- a/crates/path-cli/src/cmd_list.rs +++ b/crates/path-cli/src/cmd_list.rs @@ -375,7 +375,7 @@ fn list_claude_sessions( .last_activity .map(|t| t.format("%Y-%m-%d %H:%M").to_string()) .unwrap_or_else(|| "unknown".to_string()); - println!(" {} {:>4} msgs {}", &m.session_id, m.message_count, date); + println!(" {} {:>4} msgs {}", m.session_id, m.message_count, date); } } } @@ -395,7 +395,7 @@ fn list_claude_sessions_all(manager: &toolpath_claude::ClaudeConvo, fmt: ListFor Err(_) => continue, // skip unreadable projects rather than aborting } } - all.sort_by(|a, b| b.last_activity.cmp(&a.last_activity)); + all.sort_by_key(|s| std::cmp::Reverse(s.last_activity)); match fmt { ListFormat::Json => { @@ -547,7 +547,7 @@ fn list_gemini_sessions( }; println!( " {} {:>4} msgs{} {}", - &m.session_uuid, m.message_count, sub, date + m.session_uuid, m.message_count, sub, date ); } } @@ -568,7 +568,7 @@ fn list_gemini_sessions_all(manager: &toolpath_gemini::GeminiConvo, fmt: ListFor Err(_) => continue, } } - all.sort_by(|a, b| b.last_activity.cmp(&a.last_activity)); + all.sort_by_key(|s| std::cmp::Reverse(s.last_activity)); match fmt { ListFormat::Json => { diff --git a/crates/path-cli/src/sync/engine.rs b/crates/path-cli/src/sync/engine.rs index 29e2a76c..e7d649b4 100644 --- a/crates/path-cli/src/sync/engine.rs +++ b/crates/path-cli/src/sync/engine.rs @@ -149,7 +149,7 @@ fn is_unchanged(rec: Option<&SyncRecord>, artifact: &ArtifactRef) -> bool { /// spent its time on the sessions the user most likely wants. fn newest_first(artifacts: &[ArtifactRef]) -> Vec<&ArtifactRef> { let mut order: Vec<&ArtifactRef> = artifacts.iter().collect(); - order.sort_by(|a, b| b.modified.cmp(&a.modified)); + order.sort_by_key(|a| std::cmp::Reverse(a.modified)); order } diff --git a/crates/toolpath-pi/src/reader.rs b/crates/toolpath-pi/src/reader.rs index 3f6b0595..50d82262 100644 --- a/crates/toolpath-pi/src/reader.rs +++ b/crates/toolpath-pi/src/reader.rs @@ -356,7 +356,11 @@ pub fn list_session_files(resolver: &PathResolver, project: &str) -> Result