Skip to main content

Module diagnostic

Module diagnostic 

Source
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 ErrorLOGOS 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 message

Structs§

DiagnosticBridge
Translates rustc diagnostics into user-friendly LOGOS error messages.
LogosError
A translated error message for LOGOS users.
RustcCode
Error code from rustc (e.g., “E0382”).
RustcDiagnostic
Rustc JSON diagnostic message (subset of fields we need).
RustcSpan
Source location information from a rustc diagnostic.
RustcSpanText
Source text with highlight range from a rustc diagnostic.

Enums§

RustcMessage
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.