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
71
72
73
74
75
76
77
//! AST phase parameter (issue: phased AST split).
//!
//! The AST is parameterized over a [`Phase`] type so that variants that exist
//! only at earlier stages of compilation are statically excluded from later
//! stages.
//!
//! Two phases:
//!
//! - [`Raw`] — produced by the parser. Carries every surface sugar via
//! [`crate::syntax::ast::RawDeclSugar`] /
//! [`crate::syntax::ast::RawExprSugar`]. Consumed by the formatter and any
//! surface-aware tooling.
//! - [`Desugared`] — produced by [`crate::desugar`]. Surface-sugar slots
//! are [`core::convert::Infallible`], so `match` arms over them are
//! unreachable. Reference paths stay syntactic
//! ([`crate::syntax::ast::UnresolvedRef`]); HIR lowering is the single
//! stage that classifies and resolves them.
//!
//! ```text
//! parser → File<Raw> → desugar → File<Desugared> → HIR/IR → TIR → eval
//! ↘ formatter
//! ```
use Infallible;
use Debug;
pub
/// Marker trait for AST phases.
///
/// Sealed: only [`Raw`] and [`Desugared`] implement it.
/// Pre-desugar phase: every surface sugar is representable.
///
/// Produced by the parser. The formatter and any other surface-aware
/// consumer reads this phase.
/// Post-desugar phase: surface-sugar variants are statically impossible.
///
/// Produced by [`crate::desugar`]. Unresolved identifier paths are still
/// representable; HIR lowering resolves them. This is the final syntax-AST
/// phase — every downstream consumer reads HIR, not a further AST phase.
/// Helper for matching against `Sugar(Infallible)` arms.
///
/// In post-desugar code, `match decl.kind { ..., Sugar(s) => never(s) }`
/// is the canonical way to handle the impossible case without runtime panic.
pub const