Expand description
Diagnostic bridge for translating Rust errors to LOGOS.
Translates Rust borrow checker errors into friendly LOGOS error messages
using Socratic phrasing. Parses rustc JSON output and maps errors back
to LOGOS source locations using the SourceMap.
§Supported Error Codes
| Rust Error | LOGOS Translation |
|---|---|
| E0382 | “Cannot use ‘x’ after giving it away” |
| E0505 | “Cannot borrow ‘x’ while it’s borrowed elsewhere” |
| E0597 | “Reference ‘x’ cannot escape zone” |
§Translation Flow
rustc --error-format=json
│
▼
┌─────────────────────┐
│ parse_rustc_json() │ Parse JSON diagnostics
└──────────┬──────────┘
▼
┌─────────────────────┐
│ translate_diagnostics│ Map to LOGOS source
└──────────┬──────────┘
▼
LogosError with friendly messageStructs§
- Diagnostic
Bridge - Translates rustc diagnostics into user-friendly LOGOS error messages.
- Logos
Error - A translated error message for LOGOS users.
- Rustc
Code - Error code from rustc (e.g., “E0382”).
- Rustc
Diagnostic - Rustc JSON diagnostic message (subset of fields we need).
- Rustc
Span - Source location information from a rustc diagnostic.
- Rustc
Span Text - Source text with highlight range from a rustc diagnostic.
Enums§
- Rustc
Message - Parsed rustc output: either a diagnostic or artifact info.
Functions§
- get_
error_ code - Extracts the error code (e.g., “E0382”) from a diagnostic.
- get_
primary_ span - Extracts the primary source span from a diagnostic.
- parse_
rustc_ json - Parse rustc stderr output from
cargo build --message-format=json. - translate_
diagnostics - Translates rustc diagnostics to LOGOS errors.
- translate_
diagnostics_ all - Translates EVERY rustc diagnostic that has a LOGOS reading.