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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//! Enumeration types of any possible fragment of AST (`Fragment` / `FragmentRef`).
//!
//! Many components (diagnostics, logging, printers) want to refer to “some AST
//! node” without knowing its concrete type. This module provides:
//! - [`Fragment`]: an **owned** enum covering core AST node types.
//! - [`FragmentRef`]: a **borrowed** counterpart.
//!
//! These are handy when implementing generic facilities such as error reporters,
//! debugging helpers, or pretty-printers that need to branch on “what kind of
//! node is this?” at runtime.
//!
//! ## Notes
//! - Both enums are mechanically generated to stay in sync with the canonical
//! AST types. If you add a new core AST node, update the macro invocation at
//! the bottom of this file so `Fragment`/`FragmentRef` learn about it.
//! - The [`Unknown`] variant exists as a last-resort placeholder when a value
//! cannot be represented by a known variant. Prefer concrete variants when
//! possible.
use crate*;
/// The `mk!` macro takes a flat list of AST type identifiers and expands to
/// two enums:
/// - `Fragment` with owned variants (`Foo(Foo)`), and
/// - `FragmentRef<'a>` with borrowed variants (`Foo(&'a Foo)`).
///
/// The generated enums also implement the obvious `From<T>` conversions, making
/// it ergonomic to wrap concrete AST values as fragments.
mk!;