diff --git a/.github/generated/ast_changes_watch_list.yml b/.github/generated/ast_changes_watch_list.yml index 9bcbddf6d7f85..ead1e6756bed8 100644 --- a/.github/generated/ast_changes_watch_list.yml +++ b/.github/generated/ast_changes_watch_list.yml @@ -13,10 +13,12 @@ src: - 'crates/oxc_ast/src/generated/ast_kind.rs' - 'crates/oxc_ast/src/generated/derive_clone_in.rs' - 'crates/oxc_ast/src/generated/derive_content_eq.rs' + - 'crates/oxc_ast/src/generated/derive_dummy.rs' - 'crates/oxc_ast/src/generated/derive_estree.rs' - 'crates/oxc_ast/src/generated/derive_get_address.rs' - 'crates/oxc_ast/src/generated/derive_get_span.rs' - 'crates/oxc_ast/src/generated/derive_get_span_mut.rs' + - 'crates/oxc_ast/src/generated/derive_take_in.rs' - 'crates/oxc_ast/src/generated/get_id.rs' - 'crates/oxc_ast/src/serialize.rs' - 'crates/oxc_ast_macros/src/generated/mod.rs' @@ -31,12 +33,14 @@ src: - 'crates/oxc_regular_expression/src/generated/derive_estree.rs' - 'crates/oxc_regular_expression/src/generated/derive_get_address.rs' - 'crates/oxc_span/src/generated/assert_layouts.rs' + - 'crates/oxc_span/src/generated/derive_dummy.rs' - 'crates/oxc_span/src/generated/derive_estree.rs' - 'crates/oxc_span/src/source_type/mod.rs' - 'crates/oxc_span/src/span.rs' - 'crates/oxc_syntax/src/generated/assert_layouts.rs' - 'crates/oxc_syntax/src/generated/derive_clone_in.rs' - 'crates/oxc_syntax/src/generated/derive_content_eq.rs' + - 'crates/oxc_syntax/src/generated/derive_dummy.rs' - 'crates/oxc_syntax/src/generated/derive_estree.rs' - 'crates/oxc_syntax/src/lib.rs' - 'crates/oxc_syntax/src/module_record.rs' diff --git a/crates/oxc_allocator/src/lib.rs b/crates/oxc_allocator/src/lib.rs index 963689874d1f2..ce3621b3bf2fa 100644 --- a/crates/oxc_allocator/src/lib.rs +++ b/crates/oxc_allocator/src/lib.rs @@ -24,6 +24,7 @@ mod convert; mod from_raw_parts; pub mod hash_map; pub mod string; +mod take_in; mod vec; mod vec2; @@ -34,4 +35,5 @@ pub use clone_in::CloneIn; pub use convert::{FromIn, IntoIn}; pub use hash_map::HashMap; pub use string::String; +pub use take_in::{Dummy, TakeIn}; pub use vec::Vec; diff --git a/crates/oxc_allocator/src/take_in.rs b/crates/oxc_allocator/src/take_in.rs new file mode 100644 index 0000000000000..d26ad25225916 --- /dev/null +++ b/crates/oxc_allocator/src/take_in.rs @@ -0,0 +1,138 @@ +use std::{cell::Cell, mem, num}; + +use crate::{Allocator, Box, Vec}; + +/// A trait to replace an existing AST node with a dummy. +pub trait TakeIn<'a>: Dummy<'a> { + /// Replace node with a dummy. + #[must_use] + fn take_in(&mut self, allocator: &'a Allocator) -> Self { + let dummy = Dummy::dummy(allocator); + mem::replace(self, dummy) + } +} + +impl<'a, T> TakeIn<'a> for Vec<'a, T> {} + +/// A trait to create a dummy AST node. +pub trait Dummy<'a>: Sized { + /// Create a dummy node. + fn dummy(allocator: &'a Allocator) -> Self; +} + +impl<'a, T> Dummy<'a> for Option { + /// Create a dummy [`Option`]. + #[expect(clippy::inline_always)] + #[inline(always)] + fn dummy(_allocator: &'a Allocator) -> Self { + None + } +} + +impl<'a, T: Dummy<'a>> Dummy<'a> for Box<'a, T> { + /// Create a dummy [`Box`]. + #[inline] + fn dummy(allocator: &'a Allocator) -> Self { + Box::new_in(Dummy::dummy(allocator), allocator) + } +} + +impl<'a, T> Dummy<'a> for Vec<'a, T> { + /// Create a dummy [`Vec`]. + #[inline] + fn dummy(allocator: &'a Allocator) -> Self { + Vec::new_in(allocator) + } +} + +impl<'a, T: Dummy<'a>> Dummy<'a> for Cell { + /// Create a dummy [`Cell`]. + #[expect(clippy::inline_always)] + #[inline(always)] + fn dummy(allocator: &'a Allocator) -> Self { + Cell::new(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for () { + #[inline(always)] + fn dummy(_allocator: &'a Allocator) {} +} + +impl<'a> Dummy<'a> for bool { + #[expect(clippy::inline_always)] + #[inline(always)] + fn dummy(_allocator: &'a Allocator) -> Self { + false + } +} + +impl<'a> Dummy<'a> for &'a str { + #[expect(clippy::inline_always)] + #[inline(always)] + fn dummy(_allocator: &'a Allocator) -> Self { + "" + } +} + +macro_rules! dummy_impl_int { + ($ty:ident) => { + impl<'a> Dummy<'a> for $ty { + #[inline(always)] + fn dummy(_allocator: &'a Allocator) -> Self { + 0 + } + } + }; +} + +dummy_impl_int!(u8); +dummy_impl_int!(u16); +dummy_impl_int!(u32); +dummy_impl_int!(u64); +dummy_impl_int!(u128); +dummy_impl_int!(usize); +dummy_impl_int!(i8); +dummy_impl_int!(i16); +dummy_impl_int!(i32); +dummy_impl_int!(i64); +dummy_impl_int!(i128); +dummy_impl_int!(isize); + +macro_rules! dummy_impl_float { + ($ty:ident) => { + impl<'a> Dummy<'a> for $ty { + #[inline(always)] + fn dummy(_allocator: &'a Allocator) -> Self { + 0.0 + } + } + }; +} + +dummy_impl_float!(f32); +dummy_impl_float!(f64); + +macro_rules! dummy_impl_non_zero { + ($ty:ident) => { + impl<'a> Dummy<'a> for num::$ty { + #[inline(always)] + fn dummy(_allocator: &'a Allocator) -> Self { + Self::MIN + } + } + }; +} + +dummy_impl_non_zero!(NonZeroU8); +dummy_impl_non_zero!(NonZeroU16); +dummy_impl_non_zero!(NonZeroU32); +dummy_impl_non_zero!(NonZeroU64); +dummy_impl_non_zero!(NonZeroU128); +dummy_impl_non_zero!(NonZeroUsize); +dummy_impl_non_zero!(NonZeroI8); +dummy_impl_non_zero!(NonZeroI16); +dummy_impl_non_zero!(NonZeroI32); +dummy_impl_non_zero!(NonZeroI64); +dummy_impl_non_zero!(NonZeroI128); +dummy_impl_non_zero!(NonZeroIsize); diff --git a/crates/oxc_ast/src/ast/js.rs b/crates/oxc_ast/src/ast/js.rs index ad1ca827bd4ee..6aa13557e1f32 100644 --- a/crates/oxc_ast/src/ast/js.rs +++ b/crates/oxc_ast/src/ast/js.rs @@ -6,7 +6,7 @@ use std::cell::Cell; -use oxc_allocator::{Box, CloneIn, GetAddress, Vec}; +use oxc_allocator::{Box, CloneIn, Dummy, GetAddress, TakeIn, Vec}; use oxc_ast_macros::ast; use oxc_estree::ESTree; use oxc_span::{Atom, ContentEq, GetSpan, GetSpanMut, SourceType, Span}; @@ -29,7 +29,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(field_order(span, directives, source_type, hashbang))] pub struct Program<'a> { pub span: Span, @@ -55,7 +55,7 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum Expression<'a> { /// See [`BooleanLiteral`] for AST node details. BooleanLiteral(Box<'a, BooleanLiteral>) = 0, @@ -208,7 +208,7 @@ pub use match_expression; /// digits, `$`, or `_`. #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree( rename = "Identifier", add_fields(decorators = TsEmptyArray, optional = TsFalse, typeAnnotation = TsNull) @@ -226,7 +226,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree( rename = "Identifier", add_fields(decorators = TsEmptyArray, optional = TsFalse, typeAnnotation = TsNull) @@ -252,7 +252,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree( rename = "Identifier", add_fields(decorators = TsEmptyArray, optional = TsFalse, typeAnnotation = TsNull) @@ -278,7 +278,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(rename = "Identifier")] pub struct LabelIdentifier<'a> { pub span: Span, @@ -291,7 +291,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ThisExpression { pub span: Span, } @@ -301,7 +301,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ArrayExpression<'a> { pub span: Span, pub elements: Vec<'a, ArrayExpressionElement<'a>>, @@ -319,7 +319,7 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub enum ArrayExpressionElement<'a> { /// `...[3, 4]` in `const array = [1, 2, ...[3, 4], null];` SpreadElement(Box<'a, SpreadElement<'a>>) = 64, @@ -339,7 +339,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(via = ElisionConverter)] pub struct Elision { pub span: Span, @@ -353,7 +353,7 @@ pub struct Elision { /// If the object literal has a trailing comma, `trailing_comma` contains the span of that comma. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ObjectExpression<'a> { pub span: Span, /// Properties declared in the object @@ -365,7 +365,7 @@ pub struct ObjectExpression<'a> { /// Represents a property in an object literal. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum ObjectPropertyKind<'a> { /// `a: 1` in `const obj = { a: 1 };` ObjectProperty(Box<'a, ObjectProperty<'a>>) = 0, @@ -378,7 +378,7 @@ pub enum ObjectPropertyKind<'a> { /// Represents a property in an object literal. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(rename = "Property", field_order(span, method, shorthand, computed, key, value, kind))] pub struct ObjectProperty<'a> { pub span: Span, @@ -398,7 +398,7 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum PropertyKey<'a> { /// `a` in `const obj = { a: 1 }; obj.a;` StaticIdentifier(Box<'a, IdentifierName<'a>>) = 64, @@ -412,7 +412,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, ESTree)] +#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)] pub enum PropertyKind { /// `a: 1` in `const obj = { a: 1 };` Init = 0, @@ -427,7 +427,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(field_order(span, expressions, quasis))] pub struct TemplateLiteral<'a> { pub span: Span, @@ -440,7 +440,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TaggedTemplateExpression<'a> { pub span: Span, pub tag: Expression<'a>, @@ -454,7 +454,7 @@ pub struct TaggedTemplateExpression<'a> { /// Represents a quasi element in a template literal. #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TemplateElement<'a> { pub span: Span, pub value: TemplateElementValue<'a>, @@ -464,7 +464,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, Clone)] -#[generate_derive(CloneIn, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, ContentEq, ESTree)] #[estree(no_type)] pub struct TemplateElementValue<'a> { /// A raw interpretation where backslashes do not have special meaning. @@ -484,7 +484,7 @@ pub struct TemplateElementValue<'a> { /// #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum MemberExpression<'a> { /// `ar[0]` in `const ar = [1, 2]; ar[0];` ComputedMemberExpression(Box<'a, ComputedMemberExpression<'a>>) = 48, @@ -510,7 +510,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree( rename = "MemberExpression", add_fields(computed = True), @@ -529,7 +529,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree( rename = "MemberExpression", add_fields(computed = False), @@ -547,7 +547,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree( rename = "MemberExpression", add_fields(computed = False), @@ -579,7 +579,7 @@ pub struct PrivateFieldExpression<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct CallExpression<'a> { pub span: Span, pub callee: Expression<'a>, @@ -607,7 +607,7 @@ pub struct CallExpression<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct NewExpression<'a> { pub span: Span, pub callee: Expression<'a>, @@ -625,7 +625,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct MetaProperty<'a> { pub span: Span, pub meta: IdentifierName<'a>, @@ -637,7 +637,7 @@ pub struct MetaProperty<'a> { /// Represents a spread element, which can include an argument. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct SpreadElement<'a> { pub span: Span, /// The expression being spread. @@ -652,7 +652,7 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum Argument<'a> { /// `...[1, 2]` in `const arr = [...[1, 2]];` SpreadElement(Box<'a, SpreadElement<'a>>) = 64, @@ -667,7 +667,7 @@ pub enum Argument<'a> { /// The following syntaxes are supported: `++a`, `a++`, `--a`, `a--`. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct UpdateExpression<'a> { pub span: Span, pub operator: UpdateOperator, @@ -681,7 +681,7 @@ pub struct UpdateExpression<'a> { /// 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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(add_fields(prefix = True), field_order(span, operator, prefix, argument))] pub struct UnaryExpression<'a> { pub span: Span, @@ -694,7 +694,7 @@ pub struct UnaryExpression<'a> { /// Represents a binary expression, which include a left expression, an operator, and a right expression. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct BinaryExpression<'a> { pub span: Span, pub left: Expression<'a>, @@ -705,7 +705,7 @@ pub struct BinaryExpression<'a> { /// `#brand in obj` in `class Foo { #brand; static isFoo(obj) { return #brand in obj; } }`. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree( rename = "BinaryExpression", add_fields(operator = In), @@ -723,7 +723,7 @@ pub struct PrivateInExpression<'a> { /// The following syntaxes are supported: `||`, `&&` and `??`. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct LogicalExpression<'a> { pub span: Span, pub left: Expression<'a>, @@ -736,7 +736,7 @@ pub struct LogicalExpression<'a> { /// Represents a conditional expression, which includes a test, a consequent, and an alternate. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ConditionalExpression<'a> { pub span: Span, pub test: Expression<'a>, @@ -749,7 +749,7 @@ pub struct ConditionalExpression<'a> { /// Represents an assignment expression, which includes an operator, a target, and an expression. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct AssignmentExpression<'a> { pub span: Span, pub operator: AssignmentOperator, @@ -766,7 +766,7 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum AssignmentTarget<'a> { // `SimpleAssignmentTarget` variants added here by `inherit_variants!` macro @inherit SimpleAssignmentTarget @@ -783,7 +783,7 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum SimpleAssignmentTarget<'a> { AssignmentTargetIdentifier(Box<'a, IdentifierReference<'a>>) = 0, TSAsExpression(Box<'a, TSAsExpression<'a>>) = 1, @@ -833,7 +833,7 @@ pub use match_simple_assignment_target; #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum AssignmentTargetPattern<'a> { ArrayAssignmentTarget(Box<'a, ArrayAssignmentTarget<'a>>) = 8, ObjectAssignmentTarget(Box<'a, ObjectAssignmentTarget<'a>>) = 9, @@ -853,7 +853,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(rename = "ArrayPattern")] pub struct ArrayAssignmentTarget<'a> { pub span: Span, @@ -869,7 +869,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(rename = "ObjectPattern")] pub struct ObjectAssignmentTarget<'a> { pub span: Span, @@ -883,7 +883,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(rename = "RestElement")] pub struct AssignmentTargetRest<'a> { pub span: Span, @@ -899,7 +899,7 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum AssignmentTargetMaybeDefault<'a> { AssignmentTargetWithDefault(Box<'a, AssignmentTargetWithDefault<'a>>) = 16, // `AssignmentTarget` variants added here by `inherit_variants!` macro @@ -909,7 +909,7 @@ pub enum AssignmentTargetMaybeDefault<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(rename = "AssignmentPattern")] pub struct AssignmentTargetWithDefault<'a> { pub span: Span, @@ -921,7 +921,7 @@ pub struct AssignmentTargetWithDefault<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum AssignmentTargetProperty<'a> { AssignmentTargetPropertyIdentifier(Box<'a, AssignmentTargetPropertyIdentifier<'a>>) = 0, AssignmentTargetPropertyProperty(Box<'a, AssignmentTargetPropertyProperty<'a>>) = 1, @@ -933,7 +933,7 @@ pub enum AssignmentTargetProperty<'a> { /// and an optional init expression. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree( rename = "Property", add_fields(method = False, shorthand = True, computed = False, kind = Init), @@ -952,7 +952,7 @@ pub struct AssignmentTargetPropertyIdentifier<'a> { /// Represents an assignment target property property, which includes a name and a binding. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree( rename = "Property", add_fields(method = False, shorthand = False, kind = Init), @@ -983,7 +983,7 @@ pub struct AssignmentTargetPropertyProperty<'a> { /// Represents a sequence expression. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct SequenceExpression<'a> { pub span: Span, pub expressions: Vec<'a, Expression<'a>>, @@ -994,7 +994,7 @@ pub struct SequenceExpression<'a> { /// Represents a super expression. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct Super { pub span: Span, } @@ -1004,7 +1004,7 @@ pub struct Super { /// Represents an await expression, which can include an argument. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct AwaitExpression<'a> { pub span: Span, pub argument: Expression<'a>, @@ -1015,7 +1015,7 @@ pub struct AwaitExpression<'a> { /// Represents a chain expression, which can include an expression. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ChainExpression<'a> { pub span: Span, pub expression: ChainElement<'a>, @@ -1029,7 +1029,7 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum ChainElement<'a> { CallExpression(Box<'a, CallExpression<'a>>) = 0, /// `foo?.baz!` or `foo?.[bar]!` @@ -1044,7 +1044,7 @@ pub enum ChainElement<'a> { /// Represents a parenthesized expression, which can include an expression. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ParenthesizedExpression<'a> { pub span: Span, pub expression: Expression<'a>, @@ -1059,7 +1059,7 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum Statement<'a> { // Statements BlockStatement(Box<'a, BlockStatement<'a>>) = 0, @@ -1092,7 +1092,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(rename = "ExpressionStatement")] pub struct Directive<'a> { pub span: Span, @@ -1107,7 +1107,7 @@ pub struct Directive<'a> { /// Represents a hashbang directive, which can include a value. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct Hashbang<'a> { pub span: Span, pub value: Atom<'a>, @@ -1119,7 +1119,7 @@ pub struct Hashbang<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct BlockStatement<'a> { pub span: Span, pub body: Vec<'a, Statement<'a>>, @@ -1129,7 +1129,7 @@ pub struct BlockStatement<'a> { /// Declarations and the Variable Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum Declaration<'a> { VariableDeclaration(Box<'a, VariableDeclaration<'a>>) = 32, #[visit(args(flags = ScopeFlags::Function))] @@ -1164,7 +1164,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(field_order(span, declarations, kind, declare))] pub struct VariableDeclaration<'a> { pub span: Span, @@ -1176,7 +1176,7 @@ pub struct VariableDeclaration<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)] pub enum VariableDeclarationKind { Var = 0, Let = 1, @@ -1196,7 +1196,7 @@ pub enum VariableDeclarationKind { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct VariableDeclarator<'a> { pub span: Span, #[estree(skip)] @@ -1210,7 +1210,7 @@ pub struct VariableDeclarator<'a> { /// Empty Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct EmptyStatement { pub span: Span, } @@ -1218,7 +1218,7 @@ pub struct EmptyStatement { /// Expression Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(add_fields(directive = ExpressionStatementDirective))] // Only in TS AST pub struct ExpressionStatement<'a> { pub span: Span, @@ -1228,7 +1228,7 @@ pub struct ExpressionStatement<'a> { /// If Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct IfStatement<'a> { pub span: Span, pub test: Expression<'a>, @@ -1239,7 +1239,7 @@ pub struct IfStatement<'a> { /// Do-While Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct DoWhileStatement<'a> { pub span: Span, pub body: Statement<'a>, @@ -1249,7 +1249,7 @@ pub struct DoWhileStatement<'a> { /// While Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct WhileStatement<'a> { pub span: Span, pub test: Expression<'a>, @@ -1260,7 +1260,7 @@ pub struct WhileStatement<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ForStatement<'a> { pub span: Span, pub init: Option>, @@ -1278,7 +1278,7 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum ForStatementInit<'a> { VariableDeclaration(Box<'a, VariableDeclaration<'a>>) = 64, // `Expression` variants added here by `inherit_variants!` macro @@ -1290,7 +1290,7 @@ pub enum ForStatementInit<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ForInStatement<'a> { pub span: Span, pub left: ForStatementLeft<'a>, @@ -1307,7 +1307,7 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum ForStatementLeft<'a> { VariableDeclaration(Box<'a, VariableDeclaration<'a>>) = 16, // `AssignmentTarget` variants added here by `inherit_variants!` macro @@ -1318,7 +1318,7 @@ pub enum ForStatementLeft<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ForOfStatement<'a> { pub span: Span, pub r#await: bool, @@ -1331,7 +1331,7 @@ pub struct ForOfStatement<'a> { /// Continue Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ContinueStatement<'a> { pub span: Span, pub label: Option>, @@ -1340,7 +1340,7 @@ pub struct ContinueStatement<'a> { /// Break Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct BreakStatement<'a> { pub span: Span, pub label: Option>, @@ -1349,7 +1349,7 @@ pub struct BreakStatement<'a> { /// Return Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ReturnStatement<'a> { pub span: Span, pub argument: Option>, @@ -1358,7 +1358,7 @@ pub struct ReturnStatement<'a> { /// With Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct WithStatement<'a> { pub span: Span, pub object: Expression<'a>, @@ -1369,7 +1369,7 @@ pub struct WithStatement<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct SwitchStatement<'a> { pub span: Span, pub discriminant: Expression<'a>, @@ -1380,7 +1380,7 @@ pub struct SwitchStatement<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(field_order(span, consequent, test))] pub struct SwitchCase<'a> { pub span: Span, @@ -1391,7 +1391,7 @@ pub struct SwitchCase<'a> { /// Labelled Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(field_order(span, body, label))] pub struct LabeledStatement<'a> { pub span: Span, @@ -1408,7 +1408,7 @@ pub struct LabeledStatement<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ThrowStatement<'a> { pub span: Span, /// The expression being thrown, e.g. `err` in `throw err;` @@ -1432,7 +1432,7 @@ pub struct ThrowStatement<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TryStatement<'a> { pub span: Span, /// Statements in the `try` block @@ -1458,7 +1458,7 @@ pub struct TryStatement<'a> { #[ast(visit)] #[scope(flags = ScopeFlags::CatchClause)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct CatchClause<'a> { pub span: Span, /// The caught error parameter, e.g. `e` in `catch (e) {}` @@ -1483,7 +1483,7 @@ pub struct CatchClause<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(no_type, ts_alias = "BindingPattern")] pub struct CatchParameter<'a> { #[estree(skip)] @@ -1502,7 +1502,7 @@ pub struct CatchParameter<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct DebuggerStatement { pub span: Span, } @@ -1511,7 +1511,7 @@ pub struct DebuggerStatement { /// * #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(no_type)] pub struct BindingPattern<'a> { // estree(flatten) the attributes because estree has no `BindingPattern` @@ -1529,7 +1529,7 @@ pub struct BindingPattern<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum BindingPatternKind<'a> { /// `const a = 1` BindingIdentifier(Box<'a, BindingIdentifier<'a>>) = 0, @@ -1546,7 +1546,7 @@ pub enum BindingPatternKind<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(add_fields(decorators = TsEmptyArray))] pub struct AssignmentPattern<'a> { pub span: Span, @@ -1556,7 +1556,7 @@ pub struct AssignmentPattern<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ObjectPattern<'a> { pub span: Span, pub properties: Vec<'a, BindingProperty<'a>>, @@ -1566,7 +1566,7 @@ pub struct ObjectPattern<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree( rename = "Property", add_fields(method = False, kind = Init), @@ -1582,7 +1582,7 @@ pub struct BindingProperty<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(add_fields(decorators = TsEmptyArray, optional = TsFalse, typeAnnotation = TsNull))] pub struct ArrayPattern<'a> { pub span: Span, @@ -1602,7 +1602,7 @@ pub struct ArrayPattern<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(rename = "RestElement")] pub struct BindingRestElement<'a> { pub span: Span, @@ -1652,7 +1652,7 @@ pub struct BindingRestElement<'a> { strict_if = self.has_use_strict_directive(), )] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] // https://github.com/estree/estree/blob/master/es5.md#patterns // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/cd61c555bfc93e985b313263a42ed78074570d08/types/estree/index.d.ts#L411 #[estree( @@ -1729,7 +1729,7 @@ pub struct Function<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)] #[estree(no_rename_variants)] pub enum FunctionType { FunctionDeclaration = 0, @@ -1742,7 +1742,7 @@ pub enum FunctionType { /// #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree( via = FormalParametersConverter, add_ts_def = " @@ -1765,7 +1765,7 @@ pub struct FormalParameters<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] // Pluralize as `FormalParameterList` to avoid naming clash with `FormalParameters`. #[plural(FormalParameterList)] #[estree(no_type)] @@ -1789,7 +1789,7 @@ pub struct FormalParameter<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)] #[estree(no_rename_variants, no_ts_def)] pub enum FormalParameterKind { /// @@ -1805,7 +1805,7 @@ pub enum FormalParameterKind { /// #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(rename = "BlockStatement")] pub struct FunctionBody<'a> { pub span: Span, @@ -1822,7 +1822,7 @@ pub struct FunctionBody<'a> { strict_if = self.has_use_strict_directive(), )] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree( add_fields(id = Null, generator = False), field_order(span, id, expression, generator, r#async, params, body, type_parameters, return_type), @@ -1851,7 +1851,7 @@ pub struct ArrowFunctionExpression<'a> { /// Generator Function Definitions #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct YieldExpression<'a> { pub span: Span, pub delegate: bool, @@ -1862,7 +1862,7 @@ pub struct YieldExpression<'a> { #[ast(visit)] #[scope(flags = ScopeFlags::StrictMode)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[rustfmt::skip] #[estree(field_order( r#type, span, id, super_class, body, @@ -1941,7 +1941,7 @@ pub struct Class<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)] #[estree(no_rename_variants)] pub enum ClassType { /// Class declaration statement @@ -1959,7 +1959,7 @@ pub enum ClassType { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ClassBody<'a> { pub span: Span, pub body: Vec<'a, ClassElement<'a>>, @@ -1985,7 +1985,7 @@ pub struct ClassBody<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum ClassElement<'a> { StaticBlock(Box<'a, StaticBlock<'a>>) = 0, /// Class Methods @@ -2007,7 +2007,7 @@ pub enum ClassElement<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[rustfmt::skip] #[estree(field_order( r#type, span, r#static, computed, key, kind, value, @@ -2042,7 +2042,7 @@ pub struct MethodDefinition<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)] #[estree(no_rename_variants)] pub enum MethodDefinitionType { MethodDefinition = 0, @@ -2051,7 +2051,7 @@ pub enum MethodDefinitionType { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[rustfmt::skip] #[estree(field_order( r#type, span, r#static, computed, key, value, @@ -2144,7 +2144,7 @@ pub struct PropertyDefinition<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)] #[estree(no_rename_variants)] pub enum PropertyDefinitionType { PropertyDefinition = 0, @@ -2153,7 +2153,7 @@ pub enum PropertyDefinitionType { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)] pub enum MethodDefinitionKind { /// Class constructor Constructor = 0, @@ -2170,7 +2170,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct PrivateIdentifier<'a> { pub span: Span, pub name: Atom<'a>, @@ -2192,7 +2192,7 @@ pub struct PrivateIdentifier<'a> { #[ast(visit)] #[scope(flags = ScopeFlags::ClassStaticBlock)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct StaticBlock<'a> { pub span: Span, pub body: Vec<'a, Statement<'a>>, @@ -2224,7 +2224,7 @@ pub struct StaticBlock<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum ModuleDeclaration<'a> { /// `import hello from './world.js';` /// `import * as t from './world.js';` @@ -2259,7 +2259,7 @@ pub use match_module_declaration; #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)] #[estree(no_rename_variants)] pub enum AccessorPropertyType { AccessorProperty = 0, @@ -2276,7 +2276,7 @@ pub enum AccessorPropertyType { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[rustfmt::skip] #[estree(field_order( r#type, span, key, value, computed, r#static, @@ -2326,7 +2326,7 @@ pub struct AccessorProperty<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ImportExpression<'a> { pub span: Span, pub source: Expression<'a>, @@ -2338,7 +2338,7 @@ pub struct ImportExpression<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ImportDeclaration<'a> { pub span: Span, /// `None` for `import 'foo'`, `Some([])` for `import {} from 'foo'` @@ -2362,7 +2362,7 @@ pub struct ImportDeclaration<'a> { /// #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)] pub enum ImportPhase { Source = 0, Defer = 1, @@ -2370,7 +2370,7 @@ pub enum ImportPhase { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum ImportDeclarationSpecifier<'a> { /// import {imported} from "source" /// import {imported as local} from "source" @@ -2385,7 +2385,7 @@ pub enum ImportDeclarationSpecifier<'a> { // import {imported as local} from "source" #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ImportSpecifier<'a> { pub span: Span, pub imported: ModuleExportName<'a>, @@ -2414,7 +2414,7 @@ pub struct ImportSpecifier<'a> { /// #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ImportDefaultSpecifier<'a> { pub span: Span, /// The name of the imported symbol. @@ -2429,7 +2429,7 @@ pub struct ImportDefaultSpecifier<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ImportNamespaceSpecifier<'a> { pub span: Span, pub local: BindingIdentifier<'a>, @@ -2437,7 +2437,7 @@ pub struct ImportNamespaceSpecifier<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(no_ts_def)] pub struct WithClause<'a> { pub span: Span, @@ -2447,7 +2447,7 @@ pub struct WithClause<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ImportAttribute<'a> { pub span: Span, pub key: ImportAttributeKey<'a>, @@ -2456,7 +2456,7 @@ pub struct ImportAttribute<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub enum ImportAttributeKey<'a> { Identifier(IdentifierName<'a>) = 0, StringLiteral(StringLiteral<'a>) = 1, @@ -2475,7 +2475,7 @@ pub enum ImportAttributeKey<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ExportNamedDeclaration<'a> { pub span: Span, pub declaration: Option>, @@ -2500,7 +2500,7 @@ pub struct ExportNamedDeclaration<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ExportDefaultDeclaration<'a> { pub span: Span, #[estree(skip)] @@ -2519,7 +2519,7 @@ pub struct ExportDefaultDeclaration<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ExportAllDeclaration<'a> { pub span: Span, /// If this declaration is re-named @@ -2545,7 +2545,7 @@ pub struct ExportAllDeclaration<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct ExportSpecifier<'a> { pub span: Span, pub local: ModuleExportName<'a>, @@ -2562,7 +2562,7 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum ExportDefaultDeclarationKind<'a> { #[visit(args(flags = ScopeFlags::Function))] FunctionDeclaration(Box<'a, Function<'a>>) = 64, @@ -2584,7 +2584,7 @@ pub enum ExportDefaultDeclarationKind<'a> { /// * #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub enum ModuleExportName<'a> { IdentifierName(IdentifierName<'a>) = 0, /// For `local` in `ExportSpecifier`: `foo` in `export { foo }` @@ -2596,7 +2596,7 @@ pub enum ModuleExportName<'a> { /// See: [runtime.h](https://github.com/v8/v8/blob/5fe0aa3bc79c0a9d3ad546b79211f07105f09585/src/runtime/runtime.h#L43) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct V8IntrinsicExpression<'a> { pub span: Span, pub name: IdentifierName<'a>, diff --git a/crates/oxc_ast/src/ast/jsx.rs b/crates/oxc_ast/src/ast/jsx.rs index 01b2dc26eb37b..f3f8f278c7a53 100644 --- a/crates/oxc_ast/src/ast/jsx.rs +++ b/crates/oxc_ast/src/ast/jsx.rs @@ -4,7 +4,7 @@ // They are purely markers for codegen used in `tasks/ast_tools` and `crates/oxc_traverse/scripts`. See docs in those crates. // Read [`macro@oxc_ast_macros::ast`] for more information. -use oxc_allocator::{Box, CloneIn, GetAddress, Vec}; +use oxc_allocator::{Box, CloneIn, Dummy, GetAddress, TakeIn, Vec}; use oxc_ast_macros::ast; use oxc_estree::ESTree; use oxc_span::{Atom, ContentEq, GetSpan, GetSpanMut, Span}; @@ -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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, 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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(field_order(span, attributes, name, self_closing, type_arguments))] pub struct JSXOpeningElement<'a> { /// Node location in source code @@ -96,7 +96,7 @@ pub struct JSXOpeningElement<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct JSXClosingElement<'a> { /// Node location in source code pub span: Span, @@ -114,7 +114,7 @@ pub struct JSXClosingElement<'a> { /// See: [`React.Fragment`](https://react.dev/reference/react/Fragment) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct JSXFragment<'a> { /// Node location in source code pub span: Span, @@ -129,7 +129,7 @@ pub struct JSXFragment<'a> { /// JSX Opening Fragment (`<>`) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(add_fields(attributes = JSXOpeningFragmentAttributes, selfClosing = False))] pub struct JSXOpeningFragment { /// Node location in source code @@ -139,7 +139,7 @@ pub struct JSXOpeningFragment { /// JSX Closing Fragment (``) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct JSXClosingFragment { /// Node location in source code pub span: Span, @@ -148,7 +148,7 @@ pub struct JSXClosingFragment { /// JSX Element Name #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum JSXElementName<'a> { /// `
` Identifier(Box<'a, JSXIdentifier<'a>>) = 0, @@ -173,7 +173,7 @@ pub enum JSXElementName<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct JSXNamespacedName<'a> { /// Node location in source code pub span: Span, @@ -200,7 +200,7 @@ pub struct JSXNamespacedName<'a> { /// [`member expression`]: JSXMemberExpressionObject::MemberExpression #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct JSXMemberExpression<'a> { /// Node location in source code pub span: Span, @@ -228,7 +228,7 @@ pub struct JSXMemberExpression<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum JSXMemberExpressionObject<'a> { /// `` #[estree(via = JSXElementIdentifierReference)] @@ -255,7 +255,7 @@ pub enum JSXMemberExpressionObject<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct JSXExpressionContainer<'a> { /// Node location in source code pub span: Span, @@ -272,7 +272,7 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub enum JSXExpression<'a> { /// An empty expression /// @@ -290,7 +290,7 @@ pub enum JSXExpression<'a> { /// An empty JSX expression (`{}`) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct JSXEmptyExpression { /// Node location in source code pub span: Span, @@ -309,7 +309,7 @@ pub struct JSXEmptyExpression { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum JSXAttributeItem<'a> { /// A `key="value"` attribute Attribute(Box<'a, JSXAttribute<'a>>) = 0, @@ -330,7 +330,7 @@ pub enum JSXAttributeItem<'a> { /// // name ^^^ ^^^^ value #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct JSXAttribute<'a> { /// Node location in source code pub span: Span, @@ -351,7 +351,7 @@ pub struct JSXAttribute<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct JSXSpreadAttribute<'a> { /// Node location in source code pub span: Span, @@ -376,7 +376,7 @@ pub struct JSXSpreadAttribute<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, 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, @@ -404,7 +404,7 @@ pub enum JSXAttributeName<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum JSXAttributeValue<'a> { /// `` StringLiteral(Box<'a, StringLiteral<'a>>) = 0, @@ -423,7 +423,7 @@ pub enum JSXAttributeValue<'a> { /// [`IdentifierName`]: super::IdentifierName #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct JSXIdentifier<'a> { /// Node location in source code pub span: Span, @@ -439,7 +439,7 @@ pub struct JSXIdentifier<'a> { /// Part of a [`JSXElement`]. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum JSXChild<'a> { /// `Some Text` Text(Box<'a, JSXText<'a>>) = 0, @@ -458,7 +458,7 @@ pub enum JSXChild<'a> { /// Variant of [`JSXChild`] that represents an object spread (`{...expression}`). #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct JSXSpreadChild<'a> { /// Node location in source code pub span: Span, @@ -478,7 +478,7 @@ pub struct JSXSpreadChild<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, 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 3911784fa7683..fc4a695e1a6eb 100644 --- a/crates/oxc_ast/src/ast/literal.rs +++ b/crates/oxc_ast/src/ast/literal.rs @@ -7,7 +7,7 @@ use std::hash::Hash; use bitflags::bitflags; -use oxc_allocator::{Box, CloneIn}; +use oxc_allocator::{Box, CloneIn, Dummy, TakeIn}; use oxc_ast_macros::ast; use oxc_estree::ESTree; use oxc_regular_expression::ast::Pattern; @@ -19,7 +19,7 @@ use oxc_syntax::number::{BigintBase, NumberBase}; /// #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(rename = "Literal", add_fields(raw = BooleanLiteralRaw))] 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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(rename = "Literal", add_fields(value = Null, raw = NullLiteralRaw))] pub struct NullLiteral { /// Node location in source code @@ -45,7 +45,7 @@ pub struct NullLiteral { /// #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, ContentEq, GetSpan, GetSpanMut, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, ContentEq, GetSpan, GetSpanMut, ESTree)] #[estree(rename = "Literal")] pub struct NumericLiteral<'a> { /// Node location in source code @@ -68,7 +68,7 @@ pub struct NumericLiteral<'a> { /// #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, ContentEq, GetSpan, GetSpanMut, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, ContentEq, GetSpan, GetSpanMut, ESTree)] #[estree(rename = "Literal")] pub struct StringLiteral<'a> { /// Node location in source code @@ -93,7 +93,7 @@ pub struct StringLiteral<'a> { /// BigInt literal #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, ContentEq, GetSpan, GetSpanMut, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, ContentEq, GetSpan, GetSpanMut, ESTree)] #[estree( rename = "Literal", add_fields(value = BigIntLiteralValue, bigint = BigIntLiteralBigint), @@ -116,7 +116,7 @@ pub struct BigIntLiteral<'a> { /// #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, GetSpan, GetSpanMut, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, ContentEq, GetSpan, GetSpanMut, ESTree)] #[estree( rename = "Literal", add_fields(value = RegExpLiteralValue), @@ -140,7 +140,7 @@ pub struct RegExpLiteral<'a> { /// #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, ContentEq, ESTree)] #[estree(no_type)] pub struct RegExp<'a> { /// The regex pattern between the slashes @@ -154,7 +154,7 @@ pub struct RegExp<'a> { /// This pattern may or may not be parsed. #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, ESTree)] #[estree(via = RegExpPatternConverter)] pub enum RegExpPattern<'a> { /// Unparsed pattern. Contains string slice of the pattern. diff --git a/crates/oxc_ast/src/ast/ts.rs b/crates/oxc_ast/src/ast/ts.rs index 30671bce13f0e..bed0f3cd4287f 100644 --- a/crates/oxc_ast/src/ast/ts.rs +++ b/crates/oxc_ast/src/ast/ts.rs @@ -10,7 +10,7 @@ use std::cell::Cell; -use oxc_allocator::{Box, CloneIn, GetAddress, Vec}; +use oxc_allocator::{Box, CloneIn, Dummy, GetAddress, TakeIn, Vec}; use oxc_ast_macros::ast; use oxc_estree::ESTree; use oxc_span::{Atom, ContentEq, GetSpan, GetSpanMut, Span}; @@ -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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree( rename = "Identifier", add_fields(name = This, decorators = EmptyArray, optional = False), @@ -67,7 +67,7 @@ pub struct TSThisParameter<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSEnumDeclaration<'a> { pub span: Span, pub id: BindingIdentifier<'a>, @@ -98,7 +98,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSEnumMember<'a> { pub span: Span, pub id: TSEnumMemberName<'a>, @@ -108,7 +108,7 @@ pub struct TSEnumMember<'a> { /// TS Enum Member Name #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum TSEnumMemberName<'a> { Identifier(Box<'a, IdentifierName<'a>>) = 0, String(Box<'a, StringLiteral<'a>>) = 1, @@ -128,7 +128,7 @@ pub enum TSEnumMemberName<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSTypeAnnotation<'a> { /// starts at the `:` token and ends at the end of the type annotation pub span: Span, @@ -152,7 +152,7 @@ pub struct TSTypeAnnotation<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSLiteralType<'a> { pub span: Span, pub literal: TSLiteral<'a>, @@ -161,7 +161,7 @@ pub struct TSLiteralType<'a> { /// A literal in a [`TSLiteralType`]. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum TSLiteral<'a> { BooleanLiteral(Box<'a, BooleanLiteral>) = 0, NumericLiteral(Box<'a, NumericLiteral<'a>>) = 1, @@ -184,7 +184,7 @@ pub enum TSLiteral<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum TSType<'a> { // Keyword TSAnyKeyword(Box<'a, TSAnyKeyword>) = 0, @@ -291,7 +291,7 @@ pub use match_ts_type; flags = ScopeFlags::TsConditional, )] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSConditionalType<'a> { pub span: Span, /// The type before `extends` in the test expression. @@ -318,7 +318,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSUnionType<'a> { pub span: Span, /// The types in the union. @@ -340,7 +340,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSIntersectionType<'a> { pub span: Span, pub types: Vec<'a, TSType<'a>>, @@ -357,7 +357,7 @@ pub struct TSIntersectionType<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSParenthesizedType<'a> { pub span: Span, pub type_annotation: TSType<'a>, @@ -374,7 +374,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSTypeOperator<'a> { pub span: Span, pub operator: TSTypeOperatorOperator, @@ -385,7 +385,7 @@ pub struct TSTypeOperator<'a> { /// Operator in a [`TSTypeOperator`]. #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)] pub enum TSTypeOperatorOperator { Keyof = 0, Unique = 1, @@ -405,7 +405,7 @@ pub enum TSTypeOperatorOperator { /// #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSArrayType<'a> { pub span: Span, pub element_type: TSType<'a>, @@ -424,7 +424,7 @@ pub struct TSArrayType<'a> { /// #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSIndexedAccessType<'a> { pub span: Span, pub object_type: TSType<'a>, @@ -442,7 +442,7 @@ pub struct TSIndexedAccessType<'a> { /// #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSTupleType<'a> { pub span: Span, pub element_types: Vec<'a, TSTupleElement<'a>>, @@ -460,7 +460,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSNamedTupleMember<'a> { pub span: Span, pub element_type: TSTupleElement<'a>, @@ -479,7 +479,7 @@ pub struct TSNamedTupleMember<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSOptionalType<'a> { pub span: Span, pub type_annotation: TSType<'a>, @@ -495,7 +495,7 @@ pub struct TSOptionalType<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSRestType<'a> { pub span: Span, pub type_annotation: TSType<'a>, @@ -511,7 +511,7 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, 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`). @@ -533,7 +533,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSAnyKeyword { pub span: Span, } @@ -549,7 +549,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSStringKeyword { pub span: Span, } @@ -565,7 +565,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSBooleanKeyword { pub span: Span, } @@ -581,7 +581,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSNumberKeyword { pub span: Span, } @@ -598,7 +598,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSNeverKeyword { pub span: Span, } @@ -615,7 +615,7 @@ pub struct TSNeverKeyword { /// * [microsoft/TypeScript #40580](https://github.com/microsoft/TypeScript/pull/40580) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSIntrinsicKeyword { pub span: Span, } @@ -633,7 +633,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSUnknownKeyword { pub span: Span, } @@ -650,7 +650,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSNullKeyword { pub span: Span, } @@ -669,42 +669,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSUndefinedKeyword { pub span: Span, } #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSVoidKeyword { pub span: Span, } #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSSymbolKeyword { pub span: Span, } #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSThisType { pub span: Span, } #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSObjectKeyword { pub span: Span, } #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSBigIntKeyword { pub span: Span, } @@ -719,7 +719,7 @@ pub struct TSBigIntKeyword { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSTypeReference<'a> { pub span: Span, pub type_name: TSTypeName<'a>, @@ -731,7 +731,7 @@ pub struct TSTypeReference<'a> { /// NamespaceName . IdentifierReference #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum TSTypeName<'a> { IdentifierReference(Box<'a, IdentifierReference<'a>>) = 0, QualifiedName(Box<'a, TSQualifiedName<'a>>) = 1, @@ -756,7 +756,7 @@ pub use match_ts_type_name; /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSQualifiedName<'a> { pub span: Span, pub left: TSTypeName<'a>, @@ -765,7 +765,7 @@ pub struct TSQualifiedName<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSTypeParameterInstantiation<'a> { pub span: Span, pub params: Vec<'a, TSType<'a>>, @@ -790,7 +790,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSTypeParameter<'a> { pub span: Span, /// The name of the parameter, e.g. `T` in `type Foo = ...`. @@ -809,7 +809,7 @@ pub struct TSTypeParameter<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSTypeParameterDeclaration<'a> { pub span: Span, pub params: Vec<'a, TSTypeParameter<'a>>, @@ -826,7 +826,7 @@ pub struct TSTypeParameterDeclaration<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSTypeAliasDeclaration<'a> { pub span: Span, /// Type alias's identifier, e.g. `Foo` in `type Foo = number`. @@ -840,7 +840,7 @@ pub struct TSTypeAliasDeclaration<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)] pub enum TSAccessibility { Private = 0, Protected = 1, @@ -859,7 +859,7 @@ pub enum TSAccessibility { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSClassImplements<'a> { pub span: Span, pub expression: TSTypeName<'a>, @@ -884,7 +884,7 @@ pub struct TSClassImplements<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSInterfaceDeclaration<'a> { pub span: Span, /// The identifier (name) of the interface. @@ -904,7 +904,7 @@ pub struct TSInterfaceDeclaration<'a> { /// Body of a [`TSInterfaceDeclaration`]. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSInterfaceBody<'a> { pub span: Span, pub body: Vec<'a, TSSignature<'a>>, @@ -927,7 +927,7 @@ pub struct TSInterfaceBody<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSPropertySignature<'a> { pub span: Span, pub computed: bool, @@ -939,7 +939,7 @@ pub struct TSPropertySignature<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum TSSignature<'a> { TSIndexSignature(Box<'a, TSIndexSignature<'a>>) = 0, TSPropertySignature(Box<'a, TSPropertySignature<'a>>) = 1, @@ -961,7 +961,7 @@ pub enum TSSignature<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(add_fields(accessibility = Null))] pub struct TSIndexSignature<'a> { pub span: Span, @@ -973,7 +973,7 @@ pub struct TSIndexSignature<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSCallSignatureDeclaration<'a> { pub span: Span, pub type_parameters: Option>>, @@ -985,7 +985,7 @@ pub struct TSCallSignatureDeclaration<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)] pub enum TSMethodSignatureKind { Method = 0, Get = 1, @@ -1006,7 +1006,7 @@ pub enum TSMethodSignatureKind { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSMethodSignature<'a> { pub span: Span, pub key: PropertyKey<'a>, @@ -1024,7 +1024,7 @@ pub struct TSMethodSignature<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSConstructSignatureDeclaration<'a> { pub span: Span, pub type_parameters: Option>>, @@ -1035,7 +1035,7 @@ pub struct TSConstructSignatureDeclaration<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(rename = "Identifier", add_fields(decorators = EmptyArray, optional = False))] pub struct TSIndexSignatureName<'a> { pub span: Span, @@ -1046,7 +1046,7 @@ pub struct TSIndexSignatureName<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSInterfaceHeritage<'a> { pub span: Span, pub expression: Expression<'a>, @@ -1075,7 +1075,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSTypePredicate<'a> { pub span: Span, /// The identifier the predicate operates on @@ -1092,7 +1092,7 @@ pub struct TSTypePredicate<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub enum TSTypePredicateName<'a> { Identifier(Box<'a, IdentifierName<'a>>) = 0, This(TSThisType) = 1, @@ -1130,7 +1130,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[estree(add_fields(global = TSModuleDeclarationGlobal))] pub struct TSModuleDeclaration<'a> { pub span: Span, @@ -1160,7 +1160,7 @@ pub struct TSModuleDeclaration<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)] pub enum TSModuleDeclarationKind { /// `declare global {}` Global = 0, @@ -1192,7 +1192,7 @@ pub enum TSModuleDeclarationKind { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub enum TSModuleDeclarationName<'a> { Identifier(BindingIdentifier<'a>) = 0, StringLiteral(StringLiteral<'a>) = 1, @@ -1200,7 +1200,7 @@ pub enum TSModuleDeclarationName<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum TSModuleDeclarationBody<'a> { TSModuleDeclaration(Box<'a, TSModuleDeclaration<'a>>) = 0, TSModuleBlock(Box<'a, TSModuleBlock<'a>>) = 1, @@ -1209,7 +1209,7 @@ pub enum TSModuleDeclarationBody<'a> { // See serializer in serialize.rs #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSModuleBlock<'a> { pub span: Span, #[estree(rename = "body")] @@ -1220,7 +1220,7 @@ pub struct TSModuleBlock<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSTypeLiteral<'a> { pub span: Span, pub members: Vec<'a, TSSignature<'a>>, @@ -1241,7 +1241,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSInferType<'a> { pub span: Span, /// The type bound when the @@ -1259,7 +1259,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSTypeQuery<'a> { pub span: Span, pub expr_name: TSTypeQueryExprName<'a>, @@ -1274,7 +1274,7 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum TSTypeQueryExprName<'a> { TSImportType(Box<'a, TSImportType<'a>>) = 2, // `TSTypeName` variants added here by `inherit_variants!` macro @@ -1284,7 +1284,7 @@ pub enum TSTypeQueryExprName<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSImportType<'a> { pub span: Span, pub argument: TSType<'a>, @@ -1306,7 +1306,7 @@ pub struct TSImportType<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSFunctionType<'a> { pub span: Span, /// Generic type parameters @@ -1338,7 +1338,7 @@ pub struct TSFunctionType<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSConstructorType<'a> { pub span: Span, pub r#abstract: bool, @@ -1371,7 +1371,7 @@ pub struct TSConstructorType<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSMappedType<'a> { pub span: Span, /// Key type parameter, e.g. `P` in `[P in keyof T]`. @@ -1407,7 +1407,7 @@ pub struct TSMappedType<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)] pub enum TSMappedTypeModifierOperator { /// e.g. `?` in `{ [P in K]?: T }` True = 0, @@ -1434,7 +1434,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSTemplateLiteralType<'a> { pub span: Span, /// The string parts of the template literal. @@ -1445,7 +1445,7 @@ pub struct TSTemplateLiteralType<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSAsExpression<'a> { pub span: Span, pub expression: Expression<'a>, @@ -1466,7 +1466,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, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSSatisfiesExpression<'a> { pub span: Span, /// The value expression being constrained. @@ -1477,7 +1477,7 @@ pub struct TSSatisfiesExpression<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSTypeAssertion<'a> { pub span: Span, pub expression: Expression<'a>, @@ -1486,7 +1486,7 @@ pub struct TSTypeAssertion<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSImportEqualsDeclaration<'a> { pub span: Span, pub id: BindingIdentifier<'a>, @@ -1502,7 +1502,7 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)] pub enum TSModuleReference<'a> { ExternalModuleReference(Box<'a, TSExternalModuleReference<'a>>) = 2, // `TSTypeName` variants added here by `inherit_variants!` macro @@ -1512,7 +1512,7 @@ pub enum TSModuleReference<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSExternalModuleReference<'a> { pub span: Span, pub expression: StringLiteral<'a>, @@ -1520,7 +1520,7 @@ pub struct TSExternalModuleReference<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSNonNullExpression<'a> { pub span: Span, pub expression: Expression<'a>, @@ -1552,7 +1552,7 @@ pub struct TSNonNullExpression<'a> { /// [`CallExpression`]: crate::ast::js::CallExpression #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct Decorator<'a> { pub span: Span, pub expression: Expression<'a>, @@ -1563,7 +1563,7 @@ pub struct Decorator<'a> { /// `export = foo` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSExportAssignment<'a> { pub span: Span, pub expression: Expression<'a>, @@ -1574,7 +1574,7 @@ pub struct TSExportAssignment<'a> { /// `export as namespace foo` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSNamespaceExportDeclaration<'a> { pub span: Span, pub id: IdentifierName<'a>, @@ -1582,7 +1582,7 @@ pub struct TSNamespaceExportDeclaration<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSInstantiationExpression<'a> { pub span: Span, pub expression: Expression<'a>, @@ -1592,7 +1592,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, ESTree)] +#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)] pub enum ImportOrExportKind { /// `import { foo } from './foo'`; Value = 0, @@ -1605,7 +1605,7 @@ pub enum ImportOrExportKind { /// `type foo = ty?` or `type foo = ?ty` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct JSDocNullableType<'a> { pub span: Span, pub type_annotation: TSType<'a>, @@ -1616,7 +1616,7 @@ pub struct JSDocNullableType<'a> { /// `type foo = ty!` or `type foo = !ty` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct JSDocNonNullableType<'a> { pub span: Span, pub type_annotation: TSType<'a>, @@ -1625,7 +1625,7 @@ pub struct JSDocNonNullableType<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, 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 2753f35d2900b..69c7535feebf4 100644 --- a/crates/oxc_ast/src/ast_impl/literal.rs +++ b/crates/oxc_ast/src/ast_impl/literal.rs @@ -2,7 +2,7 @@ use std::{borrow::Cow, fmt}; -use oxc_allocator::CloneIn; +use oxc_allocator::{Allocator, CloneIn, Dummy}; use oxc_data_structures::inline_string::InlineString; use oxc_regular_expression::ast::Pattern; use oxc_span::ContentEq; @@ -213,11 +213,22 @@ impl ContentEq for RegExpFlags { impl<'alloc> CloneIn<'alloc> for RegExpFlags { type Cloned = Self; - fn clone_in(&self, _: &'alloc oxc_allocator::Allocator) -> Self::Cloned { + fn clone_in(&self, _: &'alloc Allocator) -> Self::Cloned { *self } } +impl<'a> Dummy<'a> for RegExpFlags { + /// Create a dummy [`RegExpFlags`]. + /// + /// Does not allocate any data into arena. + #[expect(clippy::inline_always)] + #[inline(always)] + fn dummy(_: &'a Allocator) -> Self { + RegExpFlags::empty() + } +} + impl TryFrom for RegExpFlags { type Error = char; diff --git a/crates/oxc_ast/src/generated/derive_dummy.rs b/crates/oxc_ast/src/generated/derive_dummy.rs new file mode 100644 index 0000000000000..b113c775cb348 --- /dev/null +++ b/crates/oxc_ast/src/generated/derive_dummy.rs @@ -0,0 +1,2861 @@ +// Auto-generated code, DO NOT EDIT DIRECTLY! +// To edit this generated file you have to edit `tasks/ast_tools/src/derives/dummy.rs` + +#![allow(unused_variables, clippy::inline_always)] + +use oxc_allocator::{Allocator, Dummy}; + +use crate::ast::js::*; +use crate::ast::jsx::*; +use crate::ast::literal::*; +use crate::ast::ts::*; + +impl<'a> Dummy<'a> for Program<'a> { + /// Create a dummy [`Program`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + source_type: Dummy::dummy(allocator), + source_text: Dummy::dummy(allocator), + comments: Dummy::dummy(allocator), + hashbang: Dummy::dummy(allocator), + directives: Dummy::dummy(allocator), + body: Dummy::dummy(allocator), + scope_id: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for Expression<'a> { + /// Create a dummy [`Expression`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::NullLiteral(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for IdentifierName<'a> { + /// Create a dummy [`IdentifierName`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), name: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for IdentifierReference<'a> { + /// Create a dummy [`IdentifierReference`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + name: Dummy::dummy(allocator), + reference_id: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for BindingIdentifier<'a> { + /// Create a dummy [`BindingIdentifier`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + name: Dummy::dummy(allocator), + symbol_id: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for LabelIdentifier<'a> { + /// Create a dummy [`LabelIdentifier`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), name: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for ThisExpression { + /// Create a dummy [`ThisExpression`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for ArrayExpression<'a> { + /// Create a dummy [`ArrayExpression`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + elements: Dummy::dummy(allocator), + trailing_comma: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for ArrayExpressionElement<'a> { + /// Create a dummy [`ArrayExpressionElement`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self::Elision(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for Elision { + /// Create a dummy [`Elision`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for ObjectExpression<'a> { + /// Create a dummy [`ObjectExpression`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + properties: Dummy::dummy(allocator), + trailing_comma: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for ObjectPropertyKind<'a> { + /// Create a dummy [`ObjectPropertyKind`]. + /// + /// Has cost of making 2 allocations (32 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::SpreadProperty(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for ObjectProperty<'a> { + /// Create a dummy [`ObjectProperty`]. + /// + /// Has cost of making 2 allocations (16 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + kind: Dummy::dummy(allocator), + key: Dummy::dummy(allocator), + value: Dummy::dummy(allocator), + method: Dummy::dummy(allocator), + shorthand: Dummy::dummy(allocator), + computed: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for PropertyKey<'a> { + /// Create a dummy [`PropertyKey`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::NullLiteral(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for PropertyKind { + /// Create a dummy [`PropertyKind`]. + /// + /// Does not allocate any data into arena. + #[inline(always)] + fn dummy(allocator: &'a Allocator) -> Self { + Self::Init + } +} + +impl<'a> Dummy<'a> for TemplateLiteral<'a> { + /// Create a dummy [`TemplateLiteral`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + quasis: Dummy::dummy(allocator), + expressions: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TaggedTemplateExpression<'a> { + /// Create a dummy [`TaggedTemplateExpression`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + tag: Dummy::dummy(allocator), + quasi: Dummy::dummy(allocator), + type_arguments: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TemplateElement<'a> { + /// Create a dummy [`TemplateElement`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + value: Dummy::dummy(allocator), + tail: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TemplateElementValue<'a> { + /// Create a dummy [`TemplateElementValue`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { raw: Dummy::dummy(allocator), cooked: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for MemberExpression<'a> { + /// Create a dummy [`MemberExpression`]. + /// + /// Has cost of making 2 allocations (64 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::StaticMemberExpression(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for ComputedMemberExpression<'a> { + /// Create a dummy [`ComputedMemberExpression`]. + /// + /// Has cost of making 2 allocations (16 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + object: Dummy::dummy(allocator), + expression: Dummy::dummy(allocator), + optional: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for StaticMemberExpression<'a> { + /// Create a dummy [`StaticMemberExpression`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + object: Dummy::dummy(allocator), + property: Dummy::dummy(allocator), + optional: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for PrivateFieldExpression<'a> { + /// Create a dummy [`PrivateFieldExpression`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + object: Dummy::dummy(allocator), + field: Dummy::dummy(allocator), + optional: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for CallExpression<'a> { + /// Create a dummy [`CallExpression`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + callee: Dummy::dummy(allocator), + type_arguments: Dummy::dummy(allocator), + arguments: Dummy::dummy(allocator), + optional: Dummy::dummy(allocator), + pure: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for NewExpression<'a> { + /// Create a dummy [`NewExpression`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + callee: Dummy::dummy(allocator), + arguments: Dummy::dummy(allocator), + type_arguments: Dummy::dummy(allocator), + pure: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for MetaProperty<'a> { + /// Create a dummy [`MetaProperty`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + meta: Dummy::dummy(allocator), + property: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for SpreadElement<'a> { + /// Create a dummy [`SpreadElement`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), argument: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for Argument<'a> { + /// Create a dummy [`Argument`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::NullLiteral(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for UpdateExpression<'a> { + /// Create a dummy [`UpdateExpression`]. + /// + /// Has cost of making 1 allocation (32 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + operator: Dummy::dummy(allocator), + prefix: Dummy::dummy(allocator), + argument: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for UnaryExpression<'a> { + /// Create a dummy [`UnaryExpression`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + operator: Dummy::dummy(allocator), + argument: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for BinaryExpression<'a> { + /// Create a dummy [`BinaryExpression`]. + /// + /// Has cost of making 2 allocations (16 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + left: Dummy::dummy(allocator), + operator: Dummy::dummy(allocator), + right: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for PrivateInExpression<'a> { + /// Create a dummy [`PrivateInExpression`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + left: Dummy::dummy(allocator), + right: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for LogicalExpression<'a> { + /// Create a dummy [`LogicalExpression`]. + /// + /// Has cost of making 2 allocations (16 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + left: Dummy::dummy(allocator), + operator: Dummy::dummy(allocator), + right: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for ConditionalExpression<'a> { + /// Create a dummy [`ConditionalExpression`]. + /// + /// Has cost of making 3 allocations (24 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + test: Dummy::dummy(allocator), + consequent: Dummy::dummy(allocator), + alternate: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for AssignmentExpression<'a> { + /// Create a dummy [`AssignmentExpression`]. + /// + /// Has cost of making 2 allocations (40 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + operator: Dummy::dummy(allocator), + left: Dummy::dummy(allocator), + right: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for AssignmentTarget<'a> { + /// Create a dummy [`AssignmentTarget`]. + /// + /// Has cost of making 1 allocation (32 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::AssignmentTargetIdentifier(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for SimpleAssignmentTarget<'a> { + /// Create a dummy [`SimpleAssignmentTarget`]. + /// + /// Has cost of making 1 allocation (32 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::AssignmentTargetIdentifier(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for AssignmentTargetPattern<'a> { + /// Create a dummy [`AssignmentTargetPattern`]. + /// + /// Has cost of making 1 allocation (64 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::ObjectAssignmentTarget(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for ArrayAssignmentTarget<'a> { + /// Create a dummy [`ArrayAssignmentTarget`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + elements: Dummy::dummy(allocator), + rest: Dummy::dummy(allocator), + trailing_comma: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for ObjectAssignmentTarget<'a> { + /// Create a dummy [`ObjectAssignmentTarget`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + properties: Dummy::dummy(allocator), + rest: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for AssignmentTargetRest<'a> { + /// Create a dummy [`AssignmentTargetRest`]. + /// + /// Has cost of making 1 allocation (32 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), target: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for AssignmentTargetMaybeDefault<'a> { + /// Create a dummy [`AssignmentTargetMaybeDefault`]. + /// + /// Has cost of making 1 allocation (32 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::AssignmentTargetIdentifier(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for AssignmentTargetWithDefault<'a> { + /// Create a dummy [`AssignmentTargetWithDefault`]. + /// + /// Has cost of making 2 allocations (40 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + binding: Dummy::dummy(allocator), + init: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for AssignmentTargetProperty<'a> { + /// Create a dummy [`AssignmentTargetProperty`]. + /// + /// Has cost of making 1 allocation (56 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::AssignmentTargetPropertyIdentifier(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for AssignmentTargetPropertyIdentifier<'a> { + /// Create a dummy [`AssignmentTargetPropertyIdentifier`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + binding: Dummy::dummy(allocator), + init: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for AssignmentTargetPropertyProperty<'a> { + /// Create a dummy [`AssignmentTargetPropertyProperty`]. + /// + /// Has cost of making 2 allocations (40 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + name: Dummy::dummy(allocator), + binding: Dummy::dummy(allocator), + computed: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for SequenceExpression<'a> { + /// Create a dummy [`SequenceExpression`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), expressions: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for Super { + /// Create a dummy [`Super`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for AwaitExpression<'a> { + /// Create a dummy [`AwaitExpression`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), argument: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for ChainExpression<'a> { + /// Create a dummy [`ChainExpression`]. + /// + /// Has cost of making 2 allocations (32 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), expression: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for ChainElement<'a> { + /// Create a dummy [`ChainElement`]. + /// + /// Has cost of making 2 allocations (32 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::TSNonNullExpression(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for ParenthesizedExpression<'a> { + /// Create a dummy [`ParenthesizedExpression`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), expression: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for Statement<'a> { + /// Create a dummy [`Statement`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::DebuggerStatement(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for Directive<'a> { + /// Create a dummy [`Directive`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + expression: Dummy::dummy(allocator), + directive: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for Hashbang<'a> { + /// Create a dummy [`Hashbang`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), value: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for BlockStatement<'a> { + /// Create a dummy [`BlockStatement`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + body: Dummy::dummy(allocator), + scope_id: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for Declaration<'a> { + /// Create a dummy [`Declaration`]. + /// + /// Has cost of making 1 allocation (56 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::VariableDeclaration(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for VariableDeclaration<'a> { + /// Create a dummy [`VariableDeclaration`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + kind: Dummy::dummy(allocator), + declarations: Dummy::dummy(allocator), + declare: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for VariableDeclarationKind { + /// Create a dummy [`VariableDeclarationKind`]. + /// + /// Does not allocate any data into arena. + #[inline(always)] + fn dummy(allocator: &'a Allocator) -> Self { + Self::Var + } +} + +impl<'a> Dummy<'a> for VariableDeclarator<'a> { + /// Create a dummy [`VariableDeclarator`]. + /// + /// Has cost of making 1 allocation (32 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + kind: Dummy::dummy(allocator), + id: Dummy::dummy(allocator), + init: Dummy::dummy(allocator), + definite: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for EmptyStatement { + /// Create a dummy [`EmptyStatement`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for ExpressionStatement<'a> { + /// Create a dummy [`ExpressionStatement`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), expression: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for IfStatement<'a> { + /// Create a dummy [`IfStatement`]. + /// + /// Has cost of making 2 allocations (16 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + test: Dummy::dummy(allocator), + consequent: Dummy::dummy(allocator), + alternate: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for DoWhileStatement<'a> { + /// Create a dummy [`DoWhileStatement`]. + /// + /// Has cost of making 2 allocations (16 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + body: Dummy::dummy(allocator), + test: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for WhileStatement<'a> { + /// Create a dummy [`WhileStatement`]. + /// + /// Has cost of making 2 allocations (16 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + test: Dummy::dummy(allocator), + body: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for ForStatement<'a> { + /// Create a dummy [`ForStatement`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + init: Dummy::dummy(allocator), + test: Dummy::dummy(allocator), + update: Dummy::dummy(allocator), + body: Dummy::dummy(allocator), + scope_id: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for ForStatementInit<'a> { + /// Create a dummy [`ForStatementInit`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::NullLiteral(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for ForInStatement<'a> { + /// Create a dummy [`ForInStatement`]. + /// + /// Has cost of making 3 allocations (48 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + left: Dummy::dummy(allocator), + right: Dummy::dummy(allocator), + body: Dummy::dummy(allocator), + scope_id: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for ForStatementLeft<'a> { + /// Create a dummy [`ForStatementLeft`]. + /// + /// Has cost of making 1 allocation (32 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::AssignmentTargetIdentifier(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for ForOfStatement<'a> { + /// Create a dummy [`ForOfStatement`]. + /// + /// Has cost of making 3 allocations (48 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + r#await: Dummy::dummy(allocator), + left: Dummy::dummy(allocator), + right: Dummy::dummy(allocator), + body: Dummy::dummy(allocator), + scope_id: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for ContinueStatement<'a> { + /// Create a dummy [`ContinueStatement`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), label: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for BreakStatement<'a> { + /// Create a dummy [`BreakStatement`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), label: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for ReturnStatement<'a> { + /// Create a dummy [`ReturnStatement`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), argument: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for WithStatement<'a> { + /// Create a dummy [`WithStatement`]. + /// + /// Has cost of making 2 allocations (16 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + object: Dummy::dummy(allocator), + body: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for SwitchStatement<'a> { + /// Create a dummy [`SwitchStatement`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + discriminant: Dummy::dummy(allocator), + cases: Dummy::dummy(allocator), + scope_id: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for SwitchCase<'a> { + /// Create a dummy [`SwitchCase`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + test: Dummy::dummy(allocator), + consequent: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for LabeledStatement<'a> { + /// Create a dummy [`LabeledStatement`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + label: Dummy::dummy(allocator), + body: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for ThrowStatement<'a> { + /// Create a dummy [`ThrowStatement`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), argument: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for TryStatement<'a> { + /// Create a dummy [`TryStatement`]. + /// + /// Has cost of making 1 allocation (48 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + block: Dummy::dummy(allocator), + handler: Dummy::dummy(allocator), + finalizer: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for CatchClause<'a> { + /// Create a dummy [`CatchClause`]. + /// + /// Has cost of making 1 allocation (48 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + param: Dummy::dummy(allocator), + body: Dummy::dummy(allocator), + scope_id: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for CatchParameter<'a> { + /// Create a dummy [`CatchParameter`]. + /// + /// Has cost of making 1 allocation (32 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), pattern: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for DebuggerStatement { + /// Create a dummy [`DebuggerStatement`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for BindingPattern<'a> { + /// Create a dummy [`BindingPattern`]. + /// + /// Has cost of making 1 allocation (32 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + kind: Dummy::dummy(allocator), + type_annotation: Dummy::dummy(allocator), + optional: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for BindingPatternKind<'a> { + /// Create a dummy [`BindingPatternKind`]. + /// + /// Has cost of making 1 allocation (32 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::BindingIdentifier(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for AssignmentPattern<'a> { + /// Create a dummy [`AssignmentPattern`]. + /// + /// Has cost of making 2 allocations (40 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + left: Dummy::dummy(allocator), + right: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for ObjectPattern<'a> { + /// Create a dummy [`ObjectPattern`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + properties: Dummy::dummy(allocator), + rest: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for BindingProperty<'a> { + /// Create a dummy [`BindingProperty`]. + /// + /// Has cost of making 2 allocations (40 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + key: Dummy::dummy(allocator), + value: Dummy::dummy(allocator), + shorthand: Dummy::dummy(allocator), + computed: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for ArrayPattern<'a> { + /// Create a dummy [`ArrayPattern`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + elements: Dummy::dummy(allocator), + rest: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for BindingRestElement<'a> { + /// Create a dummy [`BindingRestElement`]. + /// + /// Has cost of making 1 allocation (32 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), argument: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for Function<'a> { + /// Create a dummy [`Function`]. + /// + /// Has cost of making 1 allocation (56 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + r#type: Dummy::dummy(allocator), + id: Dummy::dummy(allocator), + generator: Dummy::dummy(allocator), + r#async: Dummy::dummy(allocator), + declare: Dummy::dummy(allocator), + type_parameters: Dummy::dummy(allocator), + this_param: Dummy::dummy(allocator), + params: Dummy::dummy(allocator), + return_type: Dummy::dummy(allocator), + body: Dummy::dummy(allocator), + scope_id: Dummy::dummy(allocator), + pure: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for FunctionType { + /// Create a dummy [`FunctionType`]. + /// + /// Does not allocate any data into arena. + #[inline(always)] + fn dummy(allocator: &'a Allocator) -> Self { + Self::FunctionDeclaration + } +} + +impl<'a> Dummy<'a> for FormalParameters<'a> { + /// Create a dummy [`FormalParameters`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + kind: Dummy::dummy(allocator), + items: Dummy::dummy(allocator), + rest: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for FormalParameter<'a> { + /// Create a dummy [`FormalParameter`]. + /// + /// Has cost of making 1 allocation (32 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + decorators: Dummy::dummy(allocator), + pattern: Dummy::dummy(allocator), + accessibility: Dummy::dummy(allocator), + readonly: Dummy::dummy(allocator), + r#override: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for FormalParameterKind { + /// Create a dummy [`FormalParameterKind`]. + /// + /// Does not allocate any data into arena. + #[inline(always)] + fn dummy(allocator: &'a Allocator) -> Self { + Self::FormalParameter + } +} + +impl<'a> Dummy<'a> for FunctionBody<'a> { + /// Create a dummy [`FunctionBody`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + directives: Dummy::dummy(allocator), + statements: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for ArrowFunctionExpression<'a> { + /// Create a dummy [`ArrowFunctionExpression`]. + /// + /// Has cost of making 2 allocations (128 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + expression: Dummy::dummy(allocator), + r#async: Dummy::dummy(allocator), + type_parameters: Dummy::dummy(allocator), + params: Dummy::dummy(allocator), + return_type: Dummy::dummy(allocator), + body: Dummy::dummy(allocator), + scope_id: Dummy::dummy(allocator), + pure: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for YieldExpression<'a> { + /// Create a dummy [`YieldExpression`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + delegate: Dummy::dummy(allocator), + argument: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for Class<'a> { + /// Create a dummy [`Class`]. + /// + /// Has cost of making 1 allocation (40 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + r#type: Dummy::dummy(allocator), + decorators: Dummy::dummy(allocator), + id: Dummy::dummy(allocator), + type_parameters: Dummy::dummy(allocator), + super_class: Dummy::dummy(allocator), + super_type_arguments: Dummy::dummy(allocator), + implements: Dummy::dummy(allocator), + body: Dummy::dummy(allocator), + r#abstract: Dummy::dummy(allocator), + declare: Dummy::dummy(allocator), + scope_id: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for ClassType { + /// Create a dummy [`ClassType`]. + /// + /// Does not allocate any data into arena. + #[inline(always)] + fn dummy(allocator: &'a Allocator) -> Self { + Self::ClassDeclaration + } +} + +impl<'a> Dummy<'a> for ClassBody<'a> { + /// Create a dummy [`ClassBody`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), body: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for ClassElement<'a> { + /// Create a dummy [`ClassElement`]. + /// + /// Has cost of making 1 allocation (48 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::StaticBlock(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for MethodDefinition<'a> { + /// Create a dummy [`MethodDefinition`]. + /// + /// Has cost of making 3 allocations (168 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + r#type: Dummy::dummy(allocator), + decorators: Dummy::dummy(allocator), + key: Dummy::dummy(allocator), + value: Dummy::dummy(allocator), + kind: Dummy::dummy(allocator), + computed: Dummy::dummy(allocator), + r#static: Dummy::dummy(allocator), + r#override: Dummy::dummy(allocator), + optional: Dummy::dummy(allocator), + accessibility: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for MethodDefinitionType { + /// Create a dummy [`MethodDefinitionType`]. + /// + /// Does not allocate any data into arena. + #[inline(always)] + fn dummy(allocator: &'a Allocator) -> Self { + Self::MethodDefinition + } +} + +impl<'a> Dummy<'a> for PropertyDefinition<'a> { + /// Create a dummy [`PropertyDefinition`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + r#type: Dummy::dummy(allocator), + decorators: Dummy::dummy(allocator), + key: Dummy::dummy(allocator), + value: Dummy::dummy(allocator), + computed: Dummy::dummy(allocator), + r#static: Dummy::dummy(allocator), + declare: Dummy::dummy(allocator), + r#override: Dummy::dummy(allocator), + optional: Dummy::dummy(allocator), + definite: Dummy::dummy(allocator), + readonly: Dummy::dummy(allocator), + type_annotation: Dummy::dummy(allocator), + accessibility: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for PropertyDefinitionType { + /// Create a dummy [`PropertyDefinitionType`]. + /// + /// Does not allocate any data into arena. + #[inline(always)] + fn dummy(allocator: &'a Allocator) -> Self { + Self::PropertyDefinition + } +} + +impl<'a> Dummy<'a> for MethodDefinitionKind { + /// Create a dummy [`MethodDefinitionKind`]. + /// + /// Does not allocate any data into arena. + #[inline(always)] + fn dummy(allocator: &'a Allocator) -> Self { + Self::Constructor + } +} + +impl<'a> Dummy<'a> for PrivateIdentifier<'a> { + /// Create a dummy [`PrivateIdentifier`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), name: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for StaticBlock<'a> { + /// Create a dummy [`StaticBlock`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + body: Dummy::dummy(allocator), + scope_id: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for ModuleDeclaration<'a> { + /// Create a dummy [`ModuleDeclaration`]. + /// + /// Has cost of making 1 allocation (32 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::TSNamespaceExportDeclaration(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for AccessorPropertyType { + /// Create a dummy [`AccessorPropertyType`]. + /// + /// Does not allocate any data into arena. + #[inline(always)] + fn dummy(allocator: &'a Allocator) -> Self { + Self::AccessorProperty + } +} + +impl<'a> Dummy<'a> for AccessorProperty<'a> { + /// Create a dummy [`AccessorProperty`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + r#type: Dummy::dummy(allocator), + decorators: Dummy::dummy(allocator), + key: Dummy::dummy(allocator), + value: Dummy::dummy(allocator), + computed: Dummy::dummy(allocator), + r#static: Dummy::dummy(allocator), + definite: Dummy::dummy(allocator), + type_annotation: Dummy::dummy(allocator), + accessibility: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for ImportExpression<'a> { + /// Create a dummy [`ImportExpression`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + source: Dummy::dummy(allocator), + options: Dummy::dummy(allocator), + phase: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for ImportDeclaration<'a> { + /// Create a dummy [`ImportDeclaration`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + specifiers: Dummy::dummy(allocator), + source: Dummy::dummy(allocator), + phase: Dummy::dummy(allocator), + with_clause: Dummy::dummy(allocator), + import_kind: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for ImportPhase { + /// Create a dummy [`ImportPhase`]. + /// + /// Does not allocate any data into arena. + #[inline(always)] + fn dummy(allocator: &'a Allocator) -> Self { + Self::Source + } +} + +impl<'a> Dummy<'a> for ImportDeclarationSpecifier<'a> { + /// Create a dummy [`ImportDeclarationSpecifier`]. + /// + /// Has cost of making 1 allocation (40 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::ImportDefaultSpecifier(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for ImportSpecifier<'a> { + /// Create a dummy [`ImportSpecifier`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + imported: Dummy::dummy(allocator), + local: Dummy::dummy(allocator), + import_kind: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for ImportDefaultSpecifier<'a> { + /// Create a dummy [`ImportDefaultSpecifier`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), local: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for ImportNamespaceSpecifier<'a> { + /// Create a dummy [`ImportNamespaceSpecifier`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), local: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for WithClause<'a> { + /// Create a dummy [`WithClause`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + attributes_keyword: Dummy::dummy(allocator), + with_entries: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for ImportAttribute<'a> { + /// Create a dummy [`ImportAttribute`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + key: Dummy::dummy(allocator), + value: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for ImportAttributeKey<'a> { + /// Create a dummy [`ImportAttributeKey`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self::Identifier(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for ExportNamedDeclaration<'a> { + /// Create a dummy [`ExportNamedDeclaration`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + declaration: Dummy::dummy(allocator), + specifiers: Dummy::dummy(allocator), + source: Dummy::dummy(allocator), + export_kind: Dummy::dummy(allocator), + with_clause: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for ExportDefaultDeclaration<'a> { + /// Create a dummy [`ExportDefaultDeclaration`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + exported: Dummy::dummy(allocator), + declaration: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for ExportAllDeclaration<'a> { + /// Create a dummy [`ExportAllDeclaration`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + exported: Dummy::dummy(allocator), + source: Dummy::dummy(allocator), + with_clause: Dummy::dummy(allocator), + export_kind: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for ExportSpecifier<'a> { + /// Create a dummy [`ExportSpecifier`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + local: Dummy::dummy(allocator), + exported: Dummy::dummy(allocator), + export_kind: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for ExportDefaultDeclarationKind<'a> { + /// Create a dummy [`ExportDefaultDeclarationKind`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::NullLiteral(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for ModuleExportName<'a> { + /// Create a dummy [`ModuleExportName`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self::IdentifierName(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for V8IntrinsicExpression<'a> { + /// Create a dummy [`V8IntrinsicExpression`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + name: Dummy::dummy(allocator), + arguments: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for BooleanLiteral { + /// Create a dummy [`BooleanLiteral`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), value: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for NullLiteral { + /// Create a dummy [`NullLiteral`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for NumericLiteral<'a> { + /// Create a dummy [`NumericLiteral`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + value: Dummy::dummy(allocator), + raw: Dummy::dummy(allocator), + base: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for StringLiteral<'a> { + /// Create a dummy [`StringLiteral`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + value: Dummy::dummy(allocator), + raw: Dummy::dummy(allocator), + lossy: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for BigIntLiteral<'a> { + /// Create a dummy [`BigIntLiteral`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + raw: Dummy::dummy(allocator), + base: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for RegExpLiteral<'a> { + /// Create a dummy [`RegExpLiteral`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + regex: Dummy::dummy(allocator), + raw: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for RegExp<'a> { + /// Create a dummy [`RegExp`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { pattern: Dummy::dummy(allocator), flags: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for RegExpPattern<'a> { + /// Create a dummy [`RegExpPattern`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self::Raw(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for JSXElement<'a> { + /// Create a dummy [`JSXElement`]. + /// + /// Has cost of making 2 allocations (80 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + opening_element: Dummy::dummy(allocator), + closing_element: Dummy::dummy(allocator), + children: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for JSXOpeningElement<'a> { + /// Create a dummy [`JSXOpeningElement`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + self_closing: Dummy::dummy(allocator), + name: Dummy::dummy(allocator), + attributes: Dummy::dummy(allocator), + type_arguments: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for JSXClosingElement<'a> { + /// Create a dummy [`JSXClosingElement`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), name: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for JSXFragment<'a> { + /// Create a dummy [`JSXFragment`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + opening_fragment: Dummy::dummy(allocator), + closing_fragment: Dummy::dummy(allocator), + children: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for JSXOpeningFragment { + /// Create a dummy [`JSXOpeningFragment`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for JSXClosingFragment { + /// Create a dummy [`JSXClosingFragment`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for JSXElementName<'a> { + /// Create a dummy [`JSXElementName`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::ThisExpression(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for JSXNamespacedName<'a> { + /// Create a dummy [`JSXNamespacedName`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + namespace: Dummy::dummy(allocator), + name: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for JSXMemberExpression<'a> { + /// Create a dummy [`JSXMemberExpression`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + object: Dummy::dummy(allocator), + property: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for JSXMemberExpressionObject<'a> { + /// Create a dummy [`JSXMemberExpressionObject`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::ThisExpression(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for JSXExpressionContainer<'a> { + /// Create a dummy [`JSXExpressionContainer`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), expression: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for JSXExpression<'a> { + /// Create a dummy [`JSXExpression`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self::EmptyExpression(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for JSXEmptyExpression { + /// Create a dummy [`JSXEmptyExpression`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for JSXAttributeItem<'a> { + /// Create a dummy [`JSXAttributeItem`]. + /// + /// Has cost of making 2 allocations (32 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::SpreadAttribute(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for JSXAttribute<'a> { + /// Create a dummy [`JSXAttribute`]. + /// + /// Has cost of making 1 allocation (24 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + name: Dummy::dummy(allocator), + value: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for JSXSpreadAttribute<'a> { + /// Create a dummy [`JSXSpreadAttribute`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), argument: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for JSXAttributeName<'a> { + /// Create a dummy [`JSXAttributeName`]. + /// + /// Has cost of making 1 allocation (24 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::Identifier(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for JSXAttributeValue<'a> { + /// Create a dummy [`JSXAttributeValue`]. + /// + /// Has cost of making 1 allocation (24 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::ExpressionContainer(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for JSXIdentifier<'a> { + /// Create a dummy [`JSXIdentifier`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), name: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for JSXChild<'a> { + /// Create a dummy [`JSXChild`]. + /// + /// Has cost of making 1 allocation (24 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::ExpressionContainer(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for JSXSpreadChild<'a> { + /// Create a dummy [`JSXSpreadChild`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), expression: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for JSXText<'a> { + /// Create a dummy [`JSXText`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + value: Dummy::dummy(allocator), + raw: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSThisParameter<'a> { + /// Create a dummy [`TSThisParameter`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + this_span: Dummy::dummy(allocator), + type_annotation: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSEnumDeclaration<'a> { + /// Create a dummy [`TSEnumDeclaration`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + id: Dummy::dummy(allocator), + members: Dummy::dummy(allocator), + r#const: Dummy::dummy(allocator), + declare: Dummy::dummy(allocator), + scope_id: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSEnumMember<'a> { + /// Create a dummy [`TSEnumMember`]. + /// + /// Has cost of making 1 allocation (24 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + id: Dummy::dummy(allocator), + initializer: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSEnumMemberName<'a> { + /// Create a dummy [`TSEnumMemberName`]. + /// + /// Has cost of making 1 allocation (24 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::Identifier(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for TSTypeAnnotation<'a> { + /// Create a dummy [`TSTypeAnnotation`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), type_annotation: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for TSLiteralType<'a> { + /// Create a dummy [`TSLiteralType`]. + /// + /// Has cost of making 1 allocation (16 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), literal: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for TSLiteral<'a> { + /// Create a dummy [`TSLiteral`]. + /// + /// Has cost of making 1 allocation (16 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::BooleanLiteral(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for TSType<'a> { + /// Create a dummy [`TSType`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::TSAnyKeyword(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for TSConditionalType<'a> { + /// Create a dummy [`TSConditionalType`]. + /// + /// Has cost of making 4 allocations (32 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + check_type: Dummy::dummy(allocator), + extends_type: Dummy::dummy(allocator), + true_type: Dummy::dummy(allocator), + false_type: Dummy::dummy(allocator), + scope_id: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSUnionType<'a> { + /// Create a dummy [`TSUnionType`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), types: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for TSIntersectionType<'a> { + /// Create a dummy [`TSIntersectionType`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), types: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for TSParenthesizedType<'a> { + /// Create a dummy [`TSParenthesizedType`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), type_annotation: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for TSTypeOperator<'a> { + /// Create a dummy [`TSTypeOperator`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + operator: Dummy::dummy(allocator), + type_annotation: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSTypeOperatorOperator { + /// Create a dummy [`TSTypeOperatorOperator`]. + /// + /// Does not allocate any data into arena. + #[inline(always)] + fn dummy(allocator: &'a Allocator) -> Self { + Self::Keyof + } +} + +impl<'a> Dummy<'a> for TSArrayType<'a> { + /// Create a dummy [`TSArrayType`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), element_type: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for TSIndexedAccessType<'a> { + /// Create a dummy [`TSIndexedAccessType`]. + /// + /// Has cost of making 2 allocations (16 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + object_type: Dummy::dummy(allocator), + index_type: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSTupleType<'a> { + /// Create a dummy [`TSTupleType`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), element_types: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for TSNamedTupleMember<'a> { + /// Create a dummy [`TSNamedTupleMember`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + element_type: Dummy::dummy(allocator), + label: Dummy::dummy(allocator), + optional: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSOptionalType<'a> { + /// Create a dummy [`TSOptionalType`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), type_annotation: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for TSRestType<'a> { + /// Create a dummy [`TSRestType`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), type_annotation: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for TSTupleElement<'a> { + /// Create a dummy [`TSTupleElement`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::TSAnyKeyword(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for TSAnyKeyword { + /// Create a dummy [`TSAnyKeyword`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for TSStringKeyword { + /// Create a dummy [`TSStringKeyword`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for TSBooleanKeyword { + /// Create a dummy [`TSBooleanKeyword`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for TSNumberKeyword { + /// Create a dummy [`TSNumberKeyword`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for TSNeverKeyword { + /// Create a dummy [`TSNeverKeyword`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for TSIntrinsicKeyword { + /// Create a dummy [`TSIntrinsicKeyword`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for TSUnknownKeyword { + /// Create a dummy [`TSUnknownKeyword`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for TSNullKeyword { + /// Create a dummy [`TSNullKeyword`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for TSUndefinedKeyword { + /// Create a dummy [`TSUndefinedKeyword`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for TSVoidKeyword { + /// Create a dummy [`TSVoidKeyword`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for TSSymbolKeyword { + /// Create a dummy [`TSSymbolKeyword`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for TSThisType { + /// Create a dummy [`TSThisType`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for TSObjectKeyword { + /// Create a dummy [`TSObjectKeyword`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for TSBigIntKeyword { + /// Create a dummy [`TSBigIntKeyword`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for TSTypeReference<'a> { + /// Create a dummy [`TSTypeReference`]. + /// + /// Has cost of making 1 allocation (32 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + type_name: Dummy::dummy(allocator), + type_arguments: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSTypeName<'a> { + /// Create a dummy [`TSTypeName`]. + /// + /// Has cost of making 1 allocation (32 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::IdentifierReference(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for TSQualifiedName<'a> { + /// Create a dummy [`TSQualifiedName`]. + /// + /// Has cost of making 1 allocation (32 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + left: Dummy::dummy(allocator), + right: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSTypeParameterInstantiation<'a> { + /// Create a dummy [`TSTypeParameterInstantiation`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), params: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for TSTypeParameter<'a> { + /// Create a dummy [`TSTypeParameter`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + name: Dummy::dummy(allocator), + constraint: Dummy::dummy(allocator), + default: Dummy::dummy(allocator), + r#in: Dummy::dummy(allocator), + out: Dummy::dummy(allocator), + r#const: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSTypeParameterDeclaration<'a> { + /// Create a dummy [`TSTypeParameterDeclaration`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), params: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for TSTypeAliasDeclaration<'a> { + /// Create a dummy [`TSTypeAliasDeclaration`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + id: Dummy::dummy(allocator), + type_parameters: Dummy::dummy(allocator), + type_annotation: Dummy::dummy(allocator), + declare: Dummy::dummy(allocator), + scope_id: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSAccessibility { + /// Create a dummy [`TSAccessibility`]. + /// + /// Does not allocate any data into arena. + #[inline(always)] + fn dummy(allocator: &'a Allocator) -> Self { + Self::Private + } +} + +impl<'a> Dummy<'a> for TSClassImplements<'a> { + /// Create a dummy [`TSClassImplements`]. + /// + /// Has cost of making 1 allocation (32 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + expression: Dummy::dummy(allocator), + type_arguments: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSInterfaceDeclaration<'a> { + /// Create a dummy [`TSInterfaceDeclaration`]. + /// + /// Has cost of making 1 allocation (40 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + id: Dummy::dummy(allocator), + extends: Dummy::dummy(allocator), + type_parameters: Dummy::dummy(allocator), + body: Dummy::dummy(allocator), + declare: Dummy::dummy(allocator), + scope_id: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSInterfaceBody<'a> { + /// Create a dummy [`TSInterfaceBody`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), body: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for TSPropertySignature<'a> { + /// Create a dummy [`TSPropertySignature`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + computed: Dummy::dummy(allocator), + optional: Dummy::dummy(allocator), + readonly: Dummy::dummy(allocator), + key: Dummy::dummy(allocator), + type_annotation: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSSignature<'a> { + /// Create a dummy [`TSSignature`]. + /// + /// Has cost of making 2 allocations (48 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::TSPropertySignature(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for TSIndexSignature<'a> { + /// Create a dummy [`TSIndexSignature`]. + /// + /// Has cost of making 2 allocations (32 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + parameters: Dummy::dummy(allocator), + type_annotation: Dummy::dummy(allocator), + readonly: Dummy::dummy(allocator), + r#static: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSCallSignatureDeclaration<'a> { + /// Create a dummy [`TSCallSignatureDeclaration`]. + /// + /// Has cost of making 1 allocation (56 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + type_parameters: Dummy::dummy(allocator), + this_param: Dummy::dummy(allocator), + params: Dummy::dummy(allocator), + return_type: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSMethodSignatureKind { + /// Create a dummy [`TSMethodSignatureKind`]. + /// + /// Does not allocate any data into arena. + #[inline(always)] + fn dummy(allocator: &'a Allocator) -> Self { + Self::Method + } +} + +impl<'a> Dummy<'a> for TSMethodSignature<'a> { + /// Create a dummy [`TSMethodSignature`]. + /// + /// Has cost of making 2 allocations (64 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + key: Dummy::dummy(allocator), + computed: Dummy::dummy(allocator), + optional: Dummy::dummy(allocator), + kind: Dummy::dummy(allocator), + type_parameters: Dummy::dummy(allocator), + this_param: Dummy::dummy(allocator), + params: Dummy::dummy(allocator), + return_type: Dummy::dummy(allocator), + scope_id: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSConstructSignatureDeclaration<'a> { + /// Create a dummy [`TSConstructSignatureDeclaration`]. + /// + /// Has cost of making 1 allocation (56 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + type_parameters: Dummy::dummy(allocator), + params: Dummy::dummy(allocator), + return_type: Dummy::dummy(allocator), + scope_id: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSIndexSignatureName<'a> { + /// Create a dummy [`TSIndexSignatureName`]. + /// + /// Has cost of making 2 allocations (32 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + name: Dummy::dummy(allocator), + type_annotation: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSInterfaceHeritage<'a> { + /// Create a dummy [`TSInterfaceHeritage`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + expression: Dummy::dummy(allocator), + type_arguments: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSTypePredicate<'a> { + /// Create a dummy [`TSTypePredicate`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + parameter_name: Dummy::dummy(allocator), + asserts: Dummy::dummy(allocator), + type_annotation: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSTypePredicateName<'a> { + /// Create a dummy [`TSTypePredicateName`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self::This(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for TSModuleDeclaration<'a> { + /// Create a dummy [`TSModuleDeclaration`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + id: Dummy::dummy(allocator), + body: Dummy::dummy(allocator), + kind: Dummy::dummy(allocator), + declare: Dummy::dummy(allocator), + scope_id: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSModuleDeclarationKind { + /// Create a dummy [`TSModuleDeclarationKind`]. + /// + /// Does not allocate any data into arena. + #[inline(always)] + fn dummy(allocator: &'a Allocator) -> Self { + Self::Global + } +} + +impl<'a> Dummy<'a> for TSModuleDeclarationName<'a> { + /// Create a dummy [`TSModuleDeclarationName`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self::Identifier(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for TSModuleDeclarationBody<'a> { + /// Create a dummy [`TSModuleDeclarationBody`]. + /// + /// Has cost of making 1 allocation (72 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::TSModuleBlock(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for TSModuleBlock<'a> { + /// Create a dummy [`TSModuleBlock`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + directives: Dummy::dummy(allocator), + body: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSTypeLiteral<'a> { + /// Create a dummy [`TSTypeLiteral`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), members: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for TSInferType<'a> { + /// Create a dummy [`TSInferType`]. + /// + /// Has cost of making 1 allocation (80 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), type_parameter: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for TSTypeQuery<'a> { + /// Create a dummy [`TSTypeQuery`]. + /// + /// Has cost of making 1 allocation (32 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + expr_name: Dummy::dummy(allocator), + type_arguments: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSTypeQueryExprName<'a> { + /// Create a dummy [`TSTypeQueryExprName`]. + /// + /// Has cost of making 1 allocation (32 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::IdentifierReference(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for TSImportType<'a> { + /// Create a dummy [`TSImportType`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + argument: Dummy::dummy(allocator), + options: Dummy::dummy(allocator), + qualifier: Dummy::dummy(allocator), + type_arguments: Dummy::dummy(allocator), + is_type_of: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSFunctionType<'a> { + /// Create a dummy [`TSFunctionType`]. + /// + /// Has cost of making 3 allocations (88 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + type_parameters: Dummy::dummy(allocator), + this_param: Dummy::dummy(allocator), + params: Dummy::dummy(allocator), + return_type: Dummy::dummy(allocator), + scope_id: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSConstructorType<'a> { + /// Create a dummy [`TSConstructorType`]. + /// + /// Has cost of making 3 allocations (88 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + r#abstract: Dummy::dummy(allocator), + type_parameters: Dummy::dummy(allocator), + params: Dummy::dummy(allocator), + return_type: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSMappedType<'a> { + /// Create a dummy [`TSMappedType`]. + /// + /// Has cost of making 1 allocation (80 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + type_parameter: Dummy::dummy(allocator), + name_type: Dummy::dummy(allocator), + type_annotation: Dummy::dummy(allocator), + optional: Dummy::dummy(allocator), + readonly: Dummy::dummy(allocator), + scope_id: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSMappedTypeModifierOperator { + /// Create a dummy [`TSMappedTypeModifierOperator`]. + /// + /// Does not allocate any data into arena. + #[inline(always)] + fn dummy(allocator: &'a Allocator) -> Self { + Self::True + } +} + +impl<'a> Dummy<'a> for TSTemplateLiteralType<'a> { + /// Create a dummy [`TSTemplateLiteralType`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + quasis: Dummy::dummy(allocator), + types: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSAsExpression<'a> { + /// Create a dummy [`TSAsExpression`]. + /// + /// Has cost of making 2 allocations (16 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + expression: Dummy::dummy(allocator), + type_annotation: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSSatisfiesExpression<'a> { + /// Create a dummy [`TSSatisfiesExpression`]. + /// + /// Has cost of making 2 allocations (16 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + expression: Dummy::dummy(allocator), + type_annotation: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSTypeAssertion<'a> { + /// Create a dummy [`TSTypeAssertion`]. + /// + /// Has cost of making 2 allocations (16 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + expression: Dummy::dummy(allocator), + type_annotation: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSImportEqualsDeclaration<'a> { + /// Create a dummy [`TSImportEqualsDeclaration`]. + /// + /// Has cost of making 1 allocation (32 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + id: Dummy::dummy(allocator), + module_reference: Dummy::dummy(allocator), + import_kind: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for TSModuleReference<'a> { + /// Create a dummy [`TSModuleReference`]. + /// + /// Has cost of making 1 allocation (32 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self::IdentifierReference(Dummy::dummy(allocator)) + } +} + +impl<'a> Dummy<'a> for TSExternalModuleReference<'a> { + /// Create a dummy [`TSExternalModuleReference`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), expression: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for TSNonNullExpression<'a> { + /// Create a dummy [`TSNonNullExpression`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), expression: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for Decorator<'a> { + /// Create a dummy [`Decorator`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), expression: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for TSExportAssignment<'a> { + /// Create a dummy [`TSExportAssignment`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), expression: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for TSNamespaceExportDeclaration<'a> { + /// Create a dummy [`TSNamespaceExportDeclaration`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator), id: Dummy::dummy(allocator) } + } +} + +impl<'a> Dummy<'a> for TSInstantiationExpression<'a> { + /// Create a dummy [`TSInstantiationExpression`]. + /// + /// Has cost of making 2 allocations (48 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + expression: Dummy::dummy(allocator), + type_parameters: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for ImportOrExportKind { + /// Create a dummy [`ImportOrExportKind`]. + /// + /// Does not allocate any data into arena. + #[inline(always)] + fn dummy(allocator: &'a Allocator) -> Self { + Self::Value + } +} + +impl<'a> Dummy<'a> for JSDocNullableType<'a> { + /// Create a dummy [`JSDocNullableType`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + type_annotation: Dummy::dummy(allocator), + postfix: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for JSDocNonNullableType<'a> { + /// Create a dummy [`JSDocNonNullableType`]. + /// + /// Has cost of making 1 allocation (8 bytes). + fn dummy(allocator: &'a Allocator) -> Self { + Self { + span: Dummy::dummy(allocator), + type_annotation: Dummy::dummy(allocator), + postfix: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for JSDocUnknownType { + /// Create a dummy [`JSDocUnknownType`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { span: Dummy::dummy(allocator) } + } +} diff --git a/crates/oxc_ast/src/generated/derive_take_in.rs b/crates/oxc_ast/src/generated/derive_take_in.rs new file mode 100644 index 0000000000000..1080a18ffcdc6 --- /dev/null +++ b/crates/oxc_ast/src/generated/derive_take_in.rs @@ -0,0 +1,469 @@ +// Auto-generated code, DO NOT EDIT DIRECTLY! +// To edit this generated file you have to edit `tasks/ast_tools/src/derives/take_in.rs` + +#![allow(clippy::needless_lifetimes)] + +use oxc_allocator::TakeIn; + +use crate::ast::js::*; +use crate::ast::jsx::*; +use crate::ast::literal::*; +use crate::ast::ts::*; + +impl<'a> TakeIn<'a> for Program<'a> {} + +impl<'a> TakeIn<'a> for Expression<'a> {} + +impl<'a> TakeIn<'a> for IdentifierName<'a> {} + +impl<'a> TakeIn<'a> for IdentifierReference<'a> {} + +impl<'a> TakeIn<'a> for BindingIdentifier<'a> {} + +impl<'a> TakeIn<'a> for LabelIdentifier<'a> {} + +impl<'a> TakeIn<'a> for ThisExpression {} + +impl<'a> TakeIn<'a> for ArrayExpression<'a> {} + +impl<'a> TakeIn<'a> for ArrayExpressionElement<'a> {} + +impl<'a> TakeIn<'a> for Elision {} + +impl<'a> TakeIn<'a> for ObjectExpression<'a> {} + +impl<'a> TakeIn<'a> for ObjectPropertyKind<'a> {} + +impl<'a> TakeIn<'a> for ObjectProperty<'a> {} + +impl<'a> TakeIn<'a> for PropertyKey<'a> {} + +impl<'a> TakeIn<'a> for TemplateLiteral<'a> {} + +impl<'a> TakeIn<'a> for TaggedTemplateExpression<'a> {} + +impl<'a> TakeIn<'a> for TemplateElement<'a> {} + +impl<'a> TakeIn<'a> for TemplateElementValue<'a> {} + +impl<'a> TakeIn<'a> for MemberExpression<'a> {} + +impl<'a> TakeIn<'a> for ComputedMemberExpression<'a> {} + +impl<'a> TakeIn<'a> for StaticMemberExpression<'a> {} + +impl<'a> TakeIn<'a> for PrivateFieldExpression<'a> {} + +impl<'a> TakeIn<'a> for CallExpression<'a> {} + +impl<'a> TakeIn<'a> for NewExpression<'a> {} + +impl<'a> TakeIn<'a> for MetaProperty<'a> {} + +impl<'a> TakeIn<'a> for SpreadElement<'a> {} + +impl<'a> TakeIn<'a> for Argument<'a> {} + +impl<'a> TakeIn<'a> for UpdateExpression<'a> {} + +impl<'a> TakeIn<'a> for UnaryExpression<'a> {} + +impl<'a> TakeIn<'a> for BinaryExpression<'a> {} + +impl<'a> TakeIn<'a> for PrivateInExpression<'a> {} + +impl<'a> TakeIn<'a> for LogicalExpression<'a> {} + +impl<'a> TakeIn<'a> for ConditionalExpression<'a> {} + +impl<'a> TakeIn<'a> for AssignmentExpression<'a> {} + +impl<'a> TakeIn<'a> for AssignmentTarget<'a> {} + +impl<'a> TakeIn<'a> for SimpleAssignmentTarget<'a> {} + +impl<'a> TakeIn<'a> for AssignmentTargetPattern<'a> {} + +impl<'a> TakeIn<'a> for ArrayAssignmentTarget<'a> {} + +impl<'a> TakeIn<'a> for ObjectAssignmentTarget<'a> {} + +impl<'a> TakeIn<'a> for AssignmentTargetRest<'a> {} + +impl<'a> TakeIn<'a> for AssignmentTargetMaybeDefault<'a> {} + +impl<'a> TakeIn<'a> for AssignmentTargetWithDefault<'a> {} + +impl<'a> TakeIn<'a> for AssignmentTargetProperty<'a> {} + +impl<'a> TakeIn<'a> for AssignmentTargetPropertyIdentifier<'a> {} + +impl<'a> TakeIn<'a> for AssignmentTargetPropertyProperty<'a> {} + +impl<'a> TakeIn<'a> for SequenceExpression<'a> {} + +impl<'a> TakeIn<'a> for Super {} + +impl<'a> TakeIn<'a> for AwaitExpression<'a> {} + +impl<'a> TakeIn<'a> for ChainExpression<'a> {} + +impl<'a> TakeIn<'a> for ChainElement<'a> {} + +impl<'a> TakeIn<'a> for ParenthesizedExpression<'a> {} + +impl<'a> TakeIn<'a> for Statement<'a> {} + +impl<'a> TakeIn<'a> for Directive<'a> {} + +impl<'a> TakeIn<'a> for Hashbang<'a> {} + +impl<'a> TakeIn<'a> for BlockStatement<'a> {} + +impl<'a> TakeIn<'a> for Declaration<'a> {} + +impl<'a> TakeIn<'a> for VariableDeclaration<'a> {} + +impl<'a> TakeIn<'a> for VariableDeclarator<'a> {} + +impl<'a> TakeIn<'a> for EmptyStatement {} + +impl<'a> TakeIn<'a> for ExpressionStatement<'a> {} + +impl<'a> TakeIn<'a> for IfStatement<'a> {} + +impl<'a> TakeIn<'a> for DoWhileStatement<'a> {} + +impl<'a> TakeIn<'a> for WhileStatement<'a> {} + +impl<'a> TakeIn<'a> for ForStatement<'a> {} + +impl<'a> TakeIn<'a> for ForStatementInit<'a> {} + +impl<'a> TakeIn<'a> for ForInStatement<'a> {} + +impl<'a> TakeIn<'a> for ForStatementLeft<'a> {} + +impl<'a> TakeIn<'a> for ForOfStatement<'a> {} + +impl<'a> TakeIn<'a> for ContinueStatement<'a> {} + +impl<'a> TakeIn<'a> for BreakStatement<'a> {} + +impl<'a> TakeIn<'a> for ReturnStatement<'a> {} + +impl<'a> TakeIn<'a> for WithStatement<'a> {} + +impl<'a> TakeIn<'a> for SwitchStatement<'a> {} + +impl<'a> TakeIn<'a> for SwitchCase<'a> {} + +impl<'a> TakeIn<'a> for LabeledStatement<'a> {} + +impl<'a> TakeIn<'a> for ThrowStatement<'a> {} + +impl<'a> TakeIn<'a> for TryStatement<'a> {} + +impl<'a> TakeIn<'a> for CatchClause<'a> {} + +impl<'a> TakeIn<'a> for CatchParameter<'a> {} + +impl<'a> TakeIn<'a> for DebuggerStatement {} + +impl<'a> TakeIn<'a> for BindingPattern<'a> {} + +impl<'a> TakeIn<'a> for BindingPatternKind<'a> {} + +impl<'a> TakeIn<'a> for AssignmentPattern<'a> {} + +impl<'a> TakeIn<'a> for ObjectPattern<'a> {} + +impl<'a> TakeIn<'a> for BindingProperty<'a> {} + +impl<'a> TakeIn<'a> for ArrayPattern<'a> {} + +impl<'a> TakeIn<'a> for BindingRestElement<'a> {} + +impl<'a> TakeIn<'a> for Function<'a> {} + +impl<'a> TakeIn<'a> for FormalParameters<'a> {} + +impl<'a> TakeIn<'a> for FormalParameter<'a> {} + +impl<'a> TakeIn<'a> for FunctionBody<'a> {} + +impl<'a> TakeIn<'a> for ArrowFunctionExpression<'a> {} + +impl<'a> TakeIn<'a> for YieldExpression<'a> {} + +impl<'a> TakeIn<'a> for Class<'a> {} + +impl<'a> TakeIn<'a> for ClassBody<'a> {} + +impl<'a> TakeIn<'a> for ClassElement<'a> {} + +impl<'a> TakeIn<'a> for MethodDefinition<'a> {} + +impl<'a> TakeIn<'a> for PropertyDefinition<'a> {} + +impl<'a> TakeIn<'a> for PrivateIdentifier<'a> {} + +impl<'a> TakeIn<'a> for StaticBlock<'a> {} + +impl<'a> TakeIn<'a> for ModuleDeclaration<'a> {} + +impl<'a> TakeIn<'a> for AccessorProperty<'a> {} + +impl<'a> TakeIn<'a> for ImportExpression<'a> {} + +impl<'a> TakeIn<'a> for ImportDeclaration<'a> {} + +impl<'a> TakeIn<'a> for ImportDeclarationSpecifier<'a> {} + +impl<'a> TakeIn<'a> for ImportSpecifier<'a> {} + +impl<'a> TakeIn<'a> for ImportDefaultSpecifier<'a> {} + +impl<'a> TakeIn<'a> for ImportNamespaceSpecifier<'a> {} + +impl<'a> TakeIn<'a> for WithClause<'a> {} + +impl<'a> TakeIn<'a> for ImportAttribute<'a> {} + +impl<'a> TakeIn<'a> for ImportAttributeKey<'a> {} + +impl<'a> TakeIn<'a> for ExportNamedDeclaration<'a> {} + +impl<'a> TakeIn<'a> for ExportDefaultDeclaration<'a> {} + +impl<'a> TakeIn<'a> for ExportAllDeclaration<'a> {} + +impl<'a> TakeIn<'a> for ExportSpecifier<'a> {} + +impl<'a> TakeIn<'a> for ExportDefaultDeclarationKind<'a> {} + +impl<'a> TakeIn<'a> for ModuleExportName<'a> {} + +impl<'a> TakeIn<'a> for V8IntrinsicExpression<'a> {} + +impl<'a> TakeIn<'a> for BooleanLiteral {} + +impl<'a> TakeIn<'a> for NullLiteral {} + +impl<'a> TakeIn<'a> for NumericLiteral<'a> {} + +impl<'a> TakeIn<'a> for StringLiteral<'a> {} + +impl<'a> TakeIn<'a> for BigIntLiteral<'a> {} + +impl<'a> TakeIn<'a> for RegExpLiteral<'a> {} + +impl<'a> TakeIn<'a> for RegExp<'a> {} + +impl<'a> TakeIn<'a> for RegExpPattern<'a> {} + +impl<'a> TakeIn<'a> for JSXElement<'a> {} + +impl<'a> TakeIn<'a> for JSXOpeningElement<'a> {} + +impl<'a> TakeIn<'a> for JSXClosingElement<'a> {} + +impl<'a> TakeIn<'a> for JSXFragment<'a> {} + +impl<'a> TakeIn<'a> for JSXOpeningFragment {} + +impl<'a> TakeIn<'a> for JSXClosingFragment {} + +impl<'a> TakeIn<'a> for JSXElementName<'a> {} + +impl<'a> TakeIn<'a> for JSXNamespacedName<'a> {} + +impl<'a> TakeIn<'a> for JSXMemberExpression<'a> {} + +impl<'a> TakeIn<'a> for JSXMemberExpressionObject<'a> {} + +impl<'a> TakeIn<'a> for JSXExpressionContainer<'a> {} + +impl<'a> TakeIn<'a> for JSXExpression<'a> {} + +impl<'a> TakeIn<'a> for JSXEmptyExpression {} + +impl<'a> TakeIn<'a> for JSXAttributeItem<'a> {} + +impl<'a> TakeIn<'a> for JSXAttribute<'a> {} + +impl<'a> TakeIn<'a> for JSXSpreadAttribute<'a> {} + +impl<'a> TakeIn<'a> for JSXAttributeName<'a> {} + +impl<'a> TakeIn<'a> for JSXAttributeValue<'a> {} + +impl<'a> TakeIn<'a> for JSXIdentifier<'a> {} + +impl<'a> TakeIn<'a> for JSXChild<'a> {} + +impl<'a> TakeIn<'a> for JSXSpreadChild<'a> {} + +impl<'a> TakeIn<'a> for JSXText<'a> {} + +impl<'a> TakeIn<'a> for TSThisParameter<'a> {} + +impl<'a> TakeIn<'a> for TSEnumDeclaration<'a> {} + +impl<'a> TakeIn<'a> for TSEnumMember<'a> {} + +impl<'a> TakeIn<'a> for TSEnumMemberName<'a> {} + +impl<'a> TakeIn<'a> for TSTypeAnnotation<'a> {} + +impl<'a> TakeIn<'a> for TSLiteralType<'a> {} + +impl<'a> TakeIn<'a> for TSLiteral<'a> {} + +impl<'a> TakeIn<'a> for TSType<'a> {} + +impl<'a> TakeIn<'a> for TSConditionalType<'a> {} + +impl<'a> TakeIn<'a> for TSUnionType<'a> {} + +impl<'a> TakeIn<'a> for TSIntersectionType<'a> {} + +impl<'a> TakeIn<'a> for TSParenthesizedType<'a> {} + +impl<'a> TakeIn<'a> for TSTypeOperator<'a> {} + +impl<'a> TakeIn<'a> for TSArrayType<'a> {} + +impl<'a> TakeIn<'a> for TSIndexedAccessType<'a> {} + +impl<'a> TakeIn<'a> for TSTupleType<'a> {} + +impl<'a> TakeIn<'a> for TSNamedTupleMember<'a> {} + +impl<'a> TakeIn<'a> for TSOptionalType<'a> {} + +impl<'a> TakeIn<'a> for TSRestType<'a> {} + +impl<'a> TakeIn<'a> for TSTupleElement<'a> {} + +impl<'a> TakeIn<'a> for TSAnyKeyword {} + +impl<'a> TakeIn<'a> for TSStringKeyword {} + +impl<'a> TakeIn<'a> for TSBooleanKeyword {} + +impl<'a> TakeIn<'a> for TSNumberKeyword {} + +impl<'a> TakeIn<'a> for TSNeverKeyword {} + +impl<'a> TakeIn<'a> for TSIntrinsicKeyword {} + +impl<'a> TakeIn<'a> for TSUnknownKeyword {} + +impl<'a> TakeIn<'a> for TSNullKeyword {} + +impl<'a> TakeIn<'a> for TSUndefinedKeyword {} + +impl<'a> TakeIn<'a> for TSVoidKeyword {} + +impl<'a> TakeIn<'a> for TSSymbolKeyword {} + +impl<'a> TakeIn<'a> for TSThisType {} + +impl<'a> TakeIn<'a> for TSObjectKeyword {} + +impl<'a> TakeIn<'a> for TSBigIntKeyword {} + +impl<'a> TakeIn<'a> for TSTypeReference<'a> {} + +impl<'a> TakeIn<'a> for TSTypeName<'a> {} + +impl<'a> TakeIn<'a> for TSQualifiedName<'a> {} + +impl<'a> TakeIn<'a> for TSTypeParameterInstantiation<'a> {} + +impl<'a> TakeIn<'a> for TSTypeParameter<'a> {} + +impl<'a> TakeIn<'a> for TSTypeParameterDeclaration<'a> {} + +impl<'a> TakeIn<'a> for TSTypeAliasDeclaration<'a> {} + +impl<'a> TakeIn<'a> for TSClassImplements<'a> {} + +impl<'a> TakeIn<'a> for TSInterfaceDeclaration<'a> {} + +impl<'a> TakeIn<'a> for TSInterfaceBody<'a> {} + +impl<'a> TakeIn<'a> for TSPropertySignature<'a> {} + +impl<'a> TakeIn<'a> for TSSignature<'a> {} + +impl<'a> TakeIn<'a> for TSIndexSignature<'a> {} + +impl<'a> TakeIn<'a> for TSCallSignatureDeclaration<'a> {} + +impl<'a> TakeIn<'a> for TSMethodSignature<'a> {} + +impl<'a> TakeIn<'a> for TSConstructSignatureDeclaration<'a> {} + +impl<'a> TakeIn<'a> for TSIndexSignatureName<'a> {} + +impl<'a> TakeIn<'a> for TSInterfaceHeritage<'a> {} + +impl<'a> TakeIn<'a> for TSTypePredicate<'a> {} + +impl<'a> TakeIn<'a> for TSTypePredicateName<'a> {} + +impl<'a> TakeIn<'a> for TSModuleDeclaration<'a> {} + +impl<'a> TakeIn<'a> for TSModuleDeclarationName<'a> {} + +impl<'a> TakeIn<'a> for TSModuleDeclarationBody<'a> {} + +impl<'a> TakeIn<'a> for TSModuleBlock<'a> {} + +impl<'a> TakeIn<'a> for TSTypeLiteral<'a> {} + +impl<'a> TakeIn<'a> for TSInferType<'a> {} + +impl<'a> TakeIn<'a> for TSTypeQuery<'a> {} + +impl<'a> TakeIn<'a> for TSTypeQueryExprName<'a> {} + +impl<'a> TakeIn<'a> for TSImportType<'a> {} + +impl<'a> TakeIn<'a> for TSFunctionType<'a> {} + +impl<'a> TakeIn<'a> for TSConstructorType<'a> {} + +impl<'a> TakeIn<'a> for TSMappedType<'a> {} + +impl<'a> TakeIn<'a> for TSTemplateLiteralType<'a> {} + +impl<'a> TakeIn<'a> for TSAsExpression<'a> {} + +impl<'a> TakeIn<'a> for TSSatisfiesExpression<'a> {} + +impl<'a> TakeIn<'a> for TSTypeAssertion<'a> {} + +impl<'a> TakeIn<'a> for TSImportEqualsDeclaration<'a> {} + +impl<'a> TakeIn<'a> for TSModuleReference<'a> {} + +impl<'a> TakeIn<'a> for TSExternalModuleReference<'a> {} + +impl<'a> TakeIn<'a> for TSNonNullExpression<'a> {} + +impl<'a> TakeIn<'a> for Decorator<'a> {} + +impl<'a> TakeIn<'a> for TSExportAssignment<'a> {} + +impl<'a> TakeIn<'a> for TSNamespaceExportDeclaration<'a> {} + +impl<'a> TakeIn<'a> for TSInstantiationExpression<'a> {} + +impl<'a> TakeIn<'a> for JSDocNullableType<'a> {} + +impl<'a> TakeIn<'a> for JSDocNonNullableType<'a> {} + +impl<'a> TakeIn<'a> for JSDocUnknownType {} diff --git a/crates/oxc_ast/src/lib.rs b/crates/oxc_ast/src/lib.rs index 22c44f2058dfd..b9880889f5faa 100644 --- a/crates/oxc_ast/src/lib.rs +++ b/crates/oxc_ast/src/lib.rs @@ -60,11 +60,13 @@ mod generated { pub mod ast_kind; pub mod derive_clone_in; pub mod derive_content_eq; + pub mod derive_dummy; #[cfg(feature = "serialize")] pub mod derive_estree; pub mod derive_get_address; pub mod derive_get_span; pub mod derive_get_span_mut; + pub mod derive_take_in; pub mod get_id; } diff --git a/crates/oxc_ast_macros/src/generated/mod.rs b/crates/oxc_ast_macros/src/generated/mod.rs index cdef52ace962b..4397c56c9b70d 100644 --- a/crates/oxc_ast_macros/src/generated/mod.rs +++ b/crates/oxc_ast_macros/src/generated/mod.rs @@ -7,6 +7,8 @@ use quote::quote; pub fn get_trait_crate_and_generics(trait_name: &str) -> (TokenStream, TokenStream) { match trait_name { "CloneIn" => (quote!(::oxc_allocator::CloneIn), quote!(< 'static >)), + "Dummy" => (quote!(::oxc_allocator::Dummy), quote!(< 'static >)), + "TakeIn" => (quote!(::oxc_allocator::TakeIn), quote!(< 'static >)), "GetAddress" => (quote!(::oxc_allocator::GetAddress), TokenStream::new()), "GetSpan" => (quote!(::oxc_span::GetSpan), TokenStream::new()), "GetSpanMut" => (quote!(::oxc_span::GetSpanMut), TokenStream::new()), diff --git a/crates/oxc_span/src/atom.rs b/crates/oxc_span/src/atom.rs index 12f953967e325..e9fe82321533a 100644 --- a/crates/oxc_span/src/atom.rs +++ b/crates/oxc_span/src/atom.rs @@ -4,7 +4,7 @@ use std::{ ops::Deref, }; -use oxc_allocator::{Allocator, CloneIn, FromIn}; +use oxc_allocator::{Allocator, CloneIn, Dummy, FromIn}; #[cfg(feature = "serialize")] use oxc_estree::{ESTree, Serializer as ESTreeSerializer}; #[cfg(feature = "serialize")] @@ -71,6 +71,15 @@ impl<'new_alloc> CloneIn<'new_alloc> for Atom<'_> { } } +impl<'a> Dummy<'a> for Atom<'a> { + /// Create a dummy [`Atom`]. + #[expect(clippy::inline_always)] + #[inline(always)] + fn dummy(_allocator: &'a Allocator) -> Self { + Atom::empty() + } +} + impl<'alloc> FromIn<'alloc, &Atom<'alloc>> for Atom<'alloc> { fn from_in(s: &Atom<'alloc>, _: &'alloc Allocator) -> Self { *s diff --git a/crates/oxc_span/src/generated/derive_dummy.rs b/crates/oxc_span/src/generated/derive_dummy.rs new file mode 100644 index 0000000000000..0dfd3bd2e9c5f --- /dev/null +++ b/crates/oxc_span/src/generated/derive_dummy.rs @@ -0,0 +1,51 @@ +// Auto-generated code, DO NOT EDIT DIRECTLY! +// To edit this generated file you have to edit `tasks/ast_tools/src/derives/dummy.rs` + +#![allow(unused_variables, clippy::inline_always)] + +use oxc_allocator::{Allocator, Dummy}; + +use crate::source_type::*; + +impl<'a> Dummy<'a> for SourceType { + /// Create a dummy [`SourceType`]. + /// + /// Does not allocate any data into arena. + fn dummy(allocator: &'a Allocator) -> Self { + Self { + language: Dummy::dummy(allocator), + module_kind: Dummy::dummy(allocator), + variant: Dummy::dummy(allocator), + } + } +} + +impl<'a> Dummy<'a> for Language { + /// Create a dummy [`Language`]. + /// + /// Does not allocate any data into arena. + #[inline(always)] + fn dummy(allocator: &'a Allocator) -> Self { + Self::JavaScript + } +} + +impl<'a> Dummy<'a> for ModuleKind { + /// Create a dummy [`ModuleKind`]. + /// + /// Does not allocate any data into arena. + #[inline(always)] + fn dummy(allocator: &'a Allocator) -> Self { + Self::Script + } +} + +impl<'a> Dummy<'a> for LanguageVariant { + /// Create a dummy [`LanguageVariant`]. + /// + /// Does not allocate any data into arena. + #[inline(always)] + fn dummy(allocator: &'a Allocator) -> Self { + Self::Standard + } +} diff --git a/crates/oxc_span/src/lib.rs b/crates/oxc_span/src/lib.rs index 813497418794b..d8fdbaea95116 100644 --- a/crates/oxc_span/src/lib.rs +++ b/crates/oxc_span/src/lib.rs @@ -23,6 +23,7 @@ pub use crate::{ mod generated { #[cfg(debug_assertions)] pub mod assert_layouts; + mod derive_dummy; #[cfg(feature = "serialize")] pub mod derive_estree; } diff --git a/crates/oxc_span/src/source_type/mod.rs b/crates/oxc_span/src/source_type/mod.rs index 75fd6a234da0a..73c25e819d8af 100644 --- a/crates/oxc_span/src/source_type/mod.rs +++ b/crates/oxc_span/src/source_type/mod.rs @@ -1,6 +1,6 @@ use std::{hash::Hash, path::Path}; -use oxc_allocator::{Allocator, CloneIn}; +use oxc_allocator::{Allocator, CloneIn, Dummy}; use oxc_ast_macros::ast; use oxc_estree::ESTree; @@ -12,7 +12,7 @@ pub use error::UnknownExtension; /// Source Type for JavaScript vs TypeScript / Script vs Module / JSX #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -#[generate_derive(ESTree)] +#[generate_derive(Dummy, ESTree)] #[estree(no_type, flatten)] pub struct SourceType { /// JavaScript or TypeScript, default JavaScript @@ -31,6 +31,7 @@ pub struct SourceType { /// JavaScript or TypeScript #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[generate_derive(Dummy)] pub enum Language { /// Indicates a JavaScript or JSX file JavaScript = 0, @@ -43,7 +44,7 @@ pub enum Language { /// Script or Module #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -#[generate_derive(ESTree)] +#[generate_derive(Dummy, ESTree)] pub enum ModuleKind { /// Regular JS script or CommonJS file Script = 0, @@ -63,6 +64,7 @@ pub enum ModuleKind { /// JSX for JavaScript and TypeScript #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[generate_derive(Dummy)] pub enum LanguageVariant { /// Standard JavaScript or TypeScript without any language extensions. Stage /// 3 proposals do not count as language extensions. diff --git a/crates/oxc_span/src/span.rs b/crates/oxc_span/src/span.rs index 386d0d2e036b2..bebd5ed35bee3 100644 --- a/crates/oxc_span/src/span.rs +++ b/crates/oxc_span/src/span.rs @@ -8,7 +8,7 @@ use miette::{LabeledSpan, SourceOffset, SourceSpan}; #[cfg(feature = "serialize")] use serde::{Serialize, Serializer as SerdeSerializer, ser::SerializeMap}; -use oxc_allocator::{Allocator, CloneIn}; +use oxc_allocator::{Allocator, CloneIn, Dummy}; use oxc_ast_macros::ast; use oxc_estree::ESTree; @@ -545,6 +545,15 @@ impl<'a> CloneIn<'a> for Span { } } +impl<'a> Dummy<'a> for Span { + /// Create a dummy [`Span`]. + #[expect(clippy::inline_always)] + #[inline(always)] + fn dummy(_allocator: &'a Allocator) -> Self { + SPAN + } +} + #[cfg(feature = "serialize")] impl Serialize for Span { fn serialize(&self, serializer: S) -> Result { diff --git a/crates/oxc_syntax/src/generated/derive_dummy.rs b/crates/oxc_syntax/src/generated/derive_dummy.rs new file mode 100644 index 0000000000000..029098bcf530b --- /dev/null +++ b/crates/oxc_syntax/src/generated/derive_dummy.rs @@ -0,0 +1,79 @@ +// Auto-generated code, DO NOT EDIT DIRECTLY! +// To edit this generated file you have to edit `tasks/ast_tools/src/derives/dummy.rs` + +#![allow(unused_variables, clippy::inline_always)] + +use oxc_allocator::{Allocator, Dummy}; + +use crate::number::*; +use crate::operator::*; + +impl<'a> Dummy<'a> for NumberBase { + /// Create a dummy [`NumberBase`]. + /// + /// Does not allocate any data into arena. + #[inline(always)] + fn dummy(allocator: &'a Allocator) -> Self { + Self::Float + } +} + +impl<'a> Dummy<'a> for BigintBase { + /// Create a dummy [`BigintBase`]. + /// + /// Does not allocate any data into arena. + #[inline(always)] + fn dummy(allocator: &'a Allocator) -> Self { + Self::Decimal + } +} + +impl<'a> Dummy<'a> for AssignmentOperator { + /// Create a dummy [`AssignmentOperator`]. + /// + /// Does not allocate any data into arena. + #[inline(always)] + fn dummy(allocator: &'a Allocator) -> Self { + Self::Assign + } +} + +impl<'a> Dummy<'a> for BinaryOperator { + /// Create a dummy [`BinaryOperator`]. + /// + /// Does not allocate any data into arena. + #[inline(always)] + fn dummy(allocator: &'a Allocator) -> Self { + Self::Equality + } +} + +impl<'a> Dummy<'a> for LogicalOperator { + /// Create a dummy [`LogicalOperator`]. + /// + /// Does not allocate any data into arena. + #[inline(always)] + fn dummy(allocator: &'a Allocator) -> Self { + Self::Or + } +} + +impl<'a> Dummy<'a> for UnaryOperator { + /// Create a dummy [`UnaryOperator`]. + /// + /// Does not allocate any data into arena. + #[inline(always)] + fn dummy(allocator: &'a Allocator) -> Self { + Self::UnaryPlus + } +} + +impl<'a> Dummy<'a> for UpdateOperator { + /// Create a dummy [`UpdateOperator`]. + /// + /// Does not allocate any data into arena. + #[inline(always)] + fn dummy(allocator: &'a Allocator) -> Self { + Self::Increment + } +} diff --git a/crates/oxc_syntax/src/lib.rs b/crates/oxc_syntax/src/lib.rs index 04a120876878a..ac60130701e6f 100644 --- a/crates/oxc_syntax/src/lib.rs +++ b/crates/oxc_syntax/src/lib.rs @@ -26,6 +26,7 @@ mod generated { pub mod assert_layouts; mod derive_clone_in; mod derive_content_eq; + mod derive_dummy; #[cfg(feature = "serialize")] mod derive_estree; } diff --git a/crates/oxc_syntax/src/number.rs b/crates/oxc_syntax/src/number.rs index 22246c50bb935..d531277bcba40 100644 --- a/crates/oxc_syntax/src/number.rs +++ b/crates/oxc_syntax/src/number.rs @@ -1,11 +1,12 @@ #![expect(missing_docs)] // fixme -use oxc_allocator::CloneIn; + +use oxc_allocator::{CloneIn, Dummy}; use oxc_ast_macros::ast; use oxc_span::ContentEq; #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -#[generate_derive(CloneIn, ContentEq)] +#[generate_derive(CloneIn, Dummy, ContentEq)] pub enum NumberBase { Float = 0, Decimal = 1, @@ -22,7 +23,7 @@ impl NumberBase { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -#[generate_derive(CloneIn, ContentEq)] +#[generate_derive(CloneIn, Dummy, 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 3b65cf0043400..2eede2b4e33dc 100644 --- a/crates/oxc_syntax/src/operator.rs +++ b/crates/oxc_syntax/src/operator.rs @@ -2,7 +2,7 @@ //! //! Not all operators are punctuation - some, such as `delete`, are keywords. -use oxc_allocator::CloneIn; +use oxc_allocator::{CloneIn, Dummy}; use oxc_ast_macros::ast; use oxc_estree::ESTree; use oxc_span::ContentEq; @@ -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, ESTree)] +#[generate_derive(CloneIn, Dummy, 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, ESTree)] +#[generate_derive(CloneIn, Dummy, 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, ESTree)] +#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)] pub enum LogicalOperator { /// `||` #[estree(rename = "||")] @@ -496,7 +496,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, ESTree)] +#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)] pub enum UnaryOperator { /// `+` #[estree(rename = "+")] @@ -576,7 +576,7 @@ impl UnaryOperator { /// Unary update operators. #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -#[generate_derive(CloneIn, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)] pub enum UpdateOperator { /// `++` #[estree(rename = "++")] diff --git a/tasks/ast_tools/src/derives/dummy.rs b/tasks/ast_tools/src/derives/dummy.rs new file mode 100644 index 0000000000000..85f7fd48f52f2 --- /dev/null +++ b/tasks/ast_tools/src/derives/dummy.rs @@ -0,0 +1,263 @@ +//! Derive for `Dummy` trait. + +use std::borrow::Cow; + +use proc_macro2::TokenStream; +use quote::quote; + +use crate::{ + codegen::Codegen, + schema::{ + Def, EnumDef, Schema, StructDef, TypeDef, TypeId, + extensions::{ + dummy::{Alloc, MinVariant}, + layout::GetLayout, + }, + }, + utils::format_cow, +}; + +use super::{Derive, StructOrEnum, define_derive}; + +/// Derive for `Dummy` trait. +pub struct DeriveDummy; + +define_derive!(DeriveDummy); + +impl Derive for DeriveDummy { + fn trait_name(&self) -> &'static str { + "Dummy" + } + + fn trait_has_lifetime(&self) -> bool { + true + } + + fn crate_name(&self) -> &'static str { + "oxc_allocator" + } + + fn prelude(&self) -> TokenStream { + quote! { + #![allow(unused_variables, clippy::inline_always)] + + ///@@line_break + use oxc_allocator::{Allocator, Dummy}; + } + } + + /// Initialize `dummy.alloc` on structs and enums + fn prepare(&self, schema: &mut Schema, _codegen: &Codegen) { + for type_id in schema.types.indices() { + let alloc = calculate_alloc(type_id, schema); + assert!(alloc != Alloc::NOT_CALCULATED); + } + } + + fn derive(&self, type_def: StructOrEnum, schema: &Schema) -> TokenStream { + match type_def { + StructOrEnum::Struct(struct_def) => generate_impl_for_struct(struct_def, schema), + StructOrEnum::Enum(enum_def) => generate_impl_for_enum(enum_def, schema), + } + } +} + +/// Calculate number and size of allocations required to construct a dummy for a type. +/// +/// Before calculation, set `alloc` to [`Alloc::CALCULATING`]. +/// If `calculate_alloc` is called again for that type, it returns [`Alloc::NOT_CALCULATED`], +/// which indicates the type has a circular dependency. +/// This should only happen while calculating the cost of an enum. That variant will not be chosen. +fn calculate_alloc(type_id: TypeId, schema: &mut Schema) -> Alloc { + let type_def = &mut schema.types[type_id]; + #[expect(clippy::match_same_arms)] + match type_def { + TypeDef::Struct(struct_def) => { + let alloc = &mut struct_def.dummy.alloc; + if *alloc == Alloc::NOT_CALCULATED { + *alloc = Alloc::CALCULATING; + calculate_alloc_for_struct(type_id, schema) + } else if *alloc == Alloc::CALCULATING { + Alloc::NOT_CALCULATED + } else { + *alloc + } + } + TypeDef::Enum(enum_def) => { + let alloc = &mut enum_def.dummy.alloc; + if *alloc == Alloc::NOT_CALCULATED { + *alloc = Alloc::CALCULATING; + calculate_alloc_for_enum(type_id, schema) + } else if *alloc == Alloc::CALCULATING { + Alloc::NOT_CALCULATED + } else { + *alloc + } + } + // Primitives own no further allocation beyond themselves + TypeDef::Primitive(_) => Alloc::ZERO, + // `Option`s are `None` in dummy nodes + TypeDef::Option(_) => Alloc::ZERO, + // `Box`es have cost of the inner type plus an allocation of the type itself + TypeDef::Box(box_def) => { + let inner_type_id = box_def.inner_type_id; + let mut alloc = calculate_alloc(inner_type_id, schema); + if alloc != Alloc::NOT_CALCULATED { + let inner_type = &schema.types[inner_type_id]; + alloc.bytes_64 += inner_type.layout_64().size; + alloc.bytes_32 += inner_type.layout_32().size; + alloc.count += 1; + } + alloc + } + // `Vec`s are empty in dummy nodes + TypeDef::Vec(_) => Alloc::ZERO, + // `Cell`s only own allocations if their inner type does + TypeDef::Cell(cell_def) => calculate_alloc(cell_def.inner_type_id, schema), + } +} + +/// Calculate number and size of allocations required to construct a dummy for a struct. +/// +/// Equals the total of allocations for all the struct's fields. +fn calculate_alloc_for_struct(type_id: TypeId, schema: &mut Schema) -> Alloc { + let mut alloc = Alloc::ZERO; + for field_index in schema.struct_def(type_id).field_indices() { + let field_type_id = schema.struct_def(type_id).fields[field_index].type_id; + let field_alloc = calculate_alloc(field_type_id, schema); + if field_alloc == Alloc::NOT_CALCULATED { + alloc = field_alloc; + break; + } + alloc.bytes_64 += field_alloc.bytes_64; + alloc.bytes_32 += field_alloc.bytes_32; + alloc.count += field_alloc.count; + } + + schema.struct_def_mut(type_id).dummy.alloc = alloc; + + alloc +} + +/// Calculate number and size of allocations required to construct a dummy for an enum. +/// +/// Select the enum variant which has the lowest allocation cost. +/// +/// Choice is made on these criteria, in order: +/// * Smallest number of bytes allocated on 64-bit systems. +/// * Smallest number of bytes allocated on 32-bit systems. +/// * Smallest number of individual allocations. +/// +/// Record both the allocation cost, and which variant has the smallest cost. +fn calculate_alloc_for_enum(type_id: TypeId, schema: &mut Schema) -> Alloc { + // All `#[ast]` enums are `#[repr(u8)]` or `#[repr(C, u8)]` so cannot have 0 variants + let mut alloc = Alloc::NOT_CALCULATED; + let mut min_variant = MinVariant::default(); + + // Own variants + for variant_index in schema.enum_def(type_id).variant_indices() { + let variant_type_id = schema.enum_def(type_id).variants[variant_index].field_type_id; + if let Some(variant_type_id) = variant_type_id { + let variant_alloc = calculate_alloc(variant_type_id, schema); + if variant_alloc < alloc { + alloc = variant_alloc; + min_variant = MinVariant::Own(variant_index); + } + } else { + alloc = Alloc::ZERO; + min_variant = MinVariant::Own(variant_index); + break; + } + } + + // Inherited variants + for inherits_index in schema.enum_def(type_id).inherits_indices() { + let inherits_type_id = schema.enum_def(type_id).inherits[inherits_index]; + let inherits_alloc = calculate_alloc_for_enum(inherits_type_id, schema); + if inherits_alloc < alloc { + alloc = inherits_alloc; + min_variant = schema.enum_def(inherits_type_id).dummy.min_variant; + if let MinVariant::Own(variant_index) = min_variant { + min_variant = MinVariant::Inherited(inherits_type_id, variant_index); + } + } + } + + let dummy = &mut schema.enum_def_mut(type_id).dummy; + dummy.alloc = alloc; + dummy.min_variant = min_variant; + + alloc +} + +/// Generate `Dummy` impl for struct. +fn generate_impl_for_struct(struct_def: &StructDef, schema: &Schema) -> TokenStream { + let fields = struct_def.fields.iter().map(|field| { + let field_ident = field.ident(); + quote!(#field_ident: Dummy::dummy(allocator)) + }); + + let value = quote! { + Self { + #(#fields),* + } + }; + + generate_impl(struct_def.name(), &struct_def.ty(schema), &value, struct_def.dummy.alloc, false) +} + +/// Generate `Dummy` impl for enum. +fn generate_impl_for_enum(enum_def: &EnumDef, schema: &Schema) -> TokenStream { + let variant = match enum_def.dummy.min_variant { + MinVariant::Own(variant_index) => &enum_def.variants[variant_index], + MinVariant::Inherited(inherited_type_id, variant_index) => { + &schema.enum_def(inherited_type_id).variants[variant_index] + } + }; + + let variant_ident = variant.ident(); + let (value, should_inline) = if variant.field_type(schema).is_some() { + (quote!( Self::#variant_ident(Dummy::dummy(allocator)) ), false) + } else { + (quote!( Self::#variant_ident ), true) + }; + + generate_impl( + enum_def.name(), + &enum_def.ty(schema), + &value, + enum_def.dummy.alloc, + should_inline, + ) +} + +/// Generate `Dummy` impl for a type. +fn generate_impl( + name: &str, + ty: &TokenStream, + value: &TokenStream, + alloc: Alloc, + should_inline: bool, +) -> TokenStream { + let comment1 = format!(" Create a dummy [`{name}`]."); + let comment2 = if alloc.bytes_64 == 0 { + Cow::Borrowed(" Does not allocate any data into arena.") + } else { + let s = if alloc.count > 1 { "s" } else { "" }; + format_cow!(" Has cost of making {} allocation{s} ({} bytes).", alloc.count, alloc.bytes_64) + }; + + let inline = if should_inline { quote!( #[inline(always)] ) } else { quote!() }; + + quote! { + impl<'a> Dummy<'a> for #ty { + #[doc = #comment1] + #[doc = ""] + #[doc = #comment2] + #inline + fn dummy(allocator: &'a Allocator) -> Self { + #value + } + } + } +} diff --git a/tasks/ast_tools/src/derives/mod.rs b/tasks/ast_tools/src/derives/mod.rs index dd190941ed6e4..285b6eb2289e3 100644 --- a/tasks/ast_tools/src/derives/mod.rs +++ b/tasks/ast_tools/src/derives/mod.rs @@ -16,15 +16,19 @@ use crate::{ mod clone_in; mod content_eq; +mod dummy; pub mod estree; mod get_address; mod get_span; +mod take_in; pub use clone_in::DeriveCloneIn; pub use content_eq::DeriveContentEq; +pub use dummy::DeriveDummy; pub use estree::DeriveESTree; pub use get_address::DeriveGetAddress; pub use get_span::{DeriveGetSpan, DeriveGetSpanMut}; +pub use take_in::DeriveTakeIn; /// Trait to define a derive. pub trait Derive: Runner { diff --git a/tasks/ast_tools/src/derives/take_in.rs b/tasks/ast_tools/src/derives/take_in.rs new file mode 100644 index 0000000000000..6667f5837005c --- /dev/null +++ b/tasks/ast_tools/src/derives/take_in.rs @@ -0,0 +1,43 @@ +//! Derive for `TakeIn` trait. + +use proc_macro2::TokenStream; +use quote::quote; + +use crate::schema::{Def, Schema}; + +use super::{Derive, StructOrEnum, define_derive}; + +/// Derive for `TakeIn` trait. +pub struct DeriveTakeIn; + +define_derive!(DeriveTakeIn); + +impl Derive for DeriveTakeIn { + fn trait_name(&self) -> &'static str { + "TakeIn" + } + + fn trait_has_lifetime(&self) -> bool { + true + } + + fn crate_name(&self) -> &'static str { + "oxc_allocator" + } + + fn prelude(&self) -> TokenStream { + quote! { + #![allow(clippy::needless_lifetimes)] + + ///@@line_break + use oxc_allocator::TakeIn; + } + } + + fn derive(&self, type_def: StructOrEnum, schema: &Schema) -> TokenStream { + let ty = type_def.ty(schema); + quote! { + impl<'a> TakeIn<'a> for #ty {} + } + } +} diff --git a/tasks/ast_tools/src/main.rs b/tasks/ast_tools/src/main.rs index e354fee28229c..3dfe814ff1bf6 100644 --- a/tasks/ast_tools/src/main.rs +++ b/tasks/ast_tools/src/main.rs @@ -249,6 +249,8 @@ const AST_CHANGES_WATCH_LIST_PATH: &str = ".github/generated/ast_changes_watch_l /// Derives (for use with `#[generate_derive]`) const DERIVES: &[&(dyn Derive + Sync)] = &[ &derives::DeriveCloneIn, + &derives::DeriveDummy, + &derives::DeriveTakeIn, &derives::DeriveGetAddress, &derives::DeriveGetSpan, &derives::DeriveGetSpanMut, diff --git a/tasks/ast_tools/src/schema/defs/enum.rs b/tasks/ast_tools/src/schema/defs/enum.rs index c64293e9fffbc..71d2b62fa1b6a 100644 --- a/tasks/ast_tools/src/schema/defs/enum.rs +++ b/tasks/ast_tools/src/schema/defs/enum.rs @@ -13,6 +13,7 @@ use super::{ ast_builder::AstBuilderType, clone_in::CloneInType, content_eq::ContentEqType, + dummy::DummyEnum, estree::{ESTreeEnum, ESTreeEnumVariant}, kind::Kind, layout::{GetLayout, Layout}, @@ -43,6 +44,7 @@ pub struct EnumDef { pub kind: Kind, pub layout: Layout, pub clone_in: CloneInType, + pub dummy: DummyEnum, pub content_eq: ContentEqType, pub estree: ESTreeEnum, } @@ -77,6 +79,7 @@ impl EnumDef { kind: Kind::default(), layout: Layout::default(), clone_in: CloneInType::default(), + dummy: DummyEnum::default(), content_eq: ContentEqType::default(), estree: ESTreeEnum::default(), } diff --git a/tasks/ast_tools/src/schema/defs/struct.rs b/tasks/ast_tools/src/schema/defs/struct.rs index 5f3d5a8f0491b..d5f56f446c403 100644 --- a/tasks/ast_tools/src/schema/defs/struct.rs +++ b/tasks/ast_tools/src/schema/defs/struct.rs @@ -12,6 +12,7 @@ use super::{ ast_builder::{AstBuilderStructField, AstBuilderType}, clone_in::{CloneInStructField, CloneInType}, content_eq::{ContentEqStructField, ContentEqType}, + dummy::DummyStruct, estree::{ESTreeStruct, ESTreeStructField}, kind::Kind, layout::{Layout, Offset}, @@ -39,6 +40,7 @@ pub struct StructDef { pub layout: Layout, pub span: SpanStruct, pub clone_in: CloneInType, + pub dummy: DummyStruct, pub content_eq: ContentEqType, pub estree: ESTreeStruct, } @@ -72,6 +74,7 @@ impl StructDef { layout: Layout::default(), span: SpanStruct::default(), clone_in: CloneInType::default(), + dummy: DummyStruct::default(), content_eq: ContentEqType::default(), estree: ESTreeStruct::default(), } diff --git a/tasks/ast_tools/src/schema/extensions/dummy.rs b/tasks/ast_tools/src/schema/extensions/dummy.rs new file mode 100644 index 0000000000000..4e63f60bdea2b --- /dev/null +++ b/tasks/ast_tools/src/schema/extensions/dummy.rs @@ -0,0 +1,61 @@ +use super::super::TypeId; + +/// Details for `Dummy` derive on a struct. +#[derive(Clone, Copy, Default, Debug)] +pub struct DummyStruct { + /// Details of allocations a dummy enum of this type requires + pub alloc: Alloc, +} + +/// Details for `Dummy` derive on an enum. +#[derive(Clone, Copy, Default, Debug)] +pub struct DummyEnum { + /// Details of allocations a dummy enum of this type requires + pub alloc: Alloc, + /// Variant which allocates minimum number of bytes + pub min_variant: MinVariant, +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] +pub struct Alloc { + /// Number of bytes a dummy of this type allocates on 64-bit system + pub bytes_64: u32, + /// Number of bytes a dummy of this type allocates on 32-bit system + pub bytes_32: u32, + /// Number of allocations a dummy of this type requires to construct + pub count: u32, +} + +impl Alloc { + /// [`Alloc`] representing zero cost. + pub const ZERO: Self = Self { bytes_64: 0, bytes_32: 0, count: 0 }; + + /// Sentinel value for [`Alloc`], indicating that it's not been calculated yet. + pub const NOT_CALCULATED: Self = Self { bytes_64: u32::MAX, bytes_32: 0, count: 0 }; + + /// Sentinel value for [`Alloc`], indicating that it currently being calculated. + /// Used for preventing infinite cycles. + pub const CALCULATING: Self = Self { bytes_64: 0, bytes_32: u32::MAX, count: 0 }; +} + +impl Default for Alloc { + fn default() -> Self { + Self::NOT_CALCULATED + } +} + +/// Which variant of an enum is the cheapest to generate a dummy for. +#[derive(Clone, Copy, Debug)] +pub enum MinVariant { + /// Own variant index + Own(usize), + /// Inherited variant - `TypeId` of the inherited enum and variant index + Inherited(TypeId, usize), +} + +impl Default for MinVariant { + fn default() -> Self { + // Dummy value + MinVariant::Own(0) + } +} diff --git a/tasks/ast_tools/src/schema/mod.rs b/tasks/ast_tools/src/schema/mod.rs index 1febcfdbc17a8..2b6fc91894701 100644 --- a/tasks/ast_tools/src/schema/mod.rs +++ b/tasks/ast_tools/src/schema/mod.rs @@ -18,6 +18,7 @@ pub mod extensions { pub mod ast_builder; pub mod clone_in; pub mod content_eq; + pub mod dummy; pub mod estree; pub mod kind; pub mod layout;