Skip to content

Commit

Permalink
refactor(ast, ast_tools): use full method path for generated derives …
Browse files Browse the repository at this point in the history
…trait calls. (#5462)

As of now if we remove the implementation of a trait for a type and implement the method on that type directly it wouldn't break while it isn't the original trait anymore so that method might do something entirely different.
This change is more explicit on trait calls so we hit compile errors on these kinds of changes.
  • Loading branch information
rzvxa committed Sep 5, 2024
1 parent 90facd3 commit ccc8a27
Show file tree
Hide file tree
Showing 13 changed files with 7,108 additions and 6,158 deletions.
2,900 changes: 1,696 additions & 1,204 deletions crates/oxc_ast/src/generated/derive_clone_in.rs

Large diffs are not rendered by default.

5,313 changes: 2,836 additions & 2,477 deletions crates/oxc_ast/src/generated/derive_content_eq.rs

Large diffs are not rendered by default.

2,020 changes: 1,010 additions & 1,010 deletions crates/oxc_ast/src/generated/derive_content_hash.rs

Large diffs are not rendered by default.

1,198 changes: 599 additions & 599 deletions crates/oxc_ast/src/generated/derive_get_span.rs

Large diffs are not rendered by default.

1,198 changes: 599 additions & 599 deletions crates/oxc_ast/src/generated/derive_get_span_mut.rs

Large diffs are not rendered by default.

182 changes: 102 additions & 80 deletions crates/oxc_regular_expression/src/generated/derive_clone_in.rs

Large diffs are not rendered by default.

222 changes: 119 additions & 103 deletions crates/oxc_regular_expression/src/generated/derive_content_eq.rs
Original file line number Diff line number Diff line change
@@ -1,96 +1,109 @@
// Auto-generated code, DO NOT EDIT DIRECTLY!
// To edit this generated file you have to edit `tasks/ast_tools/src/derives/content_eq.rs`

#![allow(clippy::match_like_matches_macro)]

use oxc_span::cmp::ContentEq;

#[allow(clippy::wildcard_imports)]
use crate::ast::*;

impl<'a> ContentEq for RegularExpression<'a> {
fn content_eq(&self, other: &Self) -> bool {
self.pattern.content_eq(&other.pattern) && self.flags.content_eq(&other.flags)
ContentEq::content_eq(&self.pattern, &other.pattern)
&& ContentEq::content_eq(&self.flags, &other.flags)
}
}

impl ContentEq for Flags {
fn content_eq(&self, other: &Self) -> bool {
self.global.content_eq(&other.global)
&& self.ignore_case.content_eq(&other.ignore_case)
&& self.multiline.content_eq(&other.multiline)
&& self.unicode.content_eq(&other.unicode)
&& self.sticky.content_eq(&other.sticky)
&& self.dot_all.content_eq(&other.dot_all)
&& self.has_indices.content_eq(&other.has_indices)
&& self.unicode_sets.content_eq(&other.unicode_sets)
ContentEq::content_eq(&self.global, &other.global)
&& ContentEq::content_eq(&self.ignore_case, &other.ignore_case)
&& ContentEq::content_eq(&self.multiline, &other.multiline)
&& ContentEq::content_eq(&self.unicode, &other.unicode)
&& ContentEq::content_eq(&self.sticky, &other.sticky)
&& ContentEq::content_eq(&self.dot_all, &other.dot_all)
&& ContentEq::content_eq(&self.has_indices, &other.has_indices)
&& ContentEq::content_eq(&self.unicode_sets, &other.unicode_sets)
}
}

impl<'a> ContentEq for Pattern<'a> {
fn content_eq(&self, other: &Self) -> bool {
self.body.content_eq(&other.body)
ContentEq::content_eq(&self.body, &other.body)
}
}

impl<'a> ContentEq for Disjunction<'a> {
fn content_eq(&self, other: &Self) -> bool {
self.body.content_eq(&other.body)
ContentEq::content_eq(&self.body, &other.body)
}
}

impl<'a> ContentEq for Alternative<'a> {
fn content_eq(&self, other: &Self) -> bool {
self.body.content_eq(&other.body)
ContentEq::content_eq(&self.body, &other.body)
}
}

impl<'a> ContentEq for Term<'a> {
fn content_eq(&self, other: &Self) -> bool {
match self {
Self::BoundaryAssertion(it) => {
matches!(other, Self::BoundaryAssertion(other) if it.content_eq(other))
}
Self::LookAroundAssertion(it) => {
matches!(other, Self::LookAroundAssertion(other) if it.content_eq(other))
}
Self::Quantifier(it) => {
matches!(other, Self::Quantifier(other) if it.content_eq(other))
}
Self::Character(it) => {
matches!(other, Self::Character(other) if it.content_eq(other))
}
Self::Dot(it) => matches!(other, Self::Dot(other) if it.content_eq(other)),
Self::CharacterClassEscape(it) => {
matches!(
other, Self::CharacterClassEscape(other) if it.content_eq(other)
)
}
Self::UnicodePropertyEscape(it) => {
matches!(
other, Self::UnicodePropertyEscape(other) if it.content_eq(other)
)
}
Self::CharacterClass(it) => {
matches!(other, Self::CharacterClass(other) if it.content_eq(other))
}
Self::CapturingGroup(it) => {
matches!(other, Self::CapturingGroup(other) if it.content_eq(other))
}
Self::IgnoreGroup(it) => {
matches!(other, Self::IgnoreGroup(other) if it.content_eq(other))
}
Self::IndexedReference(it) => {
matches!(other, Self::IndexedReference(other) if it.content_eq(other))
}
Self::NamedReference(it) => {
matches!(other, Self::NamedReference(other) if it.content_eq(other))
}
Self::BoundaryAssertion(it) => match other {
Self::BoundaryAssertion(other) if ContentEq::content_eq(it, other) => true,
_ => false,
},
Self::LookAroundAssertion(it) => match other {
Self::LookAroundAssertion(other) if ContentEq::content_eq(it, other) => true,
_ => false,
},
Self::Quantifier(it) => match other {
Self::Quantifier(other) if ContentEq::content_eq(it, other) => true,
_ => false,
},
Self::Character(it) => match other {
Self::Character(other) if ContentEq::content_eq(it, other) => true,
_ => false,
},
Self::Dot(it) => match other {
Self::Dot(other) if ContentEq::content_eq(it, other) => true,
_ => false,
},
Self::CharacterClassEscape(it) => match other {
Self::CharacterClassEscape(other) if ContentEq::content_eq(it, other) => true,
_ => false,
},
Self::UnicodePropertyEscape(it) => match other {
Self::UnicodePropertyEscape(other) if ContentEq::content_eq(it, other) => true,
_ => false,
},
Self::CharacterClass(it) => match other {
Self::CharacterClass(other) if ContentEq::content_eq(it, other) => true,
_ => false,
},
Self::CapturingGroup(it) => match other {
Self::CapturingGroup(other) if ContentEq::content_eq(it, other) => true,
_ => false,
},
Self::IgnoreGroup(it) => match other {
Self::IgnoreGroup(other) if ContentEq::content_eq(it, other) => true,
_ => false,
},
Self::IndexedReference(it) => match other {
Self::IndexedReference(other) if ContentEq::content_eq(it, other) => true,
_ => false,
},
Self::NamedReference(it) => match other {
Self::NamedReference(other) if ContentEq::content_eq(it, other) => true,
_ => false,
},
}
}
}

impl ContentEq for BoundaryAssertion {
fn content_eq(&self, other: &Self) -> bool {
self.kind.content_eq(&other.kind)
ContentEq::content_eq(&self.kind, &other.kind)
}
}

Expand All @@ -102,7 +115,8 @@ impl ContentEq for BoundaryAssertionKind {

impl<'a> ContentEq for LookAroundAssertion<'a> {
fn content_eq(&self, other: &Self) -> bool {
self.kind.content_eq(&other.kind) && self.body.content_eq(&other.body)
ContentEq::content_eq(&self.kind, &other.kind)
&& ContentEq::content_eq(&self.body, &other.body)
}
}

Expand All @@ -114,16 +128,17 @@ impl ContentEq for LookAroundAssertionKind {

impl<'a> ContentEq for Quantifier<'a> {
fn content_eq(&self, other: &Self) -> bool {
self.min.content_eq(&other.min)
&& self.max.content_eq(&other.max)
&& self.greedy.content_eq(&other.greedy)
&& self.body.content_eq(&other.body)
ContentEq::content_eq(&self.min, &other.min)
&& ContentEq::content_eq(&self.max, &other.max)
&& ContentEq::content_eq(&self.greedy, &other.greedy)
&& ContentEq::content_eq(&self.body, &other.body)
}
}

impl ContentEq for Character {
fn content_eq(&self, other: &Self) -> bool {
self.kind.content_eq(&other.kind) && self.value.content_eq(&other.value)
ContentEq::content_eq(&self.kind, &other.kind)
&& ContentEq::content_eq(&self.value, &other.value)
}
}

Expand All @@ -135,7 +150,7 @@ impl ContentEq for CharacterKind {

impl ContentEq for CharacterClassEscape {
fn content_eq(&self, other: &Self) -> bool {
self.kind.content_eq(&other.kind)
ContentEq::content_eq(&self.kind, &other.kind)
}
}

Expand All @@ -147,10 +162,10 @@ impl ContentEq for CharacterClassEscapeKind {

impl<'a> ContentEq for UnicodePropertyEscape<'a> {
fn content_eq(&self, other: &Self) -> bool {
self.negative.content_eq(&other.negative)
&& self.strings.content_eq(&other.strings)
&& self.name.content_eq(&other.name)
&& self.value.content_eq(&other.value)
ContentEq::content_eq(&self.negative, &other.negative)
&& ContentEq::content_eq(&self.strings, &other.strings)
&& ContentEq::content_eq(&self.name, &other.name)
&& ContentEq::content_eq(&self.value, &other.value)
}
}

Expand All @@ -162,9 +177,9 @@ impl ContentEq for Dot {

impl<'a> ContentEq for CharacterClass<'a> {
fn content_eq(&self, other: &Self) -> bool {
self.negative.content_eq(&other.negative)
&& self.kind.content_eq(&other.kind)
&& self.body.content_eq(&other.body)
ContentEq::content_eq(&self.negative, &other.negative)
&& ContentEq::content_eq(&self.kind, &other.kind)
&& ContentEq::content_eq(&self.body, &other.body)
}
}

Expand All @@ -177,84 +192,85 @@ impl ContentEq for CharacterClassContentsKind {
impl<'a> ContentEq for CharacterClassContents<'a> {
fn content_eq(&self, other: &Self) -> bool {
match self {
Self::CharacterClassRange(it) => {
matches!(other, Self::CharacterClassRange(other) if it.content_eq(other))
}
Self::CharacterClassEscape(it) => {
matches!(
other, Self::CharacterClassEscape(other) if it.content_eq(other)
)
}
Self::UnicodePropertyEscape(it) => {
matches!(
other, Self::UnicodePropertyEscape(other) if it.content_eq(other)
)
}
Self::Character(it) => {
matches!(other, Self::Character(other) if it.content_eq(other))
}
Self::NestedCharacterClass(it) => {
matches!(
other, Self::NestedCharacterClass(other) if it.content_eq(other)
)
}
Self::ClassStringDisjunction(it) => {
matches!(
other, Self::ClassStringDisjunction(other) if it.content_eq(other)
)
}
Self::CharacterClassRange(it) => match other {
Self::CharacterClassRange(other) if ContentEq::content_eq(it, other) => true,
_ => false,
},
Self::CharacterClassEscape(it) => match other {
Self::CharacterClassEscape(other) if ContentEq::content_eq(it, other) => true,
_ => false,
},
Self::UnicodePropertyEscape(it) => match other {
Self::UnicodePropertyEscape(other) if ContentEq::content_eq(it, other) => true,
_ => false,
},
Self::Character(it) => match other {
Self::Character(other) if ContentEq::content_eq(it, other) => true,
_ => false,
},
Self::NestedCharacterClass(it) => match other {
Self::NestedCharacterClass(other) if ContentEq::content_eq(it, other) => true,
_ => false,
},
Self::ClassStringDisjunction(it) => match other {
Self::ClassStringDisjunction(other) if ContentEq::content_eq(it, other) => true,
_ => false,
},
}
}
}

impl ContentEq for CharacterClassRange {
fn content_eq(&self, other: &Self) -> bool {
self.min.content_eq(&other.min) && self.max.content_eq(&other.max)
ContentEq::content_eq(&self.min, &other.min) && ContentEq::content_eq(&self.max, &other.max)
}
}

impl<'a> ContentEq for ClassStringDisjunction<'a> {
fn content_eq(&self, other: &Self) -> bool {
self.strings.content_eq(&other.strings) && self.body.content_eq(&other.body)
ContentEq::content_eq(&self.strings, &other.strings)
&& ContentEq::content_eq(&self.body, &other.body)
}
}

impl<'a> ContentEq for ClassString<'a> {
fn content_eq(&self, other: &Self) -> bool {
self.strings.content_eq(&other.strings) && self.body.content_eq(&other.body)
ContentEq::content_eq(&self.strings, &other.strings)
&& ContentEq::content_eq(&self.body, &other.body)
}
}

impl<'a> ContentEq for CapturingGroup<'a> {
fn content_eq(&self, other: &Self) -> bool {
self.name.content_eq(&other.name) && self.body.content_eq(&other.body)
ContentEq::content_eq(&self.name, &other.name)
&& ContentEq::content_eq(&self.body, &other.body)
}
}

impl<'a> ContentEq for IgnoreGroup<'a> {
fn content_eq(&self, other: &Self) -> bool {
self.enabling_modifiers.content_eq(&other.enabling_modifiers)
&& self.disabling_modifiers.content_eq(&other.disabling_modifiers)
&& self.body.content_eq(&other.body)
ContentEq::content_eq(&self.enabling_modifiers, &other.enabling_modifiers)
&& ContentEq::content_eq(&self.disabling_modifiers, &other.disabling_modifiers)
&& ContentEq::content_eq(&self.body, &other.body)
}
}

impl ContentEq for ModifierFlags {
fn content_eq(&self, other: &Self) -> bool {
self.ignore_case.content_eq(&other.ignore_case)
&& self.sticky.content_eq(&other.sticky)
&& self.multiline.content_eq(&other.multiline)
ContentEq::content_eq(&self.ignore_case, &other.ignore_case)
&& ContentEq::content_eq(&self.sticky, &other.sticky)
&& ContentEq::content_eq(&self.multiline, &other.multiline)
}
}

impl ContentEq for IndexedReference {
fn content_eq(&self, other: &Self) -> bool {
self.index.content_eq(&other.index)
ContentEq::content_eq(&self.index, &other.index)
}
}

impl<'a> ContentEq for NamedReference<'a> {
fn content_eq(&self, other: &Self) -> bool {
self.name.content_eq(&other.name)
ContentEq::content_eq(&self.name, &other.name)
}
}
Loading

0 comments on commit ccc8a27

Please sign in to comment.