1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
use TokenStream;
use ;
/// This attribute serves two purposes:
///
/// Firstly, it is a marker for `oxc_ast_tools`, to understand that a type is part of the AST.
///
/// Secondly, it adds the following code around the type:
///
/// ### `#[repr(C)]`
///
/// `#[repr]` attribute is added to the type, to make the memory layout of the type predictable:
///
/// * Structs: `#[repr(C)]`. e.g. `#[repr(C)] struct S { x: X, y: Y }`
/// * Fieldless enums: `#[repr(u8)]` e.g. `#[repr(u8)] enum E { X, Y, Z, }`.
/// * Fieldful enums: `#[repr(C, u8)]` e.g. `#[repr(C, u8)] enum E { X(X), Y(Y) }`
///
/// ### Derive `Ast` trait
///
/// `#[derive(oxc_ast_macros::Ast)]` is added to the type.
///
/// `Ast` derive macro is a no-op (see below) but allows custom attributes on AST types.
///
/// See `derives` and `generators` directories in `tasks/ast_tools` for details of the various
/// custom attributes, and how they're used.
///
/// ### Trait assertions
///
/// `oxc_ast_tools` generates code for trait impls where those traits are specified with
/// `#[generate_derive(SomeTrait)]`. This is similar to `#[derive(SomeTrait)]`, but the code is
/// generated ahead-of-time, rather than in a proc macro.
///
/// Add assertions that traits used in `#[generate_derive(...)]` are in scope.
/// Dummy derive macro for a non-existent trait `Ast`.
///
/// Does not generate any code.
/// Its only purpose is to allow the occurrence of helper attributes used in `tasks/ast_tools`.
///
/// See [`macro@ast`] for further details.