Pretty-print a verifier error.
(
func: &ir::Function,
func_w: Option<Box<dyn FuncWriter + 'a>>,
errors: VerifierErrors,
)
| 15 | |
| 16 | /// Pretty-print a verifier error. |
| 17 | pub fn pretty_verifier_error<'a>( |
| 18 | func: &ir::Function, |
| 19 | func_w: Option<Box<dyn FuncWriter + 'a>>, |
| 20 | errors: VerifierErrors, |
| 21 | ) -> String { |
| 22 | let mut errors = errors.0; |
| 23 | let mut w = String::new(); |
| 24 | let num_errors = errors.len(); |
| 25 | |
| 26 | decorate_function( |
| 27 | &mut PrettyVerifierError(func_w.unwrap_or_else(|| Box::new(PlainWriter)), &mut errors), |
| 28 | &mut w, |
| 29 | func, |
| 30 | ) |
| 31 | .unwrap(); |
| 32 | |
| 33 | writeln!( |
| 34 | w, |
| 35 | "\n; {} verifier error{} detected (see above). Compilation aborted.", |
| 36 | num_errors, |
| 37 | if num_errors == 1 { "" } else { "s" } |
| 38 | ) |
| 39 | .unwrap(); |
| 40 | |
| 41 | w |
| 42 | } |
| 43 | |
| 44 | struct PrettyVerifierError<'a>(Box<dyn FuncWriter + 'a>, &'a mut Vec<VerifierError>); |
| 45 |