authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-06-17 03:22:16-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-07-01 16:35:29-07:00
loga249cc1c7e5d9ac580d8f0cace9c7e3bfffffe57
tree3e012a2f1aa6842eae671537c8644b9b7240fcc0
parentef8d7aa25110699aa5ba9d4e0825155faa8c4319

update std.io.AllocatingWriter to new API


44 files changed, 181 insertions(+), 237 deletions(-)

lib/docs/wasm/Walk.zig+2-2
......@@ -444,9 +444,9 @@ fn parse(file_name: []const u8, source: []u8) Oom!Ast {
444444 const err_loc = std.zig.findLineColumn(ast.source, err_offset);
445445 rendered_err.clearRetainingCapacity();
446446 {
447 var aw: std.io.AllocatingWriter = undefined;
447 var aw: std.io.Writer.Allocating = .fromArrayList(gpa, &rendered_err);
448448 defer rendered_err = aw.toArrayList();
449 ast.renderError(err, aw.fromArrayList(gpa, &rendered_err)) catch |e| switch (e) {
449 ast.renderError(err, &aw.interface) catch |e| switch (e) {
450450 error.WriteFailed => return error.OutOfMemory,
451451 };
452452 }
lib/docs/wasm/main.zig+2-2
......@@ -733,9 +733,9 @@ fn render_docs(
733733 }
734734 }.render,
735735 };
736 var aw: std.io.AllocatingWriter = undefined;
736 var aw: std.io.Writer.Allocating = .fromArrayList(gpa, out);
737737 defer out.* = aw.toArrayList();
738 render.render(parsed_doc, aw.fromArrayList(gpa, out)) catch |err| switch (err) {
738 render.render(parsed_doc, &aw.interface) catch |err| switch (err) {
739739 error.WriteFailed => return error.OutOfMemory,
740740 };
741741}
lib/std/Build/Step/CheckObject.zig+8-12
......@@ -1592,10 +1592,9 @@ const MachODumper = struct {
15921592 var ctx = ObjectContext{ .gpa = gpa, .data = bytes, .header = hdr };
15931593 try ctx.parse();
15941594
1595 var aw: std.io.AllocatingWriter = undefined;
1596 aw.init(gpa);
1595 var aw: std.io.Writer.Allocating = .init(gpa);
15971596 defer aw.deinit();
1598 const bw = &aw.buffered_writer;
1597 const bw = &aw.interface;
15991598
16001599 switch (check.kind) {
16011600 .headers => {
......@@ -1746,10 +1745,9 @@ const ElfDumper = struct {
17461745 });
17471746 }
17481747
1749 var aw: std.io.AllocatingWriter = undefined;
1750 aw.init(gpa);
1748 var aw: std.io.Writer.Allocating = .init(gpa);
17511749 defer aw.deinit();
1752 const bw = &aw.buffered_writer;
1750 const bw = &aw.interface;
17531751
17541752 switch (check.kind) {
17551753 .archive_symtab => if (ctx.symtab.len > 0) {
......@@ -1894,10 +1892,9 @@ const ElfDumper = struct {
18941892 else => {},
18951893 };
18961894
1897 var aw: std.io.AllocatingWriter = undefined;
1898 aw.init(gpa);
1895 var aw: std.io.Writer.Allocating = .init(gpa);
18991896 defer aw.deinit();
1900 const bw = &aw.buffered_writer;
1897 const bw = &aw.interface;
19011898
19021899 switch (check.kind) {
19031900 .headers => {
......@@ -2355,10 +2352,9 @@ const WasmDumper = struct {
23552352 if (!mem.eql(u8, buf[0..4], &std.wasm.magic)) return error.InvalidMagicByte;
23562353 if (!mem.eql(u8, buf[4..8], &std.wasm.version)) return error.UnsupportedWasmVersion;
23572354
2358 var aw: std.io.AllocatingWriter = undefined;
2359 aw.init(gpa);
2355 var aw: std.io.Writer.Allocating = .init(gpa);
23602356 defer aw.deinit();
2361 const bw = &aw.buffered_writer;
2357 const bw = &aw.interface;
23622358
23632359 parseAndDumpInner(step, check, &br, bw) catch |err| switch (err) {
23642360 error.EndOfStream => try bw.writeAll("\n<UnexpectedEndOfStream>"),
lib/std/Build/Step/Compile.zig+2-3
......@@ -1969,14 +1969,13 @@ fn checkCompileErrors(compile: *Compile) !void {
19691969 const arena = compile.step.owner.allocator;
19701970
19711971 const actual_errors = ae: {
1972 var aw: std.io.AllocatingWriter = undefined;
1973 aw.init(arena);
1972 var aw: std.io.Writer.Allocating = .init(arena);
19741973 defer aw.deinit();
19751974 try actual_eb.renderToWriter(.{
19761975 .ttyconf = .no_color,
19771976 .include_reference_trace = false,
19781977 .include_source_line = false,
1979 }, &aw.buffered_writer);
1978 }, &aw.interface);
19801979 break :ae try aw.toOwnedSlice();
19811980 };
19821981
lib/std/Build/Step/ConfigHeader.zig+4-5
......@@ -196,10 +196,9 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
196196 man.hash.addBytes(config_header.include_path);
197197 man.hash.addOptionalBytes(config_header.include_guard_override);
198198
199 var aw: std.io.AllocatingWriter = undefined;
200 aw.init(gpa);
199 var aw: std.io.Writer.Allocating = .init(gpa);
201200 defer aw.deinit();
202 const bw = &aw.buffered_writer;
201 const bw = &aw.interface;
203202
204203 const header_text = "This file was generated by ConfigHeader using the Zig Build System.";
205204 const c_generated_line = "/* " ++ header_text ++ " */\n";
......@@ -330,13 +329,13 @@ fn render_autoconf_undef(
330329fn render_autoconf_at(
331330 step: *Step,
332331 contents: []const u8,
333 aw: *std.io.AllocatingWriter,
332 aw: *std.io.Writer.Allocating,
334333 values: std.StringArrayHashMap(Value),
335334 src_path: []const u8,
336335) !void {
337336 const build = step.owner;
338337 const allocator = build.allocator;
339 const bw = &aw.buffered_writer;
338 const bw = &aw.interface;
340339
341340 const used = allocator.alloc(bool, values.count()) catch @panic("OOM");
342341 for (used) |*u| u.* = false;
lib/std/array_list.zig+1-1
......@@ -905,7 +905,7 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?mem.Alig
905905 pub fn print(self: *Self, gpa: Allocator, comptime fmt: []const u8, args: anytype) error{OutOfMemory}!void {
906906 comptime assert(T == u8);
907907 try self.ensureUnusedCapacity(gpa, fmt.len);
908 var aw: std.io.AllocatingWriter = .fromArrayList(gpa, self);
908 var aw: std.io.Writer.Allocating = .fromArrayList(gpa, self);
909909 defer self.* = aw.toArrayList();
910910 return aw.interface.print(fmt, args) catch |err| switch (err) {
911911 error.WriteFailed => return error.OutOfMemory,
lib/std/compress/flate.zig+2-3
......@@ -341,11 +341,10 @@ test "compress/decompress" {
341341
342342fn testDecompress(comptime container: Container, compressed: []const u8, expected_plain: []const u8) !void {
343343 var in: std.io.Reader = .fixed(compressed);
344 var out: std.io.AllocatingWriter = undefined;
345 out.init(testing.allocator);
344 var out: std.io.Writer.Allocating = .init(testing.allocator);
346345 defer out.deinit();
347346
348 try Decompress.pump(container, &in, &out.buffered_writer);
347 try Decompress.pump(container, &in, &out.interface);
349348 try testing.expectEqualSlices(u8, expected_plain, out.items);
350349}
351350
lib/std/compress/flate/Decompress.zig+11-16
......@@ -729,13 +729,12 @@ test "decompress" {
729729 };
730730 for (cases) |c| {
731731 var fb: std.io.Reader = .fixed(c.in);
732 var aw: std.io.AllocatingWriter = undefined;
733 aw.init(testing.allocator);
732 var aw: std.io.Writer.Allocating = .init(testing.allocator);
734733 defer aw.deinit();
735734
736735 var decompress: Decompress = .init(&fb, .raw);
737736 var decompress_br = decompress.readable(&.{});
738 _ = try decompress_br.readRemaining(&aw.buffered_writer);
737 _ = try decompress_br.readRemaining(&aw.interface);
739738 try testing.expectEqualStrings(c.out, aw.getWritten());
740739 }
741740}
......@@ -789,13 +788,12 @@ test "gzip decompress" {
789788 };
790789 for (cases) |c| {
791790 var fb: std.io.Reader = .fixed(c.in);
792 var aw: std.io.AllocatingWriter = undefined;
793 aw.init(testing.allocator);
791 var aw: std.io.Writer.Allocating = .init(testing.allocator);
794792 defer aw.deinit();
795793
796794 var decompress: Decompress = .init(&fb, .gzip);
797795 var decompress_br = decompress.readable(&.{});
798 _ = try decompress_br.readRemaining(&aw.buffered_writer);
796 _ = try decompress_br.readRemaining(&aw.interface);
799797 try testing.expectEqualStrings(c.out, aw.getWritten());
800798 }
801799}
......@@ -818,13 +816,12 @@ test "zlib decompress" {
818816 };
819817 for (cases) |c| {
820818 var fb: std.io.Reader = .fixed(c.in);
821 var aw: std.io.AllocatingWriter = undefined;
822 aw.init(testing.allocator);
819 var aw: std.io.Writer.Allocating = .init(testing.allocator);
823820 defer aw.deinit();
824821
825822 var decompress: Decompress = .init(&fb, .zlib);
826823 var decompress_br = decompress.readable(&.{});
827 _ = try decompress_br.readRemaining(&aw.buffered_writer);
824 _ = try decompress_br.readRemaining(&aw.interface);
828825 try testing.expectEqualStrings(c.out, aw.getWritten());
829826 }
830827}
......@@ -879,18 +876,17 @@ test "fuzzing tests" {
879876
880877 inline for (cases, 0..) |c, case_no| {
881878 var in: std.io.Reader = .fixed(@embedFile("testdata/fuzz/" ++ c.input ++ ".input"));
882 var aw: std.io.AllocatingWriter = undefined;
883 aw.init(testing.allocator);
879 var aw: std.io.Writer.Allocating = .init(testing.allocator);
884880 defer aw.deinit();
885881 errdefer std.debug.print("test case failed {}\n", .{case_no});
886882
887883 var decompress: Decompress = .init(&in, .raw);
888884 var decompress_br = decompress.readable(&.{});
889885 if (c.err) |expected_err| {
890 try testing.expectError(error.ReadFailed, decompress_br.readRemaining(&aw.buffered_writer));
886 try testing.expectError(error.ReadFailed, decompress_br.readRemaining(&aw.interface));
891887 try testing.expectError(expected_err, decompress.read_err.?);
892888 } else {
893 _ = try decompress_br.readRemaining(&aw.buffered_writer);
889 _ = try decompress_br.readRemaining(&aw.interface);
894890 try testing.expectEqualStrings(c.out, aw.getWritten());
895891 }
896892 }
......@@ -901,13 +897,12 @@ test "bug 18966" {
901897 const expect = @embedFile("testdata/fuzz/bug_18966.expect");
902898
903899 var in: std.io.Reader = .fixed(input);
904 var aw: std.io.AllocatingWriter = undefined;
905 aw.init(testing.allocator);
900 var aw: std.io.Writer.Allocating = .init(testing.allocator);
906901 defer aw.deinit();
907902
908903 var decompress: Decompress = .init(&in, .gzip);
909904 var decompress_br = decompress.readable(&.{});
910 _ = try decompress_br.readRemaining(&aw.buffered_writer);
905 _ = try decompress_br.readRemaining(&aw.interface);
911906 try testing.expectEqualStrings(expect, aw.getWritten());
912907}
913908
lib/std/compress/lzma2.zig+2-3
......@@ -278,9 +278,8 @@ test decompress {
278278 0x00, 0x06, 0x57, 0x6F, 0x72, 0x6C, 0x64, 0x21, 0x0A, 0x00,
279279 };
280280 var stream: std.io.Reader = .fixed(&compressed);
281 var decomp: std.io.AllocatingWriter = undefined;
282 const decomp_bw = decomp.init(std.testing.allocator);
281 var decomp: std.io.Writer.Allocating = .init(std.testing.allocator);
283282 defer decomp.deinit();
284 try decompress(std.testing.allocator, &stream, decomp_bw);
283 try decompress(std.testing.allocator, &stream, &decomp.interface);
285284 try std.testing.expectEqualSlices(u8, expected, decomp.getWritten());
286285}
lib/std/debug.zig+2-3
......@@ -304,11 +304,10 @@ pub fn dumpHexFallible(bw: *Writer, ttyconf: std.io.tty.Config, bytes: []const u
304304
305305test dumpHexFallible {
306306 const bytes: []const u8 = &.{ 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x01, 0x12, 0x13 };
307 var aw: std.io.AllocatingWriter = undefined;
308 var bw = aw.init(std.testing.allocator);
307 var aw: std.io.Writer.Allocating = .init(std.testing.allocator);
309308 defer aw.deinit();
310309
311 try dumpHexFallible(&bw, .no_color, bytes);
310 try dumpHexFallible(&aw.interface, .no_color, bytes);
312311 const expected = try std.fmt.allocPrint(std.testing.allocator,
313312 \\{x:0>[2]} 00 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF .."3DUfw........
314313 \\{x:0>[2]} 01 12 13 ...
lib/std/fmt.zig+4-6
......@@ -853,10 +853,9 @@ pub fn count(comptime fmt: []const u8, args: anytype) usize {
853853}
854854
855855pub fn allocPrint(gpa: Allocator, comptime fmt: []const u8, args: anytype) Allocator.Error![]u8 {
856 var aw: std.io.AllocatingWriter = undefined;
857 try aw.initCapacity(gpa, fmt.len);
856 var aw = try std.io.Writer.Allocating.initCapacity(gpa, fmt.len);
858857 defer aw.deinit();
859 aw.buffered_writer.print(fmt, args) catch |err| switch (err) {
858 aw.interface.print(fmt, args) catch |err| switch (err) {
860859 error.WriteFailed => return error.OutOfMemory,
861860 };
862861 return aw.toOwnedSlice();
......@@ -868,10 +867,9 @@ pub fn allocPrintSentinel(
868867 args: anytype,
869868 comptime sentinel: u8,
870869) Allocator.Error![:sentinel]u8 {
871 var aw: std.io.AllocatingWriter = undefined;
872 try aw.initCapacity(gpa, fmt.len);
870 var aw = try std.io.Writer.Allocating.initCapacity(gpa, fmt.len);
873871 defer aw.deinit();
874 aw.buffered_writer.print(fmt, args) catch |err| switch (err) {
872 aw.interface.print(fmt, args) catch |err| switch (err) {
875873 error.WriteFailed => return error.OutOfMemory,
876874 };
877875 return aw.toOwnedSliceSentinel(sentinel);
lib/std/json.zig+2-2
......@@ -42,9 +42,9 @@ test Value {
4242}
4343
4444test Stringify {
45 var out: std.io.AllocatingWriter = undefined;
45 var out: std.io.Writer.Allocating = .init(testing.allocator);
4646 var write_stream: Stringify = .{
47 .writer = out.init(testing.allocator),
47 .writer = &out.interface,
4848 .options = .{ .whitespace = .indent_2 },
4949 };
5050 defer out.deinit();
lib/std/json/Stringify.zig+4-4
......@@ -576,8 +576,8 @@ pub fn value(v: anytype, options: Options, writer: *Writer) Error!void {
576576}
577577
578578test value {
579 var out: std.io.AllocatingWriter = undefined;
580 const writer = out.init(std.testing.allocator);
579 var out: std.io.Writer.Allocating = .init(std.testing.allocator);
580 const writer = &out.interface;
581581 defer out.deinit();
582582
583583 const T = struct { a: i32, b: []const u8 };
......@@ -616,8 +616,8 @@ test value {
616616///
617617/// Caller owns returned memory.
618618pub fn valueAlloc(gpa: Allocator, v: anytype, options: Options) error{OutOfMemory}![]u8 {
619 var aw: std.io.AllocatingWriter = undefined;
620 const writer = aw.init(gpa);
619 var aw: std.io.Writer.Allocating = .init(gpa);
620 const writer = &aw.interface;
621621 defer aw.deinit();
622622 value(v, options, writer) catch return error.OutOfMemory;
623623 return aw.toOwnedSlice();
lib/std/tar/Writer.zig+4-5
......@@ -433,8 +433,8 @@ test "write files" {
433433 {
434434 const root = "root";
435435
436 var output: std.io.AllocatingWriter = .init(testing.allocator);
437 var wrt: Writer = .{ .underlying_writer = &output.buffered_writer };
436 var output: std.io.Writer.Allocating = .init(testing.allocator);
437 var wrt: Writer = .{ .underlying_writer = &output.interface };
438438 defer output.deinit();
439439 try wrt.setRoot(root);
440440 for (files) |file|
......@@ -469,9 +469,8 @@ test "write files" {
469469 }
470470 // without root
471471 {
472 var output: std.io.AllocatingWriter = undefined;
473 output.init(testing.allocator);
474 var wrt: Writer = .{ .underlying_writer = &output.buffered_writer };
472 var output: std.io.Writer.Allocating = .init(testing.allocator);
473 var wrt: Writer = .{ .underlying_writer = &output.interface };
475474 defer output.deinit();
476475 for (files) |file| {
477476 var content: std.io.Reader = .fixed(file.content);
lib/std/zig/Ast.zig+2-3
......@@ -204,10 +204,9 @@ pub fn parse(gpa: Allocator, source: [:0]const u8, mode: Mode) Allocator.Error!A
204204/// `gpa` is used for allocating the resulting formatted source code.
205205/// Caller owns the returned slice of bytes, allocated with `gpa`.
206206pub fn renderAlloc(tree: Ast, gpa: Allocator) error{OutOfMemory}![]u8 {
207 var aw: std.io.AllocatingWriter = undefined;
208 const bw = aw.init(gpa);
207 var aw: std.io.Writer.Allocating = .init(gpa);
209208 errdefer aw.deinit();
210 render(tree, gpa, bw, .{}) catch |err| switch (err) {
209 render(tree, gpa, &aw.interface, .{}) catch |err| switch (err) {
211210 error.WriteFailed => return error.OutOfMemory,
212211 };
213212 return aw.toOwnedSlice();
lib/std/zig/Ast/Render.zig+2-3
......@@ -2142,14 +2142,13 @@ fn renderArrayInit(
21422142
21432143 const section_exprs = row_exprs[0..section_end];
21442144
2145 var sub_expr_buffer: std.io.AllocatingWriter = undefined;
2146 sub_expr_buffer.init(gpa);
2145 var sub_expr_buffer: std.io.Writer.Allocating = .init(gpa);
21472146 defer sub_expr_buffer.deinit();
21482147
21492148 const sub_expr_buffer_starts = try gpa.alloc(usize, section_exprs.len + 1);
21502149 defer gpa.free(sub_expr_buffer_starts);
21512150
2152 var auto_indenting_stream: AutoIndentingStream = .init(gpa, &sub_expr_buffer.buffered_writer, indent_delta);
2151 var auto_indenting_stream: AutoIndentingStream = .init(gpa, &sub_expr_buffer.interface, indent_delta);
21532152 defer auto_indenting_stream.deinit();
21542153 var sub_render: Render = .{
21552154 .gpa = r.gpa,
lib/std/zig/AstGen.zig+4-6
......@@ -11442,10 +11442,9 @@ fn parseStrLit(
1144211442) InnerError!void {
1144311443 const raw_string = bytes[offset..];
1144411444 const result = r: {
11445 var aw: std.io.AllocatingWriter = undefined;
11446 const bw = aw.fromArrayList(astgen.gpa, buf);
11445 var aw: std.io.Writer.Allocating = .fromArrayList(astgen.gpa, buf);
1144711446 defer buf.* = aw.toArrayList();
11448 break :r std.zig.string_literal.parseWrite(bw, raw_string) catch |err| switch (err) {
11447 break :r std.zig.string_literal.parseWrite(&aw.interface, raw_string) catch |err| switch (err) {
1144911448 error.WriteFailed => return error.OutOfMemory,
1145011449 };
1145111450 };
......@@ -13899,10 +13898,9 @@ fn lowerAstErrors(astgen: *AstGen) error{OutOfMemory}!void {
1389913898 const tree = astgen.tree;
1390013899 assert(tree.errors.len > 0);
1390113900
13902 var msg: std.io.AllocatingWriter = undefined;
13903 msg.init(gpa);
13901 var msg: std.io.Writer.Allocating = .init(gpa);
1390413902 defer msg.deinit();
13905 const msg_bw = &msg.buffered_writer;
13903 const msg_bw = &msg.interface;
1390613904
1390713905 var notes: std.ArrayListUnmanaged(u32) = .empty;
1390813906 defer notes.deinit(gpa);
lib/std/zig/ErrorBundle.zig+4-4
......@@ -788,8 +788,8 @@ pub const Wip = struct {
788788
789789 const ttyconf: std.io.tty.Config = .no_color;
790790
791 var bundle_buf: std.io.AllocatingWriter = undefined;
792 const bundle_bw = bundle_buf.init(std.testing.allocator);
791 var bundle_buf: std.io.Writer.Allocating = .init(std.testing.allocator);
792 const bundle_bw = &bundle_buf.interface;
793793 defer bundle_buf.deinit();
794794 try bundle.renderToWriter(.{ .ttyconf = ttyconf }, bundle_bw);
795795
......@@ -804,8 +804,8 @@ pub const Wip = struct {
804804 };
805805 defer copy.deinit(std.testing.allocator);
806806
807 var copy_buf: std.io.AllocatingWriter = undefined;
808 const copy_bw = copy_buf.init(std.testing.allocator);
807 var copy_buf: std.io.Writer.Allocating = .init(std.testing.allocator);
808 const copy_bw = &copy_buf.interface;
809809 defer copy_buf.deinit();
810810 try copy.renderToWriter(.{ .ttyconf = ttyconf }, copy_bw);
811811
lib/std/zig/ZonGen.zig+6-9
......@@ -467,10 +467,9 @@ fn appendIdentStr(zg: *ZonGen, ident_token: Ast.TokenIndex) error{ OutOfMemory,
467467 const raw_string = zg.tree.tokenSlice(ident_token)[offset..];
468468 try zg.string_bytes.ensureUnusedCapacity(gpa, raw_string.len);
469469 const result = r: {
470 var aw: std.io.AllocatingWriter = undefined;
471 const bw = aw.fromArrayList(gpa, &zg.string_bytes);
470 var aw: std.io.Writer.Allocating = .fromArrayList(gpa, &zg.string_bytes);
472471 defer zg.string_bytes = aw.toArrayList();
473 break :r std.zig.string_literal.parseWrite(bw, raw_string) catch |err| switch (err) {
472 break :r std.zig.string_literal.parseWrite(&aw.interface, raw_string) catch |err| switch (err) {
474473 error.WriteFailed => return error.OutOfMemory,
475474 };
476475 };
......@@ -566,10 +565,9 @@ fn strLitAsString(zg: *ZonGen, str_node: Ast.Node.Index) error{ OutOfMemory, Bad
566565 const size_hint = strLitSizeHint(zg.tree, str_node);
567566 try string_bytes.ensureUnusedCapacity(gpa, size_hint);
568567 const result = r: {
569 var aw: std.io.AllocatingWriter = undefined;
570 const bw = aw.fromArrayList(gpa, &zg.string_bytes);
568 var aw: std.io.Writer.Allocating = .fromArrayList(gpa, &zg.string_bytes);
571569 defer zg.string_bytes = aw.toArrayList();
572 break :r parseStrLit(zg.tree, str_node, bw) catch |err| switch (err) {
570 break :r parseStrLit(zg.tree, str_node, &aw.interface) catch |err| switch (err) {
573571 error.WriteFailed => return error.OutOfMemory,
574572 };
575573 };
......@@ -888,10 +886,9 @@ fn lowerAstErrors(zg: *ZonGen) Allocator.Error!void {
888886 const tree = zg.tree;
889887 assert(tree.errors.len > 0);
890888
891 var msg: std.io.AllocatingWriter = undefined;
892 msg.init(gpa);
889 var msg: std.io.Writer.Allocating = .init(gpa);
893890 defer msg.deinit();
894 const msg_bw = &msg.buffered_writer;
891 const msg_bw = &msg.interface;
895892
896893 var notes: std.ArrayListUnmanaged(Zoir.CompileError.Note) = .empty;
897894 defer notes.deinit(gpa);
lib/std/zig/llvm/Builder.zig+3-12
......@@ -8619,16 +8619,7 @@ pub fn deinit(self: *Builder) void {
86198619 self.* = undefined;
86208620}
86218621
8622pub fn setModuleAsm(self: *Builder, aw: *std.io.AllocatingWriter) *Writer {
8623 self.module_asm.clearRetainingCapacity();
8624 return self.appendModuleAsm(aw);
8625}
8626
8627pub fn appendModuleAsm(self: *Builder, aw: *std.io.AllocatingWriter) *Writer {
8628 return aw.fromArrayList(self.gpa, &self.module_asm);
8629}
8630
8631pub fn finishModuleAsm(self: *Builder, aw: *std.io.AllocatingWriter) Allocator.Error!void {
8622pub fn finishModuleAsm(self: *Builder, aw: *std.io.Writer.Allocating) Allocator.Error!void {
86328623 self.module_asm = aw.toArrayList();
86338624 if (self.module_asm.getLastOrNull()) |last| if (last != '\n')
86348625 try self.module_asm.append(self.gpa, '\n');
......@@ -8938,8 +8929,8 @@ pub fn getIntrinsic(
89388929
89398930 const name = name: {
89408931 {
8941 var aw: std.io.AllocatingWriter = undefined;
8942 const bw = aw.fromArrayList(self.gpa, &self.strtab_string_bytes);
8932 var aw: std.io.Writer.Allocating = .fromArrayList(self.gpa, &self.strtab_string_bytes);
8933 const bw = &aw.interface;
89438934 defer self.strtab_string_bytes = aw.toArrayList();
89448935 bw.print("llvm.{s}", .{@tagName(id)}) catch return error.OutOfMemory;
89458936 for (overload) |ty| bw.print(".{fm}", .{ty.fmt(self)}) catch return error.OutOfMemory;
lib/std/zig/string_literal.zig+2-3
......@@ -358,10 +358,9 @@ pub fn parseWrite(writer: *Writer, bytes: []const u8) Writer.Error!Result {
358358/// Higher level API. Does not return extra info about parse errors.
359359/// Caller owns returned memory.
360360pub fn parseAlloc(allocator: std.mem.Allocator, bytes: []const u8) ParseError![]u8 {
361 var aw: std.io.AllocatingWriter = undefined;
362 aw.init(allocator);
361 var aw: std.io.Writer.Allocating = .init(allocator);
363362 defer aw.deinit();
364 const result = parseWrite(&aw.buffered_writer, bytes) catch |err| switch (err) {
363 const result = parseWrite(&aw.interface, bytes) catch |err| switch (err) {
365364 error.WriteFailed => return error.OutOfMemory,
366365 };
367366 switch (result) {
lib/std/zon/parse.zig+2-3
......@@ -638,10 +638,9 @@ const Parser = struct {
638638 if (pointer.sentinel() != null) size_hint += 1;
639639 const gpa = self.gpa;
640640
641 var aw: std.io.AllocatingWriter = undefined;
642 try aw.initCapacity(gpa, size_hint);
641 var aw = try std.io.Writer.Allocating.initCapacity(gpa, size_hint);
643642 defer aw.deinit();
644 const parsed = ZonGen.parseStrLit(self.ast, ast_node, &aw.buffered_writer) catch |err| switch (err) {
643 const parsed = ZonGen.parseStrLit(self.ast, ast_node, &aw.interface) catch |err| switch (err) {
645644 error.WriteFailed => return error.OutOfMemory,
646645 };
647646 switch (parsed) {
lib/std/zon/stringify.zig+20-30
......@@ -1054,9 +1054,8 @@ fn expectSerializeEqual(
10541054 value: anytype,
10551055 options: SerializeOptions,
10561056) !void {
1057 var aw: std.io.AllocatingWriter = undefined;
1058 aw.init(std.testing.allocator);
1059 const bw = &aw.buffered_writer;
1057 var aw: std.io.Writer.Allocating = .init(std.testing.allocator);
1058 const bw = &aw.interface;
10601059 defer aw.deinit();
10611060
10621061 try serialize(value, options, bw);
......@@ -1157,9 +1156,8 @@ test "std.zon stringify whitespace, high level API" {
11571156}
11581157
11591158test "std.zon stringify whitespace, low level API" {
1160 var aw: std.io.AllocatingWriter = undefined;
1161 aw.init(std.testing.allocator);
1162 var s: Serializer = .{ .writer = &aw.buffered_writer };
1159 var aw: std.io.Writer.Allocating = .init(std.testing.allocator);
1160 var s: Serializer = .{ .writer = &aw.interface };
11631161 defer aw.deinit();
11641162
11651163 for ([2]bool{ true, false }) |whitespace| {
......@@ -1515,9 +1513,8 @@ test "std.zon stringify whitespace, low level API" {
15151513}
15161514
15171515test "std.zon stringify utf8 codepoints" {
1518 var aw: std.io.AllocatingWriter = undefined;
1519 aw.init(std.testing.allocator);
1520 var s: Serializer = .{ .writer = &aw.buffered_writer };
1516 var aw: std.io.Writer.Allocating = .init(std.testing.allocator);
1517 var s: Serializer = .{ .writer = &aw.interface };
15211518 defer aw.deinit();
15221519
15231520 // Printable ASCII
......@@ -1626,9 +1623,8 @@ test "std.zon stringify utf8 codepoints" {
16261623}
16271624
16281625test "std.zon stringify strings" {
1629 var aw: std.io.AllocatingWriter = undefined;
1630 aw.init(std.testing.allocator);
1631 var s: Serializer = .{ .writer = &aw.buffered_writer };
1626 var aw: std.io.Writer.Allocating = .init(std.testing.allocator);
1627 var s: Serializer = .{ .writer = &aw.interface };
16321628 defer aw.deinit();
16331629
16341630 // Minimal case
......@@ -1697,9 +1693,8 @@ test "std.zon stringify strings" {
16971693}
16981694
16991695test "std.zon stringify multiline strings" {
1700 var aw: std.io.AllocatingWriter = undefined;
1701 aw.init(std.testing.allocator);
1702 var s: Serializer = .{ .writer = &aw.buffered_writer };
1696 var aw: std.io.Writer.Allocating = .init(std.testing.allocator);
1697 var s: Serializer = .{ .writer = &aw.interface };
17031698 defer aw.deinit();
17041699
17051700 inline for (.{ true, false }) |whitespace| {
......@@ -1918,9 +1913,8 @@ test "std.zon stringify skip default fields" {
19181913}
19191914
19201915test "std.zon depth limits" {
1921 var aw: std.io.AllocatingWriter = undefined;
1922 aw.init(std.testing.allocator);
1923 const bw = &aw.buffered_writer;
1916 var aw: std.io.Writer.Allocating = .init(std.testing.allocator);
1917 const bw = &aw.interface;
19241918 defer aw.deinit();
19251919
19261920 const Recurse = struct { r: []const @This() };
......@@ -2180,9 +2174,8 @@ test "std.zon stringify primitives" {
21802174}
21812175
21822176test "std.zon stringify ident" {
2183 var aw: std.io.AllocatingWriter = undefined;
2184 aw.init(std.testing.allocator);
2185 var s: Serializer = .{ .writer = &aw.buffered_writer };
2177 var aw: std.io.Writer.Allocating = .init(std.testing.allocator);
2178 var s: Serializer = .{ .writer = &aw.interface };
21862179 defer aw.deinit();
21872180
21882181 try expectSerializeEqual(".{ .a = 0 }", .{ .a = 0 }, .{});
......@@ -2228,9 +2221,8 @@ test "std.zon stringify ident" {
22282221}
22292222
22302223test "std.zon stringify as tuple" {
2231 var aw: std.io.AllocatingWriter = undefined;
2232 aw.init(std.testing.allocator);
2233 var s: Serializer = .{ .writer = &aw.buffered_writer };
2224 var aw: std.io.Writer.Allocating = .init(std.testing.allocator);
2225 var s: Serializer = .{ .writer = &aw.interface };
22342226 defer aw.deinit();
22352227
22362228 // Tuples
......@@ -2250,9 +2242,8 @@ test "std.zon stringify as tuple" {
22502242}
22512243
22522244test "std.zon stringify as float" {
2253 var aw: std.io.AllocatingWriter = undefined;
2254 aw.init(std.testing.allocator);
2255 var s: Serializer = .{ .writer = &aw.buffered_writer };
2245 var aw: std.io.Writer.Allocating = .init(std.testing.allocator);
2246 var s: Serializer = .{ .writer = &aw.interface };
22562247 defer aw.deinit();
22572248
22582249 // Comptime float
......@@ -2355,9 +2346,8 @@ test "std.zon pointers" {
23552346}
23562347
23572348test "std.zon tuple/struct field" {
2358 var aw: std.io.AllocatingWriter = undefined;
2359 aw.init(std.testing.allocator);
2360 var s: Serializer = .{ .writer = &aw.buffered_writer };
2349 var aw: std.io.Writer.Allocating = .init(std.testing.allocator);
2350 var s: Serializer = .{ .writer = &aw.interface };
23612351 defer aw.deinit();
23622352
23632353 // Test on structs
src/Package/Fetch/git.zig+4-4
......@@ -857,8 +857,8 @@ pub const Session = struct {
857857 upload_pack_uri.query = null;
858858 upload_pack_uri.fragment = null;
859859
860 var body: std.io.AllocatingWriter = undefined;
861 const body_writer = body.init(session.allocator);
860 var body: std.io.Writer.Allocating = .init(session.allocator);
861 const body_writer = &body.interface;
862862 defer body.deinit();
863863 try Packet.write(.{ .data = "command=ls-refs\n" }, body_writer);
864864 if (session.supports_agent) {
......@@ -974,9 +974,9 @@ pub const Session = struct {
974974 upload_pack_uri.query = null;
975975 upload_pack_uri.fragment = null;
976976
977 var body: std.io.AllocatingWriter = undefined;
978 const body_writer = body.init(session.allocator);
977 var body: std.io.Writer.Allocating = .init(session.allocator);
979978 defer body.deinit();
979 const body_writer = &body.interface;
980980 try Packet.write(.{ .data = "command=fetch\n" }, body_writer);
981981 if (session.supports_agent) {
982982 try Packet.write(.{ .data = agent_capability }, body_writer);
src/Package/Manifest.zig+2-3
......@@ -471,9 +471,8 @@ const Parse = struct {
471471 offset: u32,
472472 ) InnerError!void {
473473 const raw_string = bytes[offset..];
474 var aw: std.io.AllocatingWriter = undefined;
475 const bw = aw.fromArrayList(p.gpa, buf);
476 const result = std.zig.string_literal.parseWrite(bw, raw_string);
474 var aw: std.io.Writer.Allocating = .fromArrayList(p.gpa, buf);
475 const result = std.zig.string_literal.parseWrite(&aw.interface, raw_string);
477476 buf.* = aw.toArrayList();
478477 switch (result catch return error.OutOfMemory) {
479478 .success => {},
src/Sema.zig+6-8
......@@ -3028,10 +3028,9 @@ pub fn createTypeName(
30283028 const fn_info = sema.code.getFnInfo(ip.funcZirBodyInst(sema.func_index).resolve(ip) orelse return error.AnalysisFail);
30293029 const zir_tags = sema.code.instructions.items(.tag);
30303030
3031 var aw: std.io.AllocatingWriter = undefined;
3032 aw.init(gpa);
3031 var aw: std.io.Writer.Allocating = .init(gpa);
30333032 defer aw.deinit();
3034 const bw = &aw.buffered_writer;
3033 const bw = &aw.interface;
30353034 bw.print("{f}(", .{block.type_name_ctx.fmt(ip)}) catch return error.OutOfMemory;
30363035
30373036 var arg_i: usize = 0;
......@@ -5911,9 +5910,9 @@ fn zirCompileLog(
59115910 const zcu = pt.zcu;
59125911 const gpa = zcu.gpa;
59135912
5914 var aw: std.io.AllocatingWriter = undefined;
5913 var aw: std.io.Writer.Allocating = .init(gpa);
59155914 defer aw.deinit();
5916 const bw = &aw.buffered_writer;
5915 const bw = &aw.interface;
59175916
59185917 const extra = sema.code.extraData(Zir.Inst.NodeMultiOp, extended.operand);
59195918 const src_node = extra.data.src_node;
......@@ -37369,13 +37368,12 @@ fn notePathToComptimeAllocPtr(sema: *Sema, msg: *Zcu.ErrorMsg, src: LazySrcLoc,
3736937368 error.AnalysisFail => unreachable,
3737037369 };
3737137370
37372 var second_path_aw: std.io.AllocatingWriter = undefined;
37373 second_path_aw.init(arena);
37371 var second_path_aw: std.io.Writer.Allocating = .init(arena);
3737437372 defer second_path_aw.deinit();
3737537373 const inter_name = try std.fmt.allocPrint(arena, "v{d}", .{intermediate_value_count});
3737637374 const deriv_start = @import("print_value.zig").printPtrDerivation(
3737737375 derivation,
37378 &second_path_aw.buffered_writer,
37376 &second_path_aw.interface,
3737937377 pt,
3738037378 .lvalue,
3738137379 .{ .str = inter_name },
src/arch/aarch64/Emit.zig+2-2
......@@ -452,8 +452,8 @@ fn dbgAdvancePCAndLine(emit: *Emit, line: u32, column: u32) InnerError!void {
452452 .plan9 => |dbg_out| {
453453 if (delta_pc <= 0) return; // only do this when the pc changes
454454
455 var aw: std.io.AllocatingWriter = undefined;
456 const bw = aw.fromArrayList(emit.bin_file.comp.gpa, &dbg_out.dbg_line);
455 var aw: std.io.Writer.Allocating = .fromArrayList(emit.bin_file.comp.gpa, &dbg_out.dbg_line);
456 const bw = &aw.interface;
457457 defer dbg_out.dbg_line = aw.toArrayList();
458458
459459 // increasing the line number
src/arch/arm/Emit.zig+2-2
......@@ -368,8 +368,8 @@ fn dbgAdvancePCAndLine(self: *Emit, line: u32, column: u32) !void {
368368 .plan9 => |dbg_out| {
369369 if (delta_pc <= 0) return; // only do this when the pc changes
370370
371 var aw: std.io.AllocatingWriter = undefined;
372 const bw = aw.fromArrayList(self.bin_file.comp.gpa, &dbg_out.dbg_line);
371 var aw: std.io.Writer.Allocating = .fromArrayList(self.bin_file.comp.gpa, &dbg_out.dbg_line);
372 const bw = &aw.interface;
373373 defer dbg_out.dbg_line = aw.toArrayList();
374374
375375 // increasing the line number
src/arch/riscv64/Emit.zig+2-2
......@@ -19,8 +19,8 @@ pub const Error = Lower.Error || error{
1919
2020pub fn emitMir(emit: *Emit) Error!void {
2121 const gpa = emit.bin_file.comp.gpa;
22 var aw: std.io.AllocatingWriter = undefined;
23 const bw = aw.fromArrayList(gpa, emit.code);
22 var aw: std.io.Writer.Allocating = .fromArrayList(gpa, emit.code);
23 const bw = &aw.interface;
2424 defer emit.code.* = aw.toArrayList();
2525
2626 log.debug("mir instruction len: {}", .{emit.lower.mir.instructions.len});
src/arch/x86_64/Emit.zig+2-2
......@@ -924,8 +924,8 @@ fn dbgAdvancePCAndLine(emit: *Emit, loc: Loc, pc: usize) Error!void {
924924 .plan9 => |dbg_out| {
925925 if (delta_pc <= 0) return; // only do this when the pc changes
926926
927 var aw: std.io.AllocatingWriter = undefined;
928 const bw = aw.fromArrayList(emit.lower.bin_file.comp.gpa, &dbg_out.dbg_line);
927 var aw: std.io.Writer.Allocating = .fromArrayList(emit.lower.bin_file.comp.gpa, &dbg_out.dbg_line);
928 const bw = &aw.interface;
929929 defer dbg_out.dbg_line = aw.toArrayList();
930930
931931 // increasing the line number
src/codegen.zig+2-3
......@@ -314,10 +314,9 @@ pub fn generateSymbol(
314314 const tracy = trace(@src());
315315 defer tracy.end();
316316
317 var aw: std.io.AllocatingWriter = undefined;
318 const bw = aw.fromArrayList(pt.zcu.gpa, code);
317 var aw: std.io.Writer.Allocating = .fromArrayList(pt.zcu.gpa, code);
319318 defer code.* = aw.toArrayList();
320 return generateSymbolInner(bin_file, pt, src_loc, val, bw, reloc_parent) catch |err| switch (err) {
319 return generateSymbolInner(bin_file, pt, src_loc, val, &aw.interface, reloc_parent) catch |err| switch (err) {
321320 error.WriteFailed => return error.OutOfMemory,
322321 else => |e| return e,
323322 };
src/codegen/c.zig+3-3
......@@ -694,8 +694,8 @@ pub const Function = struct {
694694/// It is not available when generating .h file.
695695pub const Object = struct {
696696 dg: DeclGen,
697 code_header: std.io.AllocatingWriter,
698 code: std.io.AllocatingWriter,
697 code_header: std.io.Writer.Allocating,
698 code: std.io.Writer.Allocating,
699699 indent_counter: usize,
700700
701701 const indent_width = 1;
......@@ -731,7 +731,7 @@ pub const DeclGen = struct {
731731 pass: Pass,
732732 is_naked_fn: bool,
733733 expected_block: ?u32,
734 fwd_decl: std.io.AllocatingWriter,
734 fwd_decl: std.io.Writer.Allocating,
735735 error_msg: ?*Zcu.ErrorMsg,
736736 ctype_pool: CType.Pool,
737737 scratch: std.ArrayListUnmanaged(u32),
src/codegen/llvm.zig+11-8
......@@ -747,13 +747,17 @@ pub const Object = struct {
747747 }
748748
749749 fn genModuleLevelAssembly(object: *Object) Allocator.Error!void {
750 var aw: std.io.AllocatingWriter = undefined;
751 const bw = object.builder.setModuleAsm(&aw);
752 errdefer aw.deinit();
750 const b = &object.builder;
751 const gpa = b.gpa;
752 b.module_asm.clearRetainingCapacity();
753753 for (object.pt.zcu.global_assembly.values()) |assembly| {
754 bw.print("{s}\n", .{assembly}) catch return error.OutOfMemory;
754 try b.module_asm.ensureUnusedCapacity(gpa, assembly.len + 1);
755 b.module_asm.appendSliceAssumeCapacity(assembly);
756 b.module_asm.appendAssumeCapacity('\n');
757 }
758 if (b.module_asm.getLastOrNull()) |last| {
759 if (last != '\n') try b.module_asm.append(gpa, '\n');
755760 }
756 try object.builder.finishModuleAsm(&aw);
757761 }
758762
759763 pub const EmitOptions = struct {
......@@ -2678,10 +2682,9 @@ pub const Object = struct {
26782682 }
26792683
26802684 fn allocTypeName(o: *Object, ty: Type) Allocator.Error![:0]const u8 {
2681 var aw: std.io.AllocatingWriter = undefined;
2682 aw.init(o.gpa);
2685 var aw: std.io.Writer.Allocating = .init(o.gpa);
26832686 defer aw.deinit();
2684 ty.print(&aw.buffered_writer, o.pt) catch return error.OutOfMemory;
2687 ty.print(&aw.interface, o.pt) catch return error.OutOfMemory;
26852688 return aw.toOwnedSliceSentinel(0);
26862689 }
26872690
src/codegen/spirv.zig+2-3
......@@ -1260,10 +1260,9 @@ const NavGen = struct {
12601260
12611261 // Turn a Zig type's name into a cache reference.
12621262 fn resolveTypeName(self: *NavGen, ty: Type) Allocator.Error![]const u8 {
1263 var aw: std.io.AllocatingWriter = undefined;
1264 aw.init(self.gpa);
1263 var aw: std.io.Writer.Allocating = .init(self.gpa);
12651264 defer aw.deinit();
1266 ty.print(&aw.buffered_writer, self.pt) catch return error.OutOfMemory;
1265 ty.print(&aw.interface, self.pt) catch return error.OutOfMemory;
12671266 return aw.toOwnedSlice();
12681267 }
12691268
src/fmt.zig+3-4
......@@ -142,7 +142,7 @@ pub fn run(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
142142 try std.zig.printAstErrorsToStderr(gpa, tree, "<stdin>", color);
143143 process.exit(2);
144144 }
145 var aw: std.io.AllocatingWriter = .init(gpa);
145 var aw: std.io.Writer.Allocating = .init(gpa);
146146 defer aw.deinit();
147147 try tree.render(gpa, &aw.interface, .{});
148148 const formatted = aw.getWritten();
......@@ -336,10 +336,9 @@ fn fmtPathFile(
336336 try fmt.out_buffer.ensureTotalCapacity(gpa, source_code.len);
337337
338338 {
339 var aw: std.io.AllocatingWriter = undefined;
340 const bw = aw.fromArrayList(gpa, &fmt.out_buffer);
339 var aw: std.io.Writer.Allocating = .fromArrayList(gpa, &fmt.out_buffer);
341340 defer fmt.out_buffer = aw.toArrayList();
342 try tree.render(gpa, bw, .{});
341 try tree.render(gpa, &aw.interface, .{});
343342 }
344343 if (mem.eql(u8, fmt.out_buffer.items, source_code))
345344 return;
src/libs/mingw.zig+5-6
......@@ -400,8 +400,7 @@ fn findDef(
400400 else => unreachable,
401401 };
402402
403 var override_path: std.io.AllocatingWriter = undefined;
404 override_path.init(gpa);
403 var override_path: std.io.Writer.Allocating = .init(gpa);
405404 defer override_path.deinit();
406405
407406 const s = path.sep_str;
......@@ -410,9 +409,9 @@ fn findDef(
410409 // Try the archtecture-specific path first.
411410 const fmt_path = "libc" ++ s ++ "mingw" ++ s ++ "{s}" ++ s ++ "{s}.def";
412411 if (zig_lib_directory.path) |p| {
413 try override_path.buffered_writer.print("{s}" ++ s ++ fmt_path, .{ p, lib_path, lib_name });
412 try override_path.interface.print("{s}" ++ s ++ fmt_path, .{ p, lib_path, lib_name });
414413 } else {
415 try override_path.buffered_writer.print(fmt_path, .{ lib_path, lib_name });
414 try override_path.interface.print(fmt_path, .{ lib_path, lib_name });
416415 }
417416 if (std.fs.cwd().access(override_path.getWritten(), .{})) |_| {
418417 return override_path.toOwnedSlice();
......@@ -444,9 +443,9 @@ fn findDef(
444443 override_path.clearRetainingCapacity();
445444 const fmt_path = "libc" ++ s ++ "mingw" ++ s ++ "lib-common" ++ s ++ "{s}.def.in";
446445 if (zig_lib_directory.path) |p| {
447 try override_path.buffered_writer.print("{s}" ++ s ++ fmt_path, .{ p, lib_name });
446 try override_path.interface.print("{s}" ++ s ++ fmt_path, .{ p, lib_name });
448447 } else {
449 try override_path.buffered_writer.print(fmt_path, .{lib_name});
448 try override_path.interface.print(fmt_path, .{lib_name});
450449 }
451450 if (std.fs.cwd().access(override_path.getWritten(), .{})) |_| {
452451 return override_path.toOwnedSlice();
src/libs/musl.zig+4-5
......@@ -115,8 +115,7 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro
115115 var c_source_files = std.ArrayList(Compilation.CSourceFile).init(comp.gpa);
116116 defer c_source_files.deinit();
117117
118 var override_path: std.io.AllocatingWriter = undefined;
119 override_path.init(comp.gpa);
118 var override_path: std.io.Writer.Allocating = .init(comp.gpa);
120119 defer override_path.deinit();
121120
122121 const s = path.sep_str;
......@@ -141,19 +140,19 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro
141140 if (!is_arch_specific) {
142141 // Look for an arch specific override.
143142 override_path.clearRetainingCapacity();
144 try override_path.buffered_writer.print("{s}" ++ s ++ "{s}" ++ s ++ "{s}.s", .{
143 try override_path.interface.print("{s}" ++ s ++ "{s}" ++ s ++ "{s}.s", .{
145144 dirname, arch_name, noextbasename,
146145 });
147146 if (source_table.contains(override_path.getWritten())) continue;
148147
149148 override_path.clearRetainingCapacity();
150 try override_path.buffered_writer.print("{s}" ++ s ++ "{s}" ++ s ++ "{s}.S", .{
149 try override_path.interface.print("{s}" ++ s ++ "{s}" ++ s ++ "{s}.S", .{
151150 dirname, arch_name, noextbasename,
152151 });
153152 if (source_table.contains(override_path.getWritten())) continue;
154153
155154 override_path.clearRetainingCapacity();
156 try override_path.buffered_writer.print("{s}" ++ s ++ "{s}" ++ s ++ "{s}.c", .{
155 try override_path.interface.print("{s}" ++ s ++ "{s}" ++ s ++ "{s}.c", .{
157156 dirname, arch_name, noextbasename,
158157 });
159158 if (source_table.contains(override_path.getWritten())) continue;
src/link/Dwarf.zig+6-7
......@@ -1446,10 +1446,10 @@ pub const WipNav = struct {
14461446 loc: u32,
14471447 cfa: Cfa.RegOff,
14481448 },
1449 debug_frame: std.io.AllocatingWriter,
1450 debug_info: std.io.AllocatingWriter,
1451 debug_line: std.io.AllocatingWriter,
1452 debug_loclists: std.io.AllocatingWriter,
1449 debug_frame: std.io.Writer.Allocating,
1450 debug_info: std.io.Writer.Allocating,
1451 debug_line: std.io.Writer.Allocating,
1452 debug_loclists: std.io.Writer.Allocating,
14531453 pending_lazy: PendingLazy,
14541454
14551455 pub fn init(wip_nav: *WipNav) void {
......@@ -4494,10 +4494,9 @@ fn refAbbrevCode(dwarf: *Dwarf, abbrev_code: AbbrevCode) UpdateError!@typeInfo(A
44944494 assert(abbrev_code != .null);
44954495 const entry: Entry.Index = @enumFromInt(@intFromEnum(abbrev_code));
44964496 if (dwarf.debug_abbrev.section.getUnit(DebugAbbrev.unit).getEntry(entry).len > 0) return @intFromEnum(abbrev_code);
4497 var daaw: std.io.AllocatingWriter = undefined;
4498 daaw.init(dwarf.gpa);
4497 var daaw: std.io.Writer.Allocating = .init(dwarf.gpa);
44994498 defer daaw.deinit();
4500 const dabw = &daaw.buffered_writer;
4499 const dabw = &daaw.interface;
45014500 const abbrev = AbbrevCode.abbrevs.get(abbrev_code);
45024501 try dabw.writeLeb128(@intFromEnum(abbrev_code));
45034502 try dabw.writeLeb128(@intFromEnum(abbrev.tag));
src/link/MachO/CodeSignature.zig+4-6
......@@ -304,11 +304,10 @@ pub fn writeAdhocSignature(
304304 var hash: [hash_size]u8 = undefined;
305305
306306 if (self.requirements) |*req| {
307 var aw: std.io.AllocatingWriter = undefined;
308 aw.init(allocator);
307 var aw: std.io.Writer.Allocating = .init(allocator);
309308 defer aw.deinit();
310309
311 try req.write(&aw.buffered_writer);
310 try req.write(&aw.interface);
312311 Sha256.hash(aw.getWritten(), &hash, .{});
313312 self.code_directory.addSpecialHash(req.slotType(), hash);
314313
......@@ -318,11 +317,10 @@ pub fn writeAdhocSignature(
318317 }
319318
320319 if (self.entitlements) |*ents| {
321 var aw: std.io.AllocatingWriter = undefined;
322 aw.init(allocator);
320 var aw: std.io.Writer.Allocating = .init(allocator);
323321 defer aw.deinit();
324322
325 try ents.write(&aw.buffered_writer);
323 try ents.write(&aw.interface);
326324 Sha256.hash(aw.getWritten(), &hash, .{});
327325 self.code_directory.addSpecialHash(ents.slotType(), hash);
328326
src/link/MachO/dyld_info/Rebase.zig+2-2
......@@ -110,8 +110,8 @@ pub fn updateSize(rebase: *Rebase, macho_file: *MachO) !void {
110110fn finalize(rebase: *Rebase, gpa: Allocator) !void {
111111 if (rebase.entries.items.len == 0) return;
112112
113 var aw: std.io.AllocatingWriter = undefined;
114 const bw = aw.fromArrayList(gpa, &rebase.buffer);
113 var aw: std.io.Writer.Allocating = .fromArrayList(gpa, &rebase.buffer);
114 const bw = &aw.interface;
115115 defer rebase.buffer = aw.toArrayList();
116116
117117 log.debug("rebase opcodes", .{});
src/link/MachO/dyld_info/bind.zig+6-6
......@@ -118,8 +118,8 @@ pub const Bind = struct {
118118 fn finalize(bind: *Bind, gpa: Allocator, ctx: *MachO) !void {
119119 if (bind.entries.items.len == 0) return;
120120
121 var aw: std.io.AllocatingWriter = undefined;
122 const bw = aw.fromArrayList(gpa, &bind.buffer);
121 var aw: std.io.Writer.Allocating = .fromArrayList(gpa, &bind.buffer);
122 const bw = &aw.interface;
123123 defer bind.buffer = aw.toArrayList();
124124
125125 log.debug("bind opcodes", .{});
......@@ -359,8 +359,8 @@ pub const WeakBind = struct {
359359 fn finalize(bind: *WeakBind, gpa: Allocator, ctx: *MachO) !void {
360360 if (bind.entries.items.len == 0) return;
361361
362 var aw: std.io.AllocatingWriter = undefined;
363 const bw = aw.fromArrayList(gpa, &bind.buffer);
362 var aw: std.io.Writer.Allocating = .fromArrayList(gpa, &bind.buffer);
363 const bw = &aw.interface;
364364 defer bind.buffer = aw.toArrayList();
365365
366366 log.debug("weak bind opcodes", .{});
......@@ -526,8 +526,8 @@ pub const LazyBind = struct {
526526 fn finalize(bind: *LazyBind, gpa: Allocator, ctx: *MachO) !void {
527527 try bind.offsets.ensureTotalCapacityPrecise(gpa, bind.entries.items.len);
528528
529 var aw: std.io.AllocatingWriter = undefined;
530 const bw = aw.fromArrayList(gpa, &bind.buffer);
529 var aw: std.io.Writer.Allocating = .fromArrayList(gpa, &bind.buffer);
530 const bw = &aw.interface;
531531 defer bind.buffer = aw.toArrayList();
532532
533533 log.debug("lazy bind opcodes", .{});
src/link/Plan9.zig+5-7
......@@ -337,7 +337,7 @@ fn putFn(self: *Plan9, nav_index: InternPool.Nav.Index, out: FnNavOutput) !void
337337 };
338338 try fn_map_res.value_ptr.functions.put(gpa, nav_index, out);
339339
340 var aw: std.io.AllocatingWriter = .init(arena);
340 var aw: std.io.Writer.Allocating = .init(arena);
341341 defer aw.deinit();
342342 const w = &aw.interface;
343343
......@@ -646,12 +646,11 @@ pub fn flush(
646646 var iovecs_i: usize = 1;
647647 var text_i: u64 = 0;
648648
649 var linecountinfo_aw: std.io.AllocatingWriter = undefined;
650 linecountinfo_aw.init(gpa);
649 var linecountinfo_aw: std.io.Writer.Allocating = .init(gpa);
651650 defer linecountinfo_aw.deinit();
652651 // text
653652 {
654 const linecountinfo_bw = &linecountinfo_aw.buffered_writer;
653 const linecountinfo_bw = &linecountinfo_aw.interface;
655654 var linecount: i64 = -1;
656655 var it_file = self.fn_nav_table.iterator();
657656 while (it_file.next()) |fentry| {
......@@ -819,10 +818,9 @@ pub fn flush(
819818 }
820819 }
821820 }
822 var syms_aw: std.io.AllocatingWriter = undefined;
823 syms_aw.init(gpa);
821 var syms_aw: std.io.Writer.Allocating = .init(gpa);
824822 defer syms_aw.deinit();
825 try self.writeSyms(&syms_aw.buffered_writer);
823 try self.writeSyms(&syms_aw.interface);
826824 const syms = syms_aw.getWritten();
827825 assert(2 + self.atomCount() - self.externCount() == iovecs_i); // we didn't write all the decls
828826 iovecs[iovecs_i] = .{ .base = syms.ptr, .len = syms.len };
src/link/SpirV.zig+4-5
......@@ -203,11 +203,10 @@ pub fn flush(
203203 // We need to export the list of error names somewhere so that we can pretty-print them in the
204204 // executor. This is not really an important thing though, so we can just dump it in any old
205205 // nonsemantic instruction. For now, just put it in OpSourceExtension with a special name.
206 var error_info: std.io.AllocatingWriter = undefined;
207 error_info.init(self.object.gpa);
206 var error_info: std.io.Writer.Allocating = .init(self.object.gpa);
208207 defer error_info.deinit();
209208
210 try error_info.buffered_writer.writeAll("zig_errors:");
209 try error_info.interface.writeAll("zig_errors:");
211210 const ip = &self.base.comp.zcu.?.intern_pool;
212211 for (ip.global_error_set.getNamesFromMainThread()) |name| {
213212 // Errors can contain pretty much any character - to encode them in a string we must escape
......@@ -215,9 +214,9 @@ pub fn flush(
215214 // name if it contains no strange characters is nice for debugging. URI encoding fits the bill.
216215 // We're using : as separator, which is a reserved character.
217216
218 try error_info.buffered_writer.writeByte(':');
217 try error_info.interface.writeByte(':');
219218 try std.Uri.Component.percentEncode(
220 &error_info.buffered_writer,
219 &error_info.interface,
221220 name.toSlice(ip),
222221 struct {
223222 fn isValidChar(c: u8) bool {
src/link/Wasm/Flush.zig+9-9
......@@ -558,7 +558,7 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void {
558558 var data_section_index: ?u32 = null;
559559
560560 assert(f.binary_bytes.items.len == 0);
561 var aw: std.io.AllocatingWriter = .fromArrayList(gpa, &f.binary_bytes);
561 var aw: std.io.Writer.Allocating = .fromArrayList(gpa, &f.binary_bytes);
562562 defer f.binary_bytes = aw.toArrayList();
563563 const w = &aw.interface;
564564
......@@ -1064,7 +1064,7 @@ const VirtualAddrs = struct {
10641064
10651065fn emitNameSection(
10661066 wasm: *Wasm,
1067 aw: *std.io.AllocatingWriter,
1067 aw: *std.io.Writer.Allocating,
10681068 data_segment_groups: []const DataSegmentGroup,
10691069) !void {
10701070 const f = &wasm.flush_buffer;
......@@ -1128,7 +1128,7 @@ fn emitNameSection(
11281128 }
11291129}
11301130
1131fn emitFeaturesSection(aw: *std.io.AllocatingWriter, target: *const std.Target) Allocator.Error!void {
1131fn emitFeaturesSection(aw: *std.io.Writer.Allocating, target: *const std.Target) Allocator.Error!void {
11321132 const feature_count = target.cpu.features.count();
11331133 if (feature_count == 0) return;
11341134
......@@ -1155,7 +1155,7 @@ fn emitFeaturesSection(aw: *std.io.AllocatingWriter, target: *const std.Target)
11551155 assert(safety_count == 0);
11561156}
11571157
1158fn emitBuildIdSection(aw: *std.io.AllocatingWriter, build_id: []const u8) !void {
1158fn emitBuildIdSection(aw: *std.io.Writer.Allocating, build_id: []const u8) !void {
11591159 const w = &aw.interface;
11601160 const header_offset = try reserveSectionHeader(w);
11611161 defer replaceSectionHeader(aw, header_offset, @intFromEnum(std.wasm.Section.custom));
......@@ -1169,7 +1169,7 @@ fn emitBuildIdSection(aw: *std.io.AllocatingWriter, build_id: []const u8) !void
11691169 try w.writeAll(build_id);
11701170}
11711171
1172fn emitProducerSection(aw: *std.io.AllocatingWriter) !void {
1172fn emitProducerSection(aw: *std.io.Writer.Allocating) !void {
11731173 const w = &aw.interface;
11741174 const header_offset = try reserveSectionHeader(w);
11751175 defer replaceSectionHeader(aw, header_offset, @intFromEnum(std.wasm.Section.custom));
......@@ -1259,7 +1259,7 @@ fn reserveVecSectionHeader(w: *Writer) Writer.Error!u32 {
12591259}
12601260
12611261fn replaceVecSectionHeader(
1262 aw: *std.io.AllocatingWriter,
1262 aw: *std.io.Writer.Allocating,
12631263 offset: u32,
12641264 section: std.wasm.Section,
12651265 n_items: u32,
......@@ -1278,7 +1278,7 @@ fn reserveSectionHeader(w: *Writer) Writer.Error!u32 {
12781278 return @intCast(offset);
12791279}
12801280
1281fn replaceSectionHeader(aw: *std.io.AllocatingWriter, offset: u32, section: u8) void {
1281fn replaceSectionHeader(aw: *std.io.Writer.Allocating, offset: u32, section: u8) void {
12821282 const header = aw.getWritten()[offset..][0..section_header_size];
12831283 header[0] = section;
12841284 std.leb.writeUnsignedFixed(5, header[1..6], @intCast(aw.interface.count - offset - section_header_size));
......@@ -1292,7 +1292,7 @@ fn reserveSizeHeader(w: *Writer) Writer.Error!u32 {
12921292 return @intCast(offset);
12931293}
12941294
1295fn replaceSizeHeader(aw: *std.io.AllocatingWriter, offset: u32) void {
1295fn replaceSizeHeader(aw: *std.io.Writer.Allocating, offset: u32) void {
12961296 const header = aw.getWritten()[offset..][0..size_header_size];
12971297 std.leb.writeUnsignedFixed(5, header[0..5], @intCast(aw.interface.count - offset - size_header_size));
12981298}
......@@ -1764,7 +1764,7 @@ fn emitInitTlsFunction(wasm: *const Wasm, w: *Writer) Writer.Error!void {
17641764 try w.writeByte(@intFromEnum(std.wasm.Opcode.end));
17651765}
17661766
1767fn emitStartSection(aw: *std.io.AllocatingWriter, i: Wasm.OutputFunctionIndex) !void {
1767fn emitStartSection(aw: *std.io.Writer.Allocating, i: Wasm.OutputFunctionIndex) !void {
17681768 const header_offset = try reserveVecSectionHeader(&aw.interface);
17691769 defer replaceVecSectionHeader(aw, header_offset, .start, @intFromEnum(i));
17701770}