aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authorRyan Liptak <squeek502@hotmail.com>2023-09-04 01:36:22 -0700
committerRyan Liptak <squeek502@hotmail.com>2023-09-15 23:36:44 -0700
commit8e35be0640998e1070cf892eaadc35fc71d64ead (patch)
tree8ec6fd4cd940b80ac4810d3ab465b415ae7dffb4 /lib/std
parentfc69529dab66254d353975844034dab545a7335b (diff)
downloadzig-8e35be0640998e1070cf892eaadc35fc71d64ead.tar.gz
zig-8e35be0640998e1070cf892eaadc35fc71d64ead.zip
ErrorBundle: rename addBundle to addBundleAsNotes, add addBundleAsRoots
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/zig/ErrorBundle.zig17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/std/zig/ErrorBundle.zig b/lib/std/zig/ErrorBundle.zig
index 31a706b8e4..141cdb1195 100644
--- a/lib/std/zig/ErrorBundle.zig
+++ b/lib/std/zig/ErrorBundle.zig
@@ -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);