authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2023-09-04 01:36:22-07:00
committergravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2023-09-15 23:36:44-07:00
log8e35be0640998e1070cf892eaadc35fc71d64ead
tree8ec6fd4cd940b80ac4810d3ab465b415ae7dffb4
parentfc69529dab66254d353975844034dab545a7335b

ErrorBundle: rename addBundle to addBundleAsNotes, add addBundleAsRoots


2 files changed, 17 insertions(+), 2 deletions(-)

lib/std/zig/ErrorBundle.zig+16-1
......@@ -421,7 +421,7 @@ pub const Wip = struct {
421421 _ = try addExtra(wip, rt);
422422 }
423423
424 pub fn addBundle(wip: *Wip, other: ErrorBundle) !void {
424 pub fn addBundleAsNotes(wip: *Wip, other: ErrorBundle) !void {
425425 const gpa = wip.gpa;
426426
427427 try wip.string_bytes.ensureUnusedCapacity(gpa, other.string_bytes.len);
......@@ -436,6 +436,21 @@ pub const Wip = struct {
436436 }
437437 }
438438
439 pub fn addBundleAsRoots(wip: *Wip, other: ErrorBundle) !void {
440 const gpa = wip.gpa;
441
442 try wip.string_bytes.ensureUnusedCapacity(gpa, other.string_bytes.len);
443 try wip.extra.ensureUnusedCapacity(gpa, other.extra.len);
444
445 const other_list = other.getMessages();
446
447 try wip.root_list.ensureUnusedCapacity(gpa, other_list.len);
448 for (other_list) |other_msg| {
449 // The ensureUnusedCapacity calls above guarantees this.
450 wip.root_list.appendAssumeCapacity(wip.addOtherMessage(other, other_msg) catch unreachable);
451 }
452 }
453
439454 pub fn reserveNotes(wip: *Wip, notes_len: u32) !u32 {
440455 try wip.extra.ensureUnusedCapacity(wip.gpa, notes_len +
441456 notes_len * @typeInfo(ErrorBundle.ErrorMessage).Struct.fields.len);
src/Compilation.zig+1-1
......@@ -2683,7 +2683,7 @@ pub fn getAllErrorsAlloc(self: *Compilation) !ErrorBundle {
26832683 .msg = try bundle.addString(value.msg),
26842684 .notes_len = if (value.children) |b| b.errorMessageCount() else 0,
26852685 });
2686 if (value.children) |b| try bundle.addBundle(b);
2686 if (value.children) |b| try bundle.addBundleAsNotes(b);
26872687 }
26882688 if (self.alloc_failure_occurred) {
26892689 try bundle.addRootErrorMessage(.{