From 2ca3105322f30b5b378166db3113fb22dce68667 Mon Sep 17 00:00:00 2001 From: Eureka Date: Tue, 17 Nov 2026 01:58:12 +0000 Subject: [PATCH] Clear all clippy -D warnings errors in huginn-mind (#69) --- crates/huginn-mind/src/desk.rs | 2 +- crates/huginn-mind/src/desk_wire.rs | 2 +- crates/huginn-mind/src/import.rs | 4 ++-- crates/huginn-mind/src/move_tests.rs | 1 - crates/huginn-mind/src/redact.rs | 7 +++++-- crates/huginn-mind/tests/desk_feed_fixtures.rs | 6 +----- 6 files changed, 10 insertions(+), 12 deletions(-) diff --git a/crates/huginn-mind/src/desk.rs b/crates/huginn-mind/src/desk.rs index 89d8e01..9c41d37 100644 --- a/crates/huginn-mind/src/desk.rs +++ b/crates/huginn-mind/src/desk.rs @@ -1468,7 +1468,7 @@ mod tests { let before = head(&mind); let id = request.request_id.clone(); let (answer, outcome) = stored(ask(&mut mind, &decider("y"), request.clone())); - assert_eq!(outcome, DeskOutcome::Refused { code: DeskRefusal::BadRetraction, retracts: sent.2.map(|target| s(target)) }, "{what}"); + assert_eq!(outcome, DeskOutcome::Refused { code: DeskRefusal::BadRetraction, retracts: sent.2.map(s) }, "{what}"); assert_eq!(head(&mind), before + 1, "{what} is stored"); // The record keeps what was sent: the choice, the note and the target it named. let record = held(&mind, &answer); diff --git a/crates/huginn-mind/src/desk_wire.rs b/crates/huginn-mind/src/desk_wire.rs index 3699f4a..67c29d3 100644 --- a/crates/huginn-mind/src/desk_wire.rs +++ b/crates/huginn-mind/src/desk_wire.rs @@ -569,7 +569,7 @@ impl Mind { let Some(PipelineDocument::DeskAnswer(stored)) = docs.find(PipelineKind::DeskAnswer, &key) else { return Err(unreadable_key()) }; let fork = stored.fork.0.as_str(); let counted_answer_id = counted_answer(&docs, fork).map(|counted| answer_seq(fork, &counted).map(n_text).ok_or_else(unreadable_key)).transpose()?; - Ok((DeskResponse::Answered { answer: project(&key, stored)?, counted_answer_id, as_of: image.head })) + Ok(DeskResponse::Answered { answer: project(&key, stored)?, counted_answer_id, as_of: image.head }) } } diff --git a/crates/huginn-mind/src/import.rs b/crates/huginn-mind/src/import.rs index e689154..c1e68e2 100644 --- a/crates/huginn-mind/src/import.rs +++ b/crates/huginn-mind/src/import.rs @@ -150,7 +150,7 @@ mod tests { fn view(document: PipelineDocument, ordinal: u64) -> PipelineDocumentView { let key = pipeline_key(&document).unwrap(); let id = PipelineRef { kind: document.kind(), id: s(&key) }; - let faculty = if ordinal % 2 == 0 { Faculty::Hands } else { Faculty::Soul }; + let faculty = if ordinal.is_multiple_of(2) { Faculty::Hands } else { Faculty::Soul }; let admission = AdmissionFacts { receipt_id: format!("receipt-{ordinal}"), admitted_at: format!("2026-11-08T16:{ordinal:02}:00Z"), @@ -226,7 +226,7 @@ mod tests { let to_source = [held.clone(), vec![moved(RECEIVER, 4)]].concat(); assert_eq!(plan(&slug(CAMPAIGN), &slug(RECEIVER), &slug(RECEIVER), to_source), Err(ImportFault::SourceIsReceiver)); let other_root = view( - resolution(r(K::Campaign, &format!("elsewhere:campaign:self")), ResolutionOutcome::Moved { to: slug(RECEIVER) }), + resolution(r(K::Campaign, "elsewhere:campaign:self"), ResolutionOutcome::Moved { to: slug(RECEIVER) }), 4, ); assert_eq!(plan_of([held, vec![other_root]].concat()), Err(ImportFault::NotMoved), "another root's move does not move this one"); diff --git a/crates/huginn-mind/src/move_tests.rs b/crates/huginn-mind/src/move_tests.rs index bc77204..84298b4 100644 --- a/crates/huginn-mind/src/move_tests.rs +++ b/crates/huginn-mind/src/move_tests.rs @@ -663,7 +663,6 @@ fn an_import_never_cites_or_resolves_a_follow_up_the_receiver_wrote() { let native = follow_up("FU-N", r(K::Question, &q1)); let native_ref = r(K::FollowUp, &pipeline_key(&native).unwrap()); committed(admit(&mut recv, vec![native])); - let before = head(&recv); // An imported record that withdraws the receiver's own follow-up mixes a replay into her work. assert_eq!( refusal(import_from_kiko(&mut recv, vec![resolution(native_ref.clone(), ResolutionOutcome::Withdrawn { reason: "x".into() })])), diff --git a/crates/huginn-mind/src/redact.rs b/crates/huginn-mind/src/redact.rs index 23ccf57..1345665 100644 --- a/crates/huginn-mind/src/redact.rs +++ b/crates/huginn-mind/src/redact.rs @@ -159,7 +159,7 @@ fn zero_width(c: char) -> bool { pub fn scrub(text: &str) -> Scrubbed { let mut hits = Vec::new(); let mut stripped: String = text.chars().filter(|c| !zero_width(*c)).collect(); - let passes: [(ScrubKind, fn(&str, usize) -> Option); 6] = [ + let passes: [(ScrubKind, Finder); 6] = [ (ScrubKind::PemBlock, pem_block), (ScrubKind::AuthorizationHeader, authorization_line), (ScrubKind::AccessToken, access_token), @@ -176,7 +176,10 @@ pub fn scrub(text: &str) -> Scrubbed { if hits.is_empty() { Scrubbed { text: text.to_owned(), hits } } else { Scrubbed { text: urls, hits } } } -fn replace_matches(text: &str, kind: ScrubKind, find: fn(&str, usize) -> Option, hits: &mut Vec) -> String { +/// A scrub pass: finds the end of one secret starting at a byte offset, if one starts there. +type Finder = fn(&str, usize) -> Option; + +fn replace_matches(text: &str, kind: ScrubKind, find: Finder, hits: &mut Vec) -> String { let mut out = String::with_capacity(text.len()); let mut at = 0; while at < text.len() { diff --git a/crates/huginn-mind/tests/desk_feed_fixtures.rs b/crates/huginn-mind/tests/desk_feed_fixtures.rs index 375e6dd..3bc922e 100644 --- a/crates/huginn-mind/tests/desk_feed_fixtures.rs +++ b/crates/huginn-mind/tests/desk_feed_fixtures.rs @@ -22,7 +22,7 @@ use huginn_mind::desk_wire::{ ForkList, ForkOption, ForkRecord, ForkRefusal, ForkRefusalCode, ForkRef, ListSchema, ListStatus, RecordSchema, }; use huginn_mind::envelope::{OperationFailure, decode_desk_request, encode_desk_failure, encode_desk_request, encode_desk_response}; -use huginn_mind::eureka_pipeline::{AccountId, DeskAuthority, Short, Slug}; +use huginn_mind::eureka_pipeline::{AccountId, DeskAuthority, Slug}; const RUNTIME: &str = "huginn-eureka"; /// Account ids as Bifrost sends them: `UserAccount.Id` rendered lowercase D-format @@ -38,10 +38,6 @@ const NON_DECIDER: &str = "9e8d7c6b-5a49-4382-b1a0-f9e8d7c6b5a4"; /// synthetic: the hash is CultLib's sample digest, not this question's. const FORK: &str = "eureka-substrate:question:desk-listing-authority"; -fn s(text: &str) -> Short { - Short(text.into()) -} - fn a(text: &str) -> AccountId { AccountId(text.into()) }