Expand description
The shared per-unit/per-file resolve-check core, used by both
bynk-emit’s check_unit_files (Mode::Build and Mode::Analyse) and
this crate’s own crate::analysis::analyse_project.
P4.1 (#1115), the same extract, don't duplicate move as
crate::project_model: check_unit_files’s per-file body is identical
for both modes except for four record_analyse_types call sites (the
error-path exits) and the final “Analyse mode always stops here, Build
mode falls through to certify+emit_unit” branch. This module owns
everything up to (not including) that branch — check_file_core
returns Some(TypedCommons) only on the fully-clean, non-blocked path, so
a caller that wants to emit knows exactly when it may. The four
error-path recordings are unconditional here now (previously gated on
mode == Mode::Analyse) — behaviour-preserving for the Mode::Build
caller, which never took that branch anyway (mode == Mode::Analyse
gated it), and whose exprs sink compile_project’s ProjectOutput
never exposes.
What stayed in bynk-emit: Mode itself (meaningless here — this
crate’s own entry point has exactly one behaviour), certify+emit_unit
(real emission), and the decision of whether to record the clean-path
types (each caller does that itself with the Some(TypedCommons) this
module hands back — bynk-emit’s Mode::Build caller skips it,
Mode::Analyse and this crate’s own entry point both call
record_analyse_types).
Structs§
- File
Check Result - The clean-path output of
check_file_core: the typed, fully-checked unit plus the per-file cross-context info that produced it — aMode::Buildcaller needs both to reachcertify+emit_unit(emit_unittakescross_context_for_fileas its own argument, so this avoids making the caller recompute it fromctx/unit_infoa second time). - Unit
Check Ctx - v0.29.4:
build_cross_context_info(and itscombined_types_forhelper) is a general map-based function — the test-emission path calls it with synthetic harness maps, notunit_info— so it keeps its parallel-map signature. The per-file core only hasunit_info, so this materialises the four views that one call needs, once per unit ahead of the file loop — but only for a context/adapter,build_cross_context_info’s only caller.UnitTableowns every declaration body in the unit, so for every other unit kind (including the seven injected first-party commons) this would otherwise be a whole-project deep clone, performed and discarded, once per unit.
Functions§
- check_
file_ core - The shared resolve+check+context-checks core for one file, factored out
of
check_unit_files(see this module’s own doc comment). ReturnsSome(FileCheckResult)only on the fully-clean, non-blocked path — the signal aMode::Buildcaller uses to know it may proceed tocertify+emit_unit. Every error/blocked exit records best-effort partial types unconditionally (seerecord_analyse_types) and returnsNone. - prepare_
unit_ check_ ctx - Build the per-unit prelude
check_file_coreshares across every file in the unit — seeUnitCheckCtx’s own doc comment. - record_
analyse_ types - Record a file’s (possibly partial) expression types into the Analyse-mode
sink. Called at every per-file exit in the check loop so
.-member completion and signature help get the receiver’s type even when a later check phase errors for the file (ADR 0094). A no-op-shaped wrapper, factored out so the four error-path exits (now unconditional, see this module’s own doc comment) and every clean-path caller share one call.