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): make AST structs repr(C). #4614

Merged
merged 1 commit into from
Aug 3, 2024
Merged
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
6 changes: 3 additions & 3 deletions crates/oxc_ast_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ fn enum_repr(enum_: &syn::ItemEnum) -> TokenStream2 {
/// It is also a lightweight macro; All of its computation is cached and
/// it only applies the following changes without any complex operation:
///
/// * Prepend `#[repr(C)]` to structs
/// * Prepend `#[repr(C, u8)]` to fieldful enums e.g. `enum E { X: u32, Y: u8 }`
/// * Prepend `#[repr(u8)]` to unit (fieldless) enums e.g. `enum E { X, Y, Z, }`
/// * Prepend `#[derive(oxc_ast_macros::Ast)]`
/// * Prepend `#[derive(oxc_ast_macros::Ast)]` to all structs and enums
///
#[proc_macro_attribute]
#[allow(clippy::missing_panics_doc)]
Expand All @@ -28,8 +29,7 @@ pub fn ast(_args: TokenStream, input: TokenStream) -> TokenStream {

let repr = match input {
syn::Item::Enum(ref enum_) => enum_repr(enum_),
// In future, we'll add `#[repr(C)]` to structs, but at present this is disabled
syn::Item::Struct(_) => TokenStream2::default(),
syn::Item::Struct(_) => quote!(#[repr(C)]),

_ => {
unreachable!()
Expand Down