diff --git a/crates/oxc_ast/src/ast/comment.rs b/crates/oxc_ast/src/ast/comment.rs index 8e1a33cf101a7..0a4e142dc2ede 100644 --- a/crates/oxc_ast/src/ast/comment.rs +++ b/crates/oxc_ast/src/ast/comment.rs @@ -1,11 +1,11 @@ #![warn(missing_docs)] use oxc_allocator::CloneIn; use oxc_ast_macros::ast; -use oxc_span::{cmp::ContentEq, hash::ContentHash, Span}; +use oxc_span::{cmp::ContentEq, Span}; /// Indicates a line or block comment. #[ast] -#[generate_derive(CloneIn, ContentEq, ContentHash)] +#[generate_derive(CloneIn, ContentEq)] #[derive(Debug, Default, Clone, Copy, Eq, PartialEq)] pub enum CommentKind { /// Line comment @@ -17,7 +17,7 @@ pub enum CommentKind { /// Information about a comment's position relative to a token. #[ast] -#[generate_derive(CloneIn, ContentEq, ContentHash)] +#[generate_derive(CloneIn, ContentEq)] #[derive(Debug, Default, Clone, Copy, Eq, PartialEq)] pub enum CommentPosition { /// Comments prior to a token until another token or trailing comment. @@ -40,7 +40,7 @@ pub enum CommentPosition { /// A comment in source code. #[ast] -#[generate_derive(CloneIn, ContentEq, ContentHash)] +#[generate_derive(CloneIn, ContentEq)] #[derive(Debug, Default, Clone, Copy, Eq, PartialEq)] pub struct Comment { /// The span of the comment text, with leading and trailing delimiters. diff --git a/crates/oxc_ast/src/ast/js.rs b/crates/oxc_ast/src/ast/js.rs index fe0c5e21b8767..1ed5f93e46e86 100644 --- a/crates/oxc_ast/src/ast/js.rs +++ b/crates/oxc_ast/src/ast/js.rs @@ -9,7 +9,7 @@ use std::cell::Cell; use oxc_allocator::{Box, CloneIn, GetAddress, Vec}; use oxc_ast_macros::ast; use oxc_estree::ESTree; -use oxc_span::{cmp::ContentEq, hash::ContentHash, Atom, GetSpan, GetSpanMut, SourceType, Span}; +use oxc_span::{cmp::ContentEq, Atom, GetSpan, GetSpanMut, SourceType, Span}; use oxc_syntax::{ operator::{ AssignmentOperator, BinaryOperator, LogicalOperator, UnaryOperator, UpdateOperator, @@ -28,7 +28,7 @@ use super::{macros::inherit_variants, *}; strict_if(self.source_type.is_strict() || self.has_use_strict_directive()), )] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct Program<'a> { pub span: Span, pub source_type: SourceType, @@ -53,7 +53,7 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum Expression<'a> { /// See [`BooleanLiteral`] for AST node details. BooleanLiteral(Box<'a, BooleanLiteral>) = 0, @@ -201,7 +201,7 @@ pub use match_expression; /// Fundamental syntactic structure used for naming variables, functions, and properties. It must start with a Unicode letter (including $ and _) and can be followed by Unicode letters, digits, $, or _. #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(type = "Identifier")] pub struct IdentifierName<'a> { pub span: Span, @@ -215,7 +215,7 @@ pub struct IdentifierName<'a> { /// See: [13.1 Identifiers](https://tc39.es/ecma262/#sec-identifiers) #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(type = "Identifier")] pub struct IdentifierReference<'a> { pub span: Span, @@ -238,7 +238,7 @@ pub struct IdentifierReference<'a> { /// See: [13.1 Identifiers](https://tc39.es/ecma262/#sec-identifiers) #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(type = "Identifier")] pub struct BindingIdentifier<'a> { pub span: Span, @@ -262,7 +262,7 @@ pub struct BindingIdentifier<'a> { /// See: [13.1 Identifiers](https://tc39.es/ecma262/#sec-identifiers) #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(type = "Identifier")] pub struct LabelIdentifier<'a> { pub span: Span, @@ -274,7 +274,7 @@ pub struct LabelIdentifier<'a> { /// Represents a `this` expression, which is a reference to the current object. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ThisExpression { pub span: Span, } @@ -284,7 +284,7 @@ pub struct ThisExpression { /// Represents an array literal, which can include elements, spread elements, or null values. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ArrayExpression<'a> { pub span: Span, #[estree(type = "Array")] @@ -303,7 +303,7 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(custom_ts_def)] pub enum ArrayExpressionElement<'a> { /// `...[3, 4]` in `const array = [1, 2, ...[3, 4], null];` @@ -324,7 +324,7 @@ pub enum ArrayExpressionElement<'a> { /// Serialized as `null` in JSON AST. See `serialize.rs`. #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq)] pub struct Elision { pub span: Span, } @@ -334,7 +334,7 @@ pub struct Elision { /// Represents an object literal, which can include properties, spread properties, or computed properties and trailing comma. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ObjectExpression<'a> { pub span: Span, /// Properties declared in the object @@ -346,7 +346,7 @@ pub struct ObjectExpression<'a> { /// Represents a property in an object literal. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum ObjectPropertyKind<'a> { /// `a: 1` in `const obj = { a: 1 };` ObjectProperty(Box<'a, ObjectProperty<'a>>) = 0, @@ -359,7 +359,7 @@ pub enum ObjectPropertyKind<'a> { /// Represents a property in an object literal. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ObjectProperty<'a> { pub span: Span, pub kind: PropertyKind, @@ -378,7 +378,7 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum PropertyKey<'a> { /// `a` in `const obj = { a: 1 }; obj.a;` StaticIdentifier(Box<'a, IdentifierName<'a>>) = 64, @@ -392,7 +392,7 @@ pub enum PropertyKey<'a> { /// Represents the kind of property in an object literal or class. #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub enum PropertyKind { /// `a: 1` in `const obj = { a: 1 };` Init = 0, @@ -407,7 +407,7 @@ pub enum PropertyKind { /// Represents a template literal, which can include quasi elements and expression elements. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TemplateLiteral<'a> { pub span: Span, pub quasis: Vec<'a, TemplateElement<'a>>, @@ -419,7 +419,7 @@ pub struct TemplateLiteral<'a> { /// Represents a tagged template expression, which can include a tag and a quasi. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TaggedTemplateExpression<'a> { pub span: Span, pub tag: Expression<'a>, @@ -433,7 +433,7 @@ pub struct TaggedTemplateExpression<'a> { /// Represents a quasi element in a template literal. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TemplateElement<'a> { pub span: Span, pub tail: bool, @@ -443,7 +443,7 @@ pub struct TemplateElement<'a> { /// See [template-strings-cooked-vs-raw](https://exploringjs.com/js/book/ch_template-literals.html#template-strings-cooked-vs-raw) #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] #[estree(no_type)] pub struct TemplateElementValue<'a> { /// A raw interpretation where backslashes do not have special meaning. @@ -462,7 +462,7 @@ pub struct TemplateElementValue<'a> { /// #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum MemberExpression<'a> { /// `ar[0]` in `const ar = [1, 2]; ar[0];` ComputedMemberExpression(Box<'a, ComputedMemberExpression<'a>>) = 48, @@ -488,7 +488,7 @@ pub use match_member_expression; /// Represents a computed member access expression, which can include an object and an expression. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ComputedMemberExpression<'a> { pub span: Span, pub object: Expression<'a>, @@ -501,7 +501,7 @@ pub struct ComputedMemberExpression<'a> { /// Represents a static member access expression, which can include an object and a property. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct StaticMemberExpression<'a> { pub span: Span, pub object: Expression<'a>, @@ -514,7 +514,7 @@ pub struct StaticMemberExpression<'a> { /// Represents a private field access expression, which can include an object and a private identifier. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct PrivateFieldExpression<'a> { pub span: Span, pub object: Expression<'a>, @@ -540,7 +540,7 @@ pub struct PrivateFieldExpression<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct CallExpression<'a> { pub span: Span, pub callee: Expression<'a>, @@ -564,7 +564,7 @@ pub struct CallExpression<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct NewExpression<'a> { pub span: Span, pub callee: Expression<'a>, @@ -578,7 +578,7 @@ pub struct NewExpression<'a> { /// Represents a meta property. The following syntaxes are supported. `import.meta`, `new.target`. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct MetaProperty<'a> { pub span: Span, pub meta: IdentifierName<'a>, @@ -590,7 +590,7 @@ pub struct MetaProperty<'a> { /// Represents a spread element, which can include an argument. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct SpreadElement<'a> { pub span: Span, /// The expression being spread. @@ -605,7 +605,7 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum Argument<'a> { /// `...[1, 2]` in `const arr = [...[1, 2]];` SpreadElement(Box<'a, SpreadElement<'a>>) = 64, @@ -619,7 +619,7 @@ pub enum Argument<'a> { /// Represents an update expression, which can include an operator and an argument. The following syntaxes are supported. `++a`, `a++`, `--a`, `a--` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct UpdateExpression<'a> { pub span: Span, pub operator: UpdateOperator, @@ -632,7 +632,7 @@ pub struct UpdateExpression<'a> { /// Represents a unary expression, which can include an operator and an argument. The following syntaxes are supported. `+a`, `-a`, `~a`, `!a`, `delete a`, `void a`, `typeof a` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct UnaryExpression<'a> { pub span: Span, pub operator: UnaryOperator, @@ -644,7 +644,7 @@ pub struct UnaryExpression<'a> { /// Represents a binary expression, which can include a left expression, an operator, and a right expression. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct BinaryExpression<'a> { pub span: Span, pub left: Expression<'a>, @@ -657,7 +657,7 @@ pub struct BinaryExpression<'a> { /// Represents a private in expression, which can include a private identifier, an operator, and a expression. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct PrivateInExpression<'a> { pub span: Span, pub left: PrivateIdentifier<'a>, @@ -670,7 +670,7 @@ pub struct PrivateInExpression<'a> { /// Represents a logical expression, which can include a left expression, an operator, and a right expression. The following syntaxes are supported. `||`, `&&` and `??` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct LogicalExpression<'a> { pub span: Span, pub left: Expression<'a>, @@ -683,7 +683,7 @@ pub struct LogicalExpression<'a> { /// Represents a conditional expression, which can include a test, a consequent, and an alternate. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ConditionalExpression<'a> { pub span: Span, pub test: Expression<'a>, @@ -696,7 +696,7 @@ pub struct ConditionalExpression<'a> { /// Represents an assignment expression, which can include an operator, a target, and a expression. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct AssignmentExpression<'a> { pub span: Span, pub operator: AssignmentOperator, @@ -713,7 +713,7 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum AssignmentTarget<'a> { // `SimpleAssignmentTarget` variants added here by `inherit_variants!` macro @inherit SimpleAssignmentTarget @@ -730,7 +730,7 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum SimpleAssignmentTarget<'a> { AssignmentTargetIdentifier(Box<'a, IdentifierReference<'a>>) = 0, TSAsExpression(Box<'a, TSAsExpression<'a>>) = 1, @@ -783,7 +783,7 @@ pub use match_simple_assignment_target; #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum AssignmentTargetPattern<'a> { ArrayAssignmentTarget(Box<'a, ArrayAssignmentTarget<'a>>) = 8, ObjectAssignmentTarget(Box<'a, ObjectAssignmentTarget<'a>>) = 9, @@ -803,7 +803,7 @@ pub use match_assignment_target_pattern; /// Represents an array assignment target, which can include elements and a rest element. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ArrayAssignmentTarget<'a> { pub span: Span, pub elements: Vec<'a, Option>>, @@ -818,7 +818,7 @@ pub struct ArrayAssignmentTarget<'a> { /// Represents an object assignment target, which can include properties and a rest element. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ObjectAssignmentTarget<'a> { pub span: Span, pub properties: Vec<'a, AssignmentTargetProperty<'a>>, @@ -831,7 +831,7 @@ pub struct ObjectAssignmentTarget<'a> { /// Represents a rest element in an array assignment target, which can include a target. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(type = "RestElement")] pub struct AssignmentTargetRest<'a> { pub span: Span, @@ -847,7 +847,7 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum AssignmentTargetMaybeDefault<'a> { AssignmentTargetWithDefault(Box<'a, AssignmentTargetWithDefault<'a>>) = 16, // `AssignmentTarget` variants added here by `inherit_variants!` macro @@ -857,7 +857,7 @@ pub enum AssignmentTargetMaybeDefault<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct AssignmentTargetWithDefault<'a> { pub span: Span, pub binding: AssignmentTarget<'a>, @@ -866,7 +866,7 @@ pub struct AssignmentTargetWithDefault<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum AssignmentTargetProperty<'a> { AssignmentTargetPropertyIdentifier(Box<'a, AssignmentTargetPropertyIdentifier<'a>>) = 0, AssignmentTargetPropertyProperty(Box<'a, AssignmentTargetPropertyProperty<'a>>) = 1, @@ -877,7 +877,7 @@ pub enum AssignmentTargetProperty<'a> { /// Represents an assignment target property identifier, which can include a binding and an init expression. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct AssignmentTargetPropertyIdentifier<'a> { pub span: Span, pub binding: IdentifierReference<'a>, @@ -889,7 +889,7 @@ pub struct AssignmentTargetPropertyIdentifier<'a> { /// Represents an assignment target property property, which can include a name and a binding. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct AssignmentTargetPropertyProperty<'a> { pub span: Span, pub name: PropertyKey<'a>, @@ -903,7 +903,7 @@ pub struct AssignmentTargetPropertyProperty<'a> { /// Represents a sequence expression, which can include expressions. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct SequenceExpression<'a> { pub span: Span, pub expressions: Vec<'a, Expression<'a>>, @@ -914,7 +914,7 @@ pub struct SequenceExpression<'a> { /// Represents a super expression. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct Super { pub span: Span, } @@ -924,7 +924,7 @@ pub struct Super { /// Represents an await expression, which can include an argument. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct AwaitExpression<'a> { pub span: Span, pub argument: Expression<'a>, @@ -935,7 +935,7 @@ pub struct AwaitExpression<'a> { /// Represents a chain expression, which can include an expression. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ChainExpression<'a> { pub span: Span, pub expression: ChainElement<'a>, @@ -949,7 +949,7 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum ChainElement<'a> { CallExpression(Box<'a, CallExpression<'a>>) = 0, /// `foo?.baz!` or `foo?.[bar]!` @@ -964,7 +964,7 @@ pub enum ChainElement<'a> { /// Represents a parenthesized expression, which can include an expression. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ParenthesizedExpression<'a> { pub span: Span, pub expression: Expression<'a>, @@ -979,7 +979,7 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum Statement<'a> { // Statements BlockStatement(Box<'a, BlockStatement<'a>>) = 0, @@ -1012,7 +1012,7 @@ pub enum Statement<'a> { /// Represents a directive statement, which can include a string literal. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct Directive<'a> { pub span: Span, /// Directive with any escapes unescaped @@ -1026,7 +1026,7 @@ pub struct Directive<'a> { /// Represents a hashbang directive, which can include a value. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct Hashbang<'a> { pub span: Span, pub value: Atom<'a>, @@ -1038,7 +1038,7 @@ pub struct Hashbang<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct BlockStatement<'a> { pub span: Span, pub body: Vec<'a, Statement<'a>>, @@ -1050,7 +1050,7 @@ pub struct BlockStatement<'a> { /// Declarations and the Variable Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum Declaration<'a> { VariableDeclaration(Box<'a, VariableDeclaration<'a>>) = 32, #[visit(args(flags = ScopeFlags::Function))] @@ -1085,7 +1085,7 @@ pub use match_declaration; /// Represents a variable declaration, which can include a kind, declarations, and modifiers. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct VariableDeclaration<'a> { pub span: Span, pub kind: VariableDeclarationKind, @@ -1096,7 +1096,7 @@ pub struct VariableDeclaration<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub enum VariableDeclarationKind { Var = 0, Const = 1, @@ -1116,7 +1116,7 @@ pub enum VariableDeclarationKind { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct VariableDeclarator<'a> { pub span: Span, #[estree(skip)] @@ -1130,7 +1130,7 @@ pub struct VariableDeclarator<'a> { /// Empty Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct EmptyStatement { pub span: Span, } @@ -1138,7 +1138,7 @@ pub struct EmptyStatement { /// Expression Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ExpressionStatement<'a> { pub span: Span, pub expression: Expression<'a>, @@ -1147,7 +1147,7 @@ pub struct ExpressionStatement<'a> { /// If Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct IfStatement<'a> { pub span: Span, pub test: Expression<'a>, @@ -1158,7 +1158,7 @@ pub struct IfStatement<'a> { /// Do-While Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct DoWhileStatement<'a> { pub span: Span, pub body: Statement<'a>, @@ -1168,7 +1168,7 @@ pub struct DoWhileStatement<'a> { /// While Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct WhileStatement<'a> { pub span: Span, pub test: Expression<'a>, @@ -1179,7 +1179,7 @@ pub struct WhileStatement<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ForStatement<'a> { pub span: Span, pub init: Option>, @@ -1199,7 +1199,7 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum ForStatementInit<'a> { VariableDeclaration(Box<'a, VariableDeclaration<'a>>) = 64, // `Expression` variants added here by `inherit_variants!` macro @@ -1211,7 +1211,7 @@ pub enum ForStatementInit<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ForInStatement<'a> { pub span: Span, pub left: ForStatementLeft<'a>, @@ -1230,7 +1230,7 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum ForStatementLeft<'a> { VariableDeclaration(Box<'a, VariableDeclaration<'a>>) = 16, // `AssignmentTarget` variants added here by `inherit_variants!` macro @@ -1241,7 +1241,7 @@ pub enum ForStatementLeft<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ForOfStatement<'a> { pub span: Span, pub r#await: bool, @@ -1256,7 +1256,7 @@ pub struct ForOfStatement<'a> { /// Continue Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ContinueStatement<'a> { pub span: Span, pub label: Option>, @@ -1265,7 +1265,7 @@ pub struct ContinueStatement<'a> { /// Break Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct BreakStatement<'a> { pub span: Span, pub label: Option>, @@ -1274,7 +1274,7 @@ pub struct BreakStatement<'a> { /// Return Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ReturnStatement<'a> { pub span: Span, pub argument: Option>, @@ -1283,7 +1283,7 @@ pub struct ReturnStatement<'a> { /// With Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct WithStatement<'a> { pub span: Span, pub object: Expression<'a>, @@ -1294,7 +1294,7 @@ pub struct WithStatement<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct SwitchStatement<'a> { pub span: Span, pub discriminant: Expression<'a>, @@ -1307,7 +1307,7 @@ pub struct SwitchStatement<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct SwitchCase<'a> { pub span: Span, pub test: Option>, @@ -1317,7 +1317,7 @@ pub struct SwitchCase<'a> { /// Labelled Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct LabeledStatement<'a> { pub span: Span, pub label: LabelIdentifier<'a>, @@ -1333,7 +1333,7 @@ pub struct LabeledStatement<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ThrowStatement<'a> { pub span: Span, /// The expression being thrown, e.g. `err` in `throw err;` @@ -1357,7 +1357,7 @@ pub struct ThrowStatement<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TryStatement<'a> { pub span: Span, /// Statements in the `try` block @@ -1383,7 +1383,7 @@ pub struct TryStatement<'a> { #[ast(visit)] #[scope(flags(ScopeFlags::CatchClause))] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct CatchClause<'a> { pub span: Span, /// The caught error parameter, e.g. `e` in `catch (e) {}` @@ -1410,7 +1410,7 @@ pub struct CatchClause<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct CatchParameter<'a> { pub span: Span, /// The bound error @@ -1426,7 +1426,7 @@ pub struct CatchParameter<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct DebuggerStatement { pub span: Span, } @@ -1435,7 +1435,7 @@ pub struct DebuggerStatement { /// * #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(no_type)] pub struct BindingPattern<'a> { // estree(flatten) the attributes because estree has no `BindingPattern` @@ -1453,7 +1453,7 @@ pub struct BindingPattern<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum BindingPatternKind<'a> { /// `const a = 1` BindingIdentifier(Box<'a, BindingIdentifier<'a>>) = 0, @@ -1470,7 +1470,7 @@ pub enum BindingPatternKind<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct AssignmentPattern<'a> { pub span: Span, pub left: BindingPattern<'a>, @@ -1479,7 +1479,7 @@ pub struct AssignmentPattern<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ObjectPattern<'a> { pub span: Span, pub properties: Vec<'a, BindingProperty<'a>>, @@ -1489,7 +1489,7 @@ pub struct ObjectPattern<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct BindingProperty<'a> { pub span: Span, pub key: PropertyKey<'a>, @@ -1500,7 +1500,7 @@ pub struct BindingProperty<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ArrayPattern<'a> { pub span: Span, pub elements: Vec<'a, Option>>, @@ -1519,7 +1519,7 @@ pub struct ArrayPattern<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(type = "RestElement")] pub struct BindingRestElement<'a> { pub span: Span, @@ -1568,7 +1568,7 @@ pub struct BindingRestElement<'a> { strict_if(self.has_use_strict_directive()), )] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct Function<'a> { pub span: Span, pub r#type: FunctionType, @@ -1631,7 +1631,7 @@ pub struct Function<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] #[estree(no_rename_variants)] pub enum FunctionType { FunctionDeclaration = 0, @@ -1644,7 +1644,7 @@ pub enum FunctionType { /// #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(custom_serialize)] pub struct FormalParameters<'a> { pub span: Span, @@ -1657,7 +1657,7 @@ pub struct FormalParameters<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct FormalParameter<'a> { pub span: Span, #[ts] @@ -1673,7 +1673,7 @@ pub struct FormalParameter<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] #[estree(no_rename_variants)] pub enum FormalParameterKind { /// @@ -1689,7 +1689,7 @@ pub enum FormalParameterKind { /// #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct FunctionBody<'a> { pub span: Span, pub directives: Vec<'a, Directive<'a>>, @@ -1703,7 +1703,7 @@ pub struct FunctionBody<'a> { strict_if(self.has_use_strict_directive()), )] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ArrowFunctionExpression<'a> { pub span: Span, /// Is the function body an arrow expression? i.e. `() => expr` instead of `() => {}` @@ -1724,7 +1724,7 @@ pub struct ArrowFunctionExpression<'a> { /// Generator Function Definitions #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct YieldExpression<'a> { pub span: Span, pub delegate: bool, @@ -1735,7 +1735,7 @@ pub struct YieldExpression<'a> { #[ast(visit)] #[scope(flags(ScopeFlags::StrictMode))] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct Class<'a> { pub span: Span, pub r#type: ClassType, @@ -1810,7 +1810,7 @@ pub struct Class<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] #[estree(no_rename_variants)] pub enum ClassType { /// Class declaration statement @@ -1828,7 +1828,7 @@ pub enum ClassType { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ClassBody<'a> { pub span: Span, pub body: Vec<'a, ClassElement<'a>>, @@ -1854,7 +1854,7 @@ pub struct ClassBody<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum ClassElement<'a> { StaticBlock(Box<'a, StaticBlock<'a>>) = 0, /// Class Methods @@ -1876,7 +1876,7 @@ pub enum ClassElement<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct MethodDefinition<'a> { pub span: Span, /// Method definition type @@ -1906,7 +1906,7 @@ pub struct MethodDefinition<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] #[estree(no_rename_variants)] pub enum MethodDefinitionType { MethodDefinition = 0, @@ -1915,7 +1915,7 @@ pub enum MethodDefinitionType { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct PropertyDefinition<'a> { pub span: Span, pub r#type: PropertyDefinitionType, @@ -2003,7 +2003,7 @@ pub struct PropertyDefinition<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] #[estree(no_rename_variants)] pub enum PropertyDefinitionType { PropertyDefinition = 0, @@ -2012,7 +2012,7 @@ pub enum PropertyDefinitionType { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub enum MethodDefinitionKind { /// Class constructor Constructor = 0, @@ -2029,7 +2029,7 @@ pub enum MethodDefinitionKind { /// See: [MDN - Private class fields](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_class_fields) #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct PrivateIdentifier<'a> { pub span: Span, pub name: Atom<'a>, @@ -2051,7 +2051,7 @@ pub struct PrivateIdentifier<'a> { #[ast(visit)] #[scope(flags(ScopeFlags::ClassStaticBlock))] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct StaticBlock<'a> { pub span: Span, pub body: Vec<'a, Statement<'a>>, @@ -2085,7 +2085,7 @@ pub struct StaticBlock<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum ModuleDeclaration<'a> { /// `import hello from './world.js';` /// `import * as t from './world.js';` @@ -2120,7 +2120,7 @@ pub use match_module_declaration; #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] #[estree(no_rename_variants)] pub enum AccessorPropertyType { AccessorProperty = 0, @@ -2137,7 +2137,7 @@ pub enum AccessorPropertyType { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct AccessorProperty<'a> { pub span: Span, pub r#type: AccessorPropertyType, @@ -2182,7 +2182,7 @@ pub struct AccessorProperty<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ImportExpression<'a> { pub span: Span, pub source: Expression<'a>, @@ -2192,7 +2192,7 @@ pub struct ImportExpression<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ImportDeclaration<'a> { pub span: Span, /// `None` for `import 'foo'`, `Some([])` for `import {} from 'foo'` @@ -2214,7 +2214,7 @@ pub struct ImportDeclaration<'a> { /// #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub enum ImportPhase { Source = 0, Defer = 1, @@ -2222,7 +2222,7 @@ pub enum ImportPhase { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum ImportDeclarationSpecifier<'a> { /// import {imported} from "source" /// import {imported as local} from "source" @@ -2237,7 +2237,7 @@ pub enum ImportDeclarationSpecifier<'a> { // import {imported as local} from "source" #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ImportSpecifier<'a> { pub span: Span, pub imported: ModuleExportName<'a>, @@ -2266,7 +2266,7 @@ pub struct ImportSpecifier<'a> { /// #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ImportDefaultSpecifier<'a> { pub span: Span, /// The name of the imported symbol. @@ -2281,7 +2281,7 @@ pub struct ImportDefaultSpecifier<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ImportNamespaceSpecifier<'a> { pub span: Span, pub local: BindingIdentifier<'a>, @@ -2289,7 +2289,7 @@ pub struct ImportNamespaceSpecifier<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct WithClause<'a> { pub span: Span, pub attributes_keyword: IdentifierName<'a>, // `with` or `assert` @@ -2298,7 +2298,7 @@ pub struct WithClause<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ImportAttribute<'a> { pub span: Span, pub key: ImportAttributeKey<'a>, @@ -2307,7 +2307,7 @@ pub struct ImportAttribute<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub enum ImportAttributeKey<'a> { Identifier(IdentifierName<'a>) = 0, StringLiteral(StringLiteral<'a>) = 1, @@ -2326,7 +2326,7 @@ pub enum ImportAttributeKey<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ExportNamedDeclaration<'a> { pub span: Span, pub declaration: Option>, @@ -2351,7 +2351,7 @@ pub struct ExportNamedDeclaration<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ExportDefaultDeclaration<'a> { pub span: Span, pub declaration: ExportDefaultDeclarationKind<'a>, @@ -2369,7 +2369,7 @@ pub struct ExportDefaultDeclaration<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ExportAllDeclaration<'a> { pub span: Span, /// If this declaration is re-named @@ -2395,7 +2395,7 @@ pub struct ExportAllDeclaration<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ExportSpecifier<'a> { pub span: Span, pub local: ModuleExportName<'a>, @@ -2412,7 +2412,7 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum ExportDefaultDeclarationKind<'a> { #[visit(args(flags = ScopeFlags::Function))] FunctionDeclaration(Box<'a, Function<'a>>) = 64, @@ -2434,7 +2434,7 @@ pub enum ExportDefaultDeclarationKind<'a> { /// * #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub enum ModuleExportName<'a> { IdentifierName(IdentifierName<'a>) = 0, /// For `local` in `ExportSpecifier`: `foo` in `export { foo }` diff --git a/crates/oxc_ast/src/ast/jsx.rs b/crates/oxc_ast/src/ast/jsx.rs index 580f3c9c03ccb..4cac72a170ee8 100644 --- a/crates/oxc_ast/src/ast/jsx.rs +++ b/crates/oxc_ast/src/ast/jsx.rs @@ -7,7 +7,7 @@ use oxc_allocator::{Box, CloneIn, GetAddress, Vec}; use oxc_ast_macros::ast; use oxc_estree::ESTree; -use oxc_span::{cmp::ContentEq, hash::ContentHash, Atom, GetSpan, GetSpanMut, Span}; +use oxc_span::{cmp::ContentEq, Atom, GetSpan, GetSpanMut, Span}; use super::{inherit_variants, js::*, literal::*, ts::*}; @@ -32,7 +32,7 @@ use super::{inherit_variants, js::*, literal::*, ts::*}; /// See: [JSX Syntax](https://facebook.github.io/jsx/) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct JSXElement<'a> { /// Node location in source code pub span: Span, @@ -61,7 +61,7 @@ pub struct JSXElement<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct JSXOpeningElement<'a> { /// Node location in source code pub span: Span, @@ -95,7 +95,7 @@ pub struct JSXOpeningElement<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct JSXClosingElement<'a> { /// Node location in source code pub span: Span, @@ -113,7 +113,7 @@ pub struct JSXClosingElement<'a> { /// See: [`React.Fragment`](https://react.dev/reference/react/Fragment) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct JSXFragment<'a> { /// Node location in source code pub span: Span, @@ -128,7 +128,7 @@ pub struct JSXFragment<'a> { /// JSX Opening Fragment (`<>`) #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct JSXOpeningFragment { /// Node location in source code pub span: Span, @@ -137,7 +137,7 @@ pub struct JSXOpeningFragment { /// JSX Closing Fragment (``) #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct JSXClosingFragment { /// Node location in source code pub span: Span, @@ -146,7 +146,7 @@ pub struct JSXClosingFragment { /// JSX Element Name #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq)] pub enum JSXElementName<'a> { /// `
` Identifier(Box<'a, JSXIdentifier<'a>>) = 0, @@ -169,7 +169,7 @@ pub enum JSXElementName<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct JSXNamespacedName<'a> { /// Node location in source code pub span: Span, @@ -196,7 +196,7 @@ pub struct JSXNamespacedName<'a> { /// [`member expression`]: JSXMemberExpressionObject::MemberExpression #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct JSXMemberExpression<'a> { /// Node location in source code pub span: Span, @@ -224,7 +224,7 @@ pub struct JSXMemberExpression<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq)] pub enum JSXMemberExpressionObject<'a> { /// `` IdentifierReference(Box<'a, IdentifierReference<'a>>) = 0, @@ -249,7 +249,7 @@ pub enum JSXMemberExpressionObject<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct JSXExpressionContainer<'a> { /// Node location in source code pub span: Span, @@ -266,7 +266,7 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub enum JSXExpression<'a> { /// An empty expression /// @@ -284,7 +284,7 @@ pub enum JSXExpression<'a> { /// An empty JSX expression (`{}`) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct JSXEmptyExpression { /// Node location in source code pub span: Span, @@ -303,7 +303,7 @@ pub struct JSXEmptyExpression { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum JSXAttributeItem<'a> { /// A `key="value"` attribute Attribute(Box<'a, JSXAttribute<'a>>) = 0, @@ -324,7 +324,7 @@ pub enum JSXAttributeItem<'a> { /// // name ^^^ ^^^^ value #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct JSXAttribute<'a> { /// Node location in source code pub span: Span, @@ -345,7 +345,7 @@ pub struct JSXAttribute<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct JSXSpreadAttribute<'a> { /// Node location in source code pub span: Span, @@ -370,7 +370,7 @@ pub struct JSXSpreadAttribute<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum JSXAttributeName<'a> { /// An attribute name without a namespace prefix, e.g. `foo` in `foo="bar"`. Identifier(Box<'a, JSXIdentifier<'a>>) = 0, @@ -398,7 +398,7 @@ pub enum JSXAttributeName<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum JSXAttributeValue<'a> { /// `` StringLiteral(Box<'a, StringLiteral<'a>>) = 0, @@ -417,7 +417,7 @@ pub enum JSXAttributeValue<'a> { /// [`IdentifierName`]: super::IdentifierName #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct JSXIdentifier<'a> { /// Node location in source code pub span: Span, @@ -432,7 +432,7 @@ pub struct JSXIdentifier<'a> { /// Part of a [`JSXElement`]. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum JSXChild<'a> { /// `Some Text` Text(Box<'a, JSXText<'a>>) = 0, @@ -451,7 +451,7 @@ pub enum JSXChild<'a> { /// Variant of [`JSXChild`] that represents an object spread (`{...expression}`). #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct JSXSpreadChild<'a> { /// Node location in source code pub span: Span, @@ -471,7 +471,7 @@ pub struct JSXSpreadChild<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct JSXText<'a> { /// Node location in source code pub span: Span, diff --git a/crates/oxc_ast/src/ast/literal.rs b/crates/oxc_ast/src/ast/literal.rs index 24ae7ad61c588..969de0dd64825 100644 --- a/crates/oxc_ast/src/ast/literal.rs +++ b/crates/oxc_ast/src/ast/literal.rs @@ -11,7 +11,7 @@ use oxc_allocator::{Box, CloneIn}; use oxc_ast_macros::ast; use oxc_estree::ESTree; use oxc_regular_expression::ast::Pattern; -use oxc_span::{cmp::ContentEq, hash::ContentHash, Atom, GetSpan, GetSpanMut, Span}; +use oxc_span::{cmp::ContentEq, Atom, GetSpan, GetSpanMut, Span}; use oxc_syntax::number::{BigintBase, NumberBase}; /// Boolean literal @@ -19,7 +19,7 @@ use oxc_syntax::number::{BigintBase, NumberBase}; /// #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(type = "Literal", via = crate::serialize::ESTreeLiteral, add_ts = "raw: string | null")] pub struct BooleanLiteral { /// Node location in source code @@ -33,7 +33,7 @@ pub struct BooleanLiteral { /// #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(type = "Literal", via = crate::serialize::ESTreeLiteral, add_ts = "value: null, raw: \"null\" | null")] pub struct NullLiteral { /// Node location in source code @@ -127,7 +127,7 @@ pub struct RegExpLiteral<'a> { /// #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] #[estree(no_type)] pub struct RegExp<'a> { /// The regex pattern between the slashes diff --git a/crates/oxc_ast/src/ast/ts.rs b/crates/oxc_ast/src/ast/ts.rs index 61bbe2661374c..a7b2fe7151293 100644 --- a/crates/oxc_ast/src/ast/ts.rs +++ b/crates/oxc_ast/src/ast/ts.rs @@ -13,7 +13,7 @@ use std::cell::Cell; use oxc_allocator::{Box, CloneIn, GetAddress, Vec}; use oxc_ast_macros::ast; use oxc_estree::ESTree; -use oxc_span::{cmp::ContentEq, hash::ContentHash, Atom, GetSpan, GetSpanMut, Span}; +use oxc_span::{cmp::ContentEq, Atom, GetSpan, GetSpanMut, Span}; use oxc_syntax::scope::ScopeId; use super::{inherit_variants, js::*, literal::*}; @@ -30,7 +30,7 @@ use super::{inherit_variants, js::*, literal::*}; /// * [TypeScript Handbook - `this` parameters](https://www.typescriptlang.org/docs/handbook/2/functions.html#this-parameters) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSThisParameter<'a> { pub span: Span, #[estree(skip)] @@ -62,7 +62,7 @@ pub struct TSThisParameter<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSEnumDeclaration<'a> { pub span: Span, pub id: BindingIdentifier<'a>, @@ -95,7 +95,7 @@ pub struct TSEnumDeclaration<'a> { /// * [TypeScript Handbook - Enums](https://www.typescriptlang.org/docs/handbook/enums.html) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSEnumMember<'a> { pub span: Span, pub id: TSEnumMemberName<'a>, @@ -105,7 +105,7 @@ pub struct TSEnumMember<'a> { /// TS Enum Member Name #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum TSEnumMemberName<'a> { Identifier(Box<'a, IdentifierName<'a>>) = 0, String(Box<'a, StringLiteral<'a>>) = 1, @@ -125,7 +125,7 @@ pub enum TSEnumMemberName<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSTypeAnnotation<'a> { /// starts at the `:` token and ends at the end of the type annotation pub span: Span, @@ -149,7 +149,7 @@ pub struct TSTypeAnnotation<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSLiteralType<'a> { pub span: Span, pub literal: TSLiteral<'a>, @@ -158,7 +158,7 @@ pub struct TSLiteralType<'a> { /// A literal in a [`TSLiteralType`]. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum TSLiteral<'a> { BooleanLiteral(Box<'a, BooleanLiteral>) = 0, NullLiteral(Box<'a, NullLiteral>) = 1, @@ -183,7 +183,7 @@ pub enum TSLiteral<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum TSType<'a> { // Keyword TSAnyKeyword(Box<'a, TSAnyKeyword>) = 0, @@ -290,7 +290,7 @@ pub use match_ts_type; #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSConditionalType<'a> { pub span: Span, /// The type before `extends` in the test expression. @@ -319,7 +319,7 @@ pub struct TSConditionalType<'a> { /// * [TypeScript Handbook - Union Types](https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes-func.html#unions) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSUnionType<'a> { pub span: Span, /// The types in the union. @@ -341,7 +341,7 @@ pub struct TSUnionType<'a> { /// * [TypeScript Handbook - Intersection Types](https://www.typescriptlang.org/docs/handbook/2/objects.html#intersection-types) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSIntersectionType<'a> { pub span: Span, pub types: Vec<'a, TSType<'a>>, @@ -358,7 +358,7 @@ pub struct TSIntersectionType<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSParenthesizedType<'a> { pub span: Span, pub type_annotation: TSType<'a>, @@ -375,7 +375,7 @@ pub struct TSParenthesizedType<'a> { /// * [TypeScript Handbook - Keyof Types](https://www.typescriptlang.org/docs/handbook/2/keyof-types.html) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSTypeOperator<'a> { pub span: Span, pub operator: TSTypeOperatorOperator, @@ -386,7 +386,7 @@ pub struct TSTypeOperator<'a> { /// Operator in a [`TSTypeOperator`]. #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub enum TSTypeOperatorOperator { Keyof = 0, Unique = 1, @@ -406,7 +406,7 @@ pub enum TSTypeOperatorOperator { /// #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSArrayType<'a> { pub span: Span, pub element_type: TSType<'a>, @@ -425,7 +425,7 @@ pub struct TSArrayType<'a> { /// #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSIndexedAccessType<'a> { pub span: Span, pub object_type: TSType<'a>, @@ -443,7 +443,7 @@ pub struct TSIndexedAccessType<'a> { /// #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSTupleType<'a> { pub span: Span, pub element_types: Vec<'a, TSTupleElement<'a>>, @@ -461,7 +461,7 @@ pub struct TSTupleType<'a> { /// * [TypeScript Handbook - Tuple Types](https://www.typescriptlang.org/docs/handbook/2/objects.html#tuple-types) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSNamedTupleMember<'a> { pub span: Span, pub element_type: TSTupleElement<'a>, @@ -480,7 +480,7 @@ pub struct TSNamedTupleMember<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSOptionalType<'a> { pub span: Span, pub type_annotation: TSType<'a>, @@ -496,7 +496,7 @@ pub struct TSOptionalType<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSRestType<'a> { pub span: Span, pub type_annotation: TSType<'a>, @@ -512,7 +512,7 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum TSTupleElement<'a> { // Discriminants start at 64, so that `TSTupleElement::is_ts_type` is a single // bitwise AND operation on the discriminant (`discriminant & 63 != 0`). @@ -534,7 +534,7 @@ pub enum TSTupleElement<'a> { /// * [TypeScript Handbook - Any Type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#any) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSAnyKeyword { pub span: Span, } @@ -550,7 +550,7 @@ pub struct TSAnyKeyword { /// * [TypeScript Handbook - Everyday Types](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#the-primitives-string-number-and-boolean) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSStringKeyword { pub span: Span, } @@ -566,7 +566,7 @@ pub struct TSStringKeyword { /// * [TypeScript Handbook - Everyday Types](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#the-primitives-string-number-and-boolean) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSBooleanKeyword { pub span: Span, } @@ -582,7 +582,7 @@ pub struct TSBooleanKeyword { /// * [TypeScript Handbook - Everyday Types](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#the-primitives-string-number-and-boolean) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSNumberKeyword { pub span: Span, } @@ -599,7 +599,7 @@ pub struct TSNumberKeyword { /// * [TypeScript Handbook - Advanced Topics](https://www.typescriptlang.org/docs/handbook/type-compatibility.html#advanced-topics) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSNeverKeyword { pub span: Span, } @@ -616,7 +616,7 @@ pub struct TSNeverKeyword { /// * [microsoft/TypeScript #40580](https://github.com/microsoft/TypeScript/pull/40580) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSIntrinsicKeyword { pub span: Span, } @@ -634,7 +634,7 @@ pub struct TSIntrinsicKeyword { /// * [TypeScript Handbook - Advanced Topics](https://www.typescriptlang.org/docs/handbook/type-compatibility.html#advanced-topics) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSUnknownKeyword { pub span: Span, } @@ -651,7 +651,7 @@ pub struct TSUnknownKeyword { /// * [TypeScript Handbook - Everyday Types](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#null-and-undefined) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSNullKeyword { pub span: Span, } @@ -670,42 +670,42 @@ pub struct TSNullKeyword { /// * [TypeScript Handbook - Everyday Types](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#null-and-undefined) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSUndefinedKeyword { pub span: Span, } #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSVoidKeyword { pub span: Span, } #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSSymbolKeyword { pub span: Span, } #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSThisType { pub span: Span, } #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSObjectKeyword { pub span: Span, } #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSBigIntKeyword { pub span: Span, } @@ -720,7 +720,7 @@ pub struct TSBigIntKeyword { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSTypeReference<'a> { pub span: Span, pub type_name: TSTypeName<'a>, @@ -732,7 +732,7 @@ pub struct TSTypeReference<'a> { /// NamespaceNameā€ƒ.ā€ƒIdentifierReference #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum TSTypeName<'a> { IdentifierReference(Box<'a, IdentifierReference<'a>>) = 0, QualifiedName(Box<'a, TSQualifiedName<'a>>) = 1, @@ -757,7 +757,7 @@ pub use match_ts_type_name; /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSQualifiedName<'a> { pub span: Span, pub left: TSTypeName<'a>, @@ -766,7 +766,7 @@ pub struct TSQualifiedName<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSTypeParameterInstantiation<'a> { pub span: Span, pub params: Vec<'a, TSType<'a>>, @@ -791,7 +791,7 @@ pub struct TSTypeParameterInstantiation<'a> { /// * [TypeScript Handbook - Variance Annotations](https://www.typescriptlang.org/docs/handbook/2/generics.html#variance-annotations) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSTypeParameter<'a> { pub span: Span, /// The name of the parameter, e.g. `T` in `type Foo = ...`. @@ -810,7 +810,7 @@ pub struct TSTypeParameter<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSTypeParameterDeclaration<'a> { pub span: Span, pub params: Vec<'a, TSTypeParameter<'a>>, @@ -827,7 +827,7 @@ pub struct TSTypeParameterDeclaration<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSTypeAliasDeclaration<'a> { pub span: Span, /// Type alias's identifier, e.g. `Foo` in `type Foo = number`. @@ -843,7 +843,7 @@ pub struct TSTypeAliasDeclaration<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub enum TSAccessibility { Private = 0, Protected = 1, @@ -862,7 +862,7 @@ pub enum TSAccessibility { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSClassImplements<'a> { pub span: Span, pub expression: TSTypeName<'a>, @@ -887,7 +887,7 @@ pub struct TSClassImplements<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSInterfaceDeclaration<'a> { pub span: Span, /// The identifier (name) of the interface. @@ -908,7 +908,7 @@ pub struct TSInterfaceDeclaration<'a> { /// Body of a [`TSInterfaceDeclaration`]. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSInterfaceBody<'a> { pub span: Span, pub body: Vec<'a, TSSignature<'a>>, @@ -931,7 +931,7 @@ pub struct TSInterfaceBody<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSPropertySignature<'a> { pub span: Span, pub computed: bool, @@ -943,7 +943,7 @@ pub struct TSPropertySignature<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum TSSignature<'a> { TSIndexSignature(Box<'a, TSIndexSignature<'a>>) = 0, TSPropertySignature(Box<'a, TSPropertySignature<'a>>) = 1, @@ -965,7 +965,7 @@ pub enum TSSignature<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSIndexSignature<'a> { pub span: Span, pub parameters: Vec<'a, TSIndexSignatureName<'a>>, @@ -976,7 +976,7 @@ pub struct TSIndexSignature<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSCallSignatureDeclaration<'a> { pub span: Span, pub type_parameters: Option>>, @@ -987,7 +987,7 @@ pub struct TSCallSignatureDeclaration<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub enum TSMethodSignatureKind { Method = 0, Get = 1, @@ -1008,7 +1008,7 @@ pub enum TSMethodSignatureKind { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSMethodSignature<'a> { pub span: Span, pub key: PropertyKey<'a>, @@ -1028,7 +1028,7 @@ pub struct TSMethodSignature<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSConstructSignatureDeclaration<'a> { pub span: Span, pub type_parameters: Option>>, @@ -1041,7 +1041,7 @@ pub struct TSConstructSignatureDeclaration<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(type = "Identifier")] pub struct TSIndexSignatureName<'a> { pub span: Span, @@ -1051,7 +1051,7 @@ pub struct TSIndexSignatureName<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSInterfaceHeritage<'a> { pub span: Span, pub expression: Expression<'a>, @@ -1080,7 +1080,7 @@ pub struct TSInterfaceHeritage<'a> { /// * [TypeScript Handbook - Assertion Functions](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSTypePredicate<'a> { pub span: Span, /// The identifier the predicate operates on @@ -1097,7 +1097,7 @@ pub struct TSTypePredicate<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub enum TSTypePredicateName<'a> { Identifier(Box<'a, IdentifierName<'a>>) = 0, This(TSThisType) = 1, @@ -1135,7 +1135,7 @@ pub enum TSTypePredicateName<'a> { strict_if(self.body.as_ref().is_some_and(TSModuleDeclarationBody::has_use_strict_directive)), )] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSModuleDeclaration<'a> { pub span: Span, /// The name of the module/namespace being declared. @@ -1166,7 +1166,7 @@ pub struct TSModuleDeclaration<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub enum TSModuleDeclarationKind { /// `declare global {}` Global = 0, @@ -1198,7 +1198,7 @@ pub enum TSModuleDeclarationKind { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub enum TSModuleDeclarationName<'a> { Identifier(BindingIdentifier<'a>) = 0, StringLiteral(StringLiteral<'a>) = 1, @@ -1206,7 +1206,7 @@ pub enum TSModuleDeclarationName<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum TSModuleDeclarationBody<'a> { TSModuleDeclaration(Box<'a, TSModuleDeclaration<'a>>) = 0, TSModuleBlock(Box<'a, TSModuleBlock<'a>>) = 1, @@ -1215,7 +1215,7 @@ pub enum TSModuleDeclarationBody<'a> { // See serializer in serialize.rs #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(custom_serialize)] pub struct TSModuleBlock<'a> { pub span: Span, @@ -1226,7 +1226,7 @@ pub struct TSModuleBlock<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSTypeLiteral<'a> { pub span: Span, pub members: Vec<'a, TSSignature<'a>>, @@ -1247,7 +1247,7 @@ pub struct TSTypeLiteral<'a> { /// * [TypeScript Handbook - Inferring With Conditional Types](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#inferring-within-conditional-types) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSInferType<'a> { pub span: Span, /// The type bound when the @@ -1265,7 +1265,7 @@ pub struct TSInferType<'a> { /// * [TypeScript Handbook - Typeof Type Operator](https://www.typescriptlang.org/docs/handbook/2/typeof-types.html) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSTypeQuery<'a> { pub span: Span, pub expr_name: TSTypeQueryExprName<'a>, @@ -1280,7 +1280,7 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum TSTypeQueryExprName<'a> { TSImportType(Box<'a, TSImportType<'a>>) = 2, // `TSTypeName` variants added here by `inherit_variants!` macro @@ -1290,7 +1290,7 @@ pub enum TSTypeQueryExprName<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSImportType<'a> { pub span: Span, /// `true` for `typeof import("foo")` @@ -1303,7 +1303,7 @@ pub struct TSImportType<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSImportAttributes<'a> { pub span: Span, pub attributes_keyword: IdentifierName<'a>, // `with` or `assert` @@ -1312,7 +1312,7 @@ pub struct TSImportAttributes<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSImportAttribute<'a> { pub span: Span, pub name: TSImportAttributeName<'a>, @@ -1321,7 +1321,7 @@ pub struct TSImportAttribute<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub enum TSImportAttributeName<'a> { Identifier(IdentifierName<'a>) = 0, StringLiteral(StringLiteral<'a>) = 1, @@ -1337,7 +1337,7 @@ pub enum TSImportAttributeName<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSFunctionType<'a> { pub span: Span, /// Generic type parameters @@ -1366,7 +1366,7 @@ pub struct TSFunctionType<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSConstructorType<'a> { pub span: Span, pub r#abstract: bool, @@ -1399,7 +1399,7 @@ pub struct TSConstructorType<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSMappedType<'a> { pub span: Span, /// Key type parameter, e.g. `P` in `[P in keyof T]`. @@ -1437,7 +1437,7 @@ pub struct TSMappedType<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub enum TSMappedTypeModifierOperator { /// e.g. `?` in `{ [P in K]?: T }` True = 0, @@ -1464,7 +1464,7 @@ pub enum TSMappedTypeModifierOperator { /// * [TypeScript Handbook - Template Literal Types](https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html#handbook-content) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSTemplateLiteralType<'a> { pub span: Span, /// The string parts of the template literal. @@ -1475,7 +1475,7 @@ pub struct TSTemplateLiteralType<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSAsExpression<'a> { pub span: Span, pub expression: Expression<'a>, @@ -1496,7 +1496,7 @@ pub struct TSAsExpression<'a> { /// * [TypeScript Handbook - The `satisfies` Operator](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-9.html#the-satisfies-operator) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSSatisfiesExpression<'a> { pub span: Span, /// The value expression being constrained. @@ -1507,7 +1507,7 @@ pub struct TSSatisfiesExpression<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSTypeAssertion<'a> { pub span: Span, pub expression: Expression<'a>, @@ -1516,7 +1516,7 @@ pub struct TSTypeAssertion<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSImportEqualsDeclaration<'a> { pub span: Span, pub id: BindingIdentifier<'a>, @@ -1532,7 +1532,7 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum TSModuleReference<'a> { ExternalModuleReference(Box<'a, TSExternalModuleReference<'a>>) = 2, // `TSTypeName` variants added here by `inherit_variants!` macro @@ -1542,7 +1542,7 @@ pub enum TSModuleReference<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSExternalModuleReference<'a> { pub span: Span, pub expression: StringLiteral<'a>, @@ -1550,7 +1550,7 @@ pub struct TSExternalModuleReference<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSNonNullExpression<'a> { pub span: Span, pub expression: Expression<'a>, @@ -1582,7 +1582,7 @@ pub struct TSNonNullExpression<'a> { /// [`CallExpression`]: crate::ast::js::CallExpression #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct Decorator<'a> { pub span: Span, pub expression: Expression<'a>, @@ -1593,7 +1593,7 @@ pub struct Decorator<'a> { /// `export = foo` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSExportAssignment<'a> { pub span: Span, pub expression: Expression<'a>, @@ -1604,7 +1604,7 @@ pub struct TSExportAssignment<'a> { /// `export as namespace foo` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSNamespaceExportDeclaration<'a> { pub span: Span, pub id: IdentifierName<'a>, @@ -1612,7 +1612,7 @@ pub struct TSNamespaceExportDeclaration<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSInstantiationExpression<'a> { pub span: Span, pub expression: Expression<'a>, @@ -1622,7 +1622,7 @@ pub struct TSInstantiationExpression<'a> { /// See [TypeScript - Type-Only Imports and Exports](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html) #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub enum ImportOrExportKind { /// `import { foo } from './foo'`; Value = 0, @@ -1635,7 +1635,7 @@ pub enum ImportOrExportKind { /// `type foo = ty?` or `type foo = ?ty` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct JSDocNullableType<'a> { pub span: Span, pub type_annotation: TSType<'a>, @@ -1646,7 +1646,7 @@ pub struct JSDocNullableType<'a> { /// `type foo = ty!` or `type foo = !ty` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct JSDocNonNullableType<'a> { pub span: Span, pub type_annotation: TSType<'a>, @@ -1655,7 +1655,7 @@ pub struct JSDocNonNullableType<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct JSDocUnknownType { pub span: Span, } diff --git a/crates/oxc_ast/src/ast_impl/literal.rs b/crates/oxc_ast/src/ast_impl/literal.rs index d654b9ac554ca..91165a5982dd3 100644 --- a/crates/oxc_ast/src/ast_impl/literal.rs +++ b/crates/oxc_ast/src/ast_impl/literal.rs @@ -1,14 +1,10 @@ //! Literals -use std::{ - borrow::Cow, - fmt, - hash::{Hash, Hasher}, -}; +use std::{borrow::Cow, fmt}; use oxc_allocator::CloneIn; use oxc_regular_expression::ast::Pattern; -use oxc_span::{cmp::ContentEq, hash::ContentHash}; +use oxc_span::cmp::ContentEq; use crate::ast::*; @@ -79,44 +75,10 @@ impl ContentEq for NumericLiteral<'_> { fn content_eq(&self, other: &Self) -> bool { // Note: `f64::content_eq` uses `==` equality. // `f64::NAN != f64::NAN` and `0.0 == -0.0`, so we follow the same here. - // If we change that behavior, we should alter `content_hash` too. ContentEq::content_eq(&self.value, &other.value) } } -impl ContentHash for NumericLiteral<'_> { - fn content_hash(&self, state: &mut H) { - // `f64` does not implement `Hash` due to ambiguity over what is the right way to hash NaN - // and +/- zero values. - // - // # NaN - // IEEE 754 defines a whole range of NaN values. - // https://doc.rust-lang.org/std/primitive.f64.html#associatedconstant.NAN - // We can ignore that complication here as the rule is that 2 types which are equal (`==`) - // must hash the same. - // `ContentEq` uses `==` equality, and even the same NaN doesn't equal itself! - // `f64::NAN != f64::NAN` - // So it doesn't matter if two NaNs have the same hash or not. - // - // # Zero - // `ContentEq` uses `==` equality, which considers `0.0` and `-0.0` equal, so we must make - // them hash the same. - // But `(0.0).to_bits() != (-0.0).to_bits()`, so we need to convert `-0.0` to `0.0`. - // - // # Infinity - // `f64::INFINITY != -f64::INFINITY` and `f64::INFINITY.to_bits() != (-f64::INFINITY).to_bits()` - // so infinity needs no special handling. - // - // Whatever the value, we convert to `u64` using `to_bits`, and hash that. - let mut value = self.value; - if value == -0.0 { - value = 0.0; - } - let value = value.to_bits(); - std::hash::Hash::hash(&value, state); - } -} - impl fmt::Display for NumericLiteral<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { // We have 2 choices here: @@ -155,12 +117,6 @@ impl ContentEq for StringLiteral<'_> { } } -impl ContentHash for StringLiteral<'_> { - fn content_hash(&self, state: &mut H) { - ContentHash::content_hash(&self.value, state); - } -} - impl AsRef for StringLiteral<'_> { #[inline] fn as_ref(&self) -> &str { @@ -188,12 +144,6 @@ impl ContentEq for BigIntLiteral<'_> { } } -impl ContentHash for BigIntLiteral<'_> { - fn content_hash(&self, state: &mut H) { - ContentHash::content_hash(&self.raw, state); - } -} - impl fmt::Display for BigIntLiteral<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.raw.fmt(f) @@ -277,16 +227,6 @@ impl ContentEq for RegExpPattern<'_> { } } -impl ContentHash for RegExpPattern<'_> { - fn content_hash(&self, state: &mut H) { - let self_str = match self { - Self::Raw(s) | Self::Invalid(s) => s, - Self::Pattern(p) => &&*p.to_string(), - }; - ContentHash::content_hash(self_str, state); - } -} - impl fmt::Display for RegExpPattern<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { @@ -302,12 +242,6 @@ impl ContentEq for RegExpFlags { } } -impl ContentHash for RegExpFlags { - fn content_hash(&self, state: &mut H) { - Hash::hash(self, state); - } -} - impl<'alloc> CloneIn<'alloc> for RegExpFlags { type Cloned = Self; diff --git a/crates/oxc_ast_macros/src/ast.rs b/crates/oxc_ast_macros/src/ast.rs index ea2b28e3f584d..6bfd1e3d015b5 100644 --- a/crates/oxc_ast_macros/src/ast.rs +++ b/crates/oxc_ast_macros/src/ast.rs @@ -81,8 +81,6 @@ fn abs_trait( (quote!(::oxc_allocator::GetAddress), TokenStream::default()) } else if ident == "ContentEq" { (quote!(::oxc_span::cmp::ContentEq), TokenStream::default()) - } else if ident == "ContentHash" { - (quote!(::oxc_span::hash::ContentHash), TokenStream::default()) } else if ident == "ESTree" { (quote!(::oxc_estree::ESTree), TokenStream::default()) } else { diff --git a/crates/oxc_regular_expression/src/ast.rs b/crates/oxc_regular_expression/src/ast.rs index af39fa3c3233b..24e8e2ebed71c 100644 --- a/crates/oxc_regular_expression/src/ast.rs +++ b/crates/oxc_regular_expression/src/ast.rs @@ -1,12 +1,12 @@ use oxc_allocator::{Box, CloneIn, GetAddress, Vec}; use oxc_ast_macros::ast; use oxc_estree::ESTree; -use oxc_span::{cmp::ContentEq, hash::ContentHash, Atom, GetSpan, Span}; +use oxc_span::{cmp::ContentEq, Atom, GetSpan, Span}; /// The root of the `PatternParser` result. #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub struct Pattern<'a> { pub span: Span, pub body: Disjunction<'a>, @@ -15,7 +15,7 @@ pub struct Pattern<'a> { /// Pile of [`Alternative`]s separated by `|`. #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub struct Disjunction<'a> { pub span: Span, pub body: Vec<'a, Alternative<'a>>, @@ -24,7 +24,7 @@ pub struct Disjunction<'a> { /// Single unit of `|` separated alternatives. #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub struct Alternative<'a> { pub span: Span, pub body: Vec<'a, Term<'a>>, @@ -33,7 +33,7 @@ pub struct Alternative<'a> { /// Single unit of [`Alternative`], containing various kinds. #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub enum Term<'a> { // Assertion, QuantifiableAssertion BoundaryAssertion(Box<'a, BoundaryAssertion>) = 0, @@ -76,7 +76,7 @@ impl GetSpan for Term<'_> { /// e.g. `^`, `$`, `\b`, `\B` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub struct BoundaryAssertion { pub span: Span, pub kind: BoundaryAssertionKind, @@ -84,7 +84,7 @@ pub struct BoundaryAssertion { #[ast] #[derive(Debug, Clone, PartialEq)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub enum BoundaryAssertionKind { Start = 0, End = 1, @@ -96,7 +96,7 @@ pub enum BoundaryAssertionKind { /// e.g. `(?=...)`, `(?!...)`, `(?<=...)`, `(? { pub span: Span, pub kind: LookAroundAssertionKind, @@ -105,7 +105,7 @@ pub struct LookAroundAssertion<'a> { #[ast] #[derive(Debug, Clone, PartialEq)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub enum LookAroundAssertionKind { Lookahead = 0, NegativeLookahead = 1, @@ -117,7 +117,7 @@ pub enum LookAroundAssertionKind { /// e.g. `a*`, `b+`, `c?`, `d{3}`, `e{4,}`, `f{5,6}` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub struct Quantifier<'a> { pub span: Span, pub min: u64, @@ -130,7 +130,7 @@ pub struct Quantifier<'a> { /// Single character. #[ast] #[derive(Debug, Clone, Copy)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub struct Character { /// This will be invalid position when `UnicodeMode` is disabled and `value` is a surrogate pair. pub span: Span, @@ -141,7 +141,7 @@ pub struct Character { #[ast] #[derive(Debug, Clone, Copy, PartialEq)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub enum CharacterKind { ControlLetter = 0, HexadecimalEscape = 1, @@ -160,7 +160,7 @@ pub enum CharacterKind { /// e.g. `\d`, `\D`, `\s`, `\S`, `\w`, `\W` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub struct CharacterClassEscape { pub span: Span, pub kind: CharacterClassEscapeKind, @@ -168,7 +168,7 @@ pub struct CharacterClassEscape { #[ast] #[derive(Debug, Clone, Copy, PartialEq)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub enum CharacterClassEscapeKind { D = 0, NegativeD = 1, @@ -182,7 +182,7 @@ pub enum CharacterClassEscapeKind { /// e.g. `\p{ASCII}`, `\P{ASCII}`, `\p{sc=Hiragana}`, `\P{sc=Hiragana}` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub struct UnicodePropertyEscape<'a> { pub span: Span, pub negative: bool, @@ -195,7 +195,7 @@ pub struct UnicodePropertyEscape<'a> { /// The `.`. #[ast] #[derive(Debug, Clone, Copy)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub struct Dot { pub span: Span, } @@ -204,7 +204,7 @@ pub struct Dot { /// e.g. `[a-z]`, `[^A-Z]`, `[abc]`, `[a&&b&&c]`, `[[a-z]--x--y]` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub struct CharacterClass<'a> { pub span: Span, pub negative: bool, @@ -218,7 +218,7 @@ pub struct CharacterClass<'a> { #[ast] #[derive(Debug, PartialEq)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub enum CharacterClassContentsKind { Union = 0, /// `UnicodeSetsMode` only. @@ -229,7 +229,7 @@ pub enum CharacterClassContentsKind { #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, GetAddress, ESTree)] +#[generate_derive(CloneIn, ContentEq, GetAddress, ESTree)] pub enum CharacterClassContents<'a> { CharacterClassRange(Box<'a, CharacterClassRange>) = 0, CharacterClassEscape(Box<'a, CharacterClassEscape>) = 1, @@ -259,7 +259,7 @@ impl GetSpan for CharacterClassContents<'_> { /// e.g. `a-z`, `A-Z`, `0-9` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub struct CharacterClassRange { pub span: Span, pub min: Character, @@ -269,7 +269,7 @@ pub struct CharacterClassRange { /// `|` separated string of characters wrapped by `\q{}`. #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub struct ClassStringDisjunction<'a> { pub span: Span, /// `true` if body is empty or contains [`ClassString`] which `strings` is `true`. @@ -280,7 +280,7 @@ pub struct ClassStringDisjunction<'a> { /// Single unit of [`ClassStringDisjunction`]. #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub struct ClassString<'a> { pub span: Span, /// `true` if body is empty or contain 2 more characters. @@ -292,7 +292,7 @@ pub struct ClassString<'a> { /// e.g. `(...)`, `(?...)` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub struct CapturingGroup<'a> { pub span: Span, /// Group name to be referenced by [`NamedReference`]. @@ -304,7 +304,7 @@ pub struct CapturingGroup<'a> { /// e.g. `(?:...)` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub struct IgnoreGroup<'a> { pub span: Span, pub modifiers: Option, @@ -315,7 +315,7 @@ pub struct IgnoreGroup<'a> { /// e.g. `i` in `(?i:...)`, `-s` in `(?-s:...)` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub struct Modifiers { pub span: Span, pub enabling: Option, @@ -325,7 +325,7 @@ pub struct Modifiers { /// Each part of modifier in [`Modifiers`]. #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub struct Modifier { pub ignore_case: bool, pub multiline: bool, @@ -336,7 +336,7 @@ pub struct Modifier { /// e.g. `\1`, `\2`, `\3` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub struct IndexedReference { pub span: Span, pub index: u32, @@ -346,7 +346,7 @@ pub struct IndexedReference { /// e.g. `\k` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub struct NamedReference<'a> { pub span: Span, pub name: Atom<'a>, diff --git a/crates/oxc_span/src/atom.rs b/crates/oxc_span/src/atom.rs index 8896dbeb2d948..870164d972087 100644 --- a/crates/oxc_span/src/atom.rs +++ b/crates/oxc_span/src/atom.rs @@ -8,7 +8,7 @@ use oxc_allocator::{Allocator, CloneIn, FromIn}; #[cfg(feature = "serialize")] use serde::Serialize; -use crate::{cmp::ContentEq, hash::ContentHash, CompactStr}; +use crate::{cmp::ContentEq, CompactStr}; /// An inlinable string for oxc_allocator. /// @@ -196,12 +196,6 @@ impl ContentEq for Atom<'_> { } } -impl ContentHash for Atom<'_> { - fn content_hash(&self, state: &mut H) { - hash::Hash::hash(self, state); - } -} - impl hash::Hash for Atom<'_> { fn hash(&self, hasher: &mut H) { self.as_str().hash(hasher); diff --git a/crates/oxc_span/src/hash.rs b/crates/oxc_span/src/hash.rs deleted file mode 100644 index 4e51f206c539c..0000000000000 --- a/crates/oxc_span/src/hash.rs +++ /dev/null @@ -1,78 +0,0 @@ -//! Specialized hashing traits -use std::{ - hash::{Hash, Hasher}, - mem::{discriminant, Discriminant}, -}; - -/// This trait works similarly to [std::hash::Hash] but it gives the liberty of hashing -/// the object's content loosely. This would mean the implementor can skip some parts of -/// the content while calculating the hash. -/// -/// As an example, In AST types we ignore fields such as [crate::Span]. -pub trait ContentHash { - /// Hash an AST node based on its content alone. - /// - /// This hash ignores node location, but respects precedence and ordering. - fn content_hash(&self, state: &mut H); -} - -/// Short-Circuting implementation for [Discriminant] since it is used to hash enums. -impl ContentHash for Discriminant { - fn content_hash(&self, state: &mut H) { - Hash::hash(self, state); - } -} - -impl ContentHash for Option { - fn content_hash(&self, state: &mut H) { - ContentHash::content_hash(&discriminant(self), state); - if let Some(it) = self { - ContentHash::content_hash(it, state); - } - } -} - -impl ContentHash for oxc_allocator::Box<'_, T> { - fn content_hash(&self, state: &mut H) { - ContentHash::content_hash(self.as_ref(), state); - } -} - -impl ContentHash for oxc_allocator::Vec<'_, T> { - fn content_hash(&self, state: &mut H) { - for piece in self { - piece.content_hash(state); - } - } -} - -impl ContentHash for [T] { - fn content_hash(&self, state: &mut H) { - for piece in self { - piece.content_hash(state); - } - } -} - -mod auto_impl_content_hash { - use super::ContentHash; - - macro_rules! impl_content_hash { - ($($t:ty)*) => { - $( - impl ContentHash for $t { - fn content_hash(&self, state: &mut H) { - std::hash::Hash::hash(self, state); - } - } - )* - }; - } - - impl_content_hash! { - char &str - bool isize usize - u8 u16 u32 u64 u128 - i8 i16 i32 i64 i128 - } -} diff --git a/crates/oxc_span/src/lib.rs b/crates/oxc_span/src/lib.rs index 2ad1c4dddd941..9198672c01d54 100644 --- a/crates/oxc_span/src/lib.rs +++ b/crates/oxc_span/src/lib.rs @@ -10,7 +10,6 @@ mod source_type; mod span; pub mod cmp; -pub mod hash; pub use crate::{ atom::Atom, diff --git a/crates/oxc_span/src/source_type/mod.rs b/crates/oxc_span/src/source_type/mod.rs index ee22fd1fa72a7..11e67ce9d8d35 100644 --- a/crates/oxc_span/src/source_type/mod.rs +++ b/crates/oxc_span/src/source_type/mod.rs @@ -4,7 +4,7 @@ use oxc_allocator::{Allocator, CloneIn}; use oxc_ast_macros::ast; use oxc_estree::ESTree; -use crate::{cmp::ContentEq, hash::ContentHash}; +use crate::cmp::ContentEq; mod error; pub use error::UnknownExtension; @@ -96,13 +96,6 @@ impl ContentEq for SourceType { } } -impl ContentHash for SourceType { - #[inline] - fn content_hash(&self, state: &mut H) { - self.hash(state); - } -} - /// Valid file extensions pub const VALID_EXTENSIONS: [&str; 8] = ["js", "mjs", "cjs", "jsx", "ts", "mts", "cts", "tsx"]; diff --git a/crates/oxc_span/src/span/types.rs b/crates/oxc_span/src/span/types.rs index a9f0e106426f0..9260b9f45d8e2 100644 --- a/crates/oxc_span/src/span/types.rs +++ b/crates/oxc_span/src/span/types.rs @@ -45,10 +45,10 @@ use oxc_estree::ESTree; /// assert_eq!(s.expand(5), s.expand_left(5).expand_right(5)); /// ``` /// -/// ## Hashing -/// [`Span`] has a normal implementation of [`Hash`]. If you want to compare two +/// ## Comparison +/// [`Span`] has a normal implementation of [`PartialEq`]. If you want to compare two /// AST nodes without considering their locations (e.g. to see if they have the -/// same content), use [`ContentHash`](crate::hash::ContentHash) instead. +/// same content), use [`ContentEq`](crate::cmp::ContentEq) instead. /// /// ## Implementation Notes /// See the [`text-size`](https://docs.rs/text-size) crate for details. diff --git a/crates/oxc_syntax/src/number.rs b/crates/oxc_syntax/src/number.rs index 3bbe84089d192..e7d8811614aaf 100644 --- a/crates/oxc_syntax/src/number.rs +++ b/crates/oxc_syntax/src/number.rs @@ -1,11 +1,11 @@ #![allow(missing_docs)] // fixme use oxc_allocator::CloneIn; use oxc_ast_macros::ast; -use oxc_span::{cmp::ContentEq, hash::ContentHash}; +use oxc_span::cmp::ContentEq; #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] +#[generate_derive(CloneIn, ContentEq)] pub enum NumberBase { Float = 0, Decimal = 1, @@ -22,7 +22,7 @@ impl NumberBase { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] +#[generate_derive(CloneIn, ContentEq)] pub enum BigintBase { Decimal = 0, Binary = 1, diff --git a/crates/oxc_syntax/src/operator.rs b/crates/oxc_syntax/src/operator.rs index 264745ffe1f6d..c50f171c521d6 100644 --- a/crates/oxc_syntax/src/operator.rs +++ b/crates/oxc_syntax/src/operator.rs @@ -5,7 +5,7 @@ use oxc_allocator::CloneIn; use oxc_ast_macros::ast; use oxc_estree::ESTree; -use oxc_span::{cmp::ContentEq, hash::ContentHash}; +use oxc_span::cmp::ContentEq; use crate::precedence::{GetPrecedence, Precedence}; @@ -15,7 +15,7 @@ use crate::precedence::{GetPrecedence, Precedence}; /// - [13.15 Assignment Operators](https://tc39.es/ecma262/#sec-assignment-operators) #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub enum AssignmentOperator { /// `=` #[estree(rename = "=")] @@ -159,7 +159,7 @@ impl AssignmentOperator { /// - [12.10 Binary Logical Operators](https://tc39.es/ecma262/#sec-binary-logical-operators) #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub enum BinaryOperator { /// `==` #[estree(rename = "==")] @@ -416,7 +416,7 @@ impl GetPrecedence for BinaryOperator { /// Logical binary operators #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub enum LogicalOperator { /// `||` #[estree(rename = "||")] @@ -478,7 +478,7 @@ impl GetPrecedence for LogicalOperator { /// - [12.5 Unary Operators](https://tc39.es/ecma262/#sec-unary-operators) #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub enum UnaryOperator { /// `+` #[estree(rename = "+")] @@ -558,7 +558,7 @@ impl UnaryOperator { /// Unary update operators. #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[generate_derive(CloneIn, ContentEq, ESTree)] pub enum UpdateOperator { /// `++` #[estree(rename = "++")]