Source
pub fn addBundleAsNotes(wip: *Wip, other: ErrorBundle) Allocator.Error!void {
const gpa = wip.gpa;
try wip.string_bytes.ensureUnusedCapacity(gpa, other.string_bytes.len);
try wip.extra.ensureUnusedCapacity(gpa, other.extra.len);
const other_list = other.getMessages();
// The ensureUnusedCapacity call above guarantees this.
const notes_start = wip.reserveNotes(@intCast(other_list.len)) catch unreachable;
for (notes_start.., other_list) |note, message| {
// This line can cause `wip.extra.items` to be resized.
const note_index = @intFromEnum(wip.addOtherMessage(other, message) catch unreachable);
wip.extra.items[note] = note_index;
}
}