fix(clippy): Rust 1.95 compatibility — sort_by_key + collapsible_match

CI runs on stable Rust which advanced from 1.93 to 1.95, introducing
two newly-enforced lints under -D warnings:

- clippy::unnecessary_sort_by (12 sites) — rewrite sort_by closures
  that only call .cmp on Copy keys as sort_by_key, using std::cmp::Reverse
  for the descending ones.
- clippy::collapsible_match (1 site) — merge the MemoryState::Dormant
  inner if into a match guard. The equivalent rewrite for the Ping/Pong
  arm in websocket.rs is blocked by a move of non-Copy Bytes across the
  match-guard boundary, so that one site gets an explicit #[allow].

Files touched:
- crates/vestige-core/src/advanced/{chains,compression,cross_project,reconsolidation}.rs
- crates/vestige-core/src/codebase/{git,relationships}.rs
- crates/vestige-core/src/neuroscience/{importance_signals,memory_states,predictive_retrieval}.rs
- crates/vestige-mcp/src/tools/{changelog,cross_reference}.rs
- crates/vestige-mcp/src/dashboard/websocket.rs

Verified: cargo clippy --workspace -- -D warnings green on rustc 1.95.0;
cargo test --workspace unchanged (1292 tests green).
This commit is contained in:
Sam Valladares 2026-04-19 21:11:49 -05:00
parent 4c2016596c
commit 318d4db147
12 changed files with 21 additions and 20 deletions

View file

@ -123,6 +123,9 @@ async fn handle_socket(socket: WebSocket, state: AppState) {
msg = receiver.next() => {
match msg {
Some(Ok(Message::Close(_))) | None => break,
// Match guards can't move out of the bound `data` (Bytes is
// not Copy), so the nested `if` is required here.
#[allow(clippy::collapsible_match, clippy::collapsible_if)]
Some(Ok(Message::Ping(data))) => {
if sender.send(Message::Pong(data)).await.is_err() {
break;

View file

@ -237,7 +237,7 @@ fn execute_system_wide(
}
// Sort by timestamp descending
events.sort_by(|a, b| b.0.cmp(&a.0));
events.sort_by_key(|b| std::cmp::Reverse(b.0));
// Truncate to limit
events.truncate(limit as usize);

View file

@ -560,7 +560,7 @@ pub async fn execute(
// Sort by date descending for supersession
let mut by_date = scored.iter().collect::<Vec<_>>();
by_date.sort_by(|a, b| b.updated_at.cmp(&a.updated_at));
by_date.sort_by_key(|b| std::cmp::Reverse(b.updated_at));
for i in 0..by_date.len() {
for j in (i + 1)..by_date.len() {