Compiler diagnostics and Rust codegen ergonomics
Diagnostics: miette vs custom errors
Current state:
mietteis a dependency ofvox-compilerand is used for Rust codegen failures (codegen_rust/pipeline.rs,emit/mod.rs, projection validation).- Parse / typecheck / HIR use bespoke error types (
ParseError,Diagnostic,HirValidationError) mapped to LSP invox-lsp.
Decision (near term):
- No forced unification until there is bandwidth to thread
Span↔miette::SourceSpan(including UTF-16 LSP offsets) through the full pipeline. - Directional preference: when adding new rich user-facing errors in codegen paths, use
miette. For LSP-facing parse/type errors, keep the existing structured diagnostics until a deliberate migration plan exists.
Rationale: Unifying on miette everywhere is high-touch (CLI, MCP, tests, serde-stable diagnostics); partial adoption already delivers value on codegen.
Rust emission: quote / prettyplease
Current state: Most Rust output is string emission under crates/vox-compiler/src/codegen_rust/emit/.
Decision:
- Pilot first: pick one hot file (e.g. a small
emit/*module with heavy escaping) and tryquote!for syntactic fragments; optionally runprettypleaseon output in tests only to validate shape. - Not a goal: rewriting the entire emitter to proc-macro style in one pass.
Rationale: quote reduces nested-quote bugs; full migration is a large formatting and snapshot-test churn.
References
crates/vox-compiler/src/codegen_rust/pipeline.rscrates/vox-compiler/src/parser/error.rscrates/vox-compiler/src/typeck/diagnostics.rscrates/vox-lsp/src/lib.rs(diagnostic mapping)