Skip to content

Commit 3a73d7c

Browse files
committed
refactor(linter): derive inmpls for PartialEq, Eq over manual ones
1 parent 3f75bbc commit 3a73d7c

File tree

3 files changed

+3
-24
lines changed

3 files changed

+3
-24
lines changed

crates/oxc_linter/src/fixer/fix.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ impl<'a> Deref for RuleFix<'a> {
279279
/// A completed, normalized fix ready to be applied to the source code.
280280
///
281281
/// Used internally by this module. Lint rules should use [`RuleFix`].
282-
#[derive(Debug, Clone)]
282+
#[derive(Debug, Clone, PartialEq, Eq)]
283283
#[non_exhaustive]
284284
pub struct Fix<'a> {
285285
pub content: Cow<'a, str>,
@@ -334,7 +334,7 @@ impl<'a> Fix<'a> {
334334
}
335335
}
336336

337-
#[derive(Debug, Clone)]
337+
#[derive(Debug, Clone, PartialEq, Eq)]
338338
pub enum PossibleFixes<'a> {
339339
None,
340340
Single(Fix<'a>),
@@ -602,12 +602,6 @@ impl<'a> CompositeFix<'a> {
602602
mod test {
603603
use super::*;
604604

605-
impl PartialEq for Fix<'_> {
606-
fn eq(&self, other: &Self) -> bool {
607-
self.span == other.span && self.content == other.content
608-
}
609-
}
610-
611605
impl Clone for CompositeFix<'_> {
612606
fn clone(&self) -> Self {
613607
match self {

crates/oxc_linter/src/fixer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ pub struct FixResult<'a> {
218218
pub messages: Vec<Message<'a>>,
219219
}
220220

221-
#[derive(Debug, Clone)]
221+
#[derive(Debug, Clone, Eq, PartialEq)]
222222
pub struct Message<'a> {
223223
pub error: OxcDiagnostic,
224224
pub fixes: PossibleFixes<'a>,

crates/oxc_linter/src/tsgolint.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -793,21 +793,6 @@ mod test {
793793
tsgolint::{Fix, Range, RuleMessage, Suggestion, TsGoLintDiagnostic},
794794
};
795795

796-
/// Implements `PartialEq` for `PossibleFixes` to enable equality assertions in tests.
797-
/// In production a `PossibleFix` can not be equal.
798-
impl PartialEq for PossibleFixes<'_> {
799-
fn eq(&self, other: &Self) -> bool {
800-
match (self, other) {
801-
(Self::None, Self::None) => true,
802-
(Self::Single(fix1), Self::Single(fix2)) => fix1 == fix2,
803-
(Self::Multiple(fixes1), Self::Multiple(fixes2)) => {
804-
fixes1.iter().zip(fixes2.iter()).all(|(f1, f2)| f1 == f2)
805-
}
806-
_ => false,
807-
}
808-
}
809-
}
810-
811796
#[test]
812797
fn test_message_from_tsgo_lint_diagnostic_basic() {
813798
let diagnostic = TsGoLintDiagnostic {

0 commit comments

Comments
 (0)