Prefix verifier errors with ;
* Prefix verifier errors with ;
extract arrow drawing code into helper
print ; at beginning of line followed by arrow and error body
@@ -84,11 +84,7 @@ fn pretty_instruction_error(
printed_instr = true;
}
- write!(w, "{1:0$}^", indent, "")?;
- for _c in cur_inst.to_string().chars() {
- write!(w, "~")?;
- }
- writeln!(w, " verifier {}", err.to_string())?;
+ print_error(w, indent, cur_inst.to_string(), err)?;
}
ir::entities::AnyEntity::Inst(_) => i += 1,
_ => unreachable!(),
@@ -133,11 +129,7 @@ fn pretty_preamble_error(
printed_entity = true;
}
- write!(w, "{1:0$}^", indent, "")?;
- for _c in entity.to_string().chars() {
- write!(w, "~")?;
- }
- writeln!(w, " verifier {}", err.to_string())?;
+ print_error(w, indent, entity.to_string(), err)?;
} else {
i += 1
}
@@ -152,6 +144,18 @@ fn pretty_preamble_error(
Ok(())
}
+/// Prints ; ^~~~~~ verifier [ERROR BODY]
+fn print_error(w: &mut Write, indent: usize, s: String, err: VerifierError) -> fmt::Result {
+ let indent = if indent < 1 { 0 } else { indent - 1 };
+
+ write!(w, ";{1:0$}^", indent, "")?;
+ for _c in s.chars() {
+ write!(w, "~")?;
+ }
+ writeln!(w, " verifier {}", err.to_string())?;
+ Ok(())
+}
+
/// Pretty-print a Cranelift error.
pub fn pretty_error(func: &ir::Function, isa: Option<&TargetIsa>, err: CodegenError) -> String {
if let CodegenError::Verifier(e) = err {
