diff --git a/crates/oxc_linter/src/fixer/fix.rs b/crates/oxc_linter/src/fixer/fix.rs index b5a108da3318b..6bb2bfa4d63f7 100644 --- a/crates/oxc_linter/src/fixer/fix.rs +++ b/crates/oxc_linter/src/fixer/fix.rs @@ -279,7 +279,7 @@ impl<'a> Deref for RuleFix<'a> { /// A completed, normalized fix ready to be applied to the source code. /// /// Used internally by this module. Lint rules should use [`RuleFix`]. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] #[non_exhaustive] pub struct Fix<'a> { pub content: Cow<'a, str>, @@ -334,7 +334,7 @@ impl<'a> Fix<'a> { } } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] pub enum PossibleFixes<'a> { None, Single(Fix<'a>), @@ -601,12 +601,6 @@ impl<'a> CompositeFix<'a> { mod test { use super::*; - impl PartialEq for Fix<'_> { - fn eq(&self, other: &Self) -> bool { - self.span == other.span && self.content == other.content - } - } - impl Clone for CompositeFix<'_> { fn clone(&self) -> Self { match self { diff --git a/crates/oxc_linter/src/fixer/mod.rs b/crates/oxc_linter/src/fixer/mod.rs index 82f6c1f845a28..aaa07761ef497 100644 --- a/crates/oxc_linter/src/fixer/mod.rs +++ b/crates/oxc_linter/src/fixer/mod.rs @@ -218,7 +218,7 @@ pub struct FixResult<'a> { pub messages: Vec>, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Eq, PartialEq)] pub struct Message<'a> { pub error: OxcDiagnostic, pub fixes: PossibleFixes<'a>, diff --git a/crates/oxc_linter/src/tsgolint.rs b/crates/oxc_linter/src/tsgolint.rs index cc56c93f50518..49e9ad6025c64 100644 --- a/crates/oxc_linter/src/tsgolint.rs +++ b/crates/oxc_linter/src/tsgolint.rs @@ -793,21 +793,6 @@ mod test { tsgolint::{Fix, Range, RuleMessage, Suggestion, TsGoLintDiagnostic}, }; - /// Implements `PartialEq` for `PossibleFixes` to enable equality assertions in tests. - /// In production a `PossibleFix` can not be equal. - impl PartialEq for PossibleFixes<'_> { - fn eq(&self, other: &Self) -> bool { - match (self, other) { - (Self::None, Self::None) => true, - (Self::Single(fix1), Self::Single(fix2)) => fix1 == fix2, - (Self::Multiple(fixes1), Self::Multiple(fixes2)) => { - fixes1.iter().zip(fixes2.iter()).all(|(f1, f2)| f1 == f2) - } - _ => false, - } - } - } - #[test] fn test_message_from_tsgo_lint_diagnostic_basic() { let diagnostic = TsGoLintDiagnostic {