mirror of
https://github.com/ziglang/zig.git
synced 2026-01-21 23:05:24 +00:00
ErrorBundle: rename addBundle to addBundleAsNotes, add addBundleAsRoots
This commit is contained in:
parent
fc69529dab
commit
8e35be0640
@ -421,7 +421,7 @@ pub const Wip = struct {
|
||||
_ = try addExtra(wip, rt);
|
||||
}
|
||||
|
||||
pub fn addBundle(wip: *Wip, other: ErrorBundle) !void {
|
||||
pub fn addBundleAsNotes(wip: *Wip, other: ErrorBundle) !void {
|
||||
const gpa = wip.gpa;
|
||||
|
||||
try wip.string_bytes.ensureUnusedCapacity(gpa, other.string_bytes.len);
|
||||
@ -436,6 +436,21 @@ pub const Wip = struct {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn addBundleAsRoots(wip: *Wip, other: ErrorBundle) !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();
|
||||
|
||||
try wip.root_list.ensureUnusedCapacity(gpa, other_list.len);
|
||||
for (other_list) |other_msg| {
|
||||
// The ensureUnusedCapacity calls above guarantees this.
|
||||
wip.root_list.appendAssumeCapacity(wip.addOtherMessage(other, other_msg) catch unreachable);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn reserveNotes(wip: *Wip, notes_len: u32) !u32 {
|
||||
try wip.extra.ensureUnusedCapacity(wip.gpa, notes_len +
|
||||
notes_len * @typeInfo(ErrorBundle.ErrorMessage).Struct.fields.len);
|
||||
|
||||
@ -2683,7 +2683,7 @@ pub fn getAllErrorsAlloc(self: *Compilation) !ErrorBundle {
|
||||
.msg = try bundle.addString(value.msg),
|
||||
.notes_len = if (value.children) |b| b.errorMessageCount() else 0,
|
||||
});
|
||||
if (value.children) |b| try bundle.addBundle(b);
|
||||
if (value.children) |b| try bundle.addBundleAsNotes(b);
|
||||
}
|
||||
if (self.alloc_failure_occurred) {
|
||||
try bundle.addRootErrorMessage(.{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user