pub fn collect_enum_variants(
modules: &[(&AIRModule, &Path)],
) -> EnumVariantRegistryExpand description
Pre-scan every reached module and build the EnumVariantRegistry.
Walks each module’s top-level EnumDecls (the only place enum variants are
declared) and records every variant. A pre-scan — rather than recording
variants as their decls are emitted — is required because a use site may
precede its enum’s declaration in source order (forward reference), and
because a used enum’s decl can live in a different module than its
construction site (cross-module use). This mirrors the Go backend’s
existing collect_methods / collect_optional_returns pre-scans.
The built-in Optional/Result constructors are pre-seeded (B1) so the
same registry describes built-in ADTs; backends treat these as a fallback
behind their bespoke Optional/Result lowering (see the module comment).