Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(ast)!: span field must be the first element #7821

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions crates/oxc_ast/src/ast/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1570,8 +1570,8 @@ pub struct BindingRestElement<'a> {
#[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)]
pub struct Function<'a> {
pub r#type: FunctionType,
pub span: Span,
pub r#type: FunctionType,
/// The function identifier. [`None`] for anonymous function expressions.
pub id: Option<BindingIdentifier<'a>>,
/// Is this a generator function?
Expand Down Expand Up @@ -1738,8 +1738,8 @@ pub struct YieldExpression<'a> {
#[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)]
pub struct Class<'a> {
pub r#type: ClassType,
pub span: Span,
pub r#type: ClassType,
/// Decorators applied to the class.
///
/// Decorators are currently a stage 3 proposal. Oxc handles both TC39 and
Expand Down Expand Up @@ -1879,11 +1879,11 @@ pub enum ClassElement<'a> {
#[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)]
pub struct MethodDefinition<'a> {
pub span: Span,
/// Method definition type
///
/// This will always be true when an `abstract` modifier is used on the method.
pub r#type: MethodDefinitionType,
pub span: Span,
#[ts]
pub decorators: Vec<'a, Decorator<'a>>,
pub key: PropertyKey<'a>,
Expand Down Expand Up @@ -1918,8 +1918,8 @@ pub enum MethodDefinitionType {
#[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)]
pub struct PropertyDefinition<'a> {
pub r#type: PropertyDefinitionType,
pub span: Span,
pub r#type: PropertyDefinitionType,
/// Decorators applied to the property.
///
/// See [`Decorator`] for more information.
Expand Down Expand Up @@ -2140,8 +2140,8 @@ pub enum AccessorPropertyType {
#[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)]
pub struct AccessorProperty<'a> {
pub r#type: AccessorPropertyType,
pub span: Span,
pub r#type: AccessorPropertyType,
/// Decorators applied to the accessor property.
///
/// See [`Decorator`] for more information.
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_ast/src/ast_builder_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ impl<'a> AstBuilder<'a> {
let params =
self.formal_parameters(SPAN, FormalParameterKind::FormalParameter, self.vec(), NONE);
let empty_function = self.function(
FunctionType::FunctionDeclaration,
SPAN,
FunctionType::FunctionDeclaration,
None,
false,
false,
Expand Down Expand Up @@ -249,8 +249,8 @@ impl<'a> AstBuilder<'a> {
scope_id: ScopeId,
) -> Box<'a, Function<'a>> {
self.alloc_function_with_scope_id(
r#type,
span,
r#type,
id,
false,
false,
Expand Down
40 changes: 20 additions & 20 deletions crates/oxc_ast/src/generated/assert_layouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,8 +543,8 @@ const _: () = {

assert!(size_of::<Function>() == 104usize);
assert!(align_of::<Function>() == 8usize);
assert!(offset_of!(Function, r#type) == 0usize);
assert!(offset_of!(Function, span) == 4usize);
assert!(offset_of!(Function, span) == 0usize);
assert!(offset_of!(Function, r#type) == 8usize);
assert!(offset_of!(Function, id) == 16usize);
assert!(offset_of!(Function, generator) == 48usize);
assert!(offset_of!(Function, r#async) == 49usize);
Expand Down Expand Up @@ -603,8 +603,8 @@ const _: () = {

assert!(size_of::<Class>() == 160usize);
assert!(align_of::<Class>() == 8usize);
assert!(offset_of!(Class, r#type) == 0usize);
assert!(offset_of!(Class, span) == 4usize);
assert!(offset_of!(Class, span) == 0usize);
assert!(offset_of!(Class, r#type) == 8usize);
assert!(offset_of!(Class, decorators) == 16usize);
assert!(offset_of!(Class, id) == 48usize);
assert!(offset_of!(Class, type_parameters) == 80usize);
Expand All @@ -629,8 +629,8 @@ const _: () = {

assert!(size_of::<MethodDefinition>() == 80usize);
assert!(align_of::<MethodDefinition>() == 8usize);
assert!(offset_of!(MethodDefinition, r#type) == 0usize);
assert!(offset_of!(MethodDefinition, span) == 4usize);
assert!(offset_of!(MethodDefinition, span) == 0usize);
assert!(offset_of!(MethodDefinition, r#type) == 8usize);
assert!(offset_of!(MethodDefinition, decorators) == 16usize);
assert!(offset_of!(MethodDefinition, key) == 48usize);
assert!(offset_of!(MethodDefinition, value) == 64usize);
Expand All @@ -646,8 +646,8 @@ const _: () = {

assert!(size_of::<PropertyDefinition>() == 104usize);
assert!(align_of::<PropertyDefinition>() == 8usize);
assert!(offset_of!(PropertyDefinition, r#type) == 0usize);
assert!(offset_of!(PropertyDefinition, span) == 4usize);
assert!(offset_of!(PropertyDefinition, span) == 0usize);
assert!(offset_of!(PropertyDefinition, r#type) == 8usize);
assert!(offset_of!(PropertyDefinition, decorators) == 16usize);
assert!(offset_of!(PropertyDefinition, key) == 48usize);
assert!(offset_of!(PropertyDefinition, value) == 64usize);
Expand Down Expand Up @@ -686,8 +686,8 @@ const _: () = {

assert!(size_of::<AccessorProperty>() == 104usize);
assert!(align_of::<AccessorProperty>() == 8usize);
assert!(offset_of!(AccessorProperty, r#type) == 0usize);
assert!(offset_of!(AccessorProperty, span) == 4usize);
assert!(offset_of!(AccessorProperty, span) == 0usize);
assert!(offset_of!(AccessorProperty, r#type) == 8usize);
assert!(offset_of!(AccessorProperty, decorators) == 16usize);
assert!(offset_of!(AccessorProperty, key) == 48usize);
assert!(offset_of!(AccessorProperty, value) == 64usize);
Expand Down Expand Up @@ -2105,8 +2105,8 @@ const _: () = {

assert!(size_of::<Function>() == 60usize);
assert!(align_of::<Function>() == 4usize);
assert!(offset_of!(Function, r#type) == 0usize);
assert!(offset_of!(Function, span) == 4usize);
assert!(offset_of!(Function, span) == 0usize);
assert!(offset_of!(Function, r#type) == 8usize);
assert!(offset_of!(Function, id) == 12usize);
assert!(offset_of!(Function, generator) == 32usize);
assert!(offset_of!(Function, r#async) == 33usize);
Expand Down Expand Up @@ -2165,8 +2165,8 @@ const _: () = {

assert!(size_of::<Class>() == 92usize);
assert!(align_of::<Class>() == 4usize);
assert!(offset_of!(Class, r#type) == 0usize);
assert!(offset_of!(Class, span) == 4usize);
assert!(offset_of!(Class, span) == 0usize);
assert!(offset_of!(Class, r#type) == 8usize);
assert!(offset_of!(Class, decorators) == 12usize);
assert!(offset_of!(Class, id) == 28usize);
assert!(offset_of!(Class, type_parameters) == 48usize);
Expand All @@ -2191,8 +2191,8 @@ const _: () = {

assert!(size_of::<MethodDefinition>() == 48usize);
assert!(align_of::<MethodDefinition>() == 4usize);
assert!(offset_of!(MethodDefinition, r#type) == 0usize);
assert!(offset_of!(MethodDefinition, span) == 4usize);
assert!(offset_of!(MethodDefinition, span) == 0usize);
assert!(offset_of!(MethodDefinition, r#type) == 8usize);
assert!(offset_of!(MethodDefinition, decorators) == 12usize);
assert!(offset_of!(MethodDefinition, key) == 28usize);
assert!(offset_of!(MethodDefinition, value) == 36usize);
Expand All @@ -2208,8 +2208,8 @@ const _: () = {

assert!(size_of::<PropertyDefinition>() == 60usize);
assert!(align_of::<PropertyDefinition>() == 4usize);
assert!(offset_of!(PropertyDefinition, r#type) == 0usize);
assert!(offset_of!(PropertyDefinition, span) == 4usize);
assert!(offset_of!(PropertyDefinition, span) == 0usize);
assert!(offset_of!(PropertyDefinition, r#type) == 8usize);
assert!(offset_of!(PropertyDefinition, decorators) == 12usize);
assert!(offset_of!(PropertyDefinition, key) == 28usize);
assert!(offset_of!(PropertyDefinition, value) == 36usize);
Expand Down Expand Up @@ -2248,8 +2248,8 @@ const _: () = {

assert!(size_of::<AccessorProperty>() == 56usize);
assert!(align_of::<AccessorProperty>() == 4usize);
assert!(offset_of!(AccessorProperty, r#type) == 0usize);
assert!(offset_of!(AccessorProperty, span) == 4usize);
assert!(offset_of!(AccessorProperty, span) == 0usize);
assert!(offset_of!(AccessorProperty, r#type) == 8usize);
assert!(offset_of!(AccessorProperty, decorators) == 12usize);
assert!(offset_of!(AccessorProperty, key) == 28usize);
assert!(offset_of!(AccessorProperty, value) == 36usize);
Expand Down
Loading
Loading