diff --git a/crates/oxc_allocator/src/address.rs b/crates/oxc_allocator/src/address.rs index 6103115d044bd..895762e56c81f 100644 --- a/crates/oxc_allocator/src/address.rs +++ b/crates/oxc_allocator/src/address.rs @@ -19,7 +19,9 @@ impl Address { /// Get the memory address of a pointer to an AST node in arena. /// /// **This method is an escape hatch only.** - /// Prefer using [`GetAddress::address`] instead, because it is more likely to produce a stable [`Address`]. + /// Prefer using [`GetAddress::address`] or [`UnstableAddress::unstable_address`] instead, + /// because they are more likely to produce a stable [`Address`]. + /// (Yes even `unstable_address` is more likely to produce a stable `Address` than this function!) /// /// If the AST node is in a [`Box`], the address is guaranteed to be a unique identifier /// for the duration of the arena's existence. @@ -97,7 +99,9 @@ impl Address { /// Get the memory address of a reference to an AST node in arena. /// /// **This method is an escape hatch only.** - /// Prefer using [`GetAddress::address`] instead, because it is more likely to produce a stable [`Address`]. + /// Prefer using [`GetAddress::address`] or [`UnstableAddress::unstable_address`] instead, + /// because they are more likely to produce a stable `Address`. + /// (Yes even `unstable_address` is more likely to produce a stable `Address` than this function!) /// /// If the AST node is in a [`Box`], the address is guaranteed to be a unique identifier /// for the duration of the arena's existence. @@ -196,3 +200,104 @@ impl GetAddress for Address { *self } } + +/// Trait for getting the memory address of an AST node which is not necessarily stable. +/// +/// See [`UnstableAddress::unstable_address`] for more details. +/// +/// This trait is implemented for all AST struct types. +/// +/// *DO NOT* implement this trait on any other type. +pub trait UnstableAddress { + /// Get the memory [`Address`] of a reference to an AST node in arena, which is not necessarily stable. + /// + /// # Stable addresses + /// + /// It's ideal to obtain an `Address` for an AST node which is guaranteed to be stable for the life of the AST. + /// + /// Then you can reliably compare two `Address`es to determine if they refer to the same node, + /// without any risk of the result being wrong because one or other of the nodes has moved in memory. + /// + /// Types which have a stable address: + /// * [`Box`] + /// * AST enums where all variants are `Box`es (e.g. `Statement`, `Expression`) + /// + /// Some other types guarantee stability for a shorter period of time: + /// * `oxc_ast::AstKind` - guaranteed stable address while `Semantic` is alive. + /// * `oxc_traverse::Ancestor` - guaranteed stable address while traversing descendents of the ancestor. + /// + /// The above types all implement [`GetAddress::address`]. If you have access to one of these types, + /// it's better to use `GetAddress::address` instead of this method. + /// + /// # Why this method exists + /// + /// Sometimes you only have access to a reference to an AST node, but you know from context that the node + /// will not move in memory during the time you need the `Address` to remain stable. + /// + /// You can use this method in such cases, but you need to be careful. For correct behavior, you must ensure + /// yourself that the node will not move in memory during the time you need the `Address` to remain accurate. + /// + /// When using this method, it is recommended to make a comment at the call site, explaining how you can prove + /// that the `Address` will remain accurate (the AST node will not move) for the time period that you need it to be. + /// + /// # When a type does not move in memory + /// + /// If the AST is immutable (e.g. in `Visit` trait), then any node in the AST is statically positioned in memory. + /// Therefore, in the linter, any reference to an AST node is guaranteed to have a stable `Address`. + /// + /// If an AST node is in `Vec`, then it'll remain at same memory address, but only as long as the `Vec` does + /// not reallocate (e.g. by `Vec::push`, `Vec::extend`). + /// + /// This method will return a stable `Address` for any AST node in such circumstances. + /// + /// # Common pitfalls + /// + /// ## References to AST nodes on the stack + /// + /// Ensure that the reference passed to this method is to a node which is in the arena, *not* on the stack. + /// + /// ```ignore + /// let binary_expr: BinaryExpression<'a> = get_owned_binary_expression_somehow(); + /// // WRONG: `binary_expr` is on the stack, so the `Address` will be meaningless + /// let address = binary_expr.unstable_address(); + /// // More correct: `binary_expr` is in the arena. + /// // Will have a stable `Address` as long as `vec` does not reallocate. + /// let mut vec = Vec::new_in(&allocator); + /// vec.push(binary_expr); + /// let address = vec[0].unstable_address(); + /// ``` + /// + /// ## AST nodes in `Vec`s + /// + /// ```ignore + /// let mut vec: &mut Vec> = get_vec_somehow(); + /// + /// let address = vec[0].unstable_address(); + /// vec.push(get_owned_binary_expression_somehow()); + /// let address_after_push = vec[0].unstable_address(); + /// + /// // This assertion may or may not pass, depending on whether `push` caused the `Vec` to reallocate. + /// // This depends on whether `vec` had spare capacity or not, prior to the `push` call. + /// assert!(address_after_push == address); + /// ``` + /// + /// # Guardrails + /// + /// This method is less error-prone than [`Address::from_ptr`] and [`Address::from_ref`], + /// because it provides a few guardrails: + /// + /// * [`UnstableAddress`] is only implemented on AST struct types, so you can't call it on a type which + /// it doesn't make sense to get the `Address` of. + /// + /// * You don't need to worry about passing it a double-reference (`&&T`), because this method will automatically + /// dereference as required. + /// + /// Even with these guardrails, usage of this method still requires care, for the reasons discussed above. + /// + /// [`Box`]: crate::Box + #[inline(always)] // Because it's a no-op + fn unstable_address(&self) -> Address { + let p = NonNull::from_ref(self); + Address(p.addr().get()) + } +} diff --git a/crates/oxc_allocator/src/lib.rs b/crates/oxc_allocator/src/lib.rs index 94a2cde892302..5ca3a798db4a9 100644 --- a/crates/oxc_allocator/src/lib.rs +++ b/crates/oxc_allocator/src/lib.rs @@ -62,7 +62,7 @@ mod vec; mod vec2; pub use accessor::AllocatorAccessor; -pub use address::{Address, GetAddress}; +pub use address::{Address, GetAddress, UnstableAddress}; pub use allocator::Allocator; #[cfg(feature = "bitset")] pub use bitset::BitSet; diff --git a/crates/oxc_ast/src/ast/js.rs b/crates/oxc_ast/src/ast/js.rs index 79c0aecaa913a..3ee5888894d14 100644 --- a/crates/oxc_ast/src/ast/js.rs +++ b/crates/oxc_ast/src/ast/js.rs @@ -22,7 +22,7 @@ use std::cell::Cell; -use oxc_allocator::{Box, CloneIn, Dummy, GetAddress, TakeIn, Vec}; +use oxc_allocator::{Box, CloneIn, Dummy, GetAddress, TakeIn, UnstableAddress, Vec}; use oxc_ast_macros::ast; use oxc_estree::ESTree; use oxc_span::{Atom, ContentEq, GetSpan, GetSpanMut, SourceType, Span}; @@ -45,7 +45,7 @@ use super::{macros::inherit_variants, *}; strict_if = self.source_type.is_strict() || self.has_use_strict_directive(), )] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree(field_order(body, source_type, hashbang, span), via = ProgramConverter)] pub struct Program<'a> { pub span: Span, @@ -225,7 +225,7 @@ pub use match_expression; /// digits, `$`, or `_`. #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree( rename = "Identifier", add_fields(decorators = TsEmptyArray, optional = TsFalse, typeAnnotation = TsNull), @@ -244,7 +244,7 @@ pub struct IdentifierName<'a> { /// See: [13.1 Identifiers](https://tc39.es/ecma262/#sec-identifiers) #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree( rename = "Identifier", add_fields(decorators = TsEmptyArray, optional = TsFalse, typeAnnotation = TsNull), @@ -273,7 +273,7 @@ pub struct IdentifierReference<'a> { /// Also see other examples in docs for [`BindingPatternKind`]. #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree( rename = "Identifier", add_fields(decorators = TsEmptyArray, optional = TsFalse, typeAnnotation = TsNull), @@ -300,7 +300,7 @@ pub struct BindingIdentifier<'a> { /// See: [13.1 Identifiers](https://tc39.es/ecma262/#sec-identifiers) #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree( rename = "Identifier", add_fields(decorators = TsEmptyArray, optional = TsFalse, typeAnnotation = TsNull), @@ -317,7 +317,7 @@ pub struct LabelIdentifier<'a> { /// Represents a `this` expression, which is a reference to the current object. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct ThisExpression { pub span: Span, } @@ -327,7 +327,7 @@ pub struct ThisExpression { /// Represents an array literal, which can include elements, spread elements, or null values. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct ArrayExpression<'a> { pub span: Span, pub elements: Vec<'a, ArrayExpressionElement<'a>>, @@ -360,7 +360,7 @@ pub enum ArrayExpressionElement<'a> { /// Array Expression Elision Element #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree(via = Null)] pub struct Elision { pub span: Span, @@ -372,7 +372,7 @@ pub struct Elision { /// or computed properties. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct ObjectExpression<'a> { pub span: Span, /// Properties declared in the object @@ -395,7 +395,7 @@ pub enum ObjectPropertyKind<'a> { /// Represents a property in an object literal. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree(rename = "Property", add_fields(optional = TsFalse))] pub struct ObjectProperty<'a> { pub span: Span, @@ -444,7 +444,7 @@ pub enum PropertyKind { /// Represents a template literal, which can include quasi elements and expression elements. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TemplateLiteral<'a> { pub span: Span, pub quasis: Vec<'a, TemplateElement<'a>>, @@ -459,7 +459,7 @@ pub struct TemplateLiteral<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TaggedTemplateExpression<'a> { pub span: Span, pub tag: Expression<'a>, @@ -473,7 +473,7 @@ pub struct TaggedTemplateExpression<'a> { /// Represents a quasi element in a template literal. #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree(via = TemplateElementConverter)] pub struct TemplateElement<'a> { pub span: Span, @@ -538,7 +538,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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree(rename = "MemberExpression", add_fields(computed = True))] pub struct ComputedMemberExpression<'a> { pub span: Span, @@ -553,7 +553,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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree(rename = "MemberExpression", add_fields(computed = False))] pub struct StaticMemberExpression<'a> { pub span: Span, @@ -567,7 +567,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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree(rename = "MemberExpression", add_fields(computed = False))] pub struct PrivateFieldExpression<'a> { pub span: Span, @@ -595,7 +595,7 @@ pub struct PrivateFieldExpression<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct CallExpression<'a> { pub span: Span, pub callee: Expression<'a>, @@ -623,7 +623,7 @@ pub struct CallExpression<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct NewExpression<'a> { pub span: Span, pub callee: Expression<'a>, @@ -641,7 +641,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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct MetaProperty<'a> { pub span: Span, pub meta: IdentifierName<'a>, @@ -653,7 +653,7 @@ pub struct MetaProperty<'a> { /// Represents a spread element, which can include an argument. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct SpreadElement<'a> { pub span: Span, /// The expression being spread. @@ -683,7 +683,7 @@ pub enum Argument<'a> { /// The following syntaxes are supported: `++a`, `a++`, `--a`, `a--`. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct UpdateExpression<'a> { pub span: Span, pub operator: UpdateOperator, @@ -697,7 +697,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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree(add_fields(prefix = True))] pub struct UnaryExpression<'a> { pub span: Span, @@ -710,7 +710,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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct BinaryExpression<'a> { pub span: Span, pub left: Expression<'a>, @@ -721,7 +721,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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree(rename = "BinaryExpression", add_fields(operator = In), field_order(left, operator, right, span))] pub struct PrivateInExpression<'a> { pub span: Span, @@ -735,7 +735,7 @@ pub struct PrivateInExpression<'a> { /// The following syntaxes are supported: `||`, `&&` and `??`. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct LogicalExpression<'a> { pub span: Span, pub left: Expression<'a>, @@ -748,7 +748,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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct ConditionalExpression<'a> { pub span: Span, pub test: Expression<'a>, @@ -761,7 +761,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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct AssignmentExpression<'a> { pub span: Span, pub operator: AssignmentOperator, @@ -865,7 +865,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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree( rename = "ArrayPattern", add_fields(decorators = TsEmptyArray, optional = TsFalse, typeAnnotation = TsNull), @@ -883,7 +883,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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree( rename = "ObjectPattern", add_fields(decorators = TsEmptyArray, optional = TsFalse, typeAnnotation = TsNull), @@ -901,7 +901,7 @@ pub struct ObjectAssignmentTarget<'a> { /// Represents rest element in an `ArrayAssignmentTarget` or `ObjectAssignmentTarget`. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree( rename = "RestElement", add_fields(decorators = TsEmptyArray, optional = TsFalse, typeAnnotation = TsNull, value = TsNull), @@ -931,7 +931,7 @@ pub enum AssignmentTargetMaybeDefault<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree( rename = "AssignmentPattern", add_fields(decorators = TsEmptyArray, optional = TsFalse, typeAnnotation = TsNull), @@ -959,7 +959,7 @@ pub enum AssignmentTargetProperty<'a> { /// and an optional init expression. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree( rename = "Property", add_fields(kind = Init, method = False, shorthand = True, computed = False, optional = TsFalse), @@ -978,7 +978,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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree( rename = "Property", add_fields(kind = Init, method = False, shorthand = False, optional = TsFalse), @@ -1009,7 +1009,7 @@ pub struct AssignmentTargetPropertyProperty<'a> { /// Represents a sequence expression. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct SequenceExpression<'a> { pub span: Span, pub expressions: Vec<'a, Expression<'a>>, @@ -1020,7 +1020,7 @@ pub struct SequenceExpression<'a> { /// Represents a super expression. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct Super { pub span: Span, } @@ -1030,7 +1030,7 @@ pub struct Super { /// Represents an await expression, which can include an argument. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct AwaitExpression<'a> { pub span: Span, pub argument: Expression<'a>, @@ -1041,7 +1041,7 @@ pub struct AwaitExpression<'a> { /// Represents a chain expression, which can include an expression. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct ChainExpression<'a> { pub span: Span, pub expression: ChainElement<'a>, @@ -1070,7 +1070,7 @@ pub enum ChainElement<'a> { /// Represents a parenthesized expression, which can include an expression. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree(via = ParenthesizedExpressionConverter)] pub struct ParenthesizedExpression<'a> { pub span: Span, @@ -1119,7 +1119,7 @@ pub enum Statement<'a> { /// Represents a directive statement, which can include a string literal. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree(rename = "ExpressionStatement")] pub struct Directive<'a> { pub span: Span, @@ -1134,7 +1134,7 @@ pub struct Directive<'a> { /// Represents a hashbang directive, which can include a value. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct Hashbang<'a> { pub span: Span, pub value: Atom<'a>, @@ -1146,7 +1146,7 @@ pub struct Hashbang<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct BlockStatement<'a> { pub span: Span, pub body: Vec<'a, Statement<'a>>, @@ -1191,7 +1191,7 @@ pub use match_declaration; /// Represents a variable declaration, which can include a kind, declarations, and modifiers. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct VariableDeclaration<'a> { pub span: Span, pub kind: VariableDeclarationKind, @@ -1222,7 +1222,7 @@ pub enum VariableDeclarationKind { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct VariableDeclarator<'a> { pub span: Span, #[estree(skip)] @@ -1236,7 +1236,7 @@ pub struct VariableDeclarator<'a> { /// Empty Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct EmptyStatement { pub span: Span, } @@ -1244,7 +1244,7 @@ pub struct EmptyStatement { /// Expression Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree(add_fields(directive = ExpressionStatementDirective))] // Only in TS AST pub struct ExpressionStatement<'a> { pub span: Span, @@ -1254,7 +1254,7 @@ pub struct ExpressionStatement<'a> { /// If Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct IfStatement<'a> { pub span: Span, pub test: Expression<'a>, @@ -1265,7 +1265,7 @@ pub struct IfStatement<'a> { /// Do-While Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct DoWhileStatement<'a> { pub span: Span, pub body: Statement<'a>, @@ -1275,7 +1275,7 @@ pub struct DoWhileStatement<'a> { /// While Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct WhileStatement<'a> { pub span: Span, pub test: Expression<'a>, @@ -1286,7 +1286,7 @@ pub struct WhileStatement<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct ForStatement<'a> { pub span: Span, pub init: Option>, @@ -1316,7 +1316,7 @@ pub enum ForStatementInit<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct ForInStatement<'a> { pub span: Span, pub left: ForStatementLeft<'a>, @@ -1345,7 +1345,7 @@ pub enum ForStatementLeft<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct ForOfStatement<'a> { pub span: Span, pub r#await: bool, @@ -1358,7 +1358,7 @@ pub struct ForOfStatement<'a> { /// Continue Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct ContinueStatement<'a> { pub span: Span, pub label: Option>, @@ -1367,7 +1367,7 @@ pub struct ContinueStatement<'a> { /// Break Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct BreakStatement<'a> { pub span: Span, pub label: Option>, @@ -1376,7 +1376,7 @@ pub struct BreakStatement<'a> { /// Return Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct ReturnStatement<'a> { pub span: Span, pub argument: Option>, @@ -1386,7 +1386,7 @@ pub struct ReturnStatement<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct WithStatement<'a> { pub span: Span, pub object: Expression<'a>, @@ -1399,7 +1399,7 @@ pub struct WithStatement<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct SwitchStatement<'a> { pub span: Span, pub discriminant: Expression<'a>, @@ -1410,7 +1410,7 @@ pub struct SwitchStatement<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct SwitchCase<'a> { pub span: Span, pub test: Option>, @@ -1420,7 +1420,7 @@ pub struct SwitchCase<'a> { /// Labelled Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct LabeledStatement<'a> { pub span: Span, pub label: LabelIdentifier<'a>, @@ -1436,7 +1436,7 @@ pub struct LabeledStatement<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct ThrowStatement<'a> { pub span: Span, /// The expression being thrown, e.g. `err` in `throw err;` @@ -1460,7 +1460,7 @@ pub struct ThrowStatement<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TryStatement<'a> { pub span: Span, /// Statements in the `try` block @@ -1486,7 +1486,7 @@ pub struct TryStatement<'a> { #[ast(visit)] #[scope(flags = ScopeFlags::CatchClause)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct CatchClause<'a> { pub span: Span, /// The caught error parameter, e.g. `e` in `catch (e) {}` @@ -1511,7 +1511,7 @@ pub struct CatchClause<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree(no_type, via = CatchParameterConverter)] pub struct CatchParameter<'a> { #[estree(skip)] @@ -1530,7 +1530,7 @@ pub struct CatchParameter<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct DebuggerStatement { pub span: Span, } @@ -1545,7 +1545,7 @@ pub struct DebuggerStatement { /// but invalid in others e.g. `const [x: T] = f();`. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree(no_type, via = BindingPatternConverter, field_order(kind, optional, type_annotation))] pub struct BindingPattern<'a> { // estree(flatten) the attributes because estree has no `BindingPattern` @@ -1618,7 +1618,7 @@ pub enum BindingPatternKind<'a> { /// See other examples in docs for [`BindingPatternKind`]. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree( add_fields(decorators = TsEmptyArray, optional = TsFalse, typeAnnotation = TsNull), field_order(decorators, left, right, optional, typeAnnotation, span), @@ -1634,7 +1634,7 @@ pub struct AssignmentPattern<'a> { /// See other examples in docs for [`BindingPatternKind`]. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree( add_fields(decorators = TsEmptyArray, optional = TsFalse, typeAnnotation = TsNull), field_order(decorators, properties, optional, typeAnnotation, span), @@ -1648,7 +1648,7 @@ pub struct ObjectPattern<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree( rename = "Property", add_fields(kind = Init, method = False, optional = TsFalse), @@ -1667,7 +1667,7 @@ pub struct BindingProperty<'a> { /// See other examples in docs for [`BindingPatternKind`]. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree( add_fields(decorators = TsEmptyArray, optional = TsFalse, typeAnnotation = TsNull), field_order(decorators, elements, optional, typeAnnotation, span), @@ -1690,7 +1690,7 @@ pub struct ArrayPattern<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree( rename = "RestElement", add_fields(decorators = TsEmptyArray, optional = TsFalse, typeAnnotation = TsNull, value = TsNull), @@ -1744,7 +1744,7 @@ pub struct BindingRestElement<'a> { strict_if = self.has_use_strict_directive(), )] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] // https://github.com/estree/estree/blob/master/es5.md#patterns // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/cd61c555bfc93e985b313263a42ed78074570d08/types/estree/index.d.ts#L411 #[estree( @@ -1840,7 +1840,7 @@ pub enum FunctionType { /// #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree( via = FormalParametersConverter, add_ts_def = " @@ -1866,7 +1866,7 @@ pub struct FormalParameters<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] // Pluralize as `FormalParameterList` to avoid naming clash with `FormalParameters`. #[plural(FormalParameterList)] #[estree( @@ -1927,7 +1927,7 @@ pub enum FormalParameterKind { /// #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree(rename = "BlockStatement")] pub struct FunctionBody<'a> { pub span: Span, @@ -1944,7 +1944,7 @@ pub struct FunctionBody<'a> { strict_if = self.has_use_strict_directive(), )] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree(add_fields(id = Null, generator = False))] pub struct ArrowFunctionExpression<'a> { pub span: Span, @@ -1978,7 +1978,7 @@ pub struct ArrowFunctionExpression<'a> { /// Generator Function Definitions #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct YieldExpression<'a> { pub span: Span, pub delegate: bool, @@ -1989,7 +1989,7 @@ pub struct YieldExpression<'a> { #[ast(visit)] #[scope(flags = ScopeFlags::StrictMode)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct Class<'a> { pub span: Span, pub r#type: ClassType, @@ -2079,7 +2079,7 @@ pub enum ClassType { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct ClassBody<'a> { pub span: Span, pub body: Vec<'a, ClassElement<'a>>, @@ -2127,7 +2127,7 @@ pub enum ClassElement<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct MethodDefinition<'a> { pub span: Span, /// Method definition type @@ -2165,7 +2165,7 @@ pub enum MethodDefinitionType { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct PropertyDefinition<'a> { pub span: Span, pub r#type: PropertyDefinitionType, @@ -2280,7 +2280,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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct PrivateIdentifier<'a> { pub span: Span, pub name: Atom<'a>, @@ -2302,7 +2302,7 @@ pub struct PrivateIdentifier<'a> { #[ast(visit)] #[scope(flags = ScopeFlags::ClassStaticBlock)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct StaticBlock<'a> { pub span: Span, pub body: Vec<'a, Statement<'a>>, @@ -2386,7 +2386,7 @@ pub enum AccessorPropertyType { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree(add_fields(declare = TsFalse, optional = TsFalse, readonly = TsFalse))] pub struct AccessorProperty<'a> { pub span: Span, @@ -2434,7 +2434,7 @@ pub struct AccessorProperty<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct ImportExpression<'a> { pub span: Span, pub source: Expression<'a>, @@ -2444,7 +2444,7 @@ pub struct ImportExpression<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct ImportDeclaration<'a> { pub span: Span, /// `None` for `import 'foo'`, `Some([])` for `import {} from 'foo'` @@ -2501,7 +2501,7 @@ pub enum ImportDeclarationSpecifier<'a> { /// and have the same `Span`. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct ImportSpecifier<'a> { pub span: Span, /// Imported symbol. @@ -2525,7 +2525,7 @@ pub struct ImportSpecifier<'a> { /// #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct ImportDefaultSpecifier<'a> { pub span: Span, /// The name of the imported symbol. @@ -2540,7 +2540,7 @@ pub struct ImportDefaultSpecifier<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct ImportNamespaceSpecifier<'a> { pub span: Span, pub local: BindingIdentifier<'a>, @@ -2548,7 +2548,7 @@ pub struct ImportNamespaceSpecifier<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree(no_type, no_ts_def)] pub struct WithClause<'a> { #[estree(skip)] @@ -2570,7 +2570,7 @@ pub enum WithClauseKeyword { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct ImportAttribute<'a> { pub span: Span, pub key: ImportAttributeKey<'a>, @@ -2598,7 +2598,7 @@ pub enum ImportAttributeKey<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct ExportNamedDeclaration<'a> { pub span: Span, pub declaration: Option>, @@ -2623,7 +2623,7 @@ pub struct ExportNamedDeclaration<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree(add_fields(exportKind = TsValue))] pub struct ExportDefaultDeclaration<'a> { pub span: Span, @@ -2641,7 +2641,7 @@ pub struct ExportDefaultDeclaration<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct ExportAllDeclaration<'a> { pub span: Span, /// If this declaration is re-named @@ -2671,7 +2671,7 @@ pub struct ExportAllDeclaration<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct ExportSpecifier<'a> { pub span: Span, pub local: ModuleExportName<'a>, @@ -2722,7 +2722,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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] 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 cf24fbbba2489..b5109a2c66476 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, Dummy, GetAddress, TakeIn, Vec}; +use oxc_allocator::{Box, CloneIn, Dummy, GetAddress, TakeIn, UnstableAddress, 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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct JSXElement<'a> { /// Node location in source code pub span: Span, @@ -64,7 +64,7 @@ pub struct JSXElement<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree(add_fields(selfClosing = JSXOpeningElementSelfClosing))] pub struct JSXOpeningElement<'a> { /// Node location in source code @@ -91,7 +91,7 @@ pub struct JSXOpeningElement<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct JSXClosingElement<'a> { /// Node location in source code pub span: Span, @@ -109,7 +109,7 @@ pub struct JSXClosingElement<'a> { /// See: [`React.Fragment`](https://react.dev/reference/react/Fragment) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct JSXFragment<'a> { /// Node location in source code pub span: Span, @@ -124,7 +124,7 @@ pub struct JSXFragment<'a> { /// JSX Opening Fragment (`<>`) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree(add_fields(attributes = JsEmptyArray, selfClosing = JsFalse))] pub struct JSXOpeningFragment { /// Node location in source code @@ -134,7 +134,7 @@ pub struct JSXOpeningFragment { /// JSX Closing Fragment (``) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct JSXClosingFragment { /// Node location in source code pub span: Span, @@ -168,7 +168,7 @@ pub enum JSXElementName<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct JSXNamespacedName<'a> { /// Node location in source code pub span: Span, @@ -195,7 +195,7 @@ pub struct JSXNamespacedName<'a> { /// [`member expression`]: JSXMemberExpressionObject::MemberExpression #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct JSXMemberExpression<'a> { /// Node location in source code pub span: Span, @@ -250,7 +250,7 @@ pub enum JSXMemberExpressionObject<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct JSXExpressionContainer<'a> { /// Node location in source code pub span: Span, @@ -285,7 +285,7 @@ pub enum JSXExpression<'a> { /// An empty JSX expression (`{}`) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct JSXEmptyExpression { /// Node location in source code pub span: Span, @@ -325,7 +325,7 @@ pub enum JSXAttributeItem<'a> { /// // name ^^^ ^^^^ value #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct JSXAttribute<'a> { /// Node location in source code pub span: Span, @@ -346,7 +346,7 @@ pub struct JSXAttribute<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct JSXSpreadAttribute<'a> { /// Node location in source code pub span: Span, @@ -418,7 +418,7 @@ pub enum JSXAttributeValue<'a> { /// [`IdentifierName`]: super::IdentifierName #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct JSXIdentifier<'a> { /// Node location in source code pub span: Span, @@ -453,7 +453,7 @@ pub enum JSXChild<'a> { /// Variant of [`JSXChild`] that represents an object spread (`{...expression}`). #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct JSXSpreadChild<'a> { /// Node location in source code pub span: Span, @@ -473,7 +473,7 @@ pub struct JSXSpreadChild<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] 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 597c097d3769c..4a97af836f372 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, Dummy, TakeIn}; +use oxc_allocator::{Box, CloneIn, Dummy, TakeIn, UnstableAddress}; 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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[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, Dummy, TakeIn, ContentEq, GetSpan, GetSpanMut, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, ContentEq, GetSpan, GetSpanMut, ESTree, UnstableAddress)] #[estree(rename = "Literal")] pub struct NumericLiteral<'a> { /// Node location in source code @@ -69,7 +69,7 @@ pub struct NumericLiteral<'a> { /// #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, Dummy, TakeIn, ContentEq, GetSpan, GetSpanMut, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, ContentEq, GetSpan, GetSpanMut, ESTree, UnstableAddress)] #[estree(rename = "Literal")] pub struct StringLiteral<'a> { /// Node location in source code @@ -99,7 +99,7 @@ pub struct StringLiteral<'a> { /// BigInt literal #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, Dummy, TakeIn, ContentEq, GetSpan, GetSpanMut, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, ContentEq, GetSpan, GetSpanMut, ESTree, UnstableAddress)] #[estree(rename = "Literal", add_fields(bigint = BigIntLiteralBigint))] pub struct BigIntLiteral<'a> { /// Node location in source code @@ -122,7 +122,7 @@ pub struct BigIntLiteral<'a> { /// #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, ContentEq, GetSpan, GetSpanMut, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, ContentEq, GetSpan, GetSpanMut, ESTree, UnstableAddress)] #[estree( rename = "Literal", add_fields(value = RegExpLiteralValue), diff --git a/crates/oxc_ast/src/ast/ts.rs b/crates/oxc_ast/src/ast/ts.rs index 02da05921f60b..ed8cb8d88f679 100644 --- a/crates/oxc_ast/src/ast/ts.rs +++ b/crates/oxc_ast/src/ast/ts.rs @@ -21,7 +21,7 @@ use std::cell::Cell; -use oxc_allocator::{Box, CloneIn, Dummy, GetAddress, TakeIn, Vec}; +use oxc_allocator::{Box, CloneIn, Dummy, GetAddress, TakeIn, UnstableAddress, Vec}; use oxc_ast_macros::ast; use oxc_estree::ESTree; use oxc_span::{Atom, ContentEq, GetSpan, GetSpanMut, Span}; @@ -41,7 +41,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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree( rename = "Identifier", add_fields(decorators = EmptyArray, name = This, optional = False), @@ -78,7 +78,7 @@ pub struct TSThisParameter<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSEnumDeclaration<'a> { pub span: Span, pub id: BindingIdentifier<'a>, @@ -104,7 +104,7 @@ pub struct TSEnumDeclaration<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSEnumBody<'a> { pub span: Span, pub members: Vec<'a, TSEnumMember<'a>>, @@ -129,7 +129,7 @@ pub struct TSEnumBody<'a> { /// * [TypeScript Handbook - Enums](https://www.typescriptlang.org/docs/handbook/enums.html) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree(add_fields(computed = TSEnumMemberComputed))] pub struct TSEnumMember<'a> { pub span: Span, @@ -175,7 +175,7 @@ pub enum TSEnumMemberName<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSTypeAnnotation<'a> { /// starts at the `:` token and ends at the end of the type annotation pub span: Span, @@ -199,7 +199,7 @@ pub struct TSTypeAnnotation<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSLiteralType<'a> { pub span: Span, pub literal: TSLiteral<'a>, @@ -336,7 +336,7 @@ pub use match_ts_type; #[ast(visit)] #[scope(flags = ScopeFlags::TsConditional)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSConditionalType<'a> { pub span: Span, /// The type before `extends` in the test expression. @@ -363,7 +363,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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSUnionType<'a> { pub span: Span, /// The types in the union. @@ -385,7 +385,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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSIntersectionType<'a> { pub span: Span, pub types: Vec<'a, TSType<'a>>, @@ -402,7 +402,7 @@ pub struct TSIntersectionType<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree(via = TSParenthesizedTypeConverter)] pub struct TSParenthesizedType<'a> { pub span: Span, @@ -420,7 +420,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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSTypeOperator<'a> { pub span: Span, pub operator: TSTypeOperatorOperator, @@ -451,7 +451,7 @@ pub enum TSTypeOperatorOperator { /// #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSArrayType<'a> { pub span: Span, pub element_type: TSType<'a>, @@ -470,7 +470,7 @@ pub struct TSArrayType<'a> { /// #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSIndexedAccessType<'a> { pub span: Span, pub object_type: TSType<'a>, @@ -488,7 +488,7 @@ pub struct TSIndexedAccessType<'a> { /// #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSTupleType<'a> { pub span: Span, pub element_types: Vec<'a, TSTupleElement<'a>>, @@ -507,7 +507,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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSNamedTupleMember<'a> { pub span: Span, pub label: IdentifierName<'a>, @@ -526,7 +526,7 @@ pub struct TSNamedTupleMember<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSOptionalType<'a> { pub span: Span, pub type_annotation: TSType<'a>, @@ -542,7 +542,7 @@ pub struct TSOptionalType<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSRestType<'a> { pub span: Span, pub type_annotation: TSType<'a>, @@ -580,7 +580,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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSAnyKeyword { pub span: Span, } @@ -596,7 +596,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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSStringKeyword { pub span: Span, } @@ -612,7 +612,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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSBooleanKeyword { pub span: Span, } @@ -628,7 +628,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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSNumberKeyword { pub span: Span, } @@ -645,7 +645,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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSNeverKeyword { pub span: Span, } @@ -662,7 +662,7 @@ pub struct TSNeverKeyword { /// * [microsoft/TypeScript #40580](https://github.com/microsoft/TypeScript/pull/40580) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSIntrinsicKeyword { pub span: Span, } @@ -680,7 +680,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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSUnknownKeyword { pub span: Span, } @@ -697,7 +697,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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSNullKeyword { pub span: Span, } @@ -716,42 +716,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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSUndefinedKeyword { pub span: Span, } #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSVoidKeyword { pub span: Span, } #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSSymbolKeyword { pub span: Span, } #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSThisType { pub span: Span, } #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSObjectKeyword { pub span: Span, } #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSBigIntKeyword { pub span: Span, } @@ -769,7 +769,7 @@ pub struct TSBigIntKeyword { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSTypeReference<'a> { pub span: Span, pub type_name: TSTypeName<'a>, @@ -809,7 +809,7 @@ pub use match_ts_type_name; /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSQualifiedName<'a> { pub span: Span, pub left: TSTypeName<'a>, @@ -818,7 +818,7 @@ pub struct TSQualifiedName<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSTypeParameterInstantiation<'a> { pub span: Span, pub params: Vec<'a, TSType<'a>>, @@ -843,7 +843,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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSTypeParameter<'a> { pub span: Span, /// The name of the parameter, e.g. `T` in `type Foo = ...`. @@ -862,7 +862,7 @@ pub struct TSTypeParameter<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSTypeParameterDeclaration<'a> { pub span: Span, pub params: Vec<'a, TSTypeParameter<'a>>, @@ -879,7 +879,7 @@ pub struct TSTypeParameterDeclaration<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSTypeAliasDeclaration<'a> { pub span: Span, /// Type alias's identifier, e.g. `Foo` in `type Foo = number`. @@ -912,7 +912,7 @@ pub enum TSAccessibility { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[plural(TSClassImplementsList)] pub struct TSClassImplements<'a> { pub span: Span, @@ -939,7 +939,7 @@ pub struct TSClassImplements<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSInterfaceDeclaration<'a> { pub span: Span, /// The identifier (name) of the interface. @@ -958,7 +958,7 @@ pub struct TSInterfaceDeclaration<'a> { /// Body of a [`TSInterfaceDeclaration`]. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSInterfaceBody<'a> { pub span: Span, pub body: Vec<'a, TSSignature<'a>>, @@ -981,7 +981,7 @@ pub struct TSInterfaceBody<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree(add_fields(accessibility = Null, r#static = False))] pub struct TSPropertySignature<'a> { pub span: Span, @@ -1016,7 +1016,7 @@ pub enum TSSignature<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree(add_fields(accessibility = Null))] pub struct TSIndexSignature<'a> { pub span: Span, @@ -1029,7 +1029,7 @@ pub struct TSIndexSignature<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSCallSignatureDeclaration<'a> { pub span: Span, pub type_parameters: Option>>, @@ -1064,7 +1064,7 @@ pub enum TSMethodSignatureKind { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree(add_fields(accessibility = Null, readonly = False, r#static = False))] pub struct TSMethodSignature<'a> { pub span: Span, @@ -1085,7 +1085,7 @@ pub struct TSMethodSignature<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSConstructSignatureDeclaration<'a> { pub span: Span, pub type_parameters: Option>>, @@ -1096,7 +1096,7 @@ pub struct TSConstructSignatureDeclaration<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree( rename = "Identifier", add_fields(decorators = EmptyArray, optional = False), @@ -1111,7 +1111,7 @@ pub struct TSIndexSignatureName<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSInterfaceHeritage<'a> { pub span: Span, pub expression: Expression<'a>, @@ -1140,7 +1140,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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSTypePredicate<'a> { pub span: Span, /// The identifier the predicate operates on @@ -1195,7 +1195,7 @@ pub enum TSTypePredicateName<'a> { strict_if = self.body.as_ref().is_some_and(TSModuleDeclarationBody::has_use_strict_directive), )] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree( via = TSModuleDeclarationConverter, add_fields(global = TSModuleDeclarationGlobal), @@ -1280,7 +1280,7 @@ pub enum TSModuleDeclarationBody<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSModuleBlock<'a> { pub span: Span, #[estree(prepend_to = body)] @@ -1290,7 +1290,7 @@ pub struct TSModuleBlock<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSTypeLiteral<'a> { pub span: Span, pub members: Vec<'a, TSSignature<'a>>, @@ -1311,7 +1311,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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSInferType<'a> { pub span: Span, /// The type bound when the @@ -1329,7 +1329,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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSTypeQuery<'a> { pub span: Span, pub expr_name: TSTypeQueryExprName<'a>, @@ -1365,7 +1365,7 @@ pub enum TSTypeQueryExprName<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSImportType<'a> { pub span: Span, pub argument: TSType<'a>, @@ -1395,7 +1395,7 @@ pub enum TSImportTypeQualifier<'a> { /// A qualified name in an import type (e.g., `a.b.c` in `import("./module").a.b.c`) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree(rename = "TSQualifiedName")] pub struct TSImportTypeQualifiedName<'a> { pub span: Span, @@ -1414,7 +1414,7 @@ pub struct TSImportTypeQualifiedName<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSFunctionType<'a> { pub span: Span, /// Generic type parameters @@ -1448,7 +1448,7 @@ pub struct TSFunctionType<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSConstructorType<'a> { pub span: Span, pub r#abstract: bool, @@ -1482,7 +1482,7 @@ pub struct TSConstructorType<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree( add_fields(key = TSMappedTypeKey, constraint = TSMappedTypeConstraint), field_order(key, constraint, name_type, type_annotation, optional, readonly, span), @@ -1550,7 +1550,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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSTemplateLiteralType<'a> { pub span: Span, /// The string parts of the template literal. @@ -1561,7 +1561,7 @@ pub struct TSTemplateLiteralType<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSAsExpression<'a> { pub span: Span, pub expression: Expression<'a>, @@ -1582,7 +1582,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, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSSatisfiesExpression<'a> { pub span: Span, /// The value expression being constrained. @@ -1601,7 +1601,7 @@ pub struct TSSatisfiesExpression<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSTypeAssertion<'a> { pub span: Span, pub type_annotation: TSType<'a>, @@ -1610,7 +1610,7 @@ pub struct TSTypeAssertion<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSImportEqualsDeclaration<'a> { pub span: Span, pub id: BindingIdentifier<'a>, @@ -1636,7 +1636,7 @@ pub enum TSModuleReference<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSExternalModuleReference<'a> { pub span: Span, pub expression: StringLiteral<'a>, @@ -1644,7 +1644,7 @@ pub struct TSExternalModuleReference<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSNonNullExpression<'a> { pub span: Span, pub expression: Expression<'a>, @@ -1676,7 +1676,7 @@ pub struct TSNonNullExpression<'a> { /// [`CallExpression`]: crate::ast::js::CallExpression #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct Decorator<'a> { pub span: Span, pub expression: Expression<'a>, @@ -1687,7 +1687,7 @@ pub struct Decorator<'a> { /// `export = foo` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSExportAssignment<'a> { pub span: Span, pub expression: Expression<'a>, @@ -1698,7 +1698,7 @@ pub struct TSExportAssignment<'a> { /// `export as namespace foo` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSNamespaceExportDeclaration<'a> { pub span: Span, pub id: IdentifierName<'a>, @@ -1706,7 +1706,7 @@ pub struct TSNamespaceExportDeclaration<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] pub struct TSInstantiationExpression<'a> { pub span: Span, pub expression: Expression<'a>, @@ -1729,7 +1729,7 @@ pub enum ImportOrExportKind { /// `type foo = ty?` or `type foo = ?ty` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree(rename = "TSJSDocNullableType")] pub struct JSDocNullableType<'a> { pub span: Span, @@ -1741,7 +1741,7 @@ pub struct JSDocNullableType<'a> { /// `type foo = ty!` or `type foo = !ty` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree(rename = "TSJSDocNonNullableType")] pub struct JSDocNonNullableType<'a> { pub span: Span, @@ -1752,7 +1752,7 @@ pub struct JSDocNonNullableType<'a> { /// `type T = (?)` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)] #[estree(rename = "TSJSDocUnknownType")] pub struct JSDocUnknownType { pub span: Span, diff --git a/crates/oxc_ast/src/generated/derive_unstable_address.rs b/crates/oxc_ast/src/generated/derive_unstable_address.rs new file mode 100644 index 0000000000000..c76b8bbb2b294 --- /dev/null +++ b/crates/oxc_ast/src/generated/derive_unstable_address.rs @@ -0,0 +1,383 @@ +// Auto-generated code, DO NOT EDIT DIRECTLY! +// To edit this generated file you have to edit `tasks/ast_tools/src/derives/unstable_address.rs`. + +use oxc_allocator::UnstableAddress; + +use crate::ast::js::*; +use crate::ast::jsx::*; +use crate::ast::literal::*; +use crate::ast::ts::*; + +impl UnstableAddress for Program<'_> {} + +impl UnstableAddress for IdentifierName<'_> {} + +impl UnstableAddress for IdentifierReference<'_> {} + +impl UnstableAddress for BindingIdentifier<'_> {} + +impl UnstableAddress for LabelIdentifier<'_> {} + +impl UnstableAddress for ThisExpression {} + +impl UnstableAddress for ArrayExpression<'_> {} + +impl UnstableAddress for Elision {} + +impl UnstableAddress for ObjectExpression<'_> {} + +impl UnstableAddress for ObjectProperty<'_> {} + +impl UnstableAddress for TemplateLiteral<'_> {} + +impl UnstableAddress for TaggedTemplateExpression<'_> {} + +impl UnstableAddress for TemplateElement<'_> {} + +impl UnstableAddress for ComputedMemberExpression<'_> {} + +impl UnstableAddress for StaticMemberExpression<'_> {} + +impl UnstableAddress for PrivateFieldExpression<'_> {} + +impl UnstableAddress for CallExpression<'_> {} + +impl UnstableAddress for NewExpression<'_> {} + +impl UnstableAddress for MetaProperty<'_> {} + +impl UnstableAddress for SpreadElement<'_> {} + +impl UnstableAddress for UpdateExpression<'_> {} + +impl UnstableAddress for UnaryExpression<'_> {} + +impl UnstableAddress for BinaryExpression<'_> {} + +impl UnstableAddress for PrivateInExpression<'_> {} + +impl UnstableAddress for LogicalExpression<'_> {} + +impl UnstableAddress for ConditionalExpression<'_> {} + +impl UnstableAddress for AssignmentExpression<'_> {} + +impl UnstableAddress for ArrayAssignmentTarget<'_> {} + +impl UnstableAddress for ObjectAssignmentTarget<'_> {} + +impl UnstableAddress for AssignmentTargetRest<'_> {} + +impl UnstableAddress for AssignmentTargetWithDefault<'_> {} + +impl UnstableAddress for AssignmentTargetPropertyIdentifier<'_> {} + +impl UnstableAddress for AssignmentTargetPropertyProperty<'_> {} + +impl UnstableAddress for SequenceExpression<'_> {} + +impl UnstableAddress for Super {} + +impl UnstableAddress for AwaitExpression<'_> {} + +impl UnstableAddress for ChainExpression<'_> {} + +impl UnstableAddress for ParenthesizedExpression<'_> {} + +impl UnstableAddress for Directive<'_> {} + +impl UnstableAddress for Hashbang<'_> {} + +impl UnstableAddress for BlockStatement<'_> {} + +impl UnstableAddress for VariableDeclaration<'_> {} + +impl UnstableAddress for VariableDeclarator<'_> {} + +impl UnstableAddress for EmptyStatement {} + +impl UnstableAddress for ExpressionStatement<'_> {} + +impl UnstableAddress for IfStatement<'_> {} + +impl UnstableAddress for DoWhileStatement<'_> {} + +impl UnstableAddress for WhileStatement<'_> {} + +impl UnstableAddress for ForStatement<'_> {} + +impl UnstableAddress for ForInStatement<'_> {} + +impl UnstableAddress for ForOfStatement<'_> {} + +impl UnstableAddress for ContinueStatement<'_> {} + +impl UnstableAddress for BreakStatement<'_> {} + +impl UnstableAddress for ReturnStatement<'_> {} + +impl UnstableAddress for WithStatement<'_> {} + +impl UnstableAddress for SwitchStatement<'_> {} + +impl UnstableAddress for SwitchCase<'_> {} + +impl UnstableAddress for LabeledStatement<'_> {} + +impl UnstableAddress for ThrowStatement<'_> {} + +impl UnstableAddress for TryStatement<'_> {} + +impl UnstableAddress for CatchClause<'_> {} + +impl UnstableAddress for CatchParameter<'_> {} + +impl UnstableAddress for DebuggerStatement {} + +impl UnstableAddress for BindingPattern<'_> {} + +impl UnstableAddress for AssignmentPattern<'_> {} + +impl UnstableAddress for ObjectPattern<'_> {} + +impl UnstableAddress for BindingProperty<'_> {} + +impl UnstableAddress for ArrayPattern<'_> {} + +impl UnstableAddress for BindingRestElement<'_> {} + +impl UnstableAddress for Function<'_> {} + +impl UnstableAddress for FormalParameters<'_> {} + +impl UnstableAddress for FormalParameter<'_> {} + +impl UnstableAddress for FunctionBody<'_> {} + +impl UnstableAddress for ArrowFunctionExpression<'_> {} + +impl UnstableAddress for YieldExpression<'_> {} + +impl UnstableAddress for Class<'_> {} + +impl UnstableAddress for ClassBody<'_> {} + +impl UnstableAddress for MethodDefinition<'_> {} + +impl UnstableAddress for PropertyDefinition<'_> {} + +impl UnstableAddress for PrivateIdentifier<'_> {} + +impl UnstableAddress for StaticBlock<'_> {} + +impl UnstableAddress for AccessorProperty<'_> {} + +impl UnstableAddress for ImportExpression<'_> {} + +impl UnstableAddress for ImportDeclaration<'_> {} + +impl UnstableAddress for ImportSpecifier<'_> {} + +impl UnstableAddress for ImportDefaultSpecifier<'_> {} + +impl UnstableAddress for ImportNamespaceSpecifier<'_> {} + +impl UnstableAddress for WithClause<'_> {} + +impl UnstableAddress for ImportAttribute<'_> {} + +impl UnstableAddress for ExportNamedDeclaration<'_> {} + +impl UnstableAddress for ExportDefaultDeclaration<'_> {} + +impl UnstableAddress for ExportAllDeclaration<'_> {} + +impl UnstableAddress for ExportSpecifier<'_> {} + +impl UnstableAddress for V8IntrinsicExpression<'_> {} + +impl UnstableAddress for BooleanLiteral {} + +impl UnstableAddress for NullLiteral {} + +impl UnstableAddress for NumericLiteral<'_> {} + +impl UnstableAddress for StringLiteral<'_> {} + +impl UnstableAddress for BigIntLiteral<'_> {} + +impl UnstableAddress for RegExpLiteral<'_> {} + +impl UnstableAddress for JSXElement<'_> {} + +impl UnstableAddress for JSXOpeningElement<'_> {} + +impl UnstableAddress for JSXClosingElement<'_> {} + +impl UnstableAddress for JSXFragment<'_> {} + +impl UnstableAddress for JSXOpeningFragment {} + +impl UnstableAddress for JSXClosingFragment {} + +impl UnstableAddress for JSXNamespacedName<'_> {} + +impl UnstableAddress for JSXMemberExpression<'_> {} + +impl UnstableAddress for JSXExpressionContainer<'_> {} + +impl UnstableAddress for JSXEmptyExpression {} + +impl UnstableAddress for JSXAttribute<'_> {} + +impl UnstableAddress for JSXSpreadAttribute<'_> {} + +impl UnstableAddress for JSXIdentifier<'_> {} + +impl UnstableAddress for JSXSpreadChild<'_> {} + +impl UnstableAddress for JSXText<'_> {} + +impl UnstableAddress for TSThisParameter<'_> {} + +impl UnstableAddress for TSEnumDeclaration<'_> {} + +impl UnstableAddress for TSEnumBody<'_> {} + +impl UnstableAddress for TSEnumMember<'_> {} + +impl UnstableAddress for TSTypeAnnotation<'_> {} + +impl UnstableAddress for TSLiteralType<'_> {} + +impl UnstableAddress for TSConditionalType<'_> {} + +impl UnstableAddress for TSUnionType<'_> {} + +impl UnstableAddress for TSIntersectionType<'_> {} + +impl UnstableAddress for TSParenthesizedType<'_> {} + +impl UnstableAddress for TSTypeOperator<'_> {} + +impl UnstableAddress for TSArrayType<'_> {} + +impl UnstableAddress for TSIndexedAccessType<'_> {} + +impl UnstableAddress for TSTupleType<'_> {} + +impl UnstableAddress for TSNamedTupleMember<'_> {} + +impl UnstableAddress for TSOptionalType<'_> {} + +impl UnstableAddress for TSRestType<'_> {} + +impl UnstableAddress for TSAnyKeyword {} + +impl UnstableAddress for TSStringKeyword {} + +impl UnstableAddress for TSBooleanKeyword {} + +impl UnstableAddress for TSNumberKeyword {} + +impl UnstableAddress for TSNeverKeyword {} + +impl UnstableAddress for TSIntrinsicKeyword {} + +impl UnstableAddress for TSUnknownKeyword {} + +impl UnstableAddress for TSNullKeyword {} + +impl UnstableAddress for TSUndefinedKeyword {} + +impl UnstableAddress for TSVoidKeyword {} + +impl UnstableAddress for TSSymbolKeyword {} + +impl UnstableAddress for TSThisType {} + +impl UnstableAddress for TSObjectKeyword {} + +impl UnstableAddress for TSBigIntKeyword {} + +impl UnstableAddress for TSTypeReference<'_> {} + +impl UnstableAddress for TSQualifiedName<'_> {} + +impl UnstableAddress for TSTypeParameterInstantiation<'_> {} + +impl UnstableAddress for TSTypeParameter<'_> {} + +impl UnstableAddress for TSTypeParameterDeclaration<'_> {} + +impl UnstableAddress for TSTypeAliasDeclaration<'_> {} + +impl UnstableAddress for TSClassImplements<'_> {} + +impl UnstableAddress for TSInterfaceDeclaration<'_> {} + +impl UnstableAddress for TSInterfaceBody<'_> {} + +impl UnstableAddress for TSPropertySignature<'_> {} + +impl UnstableAddress for TSIndexSignature<'_> {} + +impl UnstableAddress for TSCallSignatureDeclaration<'_> {} + +impl UnstableAddress for TSMethodSignature<'_> {} + +impl UnstableAddress for TSConstructSignatureDeclaration<'_> {} + +impl UnstableAddress for TSIndexSignatureName<'_> {} + +impl UnstableAddress for TSInterfaceHeritage<'_> {} + +impl UnstableAddress for TSTypePredicate<'_> {} + +impl UnstableAddress for TSModuleDeclaration<'_> {} + +impl UnstableAddress for TSModuleBlock<'_> {} + +impl UnstableAddress for TSTypeLiteral<'_> {} + +impl UnstableAddress for TSInferType<'_> {} + +impl UnstableAddress for TSTypeQuery<'_> {} + +impl UnstableAddress for TSImportType<'_> {} + +impl UnstableAddress for TSImportTypeQualifiedName<'_> {} + +impl UnstableAddress for TSFunctionType<'_> {} + +impl UnstableAddress for TSConstructorType<'_> {} + +impl UnstableAddress for TSMappedType<'_> {} + +impl UnstableAddress for TSTemplateLiteralType<'_> {} + +impl UnstableAddress for TSAsExpression<'_> {} + +impl UnstableAddress for TSSatisfiesExpression<'_> {} + +impl UnstableAddress for TSTypeAssertion<'_> {} + +impl UnstableAddress for TSImportEqualsDeclaration<'_> {} + +impl UnstableAddress for TSExternalModuleReference<'_> {} + +impl UnstableAddress for TSNonNullExpression<'_> {} + +impl UnstableAddress for Decorator<'_> {} + +impl UnstableAddress for TSExportAssignment<'_> {} + +impl UnstableAddress for TSNamespaceExportDeclaration<'_> {} + +impl UnstableAddress for TSInstantiationExpression<'_> {} + +impl UnstableAddress for JSDocNullableType<'_> {} + +impl UnstableAddress for JSDocNonNullableType<'_> {} + +impl UnstableAddress for JSDocUnknownType {} diff --git a/crates/oxc_ast/src/lib.rs b/crates/oxc_ast/src/lib.rs index ba94ec555baa3..670ccccb96437 100644 --- a/crates/oxc_ast/src/lib.rs +++ b/crates/oxc_ast/src/lib.rs @@ -68,6 +68,7 @@ mod generated { mod derive_get_span; mod derive_get_span_mut; mod derive_take_in; + mod derive_unstable_address; mod get_id; } diff --git a/crates/oxc_ast_macros/src/generated/derived_traits.rs b/crates/oxc_ast_macros/src/generated/derived_traits.rs index 75ad105c3f8eb..1146859b535e5 100644 --- a/crates/oxc_ast_macros/src/generated/derived_traits.rs +++ b/crates/oxc_ast_macros/src/generated/derived_traits.rs @@ -10,6 +10,7 @@ pub fn get_trait_crate_and_generics(trait_name: &str) -> Option<(TokenStream, To "Dummy" => (quote!(::oxc_allocator::Dummy), quote!(< 'static >)), "TakeIn" => (quote!(::oxc_allocator::TakeIn), quote!(< 'static >)), "GetAddress" => (quote!(::oxc_allocator::GetAddress), TokenStream::new()), + "UnstableAddress" => (quote!(::oxc_allocator::UnstableAddress), TokenStream::new()), "GetSpan" => (quote!(::oxc_span::GetSpan), TokenStream::new()), "GetSpanMut" => (quote!(::oxc_span::GetSpanMut), TokenStream::new()), "ContentEq" => (quote!(::oxc_span::ContentEq), TokenStream::new()), diff --git a/tasks/ast_tools/src/derives/mod.rs b/tasks/ast_tools/src/derives/mod.rs index 2f4000ec1cf49..659c547c8e5ee 100644 --- a/tasks/ast_tools/src/derives/mod.rs +++ b/tasks/ast_tools/src/derives/mod.rs @@ -21,6 +21,7 @@ pub mod estree; mod get_address; mod get_span; mod take_in; +mod unstable_address; pub use clone_in::DeriveCloneIn; pub use content_eq::DeriveContentEq; @@ -29,6 +30,7 @@ pub use estree::DeriveESTree; pub use get_address::DeriveGetAddress; pub use get_span::{DeriveGetSpan, DeriveGetSpanMut}; pub use take_in::DeriveTakeIn; +pub use unstable_address::DeriveUnstableAddress; /// Trait to define a derive. pub trait Derive: Runner { diff --git a/tasks/ast_tools/src/derives/unstable_address.rs b/tasks/ast_tools/src/derives/unstable_address.rs new file mode 100644 index 0000000000000..62eefb2696e56 --- /dev/null +++ b/tasks/ast_tools/src/derives/unstable_address.rs @@ -0,0 +1,43 @@ +//! Derive for `UnstableAddress` trait. + +use proc_macro2::TokenStream; +use quote::quote; + +use crate::schema::{Def, Schema, StructOrEnum}; + +use super::{Derive, define_derive}; + +/// Derive for `UnstableAddress` trait. +pub struct DeriveUnstableAddress; + +define_derive!(DeriveUnstableAddress); + +impl Derive for DeriveUnstableAddress { + fn trait_name(&self) -> &'static str { + "UnstableAddress" + } + + fn crate_name(&self) -> &'static str { + "oxc_allocator" + } + + fn prelude(&self) -> TokenStream { + quote! { + use oxc_allocator::UnstableAddress; + } + } + + fn derive(&self, type_def: StructOrEnum, schema: &Schema) -> TokenStream { + if let StructOrEnum::Struct(struct_def) = type_def { + let ty = struct_def.ty_anon(schema); + quote! { + impl UnstableAddress for #ty {} + } + } else { + panic!( + "`UnstableAddress` can only be implemented with `#[generate_derive]` on structs: `{}`", + type_def.name() + ); + } + } +} diff --git a/tasks/ast_tools/src/main.rs b/tasks/ast_tools/src/main.rs index c678dde94868c..98dd28dc68cb4 100644 --- a/tasks/ast_tools/src/main.rs +++ b/tasks/ast_tools/src/main.rs @@ -271,6 +271,7 @@ const DERIVES: &[&(dyn Derive + Sync)] = &[ &derives::DeriveDummy, &derives::DeriveTakeIn, &derives::DeriveGetAddress, + &derives::DeriveUnstableAddress, &derives::DeriveGetSpan, &derives::DeriveGetSpanMut, &derives::DeriveContentEq,