]> git.lizzy.rs Git - rust.git/blob - xtask/src/ast_src.rs
e6182e8572b1c669bb0a4204600a1934bf47daa2
[rust.git] / xtask / src / ast_src.rs
1 //! Defines input for code generation process.
2
3 pub(crate) struct KindsSrc<'a> {
4     pub(crate) punct: &'a [(&'a str, &'a str)],
5     pub(crate) keywords: &'a [&'a str],
6     pub(crate) contextual_keywords: &'a [&'a str],
7     pub(crate) literals: &'a [&'a str],
8     pub(crate) tokens: &'a [&'a str],
9     pub(crate) nodes: &'a [&'a str],
10 }
11
12 pub(crate) const KINDS_SRC: KindsSrc = KindsSrc {
13     punct: &[
14         (";", "SEMICOLON"),
15         (",", "COMMA"),
16         ("(", "L_PAREN"),
17         (")", "R_PAREN"),
18         ("{", "L_CURLY"),
19         ("}", "R_CURLY"),
20         ("[", "L_BRACK"),
21         ("]", "R_BRACK"),
22         ("<", "L_ANGLE"),
23         (">", "R_ANGLE"),
24         ("@", "AT"),
25         ("#", "POUND"),
26         ("~", "TILDE"),
27         ("?", "QUESTION"),
28         ("$", "DOLLAR"),
29         ("&", "AMP"),
30         ("|", "PIPE"),
31         ("+", "PLUS"),
32         ("*", "STAR"),
33         ("/", "SLASH"),
34         ("^", "CARET"),
35         ("%", "PERCENT"),
36         ("_", "UNDERSCORE"),
37         (".", "DOT"),
38         ("..", "DOT2"),
39         ("...", "DOT3"),
40         ("..=", "DOT2EQ"),
41         (":", "COLON"),
42         ("::", "COLON2"),
43         ("=", "EQ"),
44         ("==", "EQ2"),
45         ("=>", "FAT_ARROW"),
46         ("!", "BANG"),
47         ("!=", "NEQ"),
48         ("-", "MINUS"),
49         ("->", "THIN_ARROW"),
50         ("<=", "LTEQ"),
51         (">=", "GTEQ"),
52         ("+=", "PLUSEQ"),
53         ("-=", "MINUSEQ"),
54         ("|=", "PIPEEQ"),
55         ("&=", "AMPEQ"),
56         ("^=", "CARETEQ"),
57         ("/=", "SLASHEQ"),
58         ("*=", "STAREQ"),
59         ("%=", "PERCENTEQ"),
60         ("&&", "AMP2"),
61         ("||", "PIPE2"),
62         ("<<", "SHL"),
63         (">>", "SHR"),
64         ("<<=", "SHLEQ"),
65         (">>=", "SHREQ"),
66     ],
67     keywords: &[
68         "as", "async", "await", "box", "break", "const", "continue", "crate", "dyn", "else",
69         "enum", "extern", "false", "fn", "for", "if", "impl", "in", "let", "loop", "macro",
70         "match", "mod", "move", "mut", "pub", "ref", "return", "self", "static", "struct", "super",
71         "trait", "true", "try", "type", "unsafe", "use", "where", "while",
72     ],
73     contextual_keywords: &["auto", "default", "existential", "union", "raw"],
74     literals: &[
75         "INT_NUMBER",
76         "FLOAT_NUMBER",
77         "CHAR",
78         "BYTE",
79         "STRING",
80         "RAW_STRING",
81         "BYTE_STRING",
82         "RAW_BYTE_STRING",
83     ],
84     tokens: &[
85         "ERROR",
86         "IDENT",
87         "WHITESPACE",
88         "LIFETIME",
89         "COMMENT",
90         "SHEBANG",
91         "L_DOLLAR",
92         "R_DOLLAR",
93     ],
94     nodes: &[
95         "SOURCE_FILE",
96         "STRUCT_DEF",
97         "UNION_DEF",
98         "ENUM_DEF",
99         "FN_DEF",
100         "RET_TYPE",
101         "EXTERN_CRATE_ITEM",
102         "MODULE",
103         "USE_ITEM",
104         "STATIC_DEF",
105         "CONST_DEF",
106         "TRAIT_DEF",
107         "IMPL_DEF",
108         "TYPE_ALIAS_DEF",
109         "MACRO_CALL",
110         "TOKEN_TREE",
111         "MACRO_DEF",
112         "PAREN_TYPE",
113         "TUPLE_TYPE",
114         "NEVER_TYPE",
115         "PATH_TYPE",
116         "POINTER_TYPE",
117         "ARRAY_TYPE",
118         "SLICE_TYPE",
119         "REFERENCE_TYPE",
120         "PLACEHOLDER_TYPE",
121         "FN_POINTER_TYPE",
122         "FOR_TYPE",
123         "IMPL_TRAIT_TYPE",
124         "DYN_TRAIT_TYPE",
125         "OR_PAT",
126         "PAREN_PAT",
127         "REF_PAT",
128         "BOX_PAT",
129         "BIND_PAT",
130         "PLACEHOLDER_PAT",
131         "DOT_DOT_PAT",
132         "PATH_PAT",
133         "RECORD_PAT",
134         "RECORD_FIELD_PAT_LIST",
135         "RECORD_FIELD_PAT",
136         "TUPLE_STRUCT_PAT",
137         "TUPLE_PAT",
138         "SLICE_PAT",
139         "RANGE_PAT",
140         "LITERAL_PAT",
141         "MACRO_PAT",
142         // atoms
143         "TUPLE_EXPR",
144         "ARRAY_EXPR",
145         "PAREN_EXPR",
146         "PATH_EXPR",
147         "LAMBDA_EXPR",
148         "IF_EXPR",
149         "WHILE_EXPR",
150         "CONDITION",
151         "LOOP_EXPR",
152         "FOR_EXPR",
153         "CONTINUE_EXPR",
154         "BREAK_EXPR",
155         "LABEL",
156         "BLOCK_EXPR",
157         "RETURN_EXPR",
158         "MATCH_EXPR",
159         "MATCH_ARM_LIST",
160         "MATCH_ARM",
161         "MATCH_GUARD",
162         "RECORD_LIT",
163         "RECORD_FIELD_LIST",
164         "RECORD_FIELD",
165         "EFFECT_EXPR",
166         "BOX_EXPR",
167         // postfix
168         "CALL_EXPR",
169         "INDEX_EXPR",
170         "METHOD_CALL_EXPR",
171         "FIELD_EXPR",
172         "AWAIT_EXPR",
173         "TRY_EXPR",
174         "CAST_EXPR",
175         // unary
176         "REF_EXPR",
177         "PREFIX_EXPR",
178         "RANGE_EXPR", // just weird
179         "BIN_EXPR",
180         "EXTERN_BLOCK",
181         "EXTERN_ITEM_LIST",
182         "ENUM_VARIANT",
183         "RECORD_FIELD_DEF_LIST",
184         "RECORD_FIELD_DEF",
185         "TUPLE_FIELD_DEF_LIST",
186         "TUPLE_FIELD_DEF",
187         "ENUM_VARIANT_LIST",
188         "ITEM_LIST",
189         "ATTR",
190         "META_ITEM", // not an item actually
191         "USE_TREE",
192         "USE_TREE_LIST",
193         "PATH",
194         "PATH_SEGMENT",
195         "LITERAL",
196         "ALIAS",
197         "VISIBILITY",
198         "WHERE_CLAUSE",
199         "WHERE_PRED",
200         "ABI",
201         "NAME",
202         "NAME_REF",
203         "LET_STMT",
204         "EXPR_STMT",
205         "TYPE_PARAM_LIST",
206         "LIFETIME_PARAM",
207         "TYPE_PARAM",
208         "CONST_PARAM",
209         "TYPE_ARG_LIST",
210         "LIFETIME_ARG",
211         "TYPE_ARG",
212         "ASSOC_TYPE_ARG",
213         "CONST_ARG",
214         "PARAM_LIST",
215         "PARAM",
216         "SELF_PARAM",
217         "ARG_LIST",
218         "TYPE_BOUND",
219         "TYPE_BOUND_LIST",
220         // macro related
221         "MACRO_ITEMS",
222         "MACRO_STMTS",
223     ],
224 };
225
226 pub(crate) struct AstSrc<'a> {
227     pub(crate) tokens: &'a [&'a str],
228     pub(crate) nodes: &'a [AstNodeSrc<'a>],
229     pub(crate) enums: &'a [AstEnumSrc<'a>],
230 }
231
232 pub(crate) struct AstNodeSrc<'a> {
233     pub(crate) doc: &'a [&'a str],
234     pub(crate) name: &'a str,
235     pub(crate) traits: &'a [&'a str],
236     pub(crate) fields: &'a [Field<'a>],
237 }
238
239 pub(crate) enum Field<'a> {
240     Token(&'a str),
241     Node { name: &'a str, src: FieldSrc<'a> },
242 }
243
244 pub(crate) enum FieldSrc<'a> {
245     Shorthand,
246     Optional(&'a str),
247     Many(&'a str),
248 }
249
250 pub(crate) struct AstEnumSrc<'a> {
251     pub(crate) doc: &'a [&'a str],
252     pub(crate) name: &'a str,
253     pub(crate) traits: &'a [&'a str],
254     pub(crate) variants: &'a [&'a str],
255 }
256
257 macro_rules! ast_nodes {
258     ($(
259         $(#[doc = $doc:expr])+
260         struct $name:ident$(: $($trait:ident),*)? {
261             $($field_name:ident $(![$token:tt])? $(: $ty:tt)?),*$(,)?
262         }
263     )*) => {
264         [$(
265             AstNodeSrc {
266                 doc: &[$($doc),*],
267                 name: stringify!($name),
268                 traits: &[$($(stringify!($trait)),*)?],
269                 fields: &[
270                     $(field!($(T![$token])? $field_name $($ty)?)),*
271                 ],
272
273             }
274         ),*]
275     };
276 }
277
278 macro_rules! field {
279     (T![$token:tt] T) => {
280         Field::Token(stringify!($token))
281     };
282     ($field_name:ident) => {
283         Field::Node { name: stringify!($field_name), src: FieldSrc::Shorthand }
284     };
285     ($field_name:ident [$ty:ident]) => {
286         Field::Node { name: stringify!($field_name), src: FieldSrc::Many(stringify!($ty)) }
287     };
288     ($field_name:ident $ty:ident) => {
289         Field::Node { name: stringify!($field_name), src: FieldSrc::Optional(stringify!($ty)) }
290     };
291 }
292
293 macro_rules! ast_enums {
294     ($(
295         $(#[doc = $doc:expr])+
296         enum $name:ident $(: $($trait:ident),*)? {
297             $($variant:ident),*$(,)?
298         }
299     )*) => {
300         [$(
301             AstEnumSrc {
302                 doc: &[$($doc),*],
303                 name: stringify!($name),
304                 traits: &[$($(stringify!($trait)),*)?],
305                 variants: &[$(stringify!($variant)),*],
306             }
307         ),*]
308     };
309 }
310
311 pub(crate) const AST_SRC: AstSrc = AstSrc {
312     tokens: &["Whitespace", "Comment", "String", "RawString"],
313     nodes: &ast_nodes! {
314         /// The entire Rust source file. Includes all top-level inner attributes and module items.
315         ///
316         /// [Reference](https://doc.rust-lang.org/reference/crates-and-source-files.html)
317         struct SourceFile: ModuleItemOwner, AttrsOwner, DocCommentsOwner {
318             modules: [Module],
319         }
320
321         /// Function definition either with body or not.
322         /// Includes all of its attributes and doc comments.
323         ///
324         /// ```
325         /// ❰
326         ///     /// Docs
327         ///     #[attr]
328         ///     pub extern "C" fn foo<T>(#[attr] Patern {p}: Pattern) -> u32
329         ///     where
330         ///         T: Debug
331         ///     {
332         ///         42
333         ///     }
334         /// ❱
335         ///
336         /// extern "C" {
337         ///     ❰ fn fn_decl(also_variadic_ffi: u32, ...) -> u32; ❱
338         /// }
339         /// ```
340         ///
341         /// - [Reference](https://doc.rust-lang.org/reference/items/functions.html)
342         /// - [Nomicon](https://doc.rust-lang.org/nomicon/ffi.html#variadic-functions)
343         struct FnDef: VisibilityOwner, NameOwner, TypeParamsOwner, DocCommentsOwner, AttrsOwner {
344             Abi,
345             T![const],
346             T![default],
347             T![async],
348             T![unsafe],
349             T![fn],
350             ParamList,
351             RetType,
352             body: BlockExpr, // TODO: maybe it makes sense to make it `Block` instead,
353             T![;]            // Or what if there may be a posibility of tryblocks as function body?
354         }                    // But try blocks are not `BlockExpr`
355
356         /// Return type annotation.
357         ///
358         /// ```
359         /// fn foo(a: u32) ❰ -> Option<u32> ❱ { Some(a) }
360         /// ```
361         ///
362         /// [Reference](https://doc.rust-lang.org/reference/items/functions.html)
363         struct RetType { T![->], TypeRef }
364
365         /// Struct definition.
366         /// Includes all of its attributes and doc comments.
367         ///
368         /// ```
369         /// ❰
370         ///     /// Docs
371         ///     #[attr]
372         ///     struct Foo<T> where T: Debug {
373         ///         /// Docs
374         ///         #[attr]
375         ///         pub a: u32,
376         ///         b: T,
377         ///     }
378         /// ❱
379         ///
380         /// ❰ struct Foo; ❱
381         /// ❰ struct Foo<T>(#[attr] T) where T: Debug; ❱
382         /// ```
383         ///
384         /// [Reference](https://doc.rust-lang.org/reference/items/structs.html)
385         struct StructDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner {
386             T![struct],
387             FieldDefList,
388             T![;]
389         }
390
391         /// Union definition.
392         /// Includes all of its attributes and doc comments.
393         ///
394         /// ```
395         /// ❰
396         ///     /// Docs
397         ///     #[attr]
398         ///     pub union Foo<T> where T: Debug {
399         ///         /// Docs
400         ///         #[attr]
401         ///         a: T,
402         ///         b: u32,
403         ///     }
404         /// ❱
405         /// ```
406         ///
407         /// [Reference](https://doc.rust-lang.org/reference/items/unions.html)
408         struct UnionDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner {
409             T![union],
410             RecordFieldDefList,
411         }
412
413         /// Record field definition list including enclosing curly braces.
414         ///
415         /// ```
416         /// struct Foo // same for union
417         /// ❰
418         ///     {
419         ///         a: u32,
420         ///         b: bool,
421         ///     }
422         /// ❱
423         /// ```
424         ///
425         /// [Reference](https://doc.rust-lang.org/reference/items/structs.html)
426         struct RecordFieldDefList { T!['{'], fields: [RecordFieldDef], T!['}'] }
427
428         /// Record field definition including its attributes and doc comments.
429         ///
430         /// ` ``
431         /// same for union
432         /// struct Foo {
433         ///      ❰
434         ///          /// Docs
435         ///          #[attr]
436         ///          pub a: u32
437         ///      ❱
438         ///
439         ///      ❰ b: bool ❱
440         /// }
441         /// ```
442         ///
443         /// [Reference](https://doc.rust-lang.org/reference/items/structs.html)
444         struct RecordFieldDef: VisibilityOwner, NameOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner { }
445
446         /// Tuple field definition list including enclosing parens.
447         ///
448         /// ```
449         /// struct Foo ❰ (u32, String, Vec<u32>) ❱;
450         /// ```
451         ///
452         /// [Reference](https://doc.rust-lang.org/reference/items/structs.html)
453         struct TupleFieldDefList { T!['('], fields: [TupleFieldDef], T![')'] }
454
455         /// Tuple field definition including its attributes.
456         ///
457         /// ```
458         /// struct Foo(❰ #[attr] u32 ❱);
459         /// ```
460         ///
461         /// [Reference](https://doc.rust-lang.org/reference/items/structs.html)
462         struct TupleFieldDef: VisibilityOwner, AttrsOwner {
463             TypeRef,
464         }
465
466         /// Enum definition.
467         /// Includes all of its attributes and doc comments.
468         ///
469         /// ```
470         /// ❰
471         ///     /// Docs
472         ///     #[attr]
473         ///     pub enum Foo<T> where T: Debug {
474         ///         /// Docs
475         ///         #[attr]
476         ///         Bar,
477         ///         Baz(#[attr] u32),
478         ///         Bruh {
479         ///             a: u32,
480         ///             /// Docs
481         ///             #[attr]
482         ///             b: T,
483         ///         }
484         ///     }
485         /// ❱
486         /// ```
487         ///
488         /// [Reference](https://doc.rust-lang.org/reference/items/enumerations.html)
489         struct EnumDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner {
490             T![enum],
491             variant_list: EnumVariantList,
492         }
493
494         /// Enum variant definition list including enclosing curly braces.
495         ///
496         /// ```
497         /// enum Foo
498         /// ❰
499         ///     {
500         ///         Bar,
501         ///         Baz(u32),
502         ///         Bruh {
503         ///             a: u32
504         ///         }
505         ///     }
506         /// ❱
507         /// ```
508         ///
509         /// [Reference](https://doc.rust-lang.org/reference/items/enumerations.html)
510         struct EnumVariantList {
511             T!['{'],
512             variants: [EnumVariant],
513             T!['}']
514         }
515
516         /// Enum variant definition including its attributes and discriminant value definition.
517         ///
518         /// ```
519         /// enum Foo {
520         ///     ❰
521         ///         /// Docs
522         ///         #[attr]
523         ///         Bar
524         ///     ❱
525         ///
526         ///     // same for tuple and record variants
527         /// }
528         /// ```
529         ///
530         /// [Reference](https://doc.rust-lang.org/reference/items/enumerations.html)
531         struct EnumVariant: VisibilityOwner, NameOwner, DocCommentsOwner, AttrsOwner {
532             FieldDefList,
533             T![=],
534             Expr
535         }
536
537         /// Trait definition.
538         /// Includes all of its attributes and doc comments.
539         ///
540         /// ```
541         /// ❰
542         ///     /// Docs
543         ///     #[attr]
544         ///     pub unsafe trait Foo<T>: Debug where T: Debug {
545         ///         // ...
546         ///     }
547         /// ❱
548         /// ```
549         ///
550         /// [Reference](https://doc.rust-lang.org/reference/items/traits.html)
551         struct TraitDef: VisibilityOwner, NameOwner, AttrsOwner, DocCommentsOwner, TypeParamsOwner, TypeBoundsOwner {
552             T![unsafe],
553             T![auto],
554             T![trait],
555             ItemList,
556         }
557
558         /// Module definition either with body or not.
559         /// Includes all of its inner and outer attributes, module items, doc comments.
560         ///
561         /// ```
562         /// ❰
563         ///     /// Docs
564         ///     #[attr]
565         ///     pub mod foo;
566         /// ❱
567         ///
568         /// ❰
569         ///     /// Docs
570         ///     #[attr]
571         ///     pub mod bar {
572         ///        //! Inner docs
573         ///        #![inner_attr]
574         ///     }
575         /// ❱
576         /// ```
577         ///
578         /// [Reference](https://doc.rust-lang.org/reference/items/modules.html)
579         struct Module: VisibilityOwner, NameOwner, AttrsOwner, DocCommentsOwner {
580             T![mod],
581             ItemList,
582             T![;]
583         }
584
585         /// Item defintion list.
586         /// This is used for both top-level items and impl block items.
587         ///
588         /// ```
589         /// ❰
590         ///     fn foo {}
591         ///     struct Bar;
592         ///     enum Baz;
593         ///     trait Bruh;
594         ///     const BRUUH: u32 = 42;
595         /// ❱
596         ///
597         /// impl Foo
598         /// ❰
599         ///     {
600         ///         fn bar() {}
601         ///         const BAZ: u32 = 42;
602         ///     }
603         /// ❱
604         /// ```
605         ///
606         /// [Reference](https://doc.rust-lang.org/reference/items.html)
607         struct ItemList: ModuleItemOwner {
608             T!['{'],
609             assoc_items: [AssocItem],
610             T!['}']
611         }
612
613         /// Constant variable definition.
614         /// Includes all of its attributes and doc comments.
615         ///
616         /// ```
617         /// ❰
618         ///     /// Docs
619         ///     #[attr]
620         ///     pub const FOO: u32 = 42;
621         /// ❱
622         /// ```
623         ///
624         /// [Reference](https://doc.rust-lang.org/reference/items/constant-items.html)
625         struct ConstDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner {
626             T![default],
627             T![const],
628             T![=],
629             body: Expr,
630             T![;]
631         }
632
633
634         /// Static variable definition.
635         /// Includes all of its attributes and doc comments.
636         ///
637         /// ```
638         /// ❰
639         ///     /// Docs
640         ///     #[attr]
641         ///     pub static mut FOO: u32 = 42;
642         /// ❱
643         /// ```
644         ///
645         /// [Reference](https://doc.rust-lang.org/reference/items/static-items.html)
646         struct StaticDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner {
647             T![static],
648             T![mut],
649             T![=],
650             body: Expr,
651             T![;]
652         }
653
654         /// Type alias definition.
655         /// Includes associated type clauses with type bounds.
656         ///
657         /// ```
658         /// ❰
659         ///     /// Docs
660         ///     #[attr]
661         ///     pub type Foo<T> where T: Debug = T;
662         /// ❱
663         ///
664         /// trait Bar {
665         ///     ❰ type Baz: Debug; ❱
666         ///     ❰ type Bruh = String; ❱
667         ///     ❰ type Bruuh: Debug = u32; ❱
668         /// }
669         /// ```
670         ///
671         /// [Reference](https://doc.rust-lang.org/reference/items/type-aliases.html)
672         struct TypeAliasDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeBoundsOwner {
673             T![default],
674             T![type],
675             T![=],
676             TypeRef,
677             T![;]
678         }
679
680         /// Inherent and trait impl definition.
681         /// Includes all of its inner and outer attributes.
682         ///
683         /// ```
684         /// ❰
685         ///     #[attr]
686         ///     unsafe impl<T> !Foo for Bar where T: Debug {
687         ///         #![inner_attr]
688         ///         // ...
689         ///     }
690         /// ❱
691         /// ```
692         ///
693         /// [Reference](https://doc.rust-lang.org/reference/items/implementations.html)
694         struct ImplDef: TypeParamsOwner, AttrsOwner, DocCommentsOwner {
695             T![default],
696             T![const], // TODO: wat?
697             T![unsafe],
698             T![impl],
699             T![!],
700             T![for],
701             ItemList,
702         }
703
704
705         /// Parenthesized type reference.
706         /// Note: parens are only used for grouping, this is not a tuple type.
707         ///
708         /// ```
709         /// // This is effectively just `u32`.
710         /// // Single-item tuple must be defined with a trailing comma: `(u32,)`
711         /// type Foo = ❰ (u32) ❱;
712         ///
713         /// let bar: &'static ❰ (dyn Debug) ❱ = "bruh";
714         /// ```
715         struct ParenType { T!['('], TypeRef, T![')'] }
716
717         /// Unnamed tuple type.
718         ///
719         /// ```
720         /// let foo: ❰ (u32, bool) ❱ = (42, true);
721         /// ```
722         ///
723         /// [Reference](https://doc.rust-lang.org/reference/types/tuple.html)
724         struct TupleType { T!['('], fields: [TypeRef], T![')'] }
725
726         /// The never type (i.e. the exclamation point).
727         ///
728         /// ```
729         /// type T = ❰ ! ❱;
730         ///
731         /// fn no_return() -> ❰ ! ❱ {
732         ///     loop {}
733         /// }
734         /// ```
735         ///
736         /// [Reference](https://doc.rust-lang.org/reference/types/never.html)
737         struct NeverType { T![!] }
738
739         /// Path to a type.
740         /// Includes single identifier type names and elaborate paths with
741         /// generic parameters.
742         ///
743         /// ```
744         /// type Foo = ❰ String ❱;
745         /// type Bar = ❰ std::vec::Vec<T> ❱;
746         /// type Baz = ❰ ::bruh::<Bruuh as Iterator>::Item ❱;
747         /// ```
748         ///
749         /// [Reference](https://doc.rust-lang.org/reference/paths.html)
750         struct PathType { Path }
751
752         /// Raw pointer type.
753         ///
754         /// ```
755         /// type Foo = ❰ *const u32 ❱;
756         /// type Bar = ❰ *mut u32 ❱;
757         /// ```
758         ///
759         /// [Reference](https://doc.rust-lang.org/reference/types/pointer.html#raw-pointers-const-and-mut)
760         struct PointerType { T![*], T![const], T![mut], TypeRef }
761
762         /// Array type.
763         ///
764         /// ```
765         /// type Foo = ❰ [u32; 24 - 3] ❱;
766         /// ```
767         ///
768         /// [Reference](https://doc.rust-lang.org/reference/types/array.html)
769         struct ArrayType { T!['['], TypeRef, T![;], Expr, T![']'] }
770
771         /// Slice type.
772         ///
773         /// ```
774         /// type Foo = ❰ [u8] ❱;
775         /// ```
776         ///
777         /// [Reference](https://doc.rust-lang.org/reference/types/slice.html)
778         struct SliceType { T!['['], TypeRef, T![']'] }
779
780         /// Reference type.
781         ///
782         /// ```
783         /// type Foo = ❰ &'static str ❱;
784         /// ```
785         ///
786         /// [Reference](https://doc.rust-lang.org/reference/types/pointer.html)
787         struct ReferenceType { T![&], T![lifetime], T![mut], TypeRef }
788
789         /// Placeholder type (i.e. the underscore).
790         ///
791         /// ```
792         /// let foo: ❰ _ ❱ = 42_u32;
793         /// ```
794         ///
795         /// [Reference](https://doc.rust-lang.org/reference/types/inferred.html)
796         struct PlaceholderType { T![_] }
797
798         /// Function pointer type (not to be confused with `Fn*` family of traits).
799         ///
800         /// ```
801         /// type Foo = ❰ async fn(#[attr] u32, named: bool) -> u32 ❱;
802         ///
803         /// type Bar = ❰ extern "C" fn(variadic: u32, #[attr] ...) ❱;
804         /// ```
805         ///
806         /// [Reference](https://doc.rust-lang.org/reference/types/function-pointer.html)
807         struct FnPointerType { Abi, T![unsafe], T![fn], ParamList, RetType }
808
809         /// Higher order type.
810         ///
811         /// ```
812         /// type Foo = ❰ for<'a> fn(&'a str) ❱;
813         /// ```
814         ///
815         /// [Reference](https://doc.rust-lang.org/nomicon/hrtb.html)
816         struct ForType { T![for], TypeParamList, TypeRef }
817
818         /// Opaque `impl Trait` type.
819         ///
820         /// ```
821         /// fn foo(bar: ❰ impl Debug + Eq ❱) {}
822         /// ```
823         ///
824         /// [Reference](https://doc.rust-lang.org/reference/types/impl-trait.html)
825         struct ImplTraitType: TypeBoundsOwner { T![impl] }
826
827         /// Trait object type.
828         ///
829         /// ```
830         /// type Foo = ❰ dyn Debug ❱;
831         /// ```
832         ///
833         /// [Reference](https://doc.rust-lang.org/reference/types/trait-object.html)
834         struct DynTraitType: TypeBoundsOwner { T![dyn] }
835
836         /// Tuple literal.
837         ///
838         /// ```
839         /// ❰ (42, true) ❱;
840         /// ```
841         ///
842         /// [Reference](https://doc.rust-lang.org/reference/expressions/tuple-expr.html)
843         struct TupleExpr: AttrsOwner { T!['('], exprs: [Expr], T![')'] }
844
845         /// Array literal.
846         ///
847         /// ```
848         /// ❰ [#![inner_attr] true, false, true] ❱;
849         ///
850         /// ❰ ["baz"; 24] ❱;
851         /// ```
852         ///
853         /// [Reference](https://doc.rust-lang.org/reference/expressions/array-expr.html)
854         struct ArrayExpr: AttrsOwner { T!['['], exprs: [Expr], T![;], T![']'] }
855
856         /// Parenthesized expression.
857         /// Note: parens are only used for grouping, this is not a tuple literal.
858         ///
859         /// ```
860         /// ❰ (#![inner_attr] 2 + 2) ❱ * 2;
861         /// ```
862         ///
863         /// [Reference](https://doc.rust-lang.org/reference/expressions/grouped-expr.html)
864         struct ParenExpr: AttrsOwner { T!['('], Expr, T![')'] }
865
866         /// Path to a symbol in expression context.
867         /// Includes single identifier variable names and elaborate paths with
868         /// generic parameters.
869         ///
870         /// ```
871         /// ❰ Some::<i32> ❱;
872         /// ❰ foo ❱ + 42;
873         /// ❰ Vec::<i32>::push ❱;
874         /// ❰ <[i32]>::reverse ❱;
875         /// ❰ <String as std::borrow::Borrow<str>>::borrow ❱;
876         /// ```
877         ///
878         /// [Reference](https://doc.rust-lang.org/reference/expressions/path-expr.html)
879         struct PathExpr { Path }
880
881         /// Anonymous callable object literal a.k.a. closure, lambda or functor.
882         ///
883         /// ```
884         /// ❰ || 42 ❱;
885         /// ❰ |a: u32| val + 1 ❱;
886         /// ❰ async |#[attr] Pattern(_): Pattern| { bar } ❱;
887         /// ❰ move || baz ❱;
888         /// ❰ || -> u32 { closure_with_ret_type_annotation_requires_block_expr } ❱
889         /// ```
890         ///
891         /// [Reference](https://doc.rust-lang.org/reference/expressions/closure-expr.html)
892         struct LambdaExpr: AttrsOwner {
893             // T![static], // TODO: what's this?
894             T![async],
895             T![move],
896             ParamList,
897             RetType,
898             body: Expr,
899         }
900
901         /// If expression. Includes both regular `if` and `if let` forms.
902         /// Beware that `else if` is a special case syntax sugar, because in general
903         /// there has to be block expression after `else`.
904         ///
905         /// ```
906         /// ❰ if bool_cond { 42 } ❱
907         /// ❰ if bool_cond { 42 } else { 24 } ❱
908         /// ❰ if bool_cond { 42 } else if bool_cond2 { 42 } ❱
909         ///
910         /// ❰
911         ///     if let Pattern(foo) = bar {
912         ///         foo
913         ///     } else {
914         ///         panic!();
915         ///     }
916         /// ❱
917         /// ```
918         ///
919         /// [Reference](https://doc.rust-lang.org/reference/expressions/if-expr.html)
920         struct IfExpr: AttrsOwner { T![if], Condition }
921
922         /// Unconditional loop expression.
923         ///
924         /// ```
925         /// ❰
926         ///     loop {
927         ///         // yeah, it's that simple...
928         ///     }
929         /// ❱
930         /// ```
931         ///
932         /// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html)
933         struct LoopExpr: AttrsOwner, LoopBodyOwner { T![loop] }
934
935         /// Block expression with an optional prefix (label, try ketword,
936         /// unsafe keyword, async keyword...).
937         ///
938         /// ```
939         /// ❰
940         ///     'label: try {
941         ///         None?
942         ///     }
943         /// ❱
944         /// ```
945         ///
946         /// - [try block](https://doc.rust-lang.org/unstable-book/language-features/try-blocks.html)
947         /// - [unsafe block](https://doc.rust-lang.org/reference/expressions/block-expr.html#unsafe-blocks)
948         /// - [async block](https://doc.rust-lang.org/reference/expressions/block-expr.html#async-blocks)
949         struct EffectExpr: AttrsOwner { Label, T![try], T![unsafe], T![async], BlockExpr }
950
951
952         /// For loop expression.
953         /// Note: record struct literals are not valid as iterable expression
954         /// due to ambiguity.
955         ///
956         /// ```
957         /// ❰
958         /// for i in (0..4) {
959         ///     dbg!(i);
960         /// }
961         /// ❱
962         /// ```
963         ///
964         /// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html#iterator-loops)
965         struct ForExpr: AttrsOwner, LoopBodyOwner {
966             T![for],
967             Pat,
968             T![in],
969             iterable: Expr,
970         }
971
972         /// While loop expression. Includes both regular `while` and `while let` forms.
973         ///
974         /// ```
975         /// ❰
976         ///     while bool_cond {
977         ///         42;
978         ///     }
979         /// ❱
980         /// ❰
981         ///     while let Pattern(foo) = bar {
982         ///         bar += 1;
983         ///     }
984         /// ❱
985         /// ```
986         ///
987         /// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html#predicate-loops)
988         struct WhileExpr: AttrsOwner, LoopBodyOwner { T![while], Condition }
989
990         /// Continue expression.
991         ///
992         /// ```
993         /// while bool_cond {
994         ///     ❰ continue ❱;
995         /// }
996         ///
997         /// 'outer: loop {
998         ///     loop {
999         ///         ❰ continue 'outer ❱;
1000         ///     }
1001         /// }
1002         ///
1003         /// ```
1004         ///
1005         /// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html#continue-expressions)
1006         struct ContinueExpr: AttrsOwner { T![continue], T![lifetime] }
1007
1008         /// Break expression.
1009         ///
1010         /// ```
1011         /// while bool_cond {
1012         ///     ❰ break ❱;
1013         /// }
1014         /// 'outer: loop {
1015         ///     for foo in bar {
1016         ///         ❰ break 'outer ❱;
1017         ///     }
1018         /// }
1019         /// 'outer: loop {
1020         ///     loop {
1021         ///         ❰ break 'outer 42 ❱;
1022         ///     }
1023         /// }
1024         /// ```
1025         ///
1026         /// [Refernce](https://doc.rust-lang.org/reference/expressions/loop-expr.html#break-expressions)
1027         struct BreakExpr: AttrsOwner { T![break], T![lifetime], Expr }
1028
1029         /// Label.
1030         ///
1031         /// ```
1032         /// ❰ 'outer: ❱ loop {}
1033         ///
1034         /// let foo = ❰ 'bar: ❱ loop {}
1035         ///
1036         /// ❰ 'baz: ❱ {
1037         ///     break 'baz;
1038         /// }
1039         /// ```
1040         ///
1041         /// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html?highlight=label#loop-labels)
1042         /// [Labels for blocks RFC](https://github.com/rust-lang/rfcs/blob/master/text/2046-label-break-value.md)
1043         struct Label { T![lifetime] }
1044
1045         /// Block expression. Includes unsafe blocks and block labels.
1046         ///
1047         /// ```
1048         ///     let foo = ❰
1049         ///         {
1050         ///             #![inner_attr]
1051         ///             ❰ { } ❱
1052         ///
1053         ///             ❰ 'label: { break 'label } ❱
1054         ///         }
1055         ///     ❱;
1056         /// ```
1057         ///
1058         /// [Reference](https://doc.rust-lang.org/reference/expressions/block-expr.html)
1059         /// [Labels for blocks RFC](https://github.com/rust-lang/rfcs/blob/master/text/2046-label-break-value.md)
1060         struct BlockExpr: AttrsOwner, ModuleItemOwner {
1061             T!['{'], statements: [Stmt], Expr, T!['}'],
1062         }
1063
1064         /// Return expression.
1065         ///
1066         /// ```
1067         /// || ❰ return 42 ❱;
1068         ///
1069         /// fn bar() {
1070         ///     ❰ return ❱;
1071         /// }
1072         /// ```
1073         ///
1074         /// [Reference](https://doc.rust-lang.org/reference/expressions/return-expr.html)
1075         struct ReturnExpr: AttrsOwner { Expr }
1076
1077         /// Call expression (not to be confused with method call expression, it is
1078         /// a separate ast node).
1079         ///
1080         /// ```
1081         /// ❰ foo() ❱;
1082         /// ❰ &str::len("bar") ❱;
1083         /// ❰ <&str as PartialEq<&str>>::eq(&"", &"") ❱;
1084         /// ```
1085         ///
1086         /// [Reference](https://doc.rust-lang.org/reference/expressions/call-expr.html)
1087         struct CallExpr: ArgListOwner { Expr }
1088
1089         /// Method call expression.
1090         ///
1091         /// ```
1092         /// ❰ receiver_expr.method() ❱;
1093         /// ❰ receiver_expr.method::<T>(42, true) ❱;
1094         ///
1095         /// ❰ ❰ ❰ foo.bar() ❱ .baz() ❱ .bruh() ❱;
1096         /// ```
1097         ///
1098         /// [Reference](https://doc.rust-lang.org/reference/expressions/method-call-expr.html)
1099         struct MethodCallExpr: AttrsOwner, ArgListOwner {
1100             Expr, T![.], NameRef, TypeArgList,
1101         }
1102
1103         /// Index expression a.k.a. subscript operator call.
1104         ///
1105         /// ```
1106         /// ❰ foo[42] ❱;
1107         /// ```
1108         ///
1109         /// [Reference](https://doc.rust-lang.org/reference/expressions/array-expr.html)
1110         struct IndexExpr: AttrsOwner { T!['['], T![']'] }
1111
1112         /// Field access expression.
1113         ///
1114         /// ```
1115         /// ❰ expr.bar ❱;
1116         ///
1117         /// ❰ ❰ ❰ foo.bar ❱ .baz ❱ .bruh ❱;
1118         /// ```
1119         ///
1120         /// [Reference](https://doc.rust-lang.org/reference/expressions/field-expr.html)
1121         struct FieldExpr: AttrsOwner { Expr, T![.], NameRef }
1122
1123         /// Await operator call expression.
1124         ///
1125         /// ```
1126         /// ❰ expr.await ❱;
1127         /// ```
1128         ///
1129         /// [Reference](https://doc.rust-lang.org/reference/expressions/await-expr.html)
1130         struct AwaitExpr: AttrsOwner { Expr, T![.], T![await] }
1131
1132         /// The question mark operator call.
1133         ///
1134         /// ```
1135         /// ❰ expr? ❱;
1136         /// ```
1137         ///
1138         /// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#the-question-mark-operator)
1139         struct TryExpr: AttrsOwner { Expr, T![?] }
1140
1141         /// Type cast expression.
1142         ///
1143         /// ```
1144         /// ❰ expr as T ❱;
1145         /// ```
1146         ///
1147         /// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#type-cast-expressions)
1148         struct CastExpr: AttrsOwner { Expr, T![as], TypeRef }
1149
1150
1151         /// Borrow operator call.
1152         ///
1153         /// ```
1154         /// ❰ &foo ❱;
1155         /// ❰ &mut bar ❱;
1156         /// ```
1157         ///
1158         /// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#borrow-operators)
1159         struct RefExpr: AttrsOwner { T![&], T![raw], T![mut], Expr }
1160
1161         /// Prefix operator call. This is either `!` or `*` or `-`.
1162         ///
1163         /// ```
1164         /// ❰ !foo ❱;
1165         /// ❰ *bar ❱;
1166         /// ❰ -42 ❱;
1167         /// ```
1168         ///
1169         /// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html)
1170         struct PrefixExpr: AttrsOwner { /*PrefixOp,*/ Expr }
1171
1172         /// Box operator call.
1173         ///
1174         /// ```
1175         /// ❰ box 42 ❱;
1176         /// ```
1177         ///
1178         /// [RFC](https://github.com/rust-lang/rfcs/blob/0806be4f282144cfcd55b1d20284b43f87cbe1c6/text/0809-box-and-in-for-stdlib.md)
1179         struct BoxExpr: AttrsOwner { T![box], Expr }
1180
1181         /// Range operator call.
1182         ///
1183         /// ```
1184         /// ❰ 0..42 ❱;
1185         /// ❰ ..42 ❱;
1186         /// ❰ 0.. ❱;
1187         /// ❰ .. ❱;
1188         /// ❰ 0..=42 ❱;
1189         /// ❰ ..=42 ❱;
1190         /// ```
1191         ///
1192         /// [Reference](https://doc.rust-lang.org/reference/expressions/range-expr.html)
1193         struct RangeExpr: AttrsOwner { /*RangeOp*/ }
1194
1195
1196         /// Binary operator call.
1197         /// Includes all arithmetic, logic, bitwise and assignment operators.
1198         ///
1199         /// ```
1200         /// ❰ 2 + ❰ 2 * 2 ❱ ❱;
1201         /// ❰ ❰ true && false ❱ || true ❱;
1202         /// ```
1203         ///
1204         /// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#arithmetic-and-logical-binary-operators)
1205         struct BinExpr: AttrsOwner { /*BinOp*/ }
1206
1207
1208         /// [Raw] string, [raw] byte string, char, byte, integer, float or bool literal.
1209         ///
1210         /// ```
1211         /// ❰ "str" ❱;
1212         /// ❰ br##"raw byte str"## ❱;
1213         /// ❰ 'c' ❱;
1214         /// ❰ b'c' ❱;
1215         /// ❰ 42 ❱;
1216         /// ❰ 1e9 ❱;
1217         /// ❰ true ❱;
1218         /// ```
1219         ///
1220         /// [Reference](https://doc.rust-lang.org/reference/expressions/literal-expr.html)
1221         struct Literal { /*LiteralToken*/ }
1222
1223         /// Match expression.
1224         ///
1225         /// ```
1226         /// ❰
1227         ///     match expr {
1228         ///         Pat1 => {}
1229         ///         Pat2(_) => 42,
1230         ///     }
1231         /// ❱
1232         /// ```
1233         ///
1234         /// [Reference](https://doc.rust-lang.org/reference/expressions/match-expr.html)
1235         struct MatchExpr: AttrsOwner { T![match], Expr, MatchArmList }
1236
1237         /// Match arm list part of match expression. Includes its inner attributes.
1238         ///
1239         /// ```
1240         /// match expr
1241         /// ❰
1242         ///     {
1243         ///         #![inner_attr]
1244         ///         Pat1 => {}
1245         ///         Pat2(_) => 42,
1246         ///     }
1247         /// ❱
1248         /// ```
1249         ///
1250         /// [Reference](https://doc.rust-lang.org/reference/expressions/match-expr.html)
1251         struct MatchArmList: AttrsOwner { T!['{'], arms: [MatchArm], T!['}'] }
1252
1253
1254         /// Match arm.
1255         /// Note: record struct literals are not valid as target match expression
1256         /// due to ambiguity.
1257         /// ```
1258         /// match expr {
1259         ///     ❰ #[attr] Pattern(it) if bool_cond => it ❱,
1260         /// }
1261         /// ```
1262         ///
1263         /// [Reference](https://doc.rust-lang.org/reference/expressions/match-expr.html)
1264         struct MatchArm: AttrsOwner {
1265             pat: Pat,
1266             guard: MatchGuard,
1267             T![=>],
1268             Expr,
1269         }
1270
1271         /// Match guard.
1272         ///
1273         /// ```
1274         /// match expr {
1275         ///     Pattern(it) ❰ if bool_cond ❱ => it,
1276         /// }
1277         /// ```
1278         ///
1279         /// [Reference](https://doc.rust-lang.org/reference/expressions/match-expr.html#match-guards)
1280         struct MatchGuard { T![if], Expr }
1281
1282         /// Record literal expression. The same syntax is used for structs,
1283         /// unions and record enum variants.
1284         ///
1285         /// ```
1286         /// ❰
1287         ///     foo::Bar {
1288         ///         #![inner_attr]
1289         ///         baz: 42,
1290         ///         bruh: true,
1291         ///         ..spread
1292         ///     }
1293         /// ❱
1294         /// ```
1295         ///
1296         /// [Reference](https://doc.rust-lang.org/reference/expressions/struct-expr.html)
1297         struct RecordLit { Path, RecordFieldList}
1298
1299         /// Record field list including enclosing curly braces.
1300         ///
1301         /// foo::Bar ❰
1302         ///     {
1303         ///         baz: 42,
1304         ///         ..spread
1305         ///     }
1306         /// ❱
1307         ///
1308         /// [Reference](https://doc.rust-lang.org/reference/expressions/struct-expr.html)
1309         struct RecordFieldList {
1310             T!['{'],
1311             fields: [RecordField],
1312             T![..],
1313             spread: Expr,
1314             T!['}']
1315         }
1316
1317         /// Record field.
1318         ///
1319         /// ```
1320         /// foo::Bar {
1321         ///     ❰ #[attr] baz: 42 ❱
1322         /// }
1323         /// ```
1324         ///
1325         /// [Reference](https://doc.rust-lang.org/reference/expressions/struct-expr.html)
1326         struct RecordField: AttrsOwner { NameRef, T![:], Expr }
1327
1328         /// Disjunction of patterns.
1329         ///
1330         /// ```
1331         /// let ❰ Foo(it) | Bar(it) | Baz(it) ❱ = bruh;
1332         /// ```
1333         ///
1334         /// [Reference](https://doc.rust-lang.org/reference/patterns.html)
1335         struct OrPat { pats: [Pat] }
1336
1337         /// Parenthesized pattern.
1338         /// Note: parens are only used for grouping, this is not a tuple pattern.
1339         ///
1340         /// ```
1341         /// if let ❰ &(0..=42) ❱ = foo {}
1342         /// ```
1343         ///
1344         /// https://doc.rust-lang.org/reference/patterns.html#grouped-patterns
1345         struct ParenPat { T!['('], Pat, T![')'] }
1346
1347         /// Reference pattern.
1348         /// Note: this has nothing to do with `ref` keyword, the latter is used in bind patterns.
1349         ///
1350         /// ```
1351         /// let ❰ &mut foo ❱ = bar;
1352         /// ```
1353         /// // TODO: clarify on the special case of double reference pattern
1354         /// // described in the link bellow
1355         ///
1356         /// [Reference](https://doc.rust-lang.org/reference/patterns.html#reference-patterns)
1357         struct RefPat { T![&], T![mut], Pat }
1358
1359         /// Box pattern.
1360         ///
1361         /// ```
1362         /// let ❰ box foo ❱ = box 42;
1363         /// ```
1364         ///
1365         /// [Unstable book](https://doc.rust-lang.org/unstable-book/language-features/box-patterns.html)
1366         struct BoxPat { T![box], Pat }
1367
1368         /// Bind pattern.
1369         ///
1370         /// ```
1371         /// match foo {
1372         ///     Some(❰ ref mut bar ❱) => {}
1373         ///     ❰ baz @ None ❱ => {}
1374         /// }
1375         /// ```
1376         ///
1377         /// [Reference](https://doc.rust-lang.org/reference/patterns.html#identifier-patterns)
1378         struct BindPat: AttrsOwner, NameOwner { T![ref], T![mut], T![@], Pat }
1379
1380         /// Placeholder pattern a.k.a. the wildcard pattern or the underscore.
1381         ///
1382         /// ```
1383         /// let ❰ _ ❱ = foo;
1384         /// ```
1385         ///
1386         /// [Reference](https://doc.rust-lang.org/reference/patterns.html#wildcard-pattern)
1387         struct PlaceholderPat { T![_] }
1388
1389         /// Rest-of-the record/tuple pattern.
1390         /// Note: this is not the unbonded range pattern (even more: it doesn't exist).
1391         ///
1392         /// ```
1393         /// let Foo { bar, ❰ .. ❱ } = baz;
1394         /// let (❰ .. ❱, bruh) = (42, 24, 42);
1395         /// let Bruuh(❰ .. ❱) = bruuuh;
1396         /// ```
1397         ///
1398         /// [Reference](https://doc.rust-lang.org/reference/patterns.html#struct-patterns)
1399         struct DotDotPat { T![..] }
1400
1401         /// Path pattern.
1402         /// Doesn't include the underscore pattern (it is a special case, namely `PlaceholderPat`).
1403         ///
1404         /// ```
1405         /// let ❰ foo::bar::Baz ❱ { .. } = bruh;
1406         /// if let ❰ CONST ❱ = 42 {}
1407         /// ```
1408         ///
1409         /// [Reference](https://doc.rust-lang.org/reference/patterns.html#path-patterns)
1410         struct PathPat { Path }
1411
1412         /// Slice pattern.
1413         ///
1414         /// ```
1415         /// let ❰ [foo, bar, baz] ❱ = [1, 2, 3];
1416         /// ```
1417         ///
1418         /// [Reference](https://doc.rust-lang.org/reference/patterns.html#slice-patterns)
1419         struct SlicePat { T!['['], args: [Pat], T![']'] }
1420
1421         /// Range pattern.
1422         ///
1423         /// ```
1424         /// match foo {
1425         ///     ❰ 0..42 ❱ => {}
1426         ///     ❰ 0..=42 ❱ => {}
1427         /// }
1428         /// ```
1429         ///
1430         /// [Reference](https://doc.rust-lang.org/reference/patterns.html#range-patterns)
1431         struct RangePat { /*RangeSeparator*/ } // TODO: where is RangeSeparator?
1432
1433         /// Literal pattern.
1434         /// Includes only bool, number, char, and string literals.
1435         ///
1436         /// ```
1437         /// match foo {
1438         ///     Number(❰ 42 ❱) => {}
1439         ///     String(❰ "42" ❱) => {}
1440         ///     Bool(❰ true ❱) => {}
1441         /// }
1442         /// ```
1443         ///
1444         /// [Reference](https://doc.rust-lang.org/reference/patterns.html#literal-patterns)
1445         struct LiteralPat { Literal }
1446
1447         /// Macro invocation in pattern position.
1448         ///
1449         /// ```
1450         /// let ❰ foo!(my custom syntax) ❱ = baz;
1451         ///
1452         /// ```
1453         /// [Reference](https://doc.rust-lang.org/reference/macros.html#macro-invocation)
1454         struct MacroPat { MacroCall }
1455
1456         /// Record literal pattern.
1457         ///
1458         /// ```
1459         /// let ❰ foo::Bar { baz, .. } ❱ = bruh;
1460         /// ```
1461         ///
1462         /// [Reference](https://doc.rust-lang.org/reference/patterns.html#struct-patterns)
1463         struct RecordPat { RecordFieldPatList, Path }
1464
1465         /// Record literal's field patterns list including enclosing curly braces.
1466         ///
1467         /// ```
1468         /// let foo::Bar ❰ { baz, bind @ bruh, .. } ❱ = bruuh;
1469         /// ``
1470         ///
1471         /// [Reference](https://doc.rust-lang.org/reference/patterns.html#struct-patterns)
1472         struct RecordFieldPatList {
1473             T!['{'],
1474             pats: [RecordInnerPat],
1475             record_field_pats: [RecordFieldPat],
1476             bind_pats: [BindPat],
1477             T![..],
1478             T!['}']
1479         }
1480
1481         /// Record literal's field pattern.
1482         /// Note: record literal can also match tuple structs.
1483         ///
1484         /// ```
1485         /// let Foo { ❰ bar: _ ❱ } = baz;
1486         /// let TupleStruct { ❰ 0: _ ❱ } = bruh;
1487         /// ```
1488         ///
1489         /// [Reference](https://doc.rust-lang.org/reference/patterns.html#struct-patterns)
1490         struct RecordFieldPat: AttrsOwner { NameRef, T![:], Pat }
1491
1492         /// Tuple struct literal pattern.
1493         ///
1494         /// ```
1495         /// let ❰ foo::Bar(baz, bruh) ❱ = bruuh;
1496         /// ```
1497         ///
1498         /// [Reference](https://doc.rust-lang.org/reference/patterns.html#tuple-struct-patterns)
1499         struct TupleStructPat { Path, T!['('], args: [Pat], T![')'] }
1500
1501         /// Tuple pattern.
1502         /// Note: this doesn't include tuple structs (see `TupleStructPat`)
1503         ///
1504         /// ```
1505         /// let ❰ (foo, bar, .., baz) ❱ = bruh;
1506         /// ```
1507         ///
1508         /// [Reference](https://doc.rust-lang.org/reference/patterns.html#tuple-patterns)
1509         struct TuplePat { T!['('], args: [Pat], T![')'] }
1510
1511         /// Visibility.
1512         ///
1513         /// ```
1514         /// ❰ pub mod ❱ foo;
1515         /// ❰ pub(crate) ❱ struct Bar;
1516         /// ❰ pub(self) ❱ enum Baz {}
1517         /// ❰ pub(super) ❱ fn bruh() {}
1518         /// ❰ pub(in bruuh::bruuuh) ❱ type T = u64;
1519         /// ```
1520         ///
1521         /// [Reference](https://doc.rust-lang.org/reference/visibility-and-privacy.html)
1522         struct Visibility { T![pub], T![super], T![self], T![crate] }
1523
1524         /// Single identifier.
1525         /// // TODO: clarify the difference between Name and NameRef
1526         ///
1527         /// ```
1528         /// let ❰ foo ❱ = bar;
1529         /// struct ❰ Baz ❱;
1530         /// fn ❰ bruh ❱() {}
1531         /// ```
1532         ///
1533         /// [Reference](https://doc.rust-lang.org/reference/identifiers.html)
1534         struct Name { T![ident] }
1535
1536         /// Reference to a name.
1537         ///
1538         /// ```
1539         /// let foo = ❰ bar ❱(❰ Baz(❰ bruh ❱) ❱;
1540         /// ```
1541         ///
1542         /// [Reference](https://doc.rust-lang.org/reference/identifiers.html)
1543         struct NameRef { /*NameRefToken*/ } // TODO: where is NameRefToken?
1544
1545         /// Macro call.
1546         /// Includes all of its attributes and doc comments.
1547         ///
1548         /// ```
1549         /// ❰
1550         ///     /// Docs
1551         ///     #[attr]
1552         ///     macro_rules! foo {   // macro rules is also a macro call
1553         ///         ($bar: tt) => {}
1554         ///     }
1555         /// ❱
1556         ///
1557         /// ❰ foo!() ❱
1558         /// ```
1559         ///
1560         /// [Reference](https://doc.rust-lang.org/reference/macros.html)
1561         struct MacroCall: NameOwner, AttrsOwner, DocCommentsOwner {
1562             Path, T![!], TokenTree, T![;] // TODO: what is the meaning of the semicolon here?
1563         }
1564
1565         /// Attribute.
1566         ///
1567         /// ```
1568         /// ❰ #![inner_attr] ❱
1569         ///
1570         /// ❰ #[attr] ❱
1571         /// ❰ #[foo = "bar"] ❱
1572         /// ❰ #[baz(bruh::bruuh = "42")] ❱
1573         /// struct Foo;
1574         /// ```
1575         ///
1576         /// [Reference](https://doc.rust-lang.org/reference/attributes.html)
1577         struct Attr { T![#], T![!], T!['['], Path, T![=], input: AttrInput, T![']'] }
1578
1579         /// Stores a list of lexer tokens and other `TokenTree`s.
1580         /// It appears in attributes, macro_rules and macro call (foo!)
1581         ///
1582         /// ```
1583         /// macro_call! ❰ { my syntax here } ❱;
1584         /// ```
1585         ///
1586         /// [Reference](https://doc.rust-lang.org/reference/macros.html)
1587         struct TokenTree {}
1588
1589         // TODO: clarify this param vs arg i.e. delcaration vs instantiation
1590         // TODO: arg vs param doesn't really make a difference, the naming here is very confusing
1591         // This one is not so obvious as pattern vs template (@matklad)
1592         //
1593         /// Generic lifetime, type and constants parameters list **declaration**.
1594         ///
1595         /// ```
1596         /// fn foo❰ <'a, 'b, T, U, const BAR: u64> ❱() {}
1597         ///
1598         /// struct Baz❰ <T> ❱(T);
1599         ///
1600         /// impl❰ <T> ❱ Bruh<T> {}
1601         ///
1602         /// type Bruuh = for❰ <'a> ❱ fn(&'a str) -> &'a str;
1603         /// ```
1604         ///
1605         /// [Reference](https://doc.rust-lang.org/reference/items/generics.html)
1606         struct TypeParamList {
1607             T![<],
1608             generic_params: [GenericParam],
1609             type_params: [TypeParam],
1610             lifetime_params: [LifetimeParam],
1611             const_params: [ConstParam],
1612             T![>]
1613         }
1614
1615         /// Single type parameter **declaration**.
1616         ///
1617         /// ```
1618         /// fn foo<❰ K ❱, ❰ I ❱, ❰ E: Debug ❱, ❰ V = DefaultType ❱>() {}
1619         /// ```
1620         ///
1621         /// [Reference](https://doc.rust-lang.org/reference/items/generics.html)
1622         struct TypeParam: NameOwner, AttrsOwner, TypeBoundsOwner {
1623             T![=],
1624             default_type: TypeRef,
1625         }
1626
1627         /// Const generic parameter **declaration**.
1628         /// ```
1629         /// fn foo<T, U, ❰ const BAR: usize ❱, ❰ const BAZ: bool ❱>() {}
1630         /// ```
1631         ///
1632         /// [RFC](https://github.com/rust-lang/rfcs/blob/master/text/2000-const-generics.md#declaring-a-const-parameter)
1633         struct ConstParam: NameOwner, AttrsOwner, TypeAscriptionOwner {
1634             T![=],
1635             default_val: Expr,
1636         }
1637
1638         /// Lifetime parameter **declaration**.
1639         ///
1640         /// ```
1641         /// fn foo<❰ 'a ❱, ❰ 'b ❱, V, G, D>(bar: &'a str, baz: &'b mut str) {}
1642         /// ```
1643         ///
1644         /// [Reference](https://doc.rust-lang.org/reference/items/generics.html)
1645         struct LifetimeParam: AttrsOwner { T![lifetime] }
1646
1647         // TODO: better clarify where is the colon token and what `const` pertains to.
1648         // TODO: add example with `const`
1649         /// Type bound declaration clause.
1650         ///
1651         /// ```
1652         /// fn foo<T: ❰ ?Sized ❱ + ❰ Debug ❱>() {}
1653         ///
1654         /// trait Bar<T>
1655         /// where
1656         ///     T: ❰ Send ❱ + ❰ Sync ❱
1657         /// {
1658         ///     type Baz: ❰ !Sync ❱ + ❰ Debug ❱;
1659         /// }
1660         /// ```
1661         ///
1662         /// [Reference](https://doc.rust-lang.org/reference/trait-bounds.html)
1663         struct TypeBound { T![lifetime], /* Question,  */ T![const], /* Question,  */ TypeRef }
1664
1665         /// Type bounds list.
1666         ///
1667         /// ```
1668         ///
1669         /// fn foo<T: ❰ ?Sized + Debug ❱>() {}
1670         ///
1671         /// trait Bar<T>
1672         /// where
1673         ///     T: ❰ Send + Sync ❱
1674         /// {
1675         ///     type Baz: ❰ !Sync + Debug ❱;
1676         /// }
1677         /// ```
1678         ///
1679         /// [Reference](https://doc.rust-lang.org/reference/trait-bounds.html)
1680         struct TypeBoundList { bounds: [TypeBound] }
1681
1682         /// Single where predicate.
1683         ///
1684         /// ```
1685         /// trait Foo<'a, 'b, T>
1686         /// where
1687         ///     ❰ 'a: 'b ❱,
1688         ///     ❰ T: IntoIterator ❱,
1689         ///     ❰ for<'c> <T as IntoIterator>::Item: Bar<'c> ❱
1690         /// {}
1691         /// ```
1692         ///
1693         /// [Reference](https://doc.rust-lang.org/reference/items/generics.html#where-clauses)
1694         struct WherePred: TypeBoundsOwner { T![lifetime], TypeRef }
1695
1696         /// Where clause.
1697         ///
1698         /// ```
1699         /// trait Foo<'a, T> ❰ where 'a: 'static, T: Debug ❱ {}
1700         ///
1701         /// ```
1702         ///
1703         /// [Reference](https://doc.rust-lang.org/reference/items/generics.html#where-clauses)
1704         struct WhereClause { T![where], predicates: [WherePred] }
1705
1706         /// Abi declaration.
1707         /// Note: the abi string is optional.
1708         ///
1709         /// ```
1710         /// ❰ extern "C" ❱ {
1711         ///     fn foo() {}
1712         /// }
1713         ///
1714         /// type Bar = ❰ extern ❱ fn() -> u32;
1715         ///
1716         /// type Baz = ❰ extern r#"stdcall"# ❱ fn() -> bool;
1717         /// ```
1718         ///
1719         /// - [Extern blocks reference](https://doc.rust-lang.org/reference/items/external-blocks.html)
1720         /// - [FFI function pointers reference](https://doc.rust-lang.org/reference/items/functions.html#functions)
1721         struct Abi { /*String*/ }
1722
1723         // TODO: clarify how empty statements are handled
1724         /// Expression statement.
1725         /// Note: may be empty (i.e. only semicolon).
1726         ///
1727         /// ```
1728         /// ❰ 42; ❱
1729         /// ❰ foo(); ❱
1730         /// ❰ (); ❱
1731         /// ❰ {}; ❱
1732         /// ❰ /* empty */; ❱
1733         ///
1734         /// // constructions with trailing curly brace can omit the semicolon // TODO: clarify
1735         /// ❰ if bool_cond { } ❱
1736         /// ❰ loop {} ❱
1737         /// ```
1738         ///
1739         /// [Reference](https://doc.rust-lang.org/reference/statements.html)
1740         struct ExprStmt: AttrsOwner { Expr, T![;] }
1741
1742         /// Let statement.
1743         ///
1744         /// ```
1745         /// ❰ #[attr] let foo; ❱
1746         /// ❰ let bar: u64; ❱
1747         /// ❰ let baz = 42; ❱
1748         /// ❰ let bruh: bool = true; ❱
1749         /// ```
1750         ///
1751         /// [Reference](https://doc.rust-lang.org/reference/statements.html#let-statements)
1752         struct LetStmt: AttrsOwner, TypeAscriptionOwner {
1753             T![let],
1754             Pat,
1755             T![=],
1756             initializer: Expr,
1757             T![;],
1758         }
1759
1760         /// Condition of `if` or `while` expression.
1761         ///
1762         /// ```
1763         /// if ❰ true ❱ {}
1764         /// if ❰ let Pat(foo) = bar ❱ {}
1765         ///
1766         /// while ❰ true ❱ {}
1767         /// while ❰ let Pat(baz) = bruh ❱ {}
1768         /// ```
1769         ///
1770         /// [If expression reference](https://doc.rust-lang.org/reference/expressions/if-expr.html)
1771         /// [While expression reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html#predicate-loops)
1772         struct Condition { T![let], Pat, T![=], Expr }
1773
1774         // TODO: this one is used by closure expressions too, but hey use pipes instead of parens
1775         /// Parameter list **declaration**.
1776         ///
1777         /// ```
1778         /// fn foo❰ (a: u32, b: bool) ❱ -> u32 {}
1779         /// let bar = ❰ |a, b| ❱ {};
1780         ///
1781         /// impl Baz {
1782         ///     fn bruh❰ (&self, a: u32) ❱ {}
1783         /// }
1784         /// ```
1785         ///
1786         /// [Reference](https://doc.rust-lang.org/reference/items/functions.html)ocs to codegen script
1787         struct ParamList {
1788             T!['('],
1789             SelfParam,
1790             params: [Param],
1791             T![')']
1792         }
1793
1794         /// Self parameter **declaration**.
1795         ///
1796         /// ```
1797         /// impl Bruh {
1798         ///     fn foo(❰ self ❱) {}
1799         ///     fn bar(❰ &self ❱) {}
1800         ///     fn baz(❰ &mut self ❱) {}
1801         ///     fn blah<'a>(❰ &'a self ❱) {}
1802         ///     fn blin(❰ self: Box<Self> ❱) {}
1803         /// }
1804         /// ```
1805         ///
1806         /// [Reference](https://doc.rust-lang.org/reference/items/functions.html)
1807         struct SelfParam: TypeAscriptionOwner, AttrsOwner { T![&], T![mut], T![lifetime], T![self] }
1808
1809         /// Parameter **declaration**.
1810         ///
1811         /// ```
1812         /// fn foo(❰ #[attr] Pat(bar): Pat(u32) ❱, ❰ #[attr] _: bool ❱) {}
1813         ///
1814         /// extern "C" {
1815         ///     fn bar(❰ baz: u32 ❱, ❰ ... ❱) -> u32;
1816         /// }
1817         /// ```
1818         ///
1819         /// [Reference](https://doc.rust-lang.org/reference/items/functions.html)
1820         struct Param: TypeAscriptionOwner, AttrsOwner {
1821             Pat,
1822             T![...]
1823         }
1824
1825         /// Use declaration.
1826         ///
1827         /// ```
1828         /// ❰ #[attr] pub use foo; ❱
1829         /// ❰ use bar as baz; ❱
1830         /// ❰ use bruh::{self, bruuh}; ❱
1831         /// ❰ use { blin::blen, blah::* };
1832         /// ```
1833         ///
1834         /// [Reference](https://doc.rust-lang.org/reference/items/use-declarations.html)
1835         struct UseItem: AttrsOwner, VisibilityOwner {
1836             T![use],
1837             UseTree,
1838         }
1839
1840         // TODO: verify example correctness
1841         /// Use tree.
1842         ///
1843         /// ```
1844         /// pub use ❰ foo::❰ * ❱ ❱;
1845         /// use ❰ bar as baz ❱;
1846         /// use ❰ bruh::bruuh::{ ❰ self ❱, ❰ blin ❱ } ❱;
1847         /// use ❰ { ❰ blin::blen ❱ } ❱ // TODO: clarify if top-level curlies are `UseTree`
1848         /// ```
1849         ///
1850         /// [Reference](https://doc.rust-lang.org/reference/items/use-declarations.html)
1851         struct UseTree {
1852             Path, T![*], UseTreeList, Alias
1853         }
1854
1855         /// Item alias.
1856         /// Note: this is not the type alias.
1857         ///
1858         /// ```
1859         /// use foo ❰ as bar ❱;
1860         /// use baz::{bruh ❰ as _ ❱};
1861         /// extern crate bruuh ❰ as blin ❱;
1862         /// ```
1863         ///
1864         /// [Reference](https://doc.rust-lang.org/reference/items/use-declarations.html)
1865         struct Alias: NameOwner { T![as] }
1866
1867         /// Sublist of use trees.
1868         ///
1869         /// ```
1870         /// use bruh::bruuh::❰ { ❰ self ❱, ❰ blin ❱ } ❱;
1871         /// use ❰ { blin::blen::❰ {} ❱ } ❱
1872         /// ```
1873         ///
1874         /// [Reference](https://doc.rust-lang.org/reference/items/use-declarations.html)
1875         struct UseTreeList { T!['{'], use_trees: [UseTree], T!['}'] }
1876
1877         /// Extern crate item.
1878         ///
1879         /// ```
1880         /// ❰ #[attr] pub extern crate foo; ❱
1881         /// ❰ extern crate self as bar; ❱
1882         /// ```
1883         ///
1884         /// [Reference](https://doc.rust-lang.org/reference/items/extern-crates.html)
1885         struct ExternCrateItem: AttrsOwner, VisibilityOwner {
1886             T![extern], T![crate], NameRef, Alias,
1887         }
1888
1889         /// Call site arguments list.
1890         ///
1891         /// ```
1892         /// foo::<T, U>❰ (42, true) ❱;
1893         /// ```
1894         ///
1895         /// [Reference](https://doc.rust-lang.org/reference/expressions/call-expr.html)
1896         struct ArgList {
1897             T!['('],
1898             args: [Expr],
1899             T![')']
1900         }
1901
1902         // TODO: correct the example
1903         /// Path to a symbol. Includes single identifier names and elaborate paths with
1904         /// generic parameters.
1905         ///
1906         /// ```
1907         /// (0..10).❰ collect ❰ ::<Vec<_>> ❱ ❱();
1908         /// ❰ Vec ❰ ::<u8> ❰ ::with_capacity ❱ ❱ ❱(1024);
1909         /// ❰ <Foo as Bar> ❰ ::baz ❱ ❱();
1910         /// ❰ <bruh> ❰ ::bruuh ❱ ❱();
1911         /// ```
1912         ///
1913         /// [Reference](https://doc.rust-lang.org/reference/paths.html)
1914         struct Path {
1915             segment: PathSegment,
1916             qualifier: Path,
1917         }
1918
1919         // TODO: verify the example
1920         // TODO: what RetType is doing here? is this for Fn() -> T syntax?
1921         /// Segment of the path to a symbol.
1922         ///
1923         /// ```
1924         /// (0..10).❰ collect ❱ ❰ ::<Vec<_>> ❱();
1925         /// ❰ Vec >| ❰ ::<u8> ❱ ❰ ::with_capacity ❱(1024);
1926         /// ❰ <Foo as Bar> ❱ ❰ ::baz ❱();
1927         /// ❰ <bruh> ❱ ❰ ::bruuh ❱();
1928         /// ```
1929         ///
1930         /// [Reference](https://doc.rust-lang.org/reference/paths.html)
1931         struct PathSegment {
1932             T![::], T![crate], T![self], T![super], T![<], NameRef, TypeArgList, ParamList, RetType, PathType, T![>]
1933         }
1934
1935         // TODO: verify the example
1936         /// List of type arguments that are passed at generic instantiation site.
1937         ///
1938         /// ```
1939         /// use foo ❰ ::<'a, u64, Item = Bar, 42, true> ❱::bar;
1940         ///
1941         /// Vec❰ ::<bool> ❱::();
1942         /// ```
1943         ///
1944         /// [Reference](https://doc.rust-lang.org/reference/paths.html#paths-in-expressions)
1945         struct TypeArgList {
1946             T![::],
1947             T![<],
1948             generic_args: [GenericArg],
1949             type_args: [TypeArg],
1950             lifetime_args: [LifetimeArg],
1951             assoc_type_args: [AssocTypeArg],
1952             const_args: [ConstArg],
1953             T![>]
1954         }
1955
1956         /// Type argument that is passed at generic instantiation site.
1957         ///
1958         /// ```
1959         /// use foo::<'a, ❰ u64 ❱, ❰ bool ❱, Item = Bar, 42>::baz;
1960         /// ```
1961         ///
1962         /// [Reference](https://doc.rust-lang.org/reference/paths.html#paths-in-expressions)
1963         struct TypeArg { TypeRef }
1964
1965         // TODO: verify inline type bounds example
1966         /// Associated type argument that is passed at generic instantiation site.
1967         /// ```
1968         /// use foo::<'a, u64, bool, ❰ Item = Bar ❱, 42>::baz;
1969         ///
1970         /// trait Bruh<T>: Iterator<❰ Item: Debug ❱> {}
1971         /// ```
1972         ///
1973         struct AssocTypeArg : TypeBoundsOwner { NameRef, T![=], TypeRef }
1974
1975         // TODO: verify?
1976         /// Lifetime argument that is passed at generic instantiation site.
1977         ///
1978         /// ```
1979         /// fn foo<'a>(s: &'a str) {
1980         ///     bar::<❰ 'a ❱>(s);
1981         /// }
1982         /// ```
1983         ///
1984         /// [Reference](https://doc.rust-lang.org/reference/paths.html#paths-in-expressions)
1985         struct LifetimeArg { T![lifetime] }
1986
1987         // TODO: does this peratain to const generics?
1988         // What does equal sign do here?
1989         /// Constant value argument that is passed at generic instantiation site.
1990         ///
1991         /// ```
1992         /// foo::<❰ u32 ❱, ❰ true ❱>();
1993         ///
1994         /// bar::<❰ { 2 + 2} ❱>();
1995         /// ```
1996         ///
1997         /// [RFC](https://github.com/rust-lang/rfcs/blob/master/text/2000-const-generics.md#declaring-a-const-parameter)
1998         struct ConstArg { Literal, T![=], BlockExpr }
1999
2000         // TODO: Idk what I am writing here, please don't believe these words.
2001         // TODO: clarify @matklad @edwin0cheng
2002         /// Macro items is a node that holds all the items created by expanding a macro.
2003         ///
2004         /// ```
2005         /// foo!(); // expands into some items -v
2006         ///         // ❰ struct Foo; impl Bar for Foo; ❱
2007         /// ```
2008         ///
2009         /// [Reference](https://doc.rust-lang.org/reference/macros.html)
2010         struct MacroItems: ModuleItemOwner { }
2011
2012         /// List of items in an extern block.
2013         ///
2014         /// ```
2015         /// extern "C" ❰
2016         ///     {
2017         ///         fn foo();
2018         ///         static var: u32;
2019         ///     }
2020         /// ❱
2021         /// ```
2022         ///
2023         /// [Reference](https://doc.rust-lang.org/reference/items/external-blocks.html)
2024         struct ExternItemList: ModuleItemOwner {
2025             T!['{'],
2026             extern_items: [ExternItem],
2027             T!['}']
2028         }
2029
2030         /// Extern block.
2031         ///
2032         /// ```
2033         /// ❰
2034         ///     extern "C" {
2035         ///         fn foo();
2036         ///     }
2037         /// ❱
2038         ///
2039         /// ```
2040         ///
2041         /// [Reference](https://doc.rust-lang.org/reference/items/external-blocks.html)
2042         struct ExternBlock {
2043             Abi,
2044             ExternItemList
2045         }
2046
2047         /// Meta item in an attribute.
2048         ///
2049         /// ```
2050         /// #[❰ bar::baz = "42" ❱]
2051         /// #[❰ bruh(bruuh("true")) ❱]
2052         /// struct Foo;
2053         /// ```
2054         ///
2055         /// [Reference](https://doc.rust-lang.org/reference/attributes.html?highlight=meta,item#meta-item-attribute-syntax)
2056         struct MetaItem {
2057             Path, T![=], AttrInput, nested_meta_items: [MetaItem]
2058         }
2059
2060         // TODO: is this a special case of `MacroCall` where `Name` = `macro_rules`?
2061         // It doesn't seem this ast node is used anywhere
2062         /// Macro definition.
2063         ///
2064         /// ```
2065         /// ❰
2066         ///     macro_rules! foo {
2067         ///         ($bar:tt) => {$bar}
2068         ///     }
2069         /// ❱
2070         /// ```
2071         ///
2072         /// [Reference](https://doc.rust-lang.org/reference/macros-by-example.html)
2073         struct MacroDef {
2074             Name, TokenTree
2075         }
2076     },
2077     enums: &ast_enums! {
2078         /// Any kind of nominal type definition.
2079         enum NominalDef: NameOwner, TypeParamsOwner, AttrsOwner {
2080             StructDef, EnumDef, UnionDef,
2081         }
2082
2083         /// Any kind of **declared** generic parameter
2084         enum GenericParam {
2085             LifetimeParam,
2086             TypeParam,
2087             ConstParam
2088         }
2089
2090         /// Any kind of generic argument passed at instantiation site
2091         enum GenericArg {
2092             LifetimeArg,
2093             TypeArg,
2094             ConstArg,
2095             AssocTypeArg
2096         }
2097
2098         /// Any kind of construct valid in type context
2099         enum TypeRef {
2100             ParenType,
2101             TupleType,
2102             NeverType,
2103             PathType,
2104             PointerType,
2105             ArrayType,
2106             SliceType,
2107             ReferenceType,
2108             PlaceholderType,
2109             FnPointerType,
2110             ForType,
2111             ImplTraitType,
2112             DynTraitType,
2113         }
2114
2115         /// Any kind of top-level item that may appear in a module
2116         enum ModuleItem: NameOwner, AttrsOwner, VisibilityOwner {
2117             StructDef,
2118             UnionDef,
2119             EnumDef,
2120             FnDef,
2121             TraitDef,
2122             TypeAliasDef,
2123             ImplDef,
2124             UseItem,
2125             ExternCrateItem,
2126             ConstDef,
2127             StaticDef,
2128             Module,
2129             MacroCall,
2130             ExternBlock
2131         }
2132
2133
2134
2135         /// Any kind of item that may appear in an impl block
2136         ///
2137         /// // TODO: is the following a fixme?
2138         /// impl blocks can also contain MacroCall
2139         enum AssocItem: NameOwner, AttrsOwner {
2140             FnDef, TypeAliasDef, ConstDef
2141         }
2142
2143         /// Any kind of item that may appear in an extern block
2144         ///
2145         /// // TODO: is the following a fixme?
2146         /// extern blocks can also contain MacroCall
2147         enum ExternItem: NameOwner, AttrsOwner, VisibilityOwner {
2148             FnDef, StaticDef
2149         }
2150
2151         /// Any kind of expression
2152         enum Expr: AttrsOwner {
2153             TupleExpr,
2154             ArrayExpr,
2155             ParenExpr,
2156             PathExpr,
2157             LambdaExpr,
2158             IfExpr,
2159             LoopExpr,
2160             ForExpr,
2161             WhileExpr,
2162             ContinueExpr,
2163             BreakExpr,
2164             Label,
2165             BlockExpr,
2166             ReturnExpr,
2167             MatchExpr,
2168             RecordLit,
2169             CallExpr,
2170             IndexExpr,
2171             MethodCallExpr,
2172             FieldExpr,
2173             AwaitExpr,
2174             TryExpr,
2175             EffectExpr,
2176             CastExpr,
2177             RefExpr,
2178             PrefixExpr,
2179             RangeExpr,
2180             BinExpr,
2181             Literal,
2182             MacroCall,
2183             BoxExpr,
2184         }
2185
2186         /// Any kind of pattern
2187         enum Pat {
2188             OrPat,
2189             ParenPat,
2190             RefPat,
2191             BoxPat,
2192             BindPat,
2193             PlaceholderPat,
2194             DotDotPat,
2195             PathPat,
2196             RecordPat,
2197             TupleStructPat,
2198             TuplePat,
2199             SlicePat,
2200             RangePat,
2201             LiteralPat,
2202             MacroPat,
2203         }
2204
2205         /// Any kind of pattern that appears directly inside of the curly
2206         /// braces of a record pattern
2207         enum RecordInnerPat {
2208             RecordFieldPat,
2209             BindPat
2210         }
2211
2212         /// Any kind of input to an attribute
2213         enum AttrInput { Literal, TokenTree }
2214
2215         /// Any kind of statement
2216         enum Stmt {
2217             LetStmt,
2218             ExprStmt,
2219             // macro calls are parsed as expression statements
2220         }
2221
2222         /// Any kind of fields list (record or tuple field lists)
2223         enum FieldDefList {
2224             RecordFieldDefList,
2225             TupleFieldDefList,
2226         }
2227     },
2228 };