This commit is contained in:
2026-05-19 03:32:17 +02:00
parent eb84103ed6
commit e30722dde3
2 changed files with 41 additions and 13 deletions
+1 -1
View File
@@ -11,5 +11,5 @@ void main() {
// statistics::register(&mut app_instance); // statistics::register(&mut app_instance);
app_instance.boot(); app_instance.boot();
app_instance.rund(); app_instance.run();
} }
+30 -2
View File
@@ -20,6 +20,7 @@ pub struct MistDiagnosticMessage {
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum MistDiagnostic { pub enum MistDiagnostic {
Error(MistDiagnosticMessage), Error(MistDiagnosticMessage),
Warning(MistDiagnosticMessage),
} }
pub fn build( pub fn build(
@@ -51,6 +52,7 @@ pub fn build(
.or_insert_with(|| get_mapping(&fs::read_to_string(file_name).unwrap())); .or_insert_with(|| get_mapping(&fs::read_to_string(file_name).unwrap()));
for span in msg.message.spans { for span in msg.message.spans {
if span.is_primary {
let mist_span = let mist_span =
find_mapping(&map, &RustMap(span.line_end, span.column_start)).unwrap(); find_mapping(&map, &RustMap(span.line_end, span.column_start)).unwrap();
@@ -59,12 +61,25 @@ pub fn build(
.replacen(&config.output, &config.src, 1) .replacen(&config.output, &config.src, 1)
.replace(".rs", ".mist"); .replace(".rs", ".mist");
diagnostics.push(MistDiagnostic::Error(MistDiagnosticMessage { let mist_msg = MistDiagnosticMessage {
message: span.label.unwrap_or(msg.message.message.clone()), message: span.label.unwrap_or(msg.message.message.clone()),
src_path: mist_file, src_path: mist_file,
line: mist_span.1.0, line: mist_span.1.0,
column: mist_span.1.1, column: mist_span.1.1,
})); };
match msg.message.level {
cargo_metadata::diagnostic::DiagnosticLevel::Error => {
diagnostics.push(MistDiagnostic::Error(mist_msg))
}
cargo_metadata::diagnostic::DiagnosticLevel::Warning => {
diagnostics.push(MistDiagnostic::Warning(mist_msg))
}
_ => {}
}
}
} }
} }
@@ -99,6 +114,19 @@ pub fn print_diagnostics(diagnostics: Vec<MistDiagnostic>) {
line.unwrap_or_default(), line.unwrap_or_default(),
) )
} }
MistDiagnostic::Warning(msg) => {
let line = get_line(&mut files, &msg);
println!(
"\n{}:{}:{}\n \x1b[33mWarning\x1b[0m: {}\n\t{}",
msg.src_path,
msg.line + 1,
msg.column,
msg.message,
line.unwrap_or_default(),
)
}
} }
} }
} }