Skip to main content

prepend_prelude

Function prepend_prelude 

Source
pub fn prepend_prelude(
    ast: Ast,
    interner: ThreadedRodeo,
    preview_features: &PreviewFeatures,
) -> MultiErrorResult<(Ast, ThreadedRodeo)>
Expand description

ADR-0078 Phase 1: lex+parse the embedded prelude using interner and prepend its top-level items to ast. Useful for callers that bypass CompilationUnit::parse (lib tests, --emit-only flows that already have a parsed AST in hand) but still want the prelude-resident declarations (Option, Result, Arch, Os, Drop/Copy/Clone, etc.) to be visible during sema.

The frontend entry points (compile_frontend_from_ast_*) deliberately do not call this — the multi-file driver merges the prelude with all other parsed files via merge_symbols before invoking the frontend. Calling this twice on an already-merged AST would produce duplicate definitions.