Pretty-print a function verifier error for a given instruction.
(
w: &mut dyn Write,
func: &Function,
aliases: &SecondaryMap<Value, Vec<Value>>,
cur_inst: Inst,
indent: usize,
func_w: &mut dyn FuncWriter,
errors: &mut Vec<VerifierError>
| 115 | |
| 116 | /// Pretty-print a function verifier error for a given instruction. |
| 117 | fn pretty_instruction_error( |
| 118 | w: &mut dyn Write, |
| 119 | func: &Function, |
| 120 | aliases: &SecondaryMap<Value, Vec<Value>>, |
| 121 | cur_inst: Inst, |
| 122 | indent: usize, |
| 123 | func_w: &mut dyn FuncWriter, |
| 124 | errors: &mut Vec<VerifierError>, |
| 125 | ) -> fmt::Result { |
| 126 | let mut s = String::new(); |
| 127 | func_w.write_instruction(&mut s, func, aliases, cur_inst, indent)?; |
| 128 | write!(w, "{s}")?; |
| 129 | |
| 130 | // TODO: Use drain_filter here when it gets stabilized |
| 131 | let mut i = 0; |
| 132 | let mut printed_error = false; |
| 133 | while i != errors.len() { |
| 134 | match errors[i].location { |
| 135 | ir::entities::AnyEntity::Inst(inst) if inst == cur_inst => { |
| 136 | if !printed_error { |
| 137 | print_arrow(w, &s)?; |
| 138 | printed_error = true; |
| 139 | } |
| 140 | let err = errors.remove(i); |
| 141 | print_error(w, err)?; |
| 142 | } |
| 143 | _ => i += 1, |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | if printed_error { |
| 148 | w.write_char('\n')?; |
| 149 | } |
| 150 | |
| 151 | Ok(()) |
| 152 | } |
| 153 | |
| 154 | fn pretty_preamble_error( |
| 155 | w: &mut dyn Write, |
no test coverage detected