From 0cd7314831676f618160223cc3a2f12b2e2ed8ab Mon Sep 17 00:00:00 2001 From: Matthew Jackson Date: Sat, 9 May 2026 10:00:06 -0700 Subject: [PATCH] 0.18 round 1+2 integration fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two clippy issues surfaced when round 1 polish + round 2 FrameSink migrations both landed on libfreemkv main: - src/halt.rs: clippy::new_without_default fires when a public new() exists without Default. The polish pass dropped the derive thinking it was redundant — clippy disagrees, so add a manual impl that forwards to new(). Doc-comment notes why both exist. - src/disc/read_error.rs:372: pre-existing assert_eq!(.., true) trips clippy::bool_assert_comparison. Pre-0.18 precommits passed because that lint sat outside the gate; the round-2 commits brought enough new clippy surface that it now shows up. Trivial cleanup: assert!(...) instead of assert_eq!. Single contributor: MattJackson. --- src/disc/read_error.rs | 2 +- src/halt.rs | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/disc/read_error.rs b/src/disc/read_error.rs index a700b18..eccb294 100644 --- a/src/disc/read_error.rs +++ b/src/disc/read_error.rs @@ -369,6 +369,6 @@ mod tests { ctx.on_success(); assert_eq!(ctx.consecutive_good, 1); assert_eq!(ctx.consecutive_failures, 0); - assert_eq!(*ctx.damage_window.last().unwrap(), true); + assert!(*ctx.damage_window.last().unwrap()); } } diff --git a/src/halt.rs b/src/halt.rs index 23b5e1f..7000627 100644 --- a/src/halt.rs +++ b/src/halt.rs @@ -20,10 +20,11 @@ use std::sync::atomic::{AtomicBool, Ordering}; /// no `reset()` by design — construct a fresh `Halt` for a fresh /// operation. /// -/// Construct with [`Halt::new`]. We intentionally don't derive -/// `Default` — `Halt::new()` is more discoverable, matches the -/// stdlib `Mutex::new` / `Arc::new` convention, and keeps the -/// uncancelled-by-construction invariant in one named place. +/// Construct with [`Halt::new`] (or [`Halt::default`]). The `Default` +/// impl forwards to `new()` — both produce a fresh, uncancelled token. +/// The pair exists because clippy's `new_without_default` lint requires +/// `Default` whenever a public `new()` is present, even when the two +/// would do exactly the same thing. #[derive(Clone, Debug)] pub struct Halt(Arc); @@ -44,6 +45,12 @@ impl Halt { } } +impl Default for Halt { + fn default() -> Self { + Self::new() + } +} + #[cfg(test)] mod tests { use super::*; @@ -103,5 +110,4 @@ mod tests { handle.join().unwrap(); assert!(h.is_cancelled()); } - }