Skip to content

Commit c8c8742

Browse files
committed
Nicer formatting for verifier errors during define_function
1 parent 1afce7c commit c8c8742

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/base.rs

+12
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,18 @@ pub(crate) fn compile_fn(
228228
name = codegened_func.symbol_name
229229
));
230230
}
231+
Err(ModuleError::Compilation(CodegenError::Verifier(err))) => {
232+
let early_dcx = rustc_session::EarlyDiagCtxt::new(
233+
rustc_session::config::ErrorOutputType::default(),
234+
);
235+
let _ = early_dcx.early_err(format!("{:?}", err));
236+
let pretty_error = cranelift_codegen::print_errors::pretty_verifier_error(
237+
&context.func,
238+
Some(Box::new(&clif_comments)),
239+
err,
240+
);
241+
early_dcx.early_fatal(format!("cranelift verify error:\n{}", pretty_error));
242+
}
231243
Err(err) => {
232244
panic!("Error while defining {name}: {err:?}", name = codegened_func.symbol_name);
233245
}

0 commit comments

Comments
 (0)