0.18 round 1+2 integration fixes

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.
This commit is contained in:
2026-05-09 10:00:06 -07:00
parent 8e735c0fbf
commit 0cd7314831
2 changed files with 12 additions and 6 deletions
+1 -1
View File
@@ -369,6 +369,6 @@ mod tests {
ctx.on_success(); ctx.on_success();
assert_eq!(ctx.consecutive_good, 1); assert_eq!(ctx.consecutive_good, 1);
assert_eq!(ctx.consecutive_failures, 0); assert_eq!(ctx.consecutive_failures, 0);
assert_eq!(*ctx.damage_window.last().unwrap(), true); assert!(*ctx.damage_window.last().unwrap());
} }
} }
+11 -5
View File
@@ -20,10 +20,11 @@ use std::sync::atomic::{AtomicBool, Ordering};
/// no `reset()` by design — construct a fresh `Halt` for a fresh /// no `reset()` by design — construct a fresh `Halt` for a fresh
/// operation. /// operation.
/// ///
/// Construct with [`Halt::new`]. We intentionally don't derive /// Construct with [`Halt::new`] (or [`Halt::default`]). The `Default`
/// `Default` — `Halt::new()` is more discoverable, matches the /// impl forwards to `new()` — both produce a fresh, uncancelled token.
/// stdlib `Mutex::new` / `Arc::new` convention, and keeps the /// The pair exists because clippy's `new_without_default` lint requires
/// uncancelled-by-construction invariant in one named place. /// `Default` whenever a public `new()` is present, even when the two
/// would do exactly the same thing.
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct Halt(Arc<AtomicBool>); pub struct Halt(Arc<AtomicBool>);
@@ -44,6 +45,12 @@ impl Halt {
} }
} }
impl Default for Halt {
fn default() -> Self {
Self::new()
}
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
@@ -103,5 +110,4 @@ mod tests {
handle.join().unwrap(); handle.join().unwrap();
assert!(h.is_cancelled()); assert!(h.is_cancelled());
} }
} }