Builder & Error Remapping
How Mist invokes cargo and remaps Rust compiler errors back to Mist source locations.
The builder module (builder.mist in the mist_api crate) wraps cargo to:
- Spawn
cargowith--message-format=json - Parse JSON compiler messages
- For each diagnostic span, look up the corresponding
.map.jsonfile - Remap Rust line/column to Mist line/column using the mapping
- Display errors/warnings with Mist source locations and context lines
pub fn build(args: Vec<String>, root: PathBuf) -> bool {
// Spawn cargo with JSON output
// Parse CompilerMessage for each span
// Look up rev_mapper::Mapping from .map.json
// Remap to Mist positions
// Print diagnostics
}Diagnostic Output
Errors and warnings are displayed with Mist source context:
src/main.mist:10:5
Error: mismatched types
let x: i32 = "hello";
^^^^^^^