diff --git a/crates/rustfix/src/replace.rs b/crates/rustfix/src/replace.rs index 202aa6524..4cdc7c01f 100644 --- a/crates/rustfix/src/replace.rs +++ b/crates/rustfix/src/replace.rs @@ -24,7 +24,7 @@ impl State { } /// Span with a change [`State`]. -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Clone, PartialEq, Eq)] struct Span { /// Start of this span in parent data start: usize, @@ -34,6 +34,17 @@ struct Span { data: State, } +impl std::fmt::Debug for Span { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let state = match self.data { + State::Initial => "initial", + State::Replaced(_) => "replaced", + State::Inserted(_) => "inserted", + }; + write!(f, "({}, {}: {state})", self.start, self.end) + } +} + /// A container that allows easily replacing chunks of its data #[derive(Debug, Clone, Default)] pub struct Data { @@ -102,30 +113,12 @@ impl Data { .iter() .position(|p| !p.data.is_inserted() && p.start <= range.start && p.end >= range.end) else { - if tracing::enabled!(tracing::Level::DEBUG) { - let slices = self - .parts - .iter() - .map(|p| { - ( - p.start, - p.end, - match p.data { - State::Initial => "initial", - State::Replaced(..) => "replaced", - State::Inserted(..) => "inserted", - }, - ) - }) - .collect::>(); - tracing::debug!( - "no single slice covering {}..{}, current slices: {:?}", - range.start, - range.end, - slices, - ); - } - + tracing::debug!( + "no single slice covering {}..{}, current slices: {:?}", + range.start, + range.end, + self.parts, + ); return Err(Error::MaybeAlreadyReplaced(range)); };