feat(ast, span, syntax, regular_expression)!: remove ContentHash (#8512)

#8483 removed codegen-ed impls of `ContentHash` for AST nodes, because `ContentHash` is not useful. Complete the removal by removing `ContentHash` trait definition, and all remaining references to it.
This commit is contained in:
overlookmotel 2025-01-15 15:01:14 +00:00
parent cfd783aa19
commit 7066d1cc4f
15 changed files with 294 additions and 454 deletions

View file

@ -1,11 +1,11 @@
#![warn(missing_docs)] #![warn(missing_docs)]
use oxc_allocator::CloneIn; use oxc_allocator::CloneIn;
use oxc_ast_macros::ast; 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. /// Indicates a line or block comment.
#[ast] #[ast]
#[generate_derive(CloneIn, ContentEq, ContentHash)] #[generate_derive(CloneIn, ContentEq)]
#[derive(Debug, Default, Clone, Copy, Eq, PartialEq)] #[derive(Debug, Default, Clone, Copy, Eq, PartialEq)]
pub enum CommentKind { pub enum CommentKind {
/// Line comment /// Line comment
@ -17,7 +17,7 @@ pub enum CommentKind {
/// Information about a comment's position relative to a token. /// Information about a comment's position relative to a token.
#[ast] #[ast]
#[generate_derive(CloneIn, ContentEq, ContentHash)] #[generate_derive(CloneIn, ContentEq)]
#[derive(Debug, Default, Clone, Copy, Eq, PartialEq)] #[derive(Debug, Default, Clone, Copy, Eq, PartialEq)]
pub enum CommentPosition { pub enum CommentPosition {
/// Comments prior to a token until another token or trailing comment. /// Comments prior to a token until another token or trailing comment.
@ -40,7 +40,7 @@ pub enum CommentPosition {
/// A comment in source code. /// A comment in source code.
#[ast] #[ast]
#[generate_derive(CloneIn, ContentEq, ContentHash)] #[generate_derive(CloneIn, ContentEq)]
#[derive(Debug, Default, Clone, Copy, Eq, PartialEq)] #[derive(Debug, Default, Clone, Copy, Eq, PartialEq)]
pub struct Comment { pub struct Comment {
/// The span of the comment text, with leading and trailing delimiters. /// The span of the comment text, with leading and trailing delimiters.

File diff suppressed because it is too large Load diff

View file

@ -7,7 +7,7 @@
use oxc_allocator::{Box, CloneIn, GetAddress, Vec}; use oxc_allocator::{Box, CloneIn, GetAddress, Vec};
use oxc_ast_macros::ast; use oxc_ast_macros::ast;
use oxc_estree::ESTree; 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::*}; 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/) /// See: [JSX Syntax](https://facebook.github.io/jsx/)
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct JSXElement<'a> { pub struct JSXElement<'a> {
/// Node location in source code /// Node location in source code
pub span: Span, pub span: Span,
@ -61,7 +61,7 @@ pub struct JSXElement<'a> {
/// ``` /// ```
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct JSXOpeningElement<'a> { pub struct JSXOpeningElement<'a> {
/// Node location in source code /// Node location in source code
pub span: Span, pub span: Span,
@ -95,7 +95,7 @@ pub struct JSXOpeningElement<'a> {
/// ``` /// ```
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct JSXClosingElement<'a> { pub struct JSXClosingElement<'a> {
/// Node location in source code /// Node location in source code
pub span: Span, pub span: Span,
@ -113,7 +113,7 @@ pub struct JSXClosingElement<'a> {
/// See: [`React.Fragment`](https://react.dev/reference/react/Fragment) /// See: [`React.Fragment`](https://react.dev/reference/react/Fragment)
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct JSXFragment<'a> { pub struct JSXFragment<'a> {
/// Node location in source code /// Node location in source code
pub span: Span, pub span: Span,
@ -128,7 +128,7 @@ pub struct JSXFragment<'a> {
/// JSX Opening Fragment (`<>`) /// JSX Opening Fragment (`<>`)
#[ast] #[ast]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct JSXOpeningFragment { pub struct JSXOpeningFragment {
/// Node location in source code /// Node location in source code
pub span: Span, pub span: Span,
@ -137,7 +137,7 @@ pub struct JSXOpeningFragment {
/// JSX Closing Fragment (`</>`) /// JSX Closing Fragment (`</>`)
#[ast] #[ast]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct JSXClosingFragment { pub struct JSXClosingFragment {
/// Node location in source code /// Node location in source code
pub span: Span, pub span: Span,
@ -146,7 +146,7 @@ pub struct JSXClosingFragment {
/// JSX Element Name /// JSX Element Name
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq)]
pub enum JSXElementName<'a> { pub enum JSXElementName<'a> {
/// `<div />` /// `<div />`
Identifier(Box<'a, JSXIdentifier<'a>>) = 0, Identifier(Box<'a, JSXIdentifier<'a>>) = 0,
@ -169,7 +169,7 @@ pub enum JSXElementName<'a> {
/// ``` /// ```
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct JSXNamespacedName<'a> { pub struct JSXNamespacedName<'a> {
/// Node location in source code /// Node location in source code
pub span: Span, pub span: Span,
@ -196,7 +196,7 @@ pub struct JSXNamespacedName<'a> {
/// [`member expression`]: JSXMemberExpressionObject::MemberExpression /// [`member expression`]: JSXMemberExpressionObject::MemberExpression
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct JSXMemberExpression<'a> { pub struct JSXMemberExpression<'a> {
/// Node location in source code /// Node location in source code
pub span: Span, pub span: Span,
@ -224,7 +224,7 @@ pub struct JSXMemberExpression<'a> {
/// ``` /// ```
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq)]
pub enum JSXMemberExpressionObject<'a> { pub enum JSXMemberExpressionObject<'a> {
/// `<Apple.Orange />` /// `<Apple.Orange />`
IdentifierReference(Box<'a, IdentifierReference<'a>>) = 0, IdentifierReference(Box<'a, IdentifierReference<'a>>) = 0,
@ -249,7 +249,7 @@ pub enum JSXMemberExpressionObject<'a> {
/// ``` /// ```
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct JSXExpressionContainer<'a> { pub struct JSXExpressionContainer<'a> {
/// Node location in source code /// Node location in source code
pub span: Span, pub span: Span,
@ -266,7 +266,7 @@ inherit_variants! {
/// [`ast` module docs]: `super` /// [`ast` module docs]: `super`
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub enum JSXExpression<'a> { pub enum JSXExpression<'a> {
/// An empty expression /// An empty expression
/// ///
@ -284,7 +284,7 @@ pub enum JSXExpression<'a> {
/// An empty JSX expression (`{}`) /// An empty JSX expression (`{}`)
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct JSXEmptyExpression { pub struct JSXEmptyExpression {
/// Node location in source code /// Node location in source code
pub span: Span, pub span: Span,
@ -303,7 +303,7 @@ pub struct JSXEmptyExpression {
/// ``` /// ```
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
pub enum JSXAttributeItem<'a> { pub enum JSXAttributeItem<'a> {
/// A `key="value"` attribute /// A `key="value"` attribute
Attribute(Box<'a, JSXAttribute<'a>>) = 0, Attribute(Box<'a, JSXAttribute<'a>>) = 0,
@ -324,7 +324,7 @@ pub enum JSXAttributeItem<'a> {
/// // name ^^^ ^^^^ value /// // name ^^^ ^^^^ value
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct JSXAttribute<'a> { pub struct JSXAttribute<'a> {
/// Node location in source code /// Node location in source code
pub span: Span, pub span: Span,
@ -345,7 +345,7 @@ pub struct JSXAttribute<'a> {
/// ``` /// ```
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct JSXSpreadAttribute<'a> { pub struct JSXSpreadAttribute<'a> {
/// Node location in source code /// Node location in source code
pub span: Span, pub span: Span,
@ -370,7 +370,7 @@ pub struct JSXSpreadAttribute<'a> {
/// ``` /// ```
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
pub enum JSXAttributeName<'a> { pub enum JSXAttributeName<'a> {
/// An attribute name without a namespace prefix, e.g. `foo` in `foo="bar"`. /// An attribute name without a namespace prefix, e.g. `foo` in `foo="bar"`.
Identifier(Box<'a, JSXIdentifier<'a>>) = 0, Identifier(Box<'a, JSXIdentifier<'a>>) = 0,
@ -398,7 +398,7 @@ pub enum JSXAttributeName<'a> {
/// ``` /// ```
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
pub enum JSXAttributeValue<'a> { pub enum JSXAttributeValue<'a> {
/// `<Component foo="bar" />` /// `<Component foo="bar" />`
StringLiteral(Box<'a, StringLiteral<'a>>) = 0, StringLiteral(Box<'a, StringLiteral<'a>>) = 0,
@ -417,7 +417,7 @@ pub enum JSXAttributeValue<'a> {
/// [`IdentifierName`]: super::IdentifierName /// [`IdentifierName`]: super::IdentifierName
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct JSXIdentifier<'a> { pub struct JSXIdentifier<'a> {
/// Node location in source code /// Node location in source code
pub span: Span, pub span: Span,
@ -432,7 +432,7 @@ pub struct JSXIdentifier<'a> {
/// Part of a [`JSXElement`]. /// Part of a [`JSXElement`].
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
pub enum JSXChild<'a> { pub enum JSXChild<'a> {
/// `<Foo>Some Text</Foo>` /// `<Foo>Some Text</Foo>`
Text(Box<'a, JSXText<'a>>) = 0, Text(Box<'a, JSXText<'a>>) = 0,
@ -451,7 +451,7 @@ pub enum JSXChild<'a> {
/// Variant of [`JSXChild`] that represents an object spread (`{...expression}`). /// Variant of [`JSXChild`] that represents an object spread (`{...expression}`).
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct JSXSpreadChild<'a> { pub struct JSXSpreadChild<'a> {
/// Node location in source code /// Node location in source code
pub span: Span, pub span: Span,
@ -471,7 +471,7 @@ pub struct JSXSpreadChild<'a> {
/// ``` /// ```
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct JSXText<'a> { pub struct JSXText<'a> {
/// Node location in source code /// Node location in source code
pub span: Span, pub span: Span,

View file

@ -11,7 +11,7 @@ use oxc_allocator::{Box, CloneIn};
use oxc_ast_macros::ast; use oxc_ast_macros::ast;
use oxc_estree::ESTree; use oxc_estree::ESTree;
use oxc_regular_expression::ast::Pattern; 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}; use oxc_syntax::number::{BigintBase, NumberBase};
/// Boolean literal /// Boolean literal
@ -19,7 +19,7 @@ use oxc_syntax::number::{BigintBase, NumberBase};
/// <https://tc39.es/ecma262/#prod-BooleanLiteral> /// <https://tc39.es/ecma262/#prod-BooleanLiteral>
#[ast(visit)] #[ast(visit)]
#[derive(Debug, Clone)] #[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")] #[estree(type = "Literal", via = crate::serialize::ESTreeLiteral, add_ts = "raw: string | null")]
pub struct BooleanLiteral { pub struct BooleanLiteral {
/// Node location in source code /// Node location in source code
@ -33,7 +33,7 @@ pub struct BooleanLiteral {
/// <https://tc39.es/ecma262/#sec-null-literals> /// <https://tc39.es/ecma262/#sec-null-literals>
#[ast(visit)] #[ast(visit)]
#[derive(Debug, Clone)] #[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")] #[estree(type = "Literal", via = crate::serialize::ESTreeLiteral, add_ts = "value: null, raw: \"null\" | null")]
pub struct NullLiteral { pub struct NullLiteral {
/// Node location in source code /// Node location in source code
@ -127,7 +127,7 @@ pub struct RegExpLiteral<'a> {
/// <https://tc39.es/ecma262/multipage/text-processing.html#sec-regexp-regular-expression-objects> /// <https://tc39.es/ecma262/multipage/text-processing.html#sec-regexp-regular-expression-objects>
#[ast] #[ast]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
#[estree(no_type)] #[estree(no_type)]
pub struct RegExp<'a> { pub struct RegExp<'a> {
/// The regex pattern between the slashes /// The regex pattern between the slashes

View file

@ -13,7 +13,7 @@ use std::cell::Cell;
use oxc_allocator::{Box, CloneIn, GetAddress, Vec}; use oxc_allocator::{Box, CloneIn, GetAddress, Vec};
use oxc_ast_macros::ast; use oxc_ast_macros::ast;
use oxc_estree::ESTree; 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 oxc_syntax::scope::ScopeId;
use super::{inherit_variants, js::*, literal::*}; 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) /// * [TypeScript Handbook - `this` parameters](https://www.typescriptlang.org/docs/handbook/2/functions.html#this-parameters)
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSThisParameter<'a> { pub struct TSThisParameter<'a> {
pub span: Span, pub span: Span,
#[estree(skip)] #[estree(skip)]
@ -62,7 +62,7 @@ pub struct TSThisParameter<'a> {
#[ast(visit)] #[ast(visit)]
#[scope] #[scope]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSEnumDeclaration<'a> { pub struct TSEnumDeclaration<'a> {
pub span: Span, pub span: Span,
pub id: BindingIdentifier<'a>, pub id: BindingIdentifier<'a>,
@ -95,7 +95,7 @@ pub struct TSEnumDeclaration<'a> {
/// * [TypeScript Handbook - Enums](https://www.typescriptlang.org/docs/handbook/enums.html) /// * [TypeScript Handbook - Enums](https://www.typescriptlang.org/docs/handbook/enums.html)
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSEnumMember<'a> { pub struct TSEnumMember<'a> {
pub span: Span, pub span: Span,
pub id: TSEnumMemberName<'a>, pub id: TSEnumMemberName<'a>,
@ -105,7 +105,7 @@ pub struct TSEnumMember<'a> {
/// TS Enum Member Name /// TS Enum Member Name
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
pub enum TSEnumMemberName<'a> { pub enum TSEnumMemberName<'a> {
Identifier(Box<'a, IdentifierName<'a>>) = 0, Identifier(Box<'a, IdentifierName<'a>>) = 0,
String(Box<'a, StringLiteral<'a>>) = 1, String(Box<'a, StringLiteral<'a>>) = 1,
@ -125,7 +125,7 @@ pub enum TSEnumMemberName<'a> {
/// ``` /// ```
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSTypeAnnotation<'a> { pub struct TSTypeAnnotation<'a> {
/// starts at the `:` token and ends at the end of the type annotation /// starts at the `:` token and ends at the end of the type annotation
pub span: Span, pub span: Span,
@ -149,7 +149,7 @@ pub struct TSTypeAnnotation<'a> {
/// ``` /// ```
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSLiteralType<'a> { pub struct TSLiteralType<'a> {
pub span: Span, pub span: Span,
pub literal: TSLiteral<'a>, pub literal: TSLiteral<'a>,
@ -158,7 +158,7 @@ pub struct TSLiteralType<'a> {
/// A literal in a [`TSLiteralType`]. /// A literal in a [`TSLiteralType`].
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
pub enum TSLiteral<'a> { pub enum TSLiteral<'a> {
BooleanLiteral(Box<'a, BooleanLiteral>) = 0, BooleanLiteral(Box<'a, BooleanLiteral>) = 0,
NullLiteral(Box<'a, NullLiteral>) = 1, NullLiteral(Box<'a, NullLiteral>) = 1,
@ -183,7 +183,7 @@ pub enum TSLiteral<'a> {
/// ``` /// ```
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
pub enum TSType<'a> { pub enum TSType<'a> {
// Keyword // Keyword
TSAnyKeyword(Box<'a, TSAnyKeyword>) = 0, TSAnyKeyword(Box<'a, TSAnyKeyword>) = 0,
@ -290,7 +290,7 @@ pub use match_ts_type;
#[ast(visit)] #[ast(visit)]
#[scope] #[scope]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSConditionalType<'a> { pub struct TSConditionalType<'a> {
pub span: Span, pub span: Span,
/// The type before `extends` in the test expression. /// 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) /// * [TypeScript Handbook - Union Types](https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes-func.html#unions)
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSUnionType<'a> { pub struct TSUnionType<'a> {
pub span: Span, pub span: Span,
/// The types in the union. /// 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) /// * [TypeScript Handbook - Intersection Types](https://www.typescriptlang.org/docs/handbook/2/objects.html#intersection-types)
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSIntersectionType<'a> { pub struct TSIntersectionType<'a> {
pub span: Span, pub span: Span,
pub types: Vec<'a, TSType<'a>>, pub types: Vec<'a, TSType<'a>>,
@ -358,7 +358,7 @@ pub struct TSIntersectionType<'a> {
/// ``` /// ```
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSParenthesizedType<'a> { pub struct TSParenthesizedType<'a> {
pub span: Span, pub span: Span,
pub type_annotation: TSType<'a>, 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) /// * [TypeScript Handbook - Keyof Types](https://www.typescriptlang.org/docs/handbook/2/keyof-types.html)
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSTypeOperator<'a> { pub struct TSTypeOperator<'a> {
pub span: Span, pub span: Span,
pub operator: TSTypeOperatorOperator, pub operator: TSTypeOperatorOperator,
@ -386,7 +386,7 @@ pub struct TSTypeOperator<'a> {
/// Operator in a [`TSTypeOperator`]. /// Operator in a [`TSTypeOperator`].
#[ast] #[ast]
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub enum TSTypeOperatorOperator { pub enum TSTypeOperatorOperator {
Keyof = 0, Keyof = 0,
Unique = 1, Unique = 1,
@ -406,7 +406,7 @@ pub enum TSTypeOperatorOperator {
/// <https://www.typescriptlang.org/docs/handbook/2/objects.html#the-array-type> /// <https://www.typescriptlang.org/docs/handbook/2/objects.html#the-array-type>
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSArrayType<'a> { pub struct TSArrayType<'a> {
pub span: Span, pub span: Span,
pub element_type: TSType<'a>, pub element_type: TSType<'a>,
@ -425,7 +425,7 @@ pub struct TSArrayType<'a> {
/// <https://www.typescriptlang.org/docs/handbook/2/indexed-access-types.html#handbook-content> /// <https://www.typescriptlang.org/docs/handbook/2/indexed-access-types.html#handbook-content>
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSIndexedAccessType<'a> { pub struct TSIndexedAccessType<'a> {
pub span: Span, pub span: Span,
pub object_type: TSType<'a>, pub object_type: TSType<'a>,
@ -443,7 +443,7 @@ pub struct TSIndexedAccessType<'a> {
/// <https://www.typescriptlang.org/docs/handbook/2/objects.html#tuple-types> /// <https://www.typescriptlang.org/docs/handbook/2/objects.html#tuple-types>
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSTupleType<'a> { pub struct TSTupleType<'a> {
pub span: Span, pub span: Span,
pub element_types: Vec<'a, TSTupleElement<'a>>, 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) /// * [TypeScript Handbook - Tuple Types](https://www.typescriptlang.org/docs/handbook/2/objects.html#tuple-types)
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSNamedTupleMember<'a> { pub struct TSNamedTupleMember<'a> {
pub span: Span, pub span: Span,
pub element_type: TSTupleElement<'a>, pub element_type: TSTupleElement<'a>,
@ -480,7 +480,7 @@ pub struct TSNamedTupleMember<'a> {
/// ``` /// ```
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSOptionalType<'a> { pub struct TSOptionalType<'a> {
pub span: Span, pub span: Span,
pub type_annotation: TSType<'a>, pub type_annotation: TSType<'a>,
@ -496,7 +496,7 @@ pub struct TSOptionalType<'a> {
/// ``` /// ```
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSRestType<'a> { pub struct TSRestType<'a> {
pub span: Span, pub span: Span,
pub type_annotation: TSType<'a>, pub type_annotation: TSType<'a>,
@ -512,7 +512,7 @@ inherit_variants! {
/// [`ast` module docs]: `super` /// [`ast` module docs]: `super`
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
pub enum TSTupleElement<'a> { pub enum TSTupleElement<'a> {
// Discriminants start at 64, so that `TSTupleElement::is_ts_type` is a single // Discriminants start at 64, so that `TSTupleElement::is_ts_type` is a single
// bitwise AND operation on the discriminant (`discriminant & 63 != 0`). // 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) /// * [TypeScript Handbook - Any Type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#any)
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSAnyKeyword { pub struct TSAnyKeyword {
pub span: Span, 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) /// * [TypeScript Handbook - Everyday Types](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#the-primitives-string-number-and-boolean)
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSStringKeyword { pub struct TSStringKeyword {
pub span: Span, 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) /// * [TypeScript Handbook - Everyday Types](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#the-primitives-string-number-and-boolean)
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSBooleanKeyword { pub struct TSBooleanKeyword {
pub span: Span, 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) /// * [TypeScript Handbook - Everyday Types](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#the-primitives-string-number-and-boolean)
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSNumberKeyword { pub struct TSNumberKeyword {
pub span: Span, 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) /// * [TypeScript Handbook - Advanced Topics](https://www.typescriptlang.org/docs/handbook/type-compatibility.html#advanced-topics)
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSNeverKeyword { pub struct TSNeverKeyword {
pub span: Span, pub span: Span,
} }
@ -616,7 +616,7 @@ pub struct TSNeverKeyword {
/// * [microsoft/TypeScript #40580](https://github.com/microsoft/TypeScript/pull/40580) /// * [microsoft/TypeScript #40580](https://github.com/microsoft/TypeScript/pull/40580)
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSIntrinsicKeyword { pub struct TSIntrinsicKeyword {
pub span: Span, 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) /// * [TypeScript Handbook - Advanced Topics](https://www.typescriptlang.org/docs/handbook/type-compatibility.html#advanced-topics)
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSUnknownKeyword { pub struct TSUnknownKeyword {
pub span: Span, 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) /// * [TypeScript Handbook - Everyday Types](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#null-and-undefined)
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSNullKeyword { pub struct TSNullKeyword {
pub span: Span, 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) /// * [TypeScript Handbook - Everyday Types](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#null-and-undefined)
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSUndefinedKeyword { pub struct TSUndefinedKeyword {
pub span: Span, pub span: Span,
} }
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSVoidKeyword { pub struct TSVoidKeyword {
pub span: Span, pub span: Span,
} }
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSSymbolKeyword { pub struct TSSymbolKeyword {
pub span: Span, pub span: Span,
} }
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSThisType { pub struct TSThisType {
pub span: Span, pub span: Span,
} }
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSObjectKeyword { pub struct TSObjectKeyword {
pub span: Span, pub span: Span,
} }
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSBigIntKeyword { pub struct TSBigIntKeyword {
pub span: Span, pub span: Span,
} }
@ -720,7 +720,7 @@ pub struct TSBigIntKeyword {
/// ``` /// ```
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSTypeReference<'a> { pub struct TSTypeReference<'a> {
pub span: Span, pub span: Span,
pub type_name: TSTypeName<'a>, pub type_name: TSTypeName<'a>,
@ -732,7 +732,7 @@ pub struct TSTypeReference<'a> {
/// NamespaceName.IdentifierReference /// NamespaceName.IdentifierReference
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
pub enum TSTypeName<'a> { pub enum TSTypeName<'a> {
IdentifierReference(Box<'a, IdentifierReference<'a>>) = 0, IdentifierReference(Box<'a, IdentifierReference<'a>>) = 0,
QualifiedName(Box<'a, TSQualifiedName<'a>>) = 1, QualifiedName(Box<'a, TSQualifiedName<'a>>) = 1,
@ -757,7 +757,7 @@ pub use match_ts_type_name;
/// ``` /// ```
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSQualifiedName<'a> { pub struct TSQualifiedName<'a> {
pub span: Span, pub span: Span,
pub left: TSTypeName<'a>, pub left: TSTypeName<'a>,
@ -766,7 +766,7 @@ pub struct TSQualifiedName<'a> {
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSTypeParameterInstantiation<'a> { pub struct TSTypeParameterInstantiation<'a> {
pub span: Span, pub span: Span,
pub params: Vec<'a, TSType<'a>>, 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) /// * [TypeScript Handbook - Variance Annotations](https://www.typescriptlang.org/docs/handbook/2/generics.html#variance-annotations)
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSTypeParameter<'a> { pub struct TSTypeParameter<'a> {
pub span: Span, pub span: Span,
/// The name of the parameter, e.g. `T` in `type Foo<T> = ...`. /// The name of the parameter, e.g. `T` in `type Foo<T> = ...`.
@ -810,7 +810,7 @@ pub struct TSTypeParameter<'a> {
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSTypeParameterDeclaration<'a> { pub struct TSTypeParameterDeclaration<'a> {
pub span: Span, pub span: Span,
pub params: Vec<'a, TSTypeParameter<'a>>, pub params: Vec<'a, TSTypeParameter<'a>>,
@ -827,7 +827,7 @@ pub struct TSTypeParameterDeclaration<'a> {
#[ast(visit)] #[ast(visit)]
#[scope] #[scope]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSTypeAliasDeclaration<'a> { pub struct TSTypeAliasDeclaration<'a> {
pub span: Span, pub span: Span,
/// Type alias's identifier, e.g. `Foo` in `type Foo = number`. /// Type alias's identifier, e.g. `Foo` in `type Foo = number`.
@ -843,7 +843,7 @@ pub struct TSTypeAliasDeclaration<'a> {
#[ast] #[ast]
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub enum TSAccessibility { pub enum TSAccessibility {
Private = 0, Private = 0,
Protected = 1, Protected = 1,
@ -862,7 +862,7 @@ pub enum TSAccessibility {
/// ``` /// ```
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSClassImplements<'a> { pub struct TSClassImplements<'a> {
pub span: Span, pub span: Span,
pub expression: TSTypeName<'a>, pub expression: TSTypeName<'a>,
@ -887,7 +887,7 @@ pub struct TSClassImplements<'a> {
#[ast(visit)] #[ast(visit)]
#[scope] #[scope]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSInterfaceDeclaration<'a> { pub struct TSInterfaceDeclaration<'a> {
pub span: Span, pub span: Span,
/// The identifier (name) of the interface. /// The identifier (name) of the interface.
@ -908,7 +908,7 @@ pub struct TSInterfaceDeclaration<'a> {
/// Body of a [`TSInterfaceDeclaration`]. /// Body of a [`TSInterfaceDeclaration`].
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSInterfaceBody<'a> { pub struct TSInterfaceBody<'a> {
pub span: Span, pub span: Span,
pub body: Vec<'a, TSSignature<'a>>, pub body: Vec<'a, TSSignature<'a>>,
@ -931,7 +931,7 @@ pub struct TSInterfaceBody<'a> {
/// ``` /// ```
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSPropertySignature<'a> { pub struct TSPropertySignature<'a> {
pub span: Span, pub span: Span,
pub computed: bool, pub computed: bool,
@ -943,7 +943,7 @@ pub struct TSPropertySignature<'a> {
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
pub enum TSSignature<'a> { pub enum TSSignature<'a> {
TSIndexSignature(Box<'a, TSIndexSignature<'a>>) = 0, TSIndexSignature(Box<'a, TSIndexSignature<'a>>) = 0,
TSPropertySignature(Box<'a, TSPropertySignature<'a>>) = 1, TSPropertySignature(Box<'a, TSPropertySignature<'a>>) = 1,
@ -965,7 +965,7 @@ pub enum TSSignature<'a> {
/// ``` /// ```
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSIndexSignature<'a> { pub struct TSIndexSignature<'a> {
pub span: Span, pub span: Span,
pub parameters: Vec<'a, TSIndexSignatureName<'a>>, pub parameters: Vec<'a, TSIndexSignatureName<'a>>,
@ -976,7 +976,7 @@ pub struct TSIndexSignature<'a> {
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSCallSignatureDeclaration<'a> { pub struct TSCallSignatureDeclaration<'a> {
pub span: Span, pub span: Span,
pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>, pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
@ -987,7 +987,7 @@ pub struct TSCallSignatureDeclaration<'a> {
#[ast] #[ast]
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub enum TSMethodSignatureKind { pub enum TSMethodSignatureKind {
Method = 0, Method = 0,
Get = 1, Get = 1,
@ -1008,7 +1008,7 @@ pub enum TSMethodSignatureKind {
#[ast(visit)] #[ast(visit)]
#[scope] #[scope]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSMethodSignature<'a> { pub struct TSMethodSignature<'a> {
pub span: Span, pub span: Span,
pub key: PropertyKey<'a>, pub key: PropertyKey<'a>,
@ -1028,7 +1028,7 @@ pub struct TSMethodSignature<'a> {
#[ast(visit)] #[ast(visit)]
#[scope] #[scope]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSConstructSignatureDeclaration<'a> { pub struct TSConstructSignatureDeclaration<'a> {
pub span: Span, pub span: Span,
pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>, pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
@ -1041,7 +1041,7 @@ pub struct TSConstructSignatureDeclaration<'a> {
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
#[estree(type = "Identifier")] #[estree(type = "Identifier")]
pub struct TSIndexSignatureName<'a> { pub struct TSIndexSignatureName<'a> {
pub span: Span, pub span: Span,
@ -1051,7 +1051,7 @@ pub struct TSIndexSignatureName<'a> {
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSInterfaceHeritage<'a> { pub struct TSInterfaceHeritage<'a> {
pub span: Span, pub span: Span,
pub expression: Expression<'a>, 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) /// * [TypeScript Handbook - Assertion Functions](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions)
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSTypePredicate<'a> { pub struct TSTypePredicate<'a> {
pub span: Span, pub span: Span,
/// The identifier the predicate operates on /// The identifier the predicate operates on
@ -1097,7 +1097,7 @@ pub struct TSTypePredicate<'a> {
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub enum TSTypePredicateName<'a> { pub enum TSTypePredicateName<'a> {
Identifier(Box<'a, IdentifierName<'a>>) = 0, Identifier(Box<'a, IdentifierName<'a>>) = 0,
This(TSThisType) = 1, 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)), strict_if(self.body.as_ref().is_some_and(TSModuleDeclarationBody::has_use_strict_directive)),
)] )]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSModuleDeclaration<'a> { pub struct TSModuleDeclaration<'a> {
pub span: Span, pub span: Span,
/// The name of the module/namespace being declared. /// The name of the module/namespace being declared.
@ -1166,7 +1166,7 @@ pub struct TSModuleDeclaration<'a> {
#[ast] #[ast]
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub enum TSModuleDeclarationKind { pub enum TSModuleDeclarationKind {
/// `declare global {}` /// `declare global {}`
Global = 0, Global = 0,
@ -1198,7 +1198,7 @@ pub enum TSModuleDeclarationKind {
/// ``` /// ```
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub enum TSModuleDeclarationName<'a> { pub enum TSModuleDeclarationName<'a> {
Identifier(BindingIdentifier<'a>) = 0, Identifier(BindingIdentifier<'a>) = 0,
StringLiteral(StringLiteral<'a>) = 1, StringLiteral(StringLiteral<'a>) = 1,
@ -1206,7 +1206,7 @@ pub enum TSModuleDeclarationName<'a> {
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
pub enum TSModuleDeclarationBody<'a> { pub enum TSModuleDeclarationBody<'a> {
TSModuleDeclaration(Box<'a, TSModuleDeclaration<'a>>) = 0, TSModuleDeclaration(Box<'a, TSModuleDeclaration<'a>>) = 0,
TSModuleBlock(Box<'a, TSModuleBlock<'a>>) = 1, TSModuleBlock(Box<'a, TSModuleBlock<'a>>) = 1,
@ -1215,7 +1215,7 @@ pub enum TSModuleDeclarationBody<'a> {
// See serializer in serialize.rs // See serializer in serialize.rs
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
#[estree(custom_serialize)] #[estree(custom_serialize)]
pub struct TSModuleBlock<'a> { pub struct TSModuleBlock<'a> {
pub span: Span, pub span: Span,
@ -1226,7 +1226,7 @@ pub struct TSModuleBlock<'a> {
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSTypeLiteral<'a> { pub struct TSTypeLiteral<'a> {
pub span: Span, pub span: Span,
pub members: Vec<'a, TSSignature<'a>>, 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) /// * [TypeScript Handbook - Inferring With Conditional Types](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#inferring-within-conditional-types)
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSInferType<'a> { pub struct TSInferType<'a> {
pub span: Span, pub span: Span,
/// The type bound when the /// 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) /// * [TypeScript Handbook - Typeof Type Operator](https://www.typescriptlang.org/docs/handbook/2/typeof-types.html)
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSTypeQuery<'a> { pub struct TSTypeQuery<'a> {
pub span: Span, pub span: Span,
pub expr_name: TSTypeQueryExprName<'a>, pub expr_name: TSTypeQueryExprName<'a>,
@ -1280,7 +1280,7 @@ inherit_variants! {
/// [`ast` module docs]: `super` /// [`ast` module docs]: `super`
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
pub enum TSTypeQueryExprName<'a> { pub enum TSTypeQueryExprName<'a> {
TSImportType(Box<'a, TSImportType<'a>>) = 2, TSImportType(Box<'a, TSImportType<'a>>) = 2,
// `TSTypeName` variants added here by `inherit_variants!` macro // `TSTypeName` variants added here by `inherit_variants!` macro
@ -1290,7 +1290,7 @@ pub enum TSTypeQueryExprName<'a> {
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSImportType<'a> { pub struct TSImportType<'a> {
pub span: Span, pub span: Span,
/// `true` for `typeof import("foo")` /// `true` for `typeof import("foo")`
@ -1303,7 +1303,7 @@ pub struct TSImportType<'a> {
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSImportAttributes<'a> { pub struct TSImportAttributes<'a> {
pub span: Span, pub span: Span,
pub attributes_keyword: IdentifierName<'a>, // `with` or `assert` pub attributes_keyword: IdentifierName<'a>, // `with` or `assert`
@ -1312,7 +1312,7 @@ pub struct TSImportAttributes<'a> {
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSImportAttribute<'a> { pub struct TSImportAttribute<'a> {
pub span: Span, pub span: Span,
pub name: TSImportAttributeName<'a>, pub name: TSImportAttributeName<'a>,
@ -1321,7 +1321,7 @@ pub struct TSImportAttribute<'a> {
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub enum TSImportAttributeName<'a> { pub enum TSImportAttributeName<'a> {
Identifier(IdentifierName<'a>) = 0, Identifier(IdentifierName<'a>) = 0,
StringLiteral(StringLiteral<'a>) = 1, StringLiteral(StringLiteral<'a>) = 1,
@ -1337,7 +1337,7 @@ pub enum TSImportAttributeName<'a> {
/// ``` /// ```
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSFunctionType<'a> { pub struct TSFunctionType<'a> {
pub span: Span, pub span: Span,
/// Generic type parameters /// Generic type parameters
@ -1366,7 +1366,7 @@ pub struct TSFunctionType<'a> {
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSConstructorType<'a> { pub struct TSConstructorType<'a> {
pub span: Span, pub span: Span,
pub r#abstract: bool, pub r#abstract: bool,
@ -1399,7 +1399,7 @@ pub struct TSConstructorType<'a> {
#[ast(visit)] #[ast(visit)]
#[scope] #[scope]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSMappedType<'a> { pub struct TSMappedType<'a> {
pub span: Span, pub span: Span,
/// Key type parameter, e.g. `P` in `[P in keyof T]`. /// Key type parameter, e.g. `P` in `[P in keyof T]`.
@ -1437,7 +1437,7 @@ pub struct TSMappedType<'a> {
#[ast] #[ast]
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub enum TSMappedTypeModifierOperator { pub enum TSMappedTypeModifierOperator {
/// e.g. `?` in `{ [P in K]?: T }` /// e.g. `?` in `{ [P in K]?: T }`
True = 0, 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) /// * [TypeScript Handbook - Template Literal Types](https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html#handbook-content)
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSTemplateLiteralType<'a> { pub struct TSTemplateLiteralType<'a> {
pub span: Span, pub span: Span,
/// The string parts of the template literal. /// The string parts of the template literal.
@ -1475,7 +1475,7 @@ pub struct TSTemplateLiteralType<'a> {
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSAsExpression<'a> { pub struct TSAsExpression<'a> {
pub span: Span, pub span: Span,
pub expression: Expression<'a>, 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) /// * [TypeScript Handbook - The `satisfies` Operator](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-9.html#the-satisfies-operator)
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSSatisfiesExpression<'a> { pub struct TSSatisfiesExpression<'a> {
pub span: Span, pub span: Span,
/// The value expression being constrained. /// The value expression being constrained.
@ -1507,7 +1507,7 @@ pub struct TSSatisfiesExpression<'a> {
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSTypeAssertion<'a> { pub struct TSTypeAssertion<'a> {
pub span: Span, pub span: Span,
pub expression: Expression<'a>, pub expression: Expression<'a>,
@ -1516,7 +1516,7 @@ pub struct TSTypeAssertion<'a> {
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSImportEqualsDeclaration<'a> { pub struct TSImportEqualsDeclaration<'a> {
pub span: Span, pub span: Span,
pub id: BindingIdentifier<'a>, pub id: BindingIdentifier<'a>,
@ -1532,7 +1532,7 @@ inherit_variants! {
/// [`ast` module docs]: `super` /// [`ast` module docs]: `super`
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
pub enum TSModuleReference<'a> { pub enum TSModuleReference<'a> {
ExternalModuleReference(Box<'a, TSExternalModuleReference<'a>>) = 2, ExternalModuleReference(Box<'a, TSExternalModuleReference<'a>>) = 2,
// `TSTypeName` variants added here by `inherit_variants!` macro // `TSTypeName` variants added here by `inherit_variants!` macro
@ -1542,7 +1542,7 @@ pub enum TSModuleReference<'a> {
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSExternalModuleReference<'a> { pub struct TSExternalModuleReference<'a> {
pub span: Span, pub span: Span,
pub expression: StringLiteral<'a>, pub expression: StringLiteral<'a>,
@ -1550,7 +1550,7 @@ pub struct TSExternalModuleReference<'a> {
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSNonNullExpression<'a> { pub struct TSNonNullExpression<'a> {
pub span: Span, pub span: Span,
pub expression: Expression<'a>, pub expression: Expression<'a>,
@ -1582,7 +1582,7 @@ pub struct TSNonNullExpression<'a> {
/// [`CallExpression`]: crate::ast::js::CallExpression /// [`CallExpression`]: crate::ast::js::CallExpression
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct Decorator<'a> { pub struct Decorator<'a> {
pub span: Span, pub span: Span,
pub expression: Expression<'a>, pub expression: Expression<'a>,
@ -1593,7 +1593,7 @@ pub struct Decorator<'a> {
/// `export = foo` /// `export = foo`
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSExportAssignment<'a> { pub struct TSExportAssignment<'a> {
pub span: Span, pub span: Span,
pub expression: Expression<'a>, pub expression: Expression<'a>,
@ -1604,7 +1604,7 @@ pub struct TSExportAssignment<'a> {
/// `export as namespace foo` /// `export as namespace foo`
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSNamespaceExportDeclaration<'a> { pub struct TSNamespaceExportDeclaration<'a> {
pub span: Span, pub span: Span,
pub id: IdentifierName<'a>, pub id: IdentifierName<'a>,
@ -1612,7 +1612,7 @@ pub struct TSNamespaceExportDeclaration<'a> {
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSInstantiationExpression<'a> { pub struct TSInstantiationExpression<'a> {
pub span: Span, pub span: Span,
pub expression: Expression<'a>, 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) /// See [TypeScript - Type-Only Imports and Exports](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html)
#[ast] #[ast]
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub enum ImportOrExportKind { pub enum ImportOrExportKind {
/// `import { foo } from './foo'`; /// `import { foo } from './foo'`;
Value = 0, Value = 0,
@ -1635,7 +1635,7 @@ pub enum ImportOrExportKind {
/// `type foo = ty?` or `type foo = ?ty` /// `type foo = ty?` or `type foo = ?ty`
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct JSDocNullableType<'a> { pub struct JSDocNullableType<'a> {
pub span: Span, pub span: Span,
pub type_annotation: TSType<'a>, pub type_annotation: TSType<'a>,
@ -1646,7 +1646,7 @@ pub struct JSDocNullableType<'a> {
/// `type foo = ty!` or `type foo = !ty` /// `type foo = ty!` or `type foo = !ty`
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct JSDocNonNullableType<'a> { pub struct JSDocNonNullableType<'a> {
pub span: Span, pub span: Span,
pub type_annotation: TSType<'a>, pub type_annotation: TSType<'a>,
@ -1655,7 +1655,7 @@ pub struct JSDocNonNullableType<'a> {
#[ast(visit)] #[ast(visit)]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct JSDocUnknownType { pub struct JSDocUnknownType {
pub span: Span, pub span: Span,
} }

View file

@ -1,14 +1,10 @@
//! Literals //! Literals
use std::{ use std::{borrow::Cow, fmt};
borrow::Cow,
fmt,
hash::{Hash, Hasher},
};
use oxc_allocator::CloneIn; use oxc_allocator::CloneIn;
use oxc_regular_expression::ast::Pattern; use oxc_regular_expression::ast::Pattern;
use oxc_span::{cmp::ContentEq, hash::ContentHash}; use oxc_span::cmp::ContentEq;
use crate::ast::*; use crate::ast::*;
@ -79,44 +75,10 @@ impl ContentEq for NumericLiteral<'_> {
fn content_eq(&self, other: &Self) -> bool { fn content_eq(&self, other: &Self) -> bool {
// Note: `f64::content_eq` uses `==` equality. // Note: `f64::content_eq` uses `==` equality.
// `f64::NAN != f64::NAN` and `0.0 == -0.0`, so we follow the same here. // `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) ContentEq::content_eq(&self.value, &other.value)
} }
} }
impl ContentHash for NumericLiteral<'_> {
fn content_hash<H: Hasher>(&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<'_> { impl fmt::Display for NumericLiteral<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// We have 2 choices here: // We have 2 choices here:
@ -155,12 +117,6 @@ impl ContentEq for StringLiteral<'_> {
} }
} }
impl ContentHash for StringLiteral<'_> {
fn content_hash<H: Hasher>(&self, state: &mut H) {
ContentHash::content_hash(&self.value, state);
}
}
impl AsRef<str> for StringLiteral<'_> { impl AsRef<str> for StringLiteral<'_> {
#[inline] #[inline]
fn as_ref(&self) -> &str { fn as_ref(&self) -> &str {
@ -188,12 +144,6 @@ impl ContentEq for BigIntLiteral<'_> {
} }
} }
impl ContentHash for BigIntLiteral<'_> {
fn content_hash<H: Hasher>(&self, state: &mut H) {
ContentHash::content_hash(&self.raw, state);
}
}
impl fmt::Display for BigIntLiteral<'_> { impl fmt::Display for BigIntLiteral<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.raw.fmt(f) self.raw.fmt(f)
@ -277,16 +227,6 @@ impl ContentEq for RegExpPattern<'_> {
} }
} }
impl ContentHash for RegExpPattern<'_> {
fn content_hash<H: Hasher>(&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<'_> { impl fmt::Display for RegExpPattern<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
@ -302,12 +242,6 @@ impl ContentEq for RegExpFlags {
} }
} }
impl ContentHash for RegExpFlags {
fn content_hash<H: Hasher>(&self, state: &mut H) {
Hash::hash(self, state);
}
}
impl<'alloc> CloneIn<'alloc> for RegExpFlags { impl<'alloc> CloneIn<'alloc> for RegExpFlags {
type Cloned = Self; type Cloned = Self;

View file

@ -81,8 +81,6 @@ fn abs_trait(
(quote!(::oxc_allocator::GetAddress), TokenStream::default()) (quote!(::oxc_allocator::GetAddress), TokenStream::default())
} else if ident == "ContentEq" { } else if ident == "ContentEq" {
(quote!(::oxc_span::cmp::ContentEq), TokenStream::default()) (quote!(::oxc_span::cmp::ContentEq), TokenStream::default())
} else if ident == "ContentHash" {
(quote!(::oxc_span::hash::ContentHash), TokenStream::default())
} else if ident == "ESTree" { } else if ident == "ESTree" {
(quote!(::oxc_estree::ESTree), TokenStream::default()) (quote!(::oxc_estree::ESTree), TokenStream::default())
} else { } else {

View file

@ -1,12 +1,12 @@
use oxc_allocator::{Box, CloneIn, GetAddress, Vec}; use oxc_allocator::{Box, CloneIn, GetAddress, Vec};
use oxc_ast_macros::ast; use oxc_ast_macros::ast;
use oxc_estree::ESTree; 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. /// The root of the `PatternParser` result.
#[ast] #[ast]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub struct Pattern<'a> { pub struct Pattern<'a> {
pub span: Span, pub span: Span,
pub body: Disjunction<'a>, pub body: Disjunction<'a>,
@ -15,7 +15,7 @@ pub struct Pattern<'a> {
/// Pile of [`Alternative`]s separated by `|`. /// Pile of [`Alternative`]s separated by `|`.
#[ast] #[ast]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub struct Disjunction<'a> { pub struct Disjunction<'a> {
pub span: Span, pub span: Span,
pub body: Vec<'a, Alternative<'a>>, pub body: Vec<'a, Alternative<'a>>,
@ -24,7 +24,7 @@ pub struct Disjunction<'a> {
/// Single unit of `|` separated alternatives. /// Single unit of `|` separated alternatives.
#[ast] #[ast]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub struct Alternative<'a> { pub struct Alternative<'a> {
pub span: Span, pub span: Span,
pub body: Vec<'a, Term<'a>>, pub body: Vec<'a, Term<'a>>,
@ -33,7 +33,7 @@ pub struct Alternative<'a> {
/// Single unit of [`Alternative`], containing various kinds. /// Single unit of [`Alternative`], containing various kinds.
#[ast] #[ast]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub enum Term<'a> { pub enum Term<'a> {
// Assertion, QuantifiableAssertion // Assertion, QuantifiableAssertion
BoundaryAssertion(Box<'a, BoundaryAssertion>) = 0, BoundaryAssertion(Box<'a, BoundaryAssertion>) = 0,
@ -76,7 +76,7 @@ impl GetSpan for Term<'_> {
/// e.g. `^`, `$`, `\b`, `\B` /// e.g. `^`, `$`, `\b`, `\B`
#[ast] #[ast]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub struct BoundaryAssertion { pub struct BoundaryAssertion {
pub span: Span, pub span: Span,
pub kind: BoundaryAssertionKind, pub kind: BoundaryAssertionKind,
@ -84,7 +84,7 @@ pub struct BoundaryAssertion {
#[ast] #[ast]
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub enum BoundaryAssertionKind { pub enum BoundaryAssertionKind {
Start = 0, Start = 0,
End = 1, End = 1,
@ -96,7 +96,7 @@ pub enum BoundaryAssertionKind {
/// e.g. `(?=...)`, `(?!...)`, `(?<=...)`, `(?<!...)` /// e.g. `(?=...)`, `(?!...)`, `(?<=...)`, `(?<!...)`
#[ast] #[ast]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub struct LookAroundAssertion<'a> { pub struct LookAroundAssertion<'a> {
pub span: Span, pub span: Span,
pub kind: LookAroundAssertionKind, pub kind: LookAroundAssertionKind,
@ -105,7 +105,7 @@ pub struct LookAroundAssertion<'a> {
#[ast] #[ast]
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub enum LookAroundAssertionKind { pub enum LookAroundAssertionKind {
Lookahead = 0, Lookahead = 0,
NegativeLookahead = 1, NegativeLookahead = 1,
@ -117,7 +117,7 @@ pub enum LookAroundAssertionKind {
/// e.g. `a*`, `b+`, `c?`, `d{3}`, `e{4,}`, `f{5,6}` /// e.g. `a*`, `b+`, `c?`, `d{3}`, `e{4,}`, `f{5,6}`
#[ast] #[ast]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub struct Quantifier<'a> { pub struct Quantifier<'a> {
pub span: Span, pub span: Span,
pub min: u64, pub min: u64,
@ -130,7 +130,7 @@ pub struct Quantifier<'a> {
/// Single character. /// Single character.
#[ast] #[ast]
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub struct Character { pub struct Character {
/// This will be invalid position when `UnicodeMode` is disabled and `value` is a surrogate pair. /// This will be invalid position when `UnicodeMode` is disabled and `value` is a surrogate pair.
pub span: Span, pub span: Span,
@ -141,7 +141,7 @@ pub struct Character {
#[ast] #[ast]
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub enum CharacterKind { pub enum CharacterKind {
ControlLetter = 0, ControlLetter = 0,
HexadecimalEscape = 1, HexadecimalEscape = 1,
@ -160,7 +160,7 @@ pub enum CharacterKind {
/// e.g. `\d`, `\D`, `\s`, `\S`, `\w`, `\W` /// e.g. `\d`, `\D`, `\s`, `\S`, `\w`, `\W`
#[ast] #[ast]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub struct CharacterClassEscape { pub struct CharacterClassEscape {
pub span: Span, pub span: Span,
pub kind: CharacterClassEscapeKind, pub kind: CharacterClassEscapeKind,
@ -168,7 +168,7 @@ pub struct CharacterClassEscape {
#[ast] #[ast]
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub enum CharacterClassEscapeKind { pub enum CharacterClassEscapeKind {
D = 0, D = 0,
NegativeD = 1, NegativeD = 1,
@ -182,7 +182,7 @@ pub enum CharacterClassEscapeKind {
/// e.g. `\p{ASCII}`, `\P{ASCII}`, `\p{sc=Hiragana}`, `\P{sc=Hiragana}` /// e.g. `\p{ASCII}`, `\P{ASCII}`, `\p{sc=Hiragana}`, `\P{sc=Hiragana}`
#[ast] #[ast]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub struct UnicodePropertyEscape<'a> { pub struct UnicodePropertyEscape<'a> {
pub span: Span, pub span: Span,
pub negative: bool, pub negative: bool,
@ -195,7 +195,7 @@ pub struct UnicodePropertyEscape<'a> {
/// The `.`. /// The `.`.
#[ast] #[ast]
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub struct Dot { pub struct Dot {
pub span: Span, pub span: Span,
} }
@ -204,7 +204,7 @@ pub struct Dot {
/// e.g. `[a-z]`, `[^A-Z]`, `[abc]`, `[a&&b&&c]`, `[[a-z]--x--y]` /// e.g. `[a-z]`, `[^A-Z]`, `[abc]`, `[a&&b&&c]`, `[[a-z]--x--y]`
#[ast] #[ast]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub struct CharacterClass<'a> { pub struct CharacterClass<'a> {
pub span: Span, pub span: Span,
pub negative: bool, pub negative: bool,
@ -218,7 +218,7 @@ pub struct CharacterClass<'a> {
#[ast] #[ast]
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub enum CharacterClassContentsKind { pub enum CharacterClassContentsKind {
Union = 0, Union = 0,
/// `UnicodeSetsMode` only. /// `UnicodeSetsMode` only.
@ -229,7 +229,7 @@ pub enum CharacterClassContentsKind {
#[ast] #[ast]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, ContentEq, ContentHash, GetAddress, ESTree)] #[generate_derive(CloneIn, ContentEq, GetAddress, ESTree)]
pub enum CharacterClassContents<'a> { pub enum CharacterClassContents<'a> {
CharacterClassRange(Box<'a, CharacterClassRange>) = 0, CharacterClassRange(Box<'a, CharacterClassRange>) = 0,
CharacterClassEscape(Box<'a, CharacterClassEscape>) = 1, CharacterClassEscape(Box<'a, CharacterClassEscape>) = 1,
@ -259,7 +259,7 @@ impl GetSpan for CharacterClassContents<'_> {
/// e.g. `a-z`, `A-Z`, `0-9` /// e.g. `a-z`, `A-Z`, `0-9`
#[ast] #[ast]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub struct CharacterClassRange { pub struct CharacterClassRange {
pub span: Span, pub span: Span,
pub min: Character, pub min: Character,
@ -269,7 +269,7 @@ pub struct CharacterClassRange {
/// `|` separated string of characters wrapped by `\q{}`. /// `|` separated string of characters wrapped by `\q{}`.
#[ast] #[ast]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub struct ClassStringDisjunction<'a> { pub struct ClassStringDisjunction<'a> {
pub span: Span, pub span: Span,
/// `true` if body is empty or contains [`ClassString`] which `strings` is `true`. /// `true` if body is empty or contains [`ClassString`] which `strings` is `true`.
@ -280,7 +280,7 @@ pub struct ClassStringDisjunction<'a> {
/// Single unit of [`ClassStringDisjunction`]. /// Single unit of [`ClassStringDisjunction`].
#[ast] #[ast]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub struct ClassString<'a> { pub struct ClassString<'a> {
pub span: Span, pub span: Span,
/// `true` if body is empty or contain 2 more characters. /// `true` if body is empty or contain 2 more characters.
@ -292,7 +292,7 @@ pub struct ClassString<'a> {
/// e.g. `(...)`, `(?<name>...)` /// e.g. `(...)`, `(?<name>...)`
#[ast] #[ast]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub struct CapturingGroup<'a> { pub struct CapturingGroup<'a> {
pub span: Span, pub span: Span,
/// Group name to be referenced by [`NamedReference`]. /// Group name to be referenced by [`NamedReference`].
@ -304,7 +304,7 @@ pub struct CapturingGroup<'a> {
/// e.g. `(?:...)` /// e.g. `(?:...)`
#[ast] #[ast]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub struct IgnoreGroup<'a> { pub struct IgnoreGroup<'a> {
pub span: Span, pub span: Span,
pub modifiers: Option<Modifiers>, pub modifiers: Option<Modifiers>,
@ -315,7 +315,7 @@ pub struct IgnoreGroup<'a> {
/// e.g. `i` in `(?i:...)`, `-s` in `(?-s:...)` /// e.g. `i` in `(?i:...)`, `-s` in `(?-s:...)`
#[ast] #[ast]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub struct Modifiers { pub struct Modifiers {
pub span: Span, pub span: Span,
pub enabling: Option<Modifier>, pub enabling: Option<Modifier>,
@ -325,7 +325,7 @@ pub struct Modifiers {
/// Each part of modifier in [`Modifiers`]. /// Each part of modifier in [`Modifiers`].
#[ast] #[ast]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub struct Modifier { pub struct Modifier {
pub ignore_case: bool, pub ignore_case: bool,
pub multiline: bool, pub multiline: bool,
@ -336,7 +336,7 @@ pub struct Modifier {
/// e.g. `\1`, `\2`, `\3` /// e.g. `\1`, `\2`, `\3`
#[ast] #[ast]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub struct IndexedReference { pub struct IndexedReference {
pub span: Span, pub span: Span,
pub index: u32, pub index: u32,
@ -346,7 +346,7 @@ pub struct IndexedReference {
/// e.g. `\k<name>` /// e.g. `\k<name>`
#[ast] #[ast]
#[derive(Debug)] #[derive(Debug)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub struct NamedReference<'a> { pub struct NamedReference<'a> {
pub span: Span, pub span: Span,
pub name: Atom<'a>, pub name: Atom<'a>,

View file

@ -8,7 +8,7 @@ use oxc_allocator::{Allocator, CloneIn, FromIn};
#[cfg(feature = "serialize")] #[cfg(feature = "serialize")]
use serde::Serialize; use serde::Serialize;
use crate::{cmp::ContentEq, hash::ContentHash, CompactStr}; use crate::{cmp::ContentEq, CompactStr};
/// An inlinable string for oxc_allocator. /// An inlinable string for oxc_allocator.
/// ///
@ -196,12 +196,6 @@ impl ContentEq for Atom<'_> {
} }
} }
impl ContentHash for Atom<'_> {
fn content_hash<H: hash::Hasher>(&self, state: &mut H) {
hash::Hash::hash(self, state);
}
}
impl hash::Hash for Atom<'_> { impl hash::Hash for Atom<'_> {
fn hash<H: hash::Hasher>(&self, hasher: &mut H) { fn hash<H: hash::Hasher>(&self, hasher: &mut H) {
self.as_str().hash(hasher); self.as_str().hash(hasher);

View file

@ -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<H: Hasher>(&self, state: &mut H);
}
/// Short-Circuting implementation for [Discriminant] since it is used to hash enums.
impl<T> ContentHash for Discriminant<T> {
fn content_hash<H: Hasher>(&self, state: &mut H) {
Hash::hash(self, state);
}
}
impl<T: ContentHash> ContentHash for Option<T> {
fn content_hash<H: Hasher>(&self, state: &mut H) {
ContentHash::content_hash(&discriminant(self), state);
if let Some(it) = self {
ContentHash::content_hash(it, state);
}
}
}
impl<T: ContentHash> ContentHash for oxc_allocator::Box<'_, T> {
fn content_hash<H: Hasher>(&self, state: &mut H) {
ContentHash::content_hash(self.as_ref(), state);
}
}
impl<T: ContentHash> ContentHash for oxc_allocator::Vec<'_, T> {
fn content_hash<H: Hasher>(&self, state: &mut H) {
for piece in self {
piece.content_hash(state);
}
}
}
impl<T: ContentHash> ContentHash for [T] {
fn content_hash<H: Hasher>(&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<H: std::hash::Hasher>(&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
}
}

View file

@ -10,7 +10,6 @@ mod source_type;
mod span; mod span;
pub mod cmp; pub mod cmp;
pub mod hash;
pub use crate::{ pub use crate::{
atom::Atom, atom::Atom,

View file

@ -4,7 +4,7 @@ use oxc_allocator::{Allocator, CloneIn};
use oxc_ast_macros::ast; use oxc_ast_macros::ast;
use oxc_estree::ESTree; use oxc_estree::ESTree;
use crate::{cmp::ContentEq, hash::ContentHash}; use crate::cmp::ContentEq;
mod error; mod error;
pub use error::UnknownExtension; pub use error::UnknownExtension;
@ -96,13 +96,6 @@ impl ContentEq for SourceType {
} }
} }
impl ContentHash for SourceType {
#[inline]
fn content_hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.hash(state);
}
}
/// Valid file extensions /// Valid file extensions
pub const VALID_EXTENSIONS: [&str; 8] = ["js", "mjs", "cjs", "jsx", "ts", "mts", "cts", "tsx"]; pub const VALID_EXTENSIONS: [&str; 8] = ["js", "mjs", "cjs", "jsx", "ts", "mts", "cts", "tsx"];

View file

@ -45,10 +45,10 @@ use oxc_estree::ESTree;
/// assert_eq!(s.expand(5), s.expand_left(5).expand_right(5)); /// assert_eq!(s.expand(5), s.expand_left(5).expand_right(5));
/// ``` /// ```
/// ///
/// ## Hashing /// ## Comparison
/// [`Span`] has a normal implementation of [`Hash`]. If you want to compare two /// [`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 /// 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 /// ## Implementation Notes
/// See the [`text-size`](https://docs.rs/text-size) crate for details. /// See the [`text-size`](https://docs.rs/text-size) crate for details.

View file

@ -1,11 +1,11 @@
#![allow(missing_docs)] // fixme #![allow(missing_docs)] // fixme
use oxc_allocator::CloneIn; use oxc_allocator::CloneIn;
use oxc_ast_macros::ast; use oxc_ast_macros::ast;
use oxc_span::{cmp::ContentEq, hash::ContentHash}; use oxc_span::cmp::ContentEq;
#[ast] #[ast]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[generate_derive(CloneIn, ContentEq, ContentHash)] #[generate_derive(CloneIn, ContentEq)]
pub enum NumberBase { pub enum NumberBase {
Float = 0, Float = 0,
Decimal = 1, Decimal = 1,
@ -22,7 +22,7 @@ impl NumberBase {
#[ast] #[ast]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[generate_derive(CloneIn, ContentEq, ContentHash)] #[generate_derive(CloneIn, ContentEq)]
pub enum BigintBase { pub enum BigintBase {
Decimal = 0, Decimal = 0,
Binary = 1, Binary = 1,

View file

@ -5,7 +5,7 @@
use oxc_allocator::CloneIn; use oxc_allocator::CloneIn;
use oxc_ast_macros::ast; use oxc_ast_macros::ast;
use oxc_estree::ESTree; use oxc_estree::ESTree;
use oxc_span::{cmp::ContentEq, hash::ContentHash}; use oxc_span::cmp::ContentEq;
use crate::precedence::{GetPrecedence, Precedence}; 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) /// - [13.15 Assignment Operators](https://tc39.es/ecma262/#sec-assignment-operators)
#[ast] #[ast]
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub enum AssignmentOperator { pub enum AssignmentOperator {
/// `=` /// `=`
#[estree(rename = "=")] #[estree(rename = "=")]
@ -159,7 +159,7 @@ impl AssignmentOperator {
/// - [12.10 Binary Logical Operators](https://tc39.es/ecma262/#sec-binary-logical-operators) /// - [12.10 Binary Logical Operators](https://tc39.es/ecma262/#sec-binary-logical-operators)
#[ast] #[ast]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub enum BinaryOperator { pub enum BinaryOperator {
/// `==` /// `==`
#[estree(rename = "==")] #[estree(rename = "==")]
@ -416,7 +416,7 @@ impl GetPrecedence for BinaryOperator {
/// Logical binary operators /// Logical binary operators
#[ast] #[ast]
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub enum LogicalOperator { pub enum LogicalOperator {
/// `||` /// `||`
#[estree(rename = "||")] #[estree(rename = "||")]
@ -478,7 +478,7 @@ impl GetPrecedence for LogicalOperator {
/// - [12.5 Unary Operators](https://tc39.es/ecma262/#sec-unary-operators) /// - [12.5 Unary Operators](https://tc39.es/ecma262/#sec-unary-operators)
#[ast] #[ast]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub enum UnaryOperator { pub enum UnaryOperator {
/// `+` /// `+`
#[estree(rename = "+")] #[estree(rename = "+")]
@ -558,7 +558,7 @@ impl UnaryOperator {
/// Unary update operators. /// Unary update operators.
#[ast] #[ast]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[generate_derive(CloneIn, ContentEq, ESTree)]
pub enum UpdateOperator { pub enum UpdateOperator {
/// `++` /// `++`
#[estree(rename = "++")] #[estree(rename = "++")]