Expand description
Bynk’s shared diagnostic-rendering layer.
The presentation layer over [bynk_syntax::CompileError]: ariadne human
output and the short/json-feeding line forms. Every renderer takes
&[CompileError] + source + filename — it is agnostic about where the
errors came from. Both CLI front-ends adopt it so they render identically
(ADR 0100).
Invariant (ADR 0100): this crate depends on bynk-syntax only (plus
ariadne). It must never see AttributedError/ProjectFailure (which live
in bynk-emit): the AttributedError → CompileError flattening stays above
render, in the front-end, so there is no render → emit cycle. A function
here taking a ProjectFailure would not even compile — the dependency isn’t
present, by design.
Extracted from bynkc as slice 6 of the crate-decomposition track.
Functions§
- print_
errors - Render to stderr with color, used by the CLI.
- print_
errors_ short - v0.38 (ADR 0071): one terse line per diagnostic for tooling consumers
(
bynkc check --format short):path:line:col: <severity>[<category>]: <message>. Line/column are 1-indexed, computed from the byte span against the source. The VS Codebynkcproblem-matcher keys off this exact shape — keep it stable. - print_
project_ errors - Render project-level errors as plain
[category] messagelines — the fallback for errors with no file attribution. Rich, source-context rendering lives in the front-end’s project-failure renderer (v0.24). - render_
errors - Render a list of compile errors to a string (for tests) using the given filename as the diagnostic source label.
- render_
errors_ plain - Render a list of compile errors to a string with colour disabled and the
given filename as the source label. Unlike
render_errors, the output contains no ANSI escape codes, so it is byte-stable — suitable for the committed diagnostic transcripts undersite/src/diagnostics/. - render_
errors_ short - The string form of
print_errors_short— one…[category]: messageline per error, each newline-terminated. The renderer behind the CLI’s--format short, exposed for testing. - render_
project_ errors - Render a list of compile errors as plain
[category] messagelines (with notes), for test assertion. - severity_
word "error"/"warning"for an error’s [Severity].- short_
line - One terse
path:line:col: severity[category]: messageline for a single error against its source. The front-end’s project-failure short renderer flattens an attributed error to(label, text, error)and calls this.