Skip to main content

Crate bynk_render

Crate bynk_render 

Source
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 Code bynkc problem-matcher keys off this exact shape — keep it stable.
print_project_errors
Render project-level errors as plain [category] message lines — 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 under site/src/diagnostics/.
render_errors_short
The string form of print_errors_short — one …[category]: message line 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] message lines (with notes), for test assertion.
severity_word
"error" / "warning" for an error’s [Severity].
short_line
One terse path:line:col: severity[category]: message line 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.