Expand description
Rust compiler diagnostic parsing.
This module provides types and a parser for rustc --error-format=json output.
Each line of stderr from rustc in JSON mode is a JSON object containing
diagnostic information. This module parses those objects into structured
RustDiagnostic values.
§Example
use adk_code::diagnostics::parse_diagnostics;
let stderr = r#"{"message":"expected `;`","code":{"code":"E0308","explanation":null},"level":"error","spans":[{"file_name":"main.rs","byte_start":10,"byte_end":11,"line_start":1,"line_end":1,"column_start":11,"column_end":12,"is_primary":true,"text":[{"text":"let x = 1","highlight_start":11,"highlight_end":12}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error: expected `;`"}"#;
let diagnostics = parse_diagnostics(stderr);
assert_eq!(diagnostics.len(), 1);
assert_eq!(diagnostics[0].level, "error");Structs§
- Diagnostic
Span - A source span within a diagnostic.
- Rust
Diagnostic - A parsed Rust compiler diagnostic.
- Span
Text - A line of source text with highlight markers.
Functions§
- parse_
diagnostics - Parse rustc JSON diagnostics from
--error-format=jsonoutput.