pub fn phase_diagnostic<E: PhaseError>(
module: &Name,
phase: &str,
errors: &[E],
file: Option<SourceFileId>,
) -> Diagnostic<SourceFileId>Expand description
Render the errors one phase produced for one module.
A Diagnostic has room for exactly one headline, so a lone error gets to be that
headline and a group is summarised instead, with every message demoted to a note.
phase names the phase in that summary line (“canonical”, “type”, …).
file is the module’s source file when the caller knows it, and it is handed
straight to spans_to_labels as the fallback that function describes: a label
of its own — the cross-module ones ERR-5 added — renders regardless, so a
CompilationError built by hand, as the tests in this module do, loses only the
labels about the module under check. check_package always wraps in
CompilationError::InFile and so loses none.
Both branches attach labels: only the headline demotion differs between one error and a group, and an error that got swallowed into a note still knows where it was.
Public because CompilationError::as_diagnostic shares it with
zelkova::BuildError::as_diagnostic, which renders the driver’s own per-module
errors through it.