diff --git a/crates/oxc_ast_macros/src/lib.rs b/crates/oxc_ast_macros/src/lib.rs index c4ecedf948617..44d5c46385f2b 100644 --- a/crates/oxc_ast_macros/src/lib.rs +++ b/crates/oxc_ast_macros/src/lib.rs @@ -58,7 +58,7 @@ fn assert_generated_derives(attrs: &[syn::Attribute]) -> TokenStream2 { } else if ident == "GetSpanMut" { (quote!(::oxc_span::GetSpanMut), TokenStream2::default()) } else if ident == "ContentEq" { - (quote!(::oxc_span::cmp::ContentEq), quote!(<()>)) + (quote!(::oxc_span::cmp::ContentEq), TokenStream2::default()) } else if ident == "ContentHash" { (quote!(::oxc_span::hash::ContentHash), TokenStream2::default()) } else { diff --git a/crates/oxc_span/src/atom.rs b/crates/oxc_span/src/atom.rs index 03152bed92fdb..8a0541d9613cf 100644 --- a/crates/oxc_span/src/atom.rs +++ b/crates/oxc_span/src/atom.rs @@ -180,30 +180,6 @@ impl<'a> ContentEq for Atom<'a> { } } -impl<'a> ContentEq> for &str { - fn content_eq(&self, other: &Atom<'a>) -> bool { - self == other - } -} - -impl<'a> ContentEq for Atom<'a> { - fn content_eq(&self, other: &str) -> bool { - self == other - } -} - -impl<'a> ContentEq> for Cow<'_, str> { - fn content_eq(&self, other: &Atom<'a>) -> bool { - self == other - } -} - -impl<'a> ContentEq<&Atom<'a>> for Cow<'_, str> { - fn content_eq(&self, other: &&Atom<'a>) -> bool { - self == other - } -} - impl<'a> ContentHash for Atom<'a> { fn content_hash(&self, state: &mut H) { hash::Hash::hash(self, state); diff --git a/crates/oxc_span/src/cmp.rs b/crates/oxc_span/src/cmp.rs index 23a327854b350..acf08893ed76f 100644 --- a/crates/oxc_span/src/cmp.rs +++ b/crates/oxc_span/src/cmp.rs @@ -5,17 +5,17 @@ /// /// One should always prefer using the [PartialEq] over this since implementations of this trait /// inherently are slower or in the best-case scenario as fast as the [PartialEq] comparison. -pub trait ContentEq { +pub trait ContentEq { /// This method tests for contents of `self` and `other` to be equal. #[must_use] - fn content_eq(&self, other: &Rhs) -> bool; + fn content_eq(&self, other: &Self) -> bool; /// This method tests for contents of `self` and `other` not to be equal. /// The default implementation is almost always /// sufficient, and should not be overridden without very good reason. #[inline] #[must_use] - fn content_ne(&self, other: &Rhs) -> bool { + fn content_ne(&self, other: &Self) -> bool { !self.content_eq(other) } } @@ -32,66 +32,6 @@ impl ContentEq for () { } } -/// Blanket implementation for references -impl ContentEq<&B> for &A -where - A: ContentEq, -{ - #[inline] - fn content_eq(&self, other: &&B) -> bool { - ContentEq::content_eq(*self, *other) - } - #[inline] - fn content_ne(&self, other: &&B) -> bool { - ContentEq::content_ne(*self, *other) - } -} - -/// Blanket implementation for mutable references -impl ContentEq<&mut B> for &mut A -where - A: ContentEq, -{ - #[inline] - fn content_eq(&self, other: &&mut B) -> bool { - ContentEq::content_eq(*self, *other) - } - #[inline] - fn content_ne(&self, other: &&mut B) -> bool { - ContentEq::content_ne(*self, *other) - } -} - -/// Blanket implementation for mixed references -impl ContentEq<&mut B> for &A -where - A: ContentEq, -{ - #[inline] - fn content_eq(&self, other: &&mut B) -> bool { - ContentEq::content_eq(*self, *other) - } - #[inline] - fn content_ne(&self, other: &&mut B) -> bool { - ContentEq::content_ne(*self, *other) - } -} - -/// Blanket implementation for mixed references -impl ContentEq<&B> for &mut A -where - A: ContentEq, -{ - #[inline] - fn content_eq(&self, other: &&B) -> bool { - ContentEq::content_eq(*self, *other) - } - #[inline] - fn content_ne(&self, other: &&B) -> bool { - ContentEq::content_ne(*self, *other) - } -} - /// Blanket implementation for [Option] types impl ContentEq for Option { #[inline]