Function cranelift_codegen::write::decorate_function
source · pub fn decorate_function<FW: FuncWriter>(
func_w: &mut FW,
w: &mut dyn Write,
func: &Function
) -> ResultExpand description
Writes func to w as text.
write_function_plain is passed as ‘closure’ to print instructions as text.
pretty_function_error is passed as ‘closure’ to add error decoration.
Examples found in repository?
More examples
src/print_errors.rs (lines 26-30)
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
pub fn pretty_verifier_error<'a>(
func: &ir::Function,
func_w: Option<Box<dyn FuncWriter + 'a>>,
errors: VerifierErrors,
) -> String {
let mut errors = errors.0;
let mut w = String::new();
let num_errors = errors.len();
decorate_function(
&mut PrettyVerifierError(func_w.unwrap_or_else(|| Box::new(PlainWriter)), &mut errors),
&mut w,
func,
)
.unwrap();
writeln!(
w,
"\n; {} verifier error{} detected (see above). Compilation aborted.",
num_errors,
if num_errors == 1 { "" } else { "s" }
)
.unwrap();
w
}