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 {...@@ -444,9 +444,9 @@ fn parse(file_name: []const u8, source: []u8) Oom!Ast {
444 const err_loc = std.zig.findLineColumn(ast.source, err_offset);444 const err_loc = std.zig.findLineColumn(ast.source, err_offset);
445 rendered_err.clearRetainingCapacity();445 rendered_err.clearRetainingCapacity();
446 {446 {
447 var aw: std.io.AllocatingWriter = undefined;447 var aw: std.io.Writer.Allocating = .fromArrayList(gpa, &rendered_err);
448 defer rendered_err = aw.toArrayList();448 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) {
450 error.WriteFailed => return error.OutOfMemory,450 error.WriteFailed => return error.OutOfMemory,
451 };451 };
452 }452 }
lib/docs/wasm/main.zig+2-2
...@@ -733,9 +733,9 @@ fn render_docs(...@@ -733,9 +733,9 @@ fn render_docs(
733 }733 }
734 }.render,734 }.render,
735 };735 };
736 var aw: std.io.AllocatingWriter = undefined;736 var aw: std.io.Writer.Allocating = .fromArrayList(gpa, out);
737 defer out.* = aw.toArrayList();737 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) {
739 error.WriteFailed => return error.OutOfMemory,739 error.WriteFailed => return error.OutOfMemory,
740 };740 };
741}741}
lib/std/Build/Step/CheckObject.zig+8-12
...@@ -1592,10 +1592,9 @@ const MachODumper = struct {...@@ -1592,10 +1592,9 @@ const MachODumper = struct {
1592 var ctx = ObjectContext{ .gpa = gpa, .data = bytes, .header = hdr };1592 var ctx = ObjectContext{ .gpa = gpa, .data = bytes, .header = hdr };
1593 try ctx.parse();1593 try ctx.parse();
15941594
1595 var aw: std.io.AllocatingWriter = undefined;1595 var aw: std.io.Writer.Allocating = .init(gpa);
1596 aw.init(gpa);
1597 defer aw.deinit();1596 defer aw.deinit();
1598 const bw = &aw.buffered_writer;1597 const bw = &aw.interface;
15991598
1600 switch (check.kind) {1599 switch (check.kind) {
1601 .headers => {1600 .headers => {
...@@ -1746,10 +1745,9 @@ const ElfDumper = struct {...@@ -1746,10 +1745,9 @@ const ElfDumper = struct {
1746 });1745 });
1747 }1746 }
17481747
1749 var aw: std.io.AllocatingWriter = undefined;1748 var aw: std.io.Writer.Allocating = .init(gpa);
1750 aw.init(gpa);
1751 defer aw.deinit();1749 defer aw.deinit();
1752 const bw = &aw.buffered_writer;1750 const bw = &aw.interface;
17531751
1754 switch (check.kind) {1752 switch (check.kind) {
1755 .archive_symtab => if (ctx.symtab.len > 0) {1753 .archive_symtab => if (ctx.symtab.len > 0) {
...@@ -1894,10 +1892,9 @@ const ElfDumper = struct {...@@ -1894,10 +1892,9 @@ const ElfDumper = struct {
1894 else => {},1892 else => {},
1895 };1893 };
18961894
1897 var aw: std.io.AllocatingWriter = undefined;1895 var aw: std.io.Writer.Allocating = .init(gpa);
1898 aw.init(gpa);
1899 defer aw.deinit();1896 defer aw.deinit();
1900 const bw = &aw.buffered_writer;1897 const bw = &aw.interface;
19011898
1902 switch (check.kind) {1899 switch (check.kind) {
1903 .headers => {1900 .headers => {
...@@ -2355,10 +2352,9 @@ const WasmDumper = struct {...@@ -2355,10 +2352,9 @@ const WasmDumper = struct {
2355 if (!mem.eql(u8, buf[0..4], &std.wasm.magic)) return error.InvalidMagicByte;2352 if (!mem.eql(u8, buf[0..4], &std.wasm.magic)) return error.InvalidMagicByte;
2356 if (!mem.eql(u8, buf[4..8], &std.wasm.version)) return error.UnsupportedWasmVersion;2353 if (!mem.eql(u8, buf[4..8], &std.wasm.version)) return error.UnsupportedWasmVersion;
23572354
2358 var aw: std.io.AllocatingWriter = undefined;2355 var aw: std.io.Writer.Allocating = .init(gpa);
2359 aw.init(gpa);
2360 defer aw.deinit();2356 defer aw.deinit();
2361 const bw = &aw.buffered_writer;2357 const bw = &aw.interface;
23622358
2363 parseAndDumpInner(step, check, &br, bw) catch |err| switch (err) {2359 parseAndDumpInner(step, check, &br, bw) catch |err| switch (err) {
2364 error.EndOfStream => try bw.writeAll("\n<UnexpectedEndOfStream>"),2360 error.EndOfStream => try bw.writeAll("\n<UnexpectedEndOfStream>"),
lib/std/Build/Step/Compile.zig+2-3
...@@ -1969,14 +1969,13 @@ fn checkCompileErrors(compile: *Compile) !void {...@@ -1969,14 +1969,13 @@ fn checkCompileErrors(compile: *Compile) !void {
1969 const arena = compile.step.owner.allocator;1969 const arena = compile.step.owner.allocator;
19701970
1971 const actual_errors = ae: {1971 const actual_errors = ae: {
1972 var aw: std.io.AllocatingWriter = undefined;1972 var aw: std.io.Writer.Allocating = .init(arena);
1973 aw.init(arena);
1974 defer aw.deinit();1973 defer aw.deinit();
1975 try actual_eb.renderToWriter(.{1974 try actual_eb.renderToWriter(.{
1976 .ttyconf = .no_color,1975 .ttyconf = .no_color,
1977 .include_reference_trace = false,1976 .include_reference_trace = false,
1978 .include_source_line = false,1977 .include_source_line = false,
1979 }, &aw.buffered_writer);1978 }, &aw.interface);
1980 break :ae try aw.toOwnedSlice();1979 break :ae try aw.toOwnedSlice();
1981 };1980 };
19821981
lib/std/Build/Step/ConfigHeader.zig+4-5
...@@ -196,10 +196,9 @@ fn make(step: *Step, options: Step.MakeOptions) !void {...@@ -196,10 +196,9 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
196 man.hash.addBytes(config_header.include_path);196 man.hash.addBytes(config_header.include_path);
197 man.hash.addOptionalBytes(config_header.include_guard_override);197 man.hash.addOptionalBytes(config_header.include_guard_override);
198198
199 var aw: std.io.AllocatingWriter = undefined;199 var aw: std.io.Writer.Allocating = .init(gpa);
200 aw.init(gpa);
201 defer aw.deinit();200 defer aw.deinit();
202 const bw = &aw.buffered_writer;201 const bw = &aw.interface;
203202
204 const header_text = "This file was generated by ConfigHeader using the Zig Build System.";203 const header_text = "This file was generated by ConfigHeader using the Zig Build System.";
205 const c_generated_line = "/* " ++ header_text ++ " */\n";204 const c_generated_line = "/* " ++ header_text ++ " */\n";
...@@ -330,13 +329,13 @@ fn render_autoconf_undef(...@@ -330,13 +329,13 @@ fn render_autoconf_undef(
330fn render_autoconf_at(329fn render_autoconf_at(
331 step: *Step,330 step: *Step,
332 contents: []const u8,331 contents: []const u8,
333 aw: *std.io.AllocatingWriter,332 aw: *std.io.Writer.Allocating,
334 values: std.StringArrayHashMap(Value),333 values: std.StringArrayHashMap(Value),
335 src_path: []const u8,334 src_path: []const u8,
336) !void {335) !void {
337 const build = step.owner;336 const build = step.owner;
338 const allocator = build.allocator;337 const allocator = build.allocator;
339 const bw = &aw.buffered_writer;338 const bw = &aw.interface;
340339
341 const used = allocator.alloc(bool, values.count()) catch @panic("OOM");340 const used = allocator.alloc(bool, values.count()) catch @panic("OOM");
342 for (used) |*u| u.* = false;341 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...@@ -905,7 +905,7 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?mem.Alig
905 pub fn print(self: *Self, gpa: Allocator, comptime fmt: []const u8, args: anytype) error{OutOfMemory}!void {905 pub fn print(self: *Self, gpa: Allocator, comptime fmt: []const u8, args: anytype) error{OutOfMemory}!void {
906 comptime assert(T == u8);906 comptime assert(T == u8);
907 try self.ensureUnusedCapacity(gpa, fmt.len);907 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);
909 defer self.* = aw.toArrayList();909 defer self.* = aw.toArrayList();
910 return aw.interface.print(fmt, args) catch |err| switch (err) {910 return aw.interface.print(fmt, args) catch |err| switch (err) {
911 error.WriteFailed => return error.OutOfMemory,911 error.WriteFailed => return error.OutOfMemory,
lib/std/compress/flate.zig+2-3
...@@ -341,11 +341,10 @@ test "compress/decompress" {...@@ -341,11 +341,10 @@ test "compress/decompress" {
341341
342fn testDecompress(comptime container: Container, compressed: []const u8, expected_plain: []const u8) !void {342fn testDecompress(comptime container: Container, compressed: []const u8, expected_plain: []const u8) !void {
343 var in: std.io.Reader = .fixed(compressed);343 var in: std.io.Reader = .fixed(compressed);
344 var out: std.io.AllocatingWriter = undefined;344 var out: std.io.Writer.Allocating = .init(testing.allocator);
345 out.init(testing.allocator);
346 defer out.deinit();345 defer out.deinit();
347346
348 try Decompress.pump(container, &in, &out.buffered_writer);347 try Decompress.pump(container, &in, &out.interface);
349 try testing.expectEqualSlices(u8, expected_plain, out.items);348 try testing.expectEqualSlices(u8, expected_plain, out.items);
350}349}
351350
lib/std/compress/flate/Decompress.zig+11-16
...@@ -729,13 +729,12 @@ test "decompress" {...@@ -729,13 +729,12 @@ test "decompress" {
729 };729 };
730 for (cases) |c| {730 for (cases) |c| {
731 var fb: std.io.Reader = .fixed(c.in);731 var fb: std.io.Reader = .fixed(c.in);
732 var aw: std.io.AllocatingWriter = undefined;732 var aw: std.io.Writer.Allocating = .init(testing.allocator);
733 aw.init(testing.allocator);
734 defer aw.deinit();733 defer aw.deinit();
735734
736 var decompress: Decompress = .init(&fb, .raw);735 var decompress: Decompress = .init(&fb, .raw);
737 var decompress_br = decompress.readable(&.{});736 var decompress_br = decompress.readable(&.{});
738 _ = try decompress_br.readRemaining(&aw.buffered_writer);737 _ = try decompress_br.readRemaining(&aw.interface);
739 try testing.expectEqualStrings(c.out, aw.getWritten());738 try testing.expectEqualStrings(c.out, aw.getWritten());
740 }739 }
741}740}
...@@ -789,13 +788,12 @@ test "gzip decompress" {...@@ -789,13 +788,12 @@ test "gzip decompress" {
789 };788 };
790 for (cases) |c| {789 for (cases) |c| {
791 var fb: std.io.Reader = .fixed(c.in);790 var fb: std.io.Reader = .fixed(c.in);
792 var aw: std.io.AllocatingWriter = undefined;791 var aw: std.io.Writer.Allocating = .init(testing.allocator);
793 aw.init(testing.allocator);
794 defer aw.deinit();792 defer aw.deinit();
795793
796 var decompress: Decompress = .init(&fb, .gzip);794 var decompress: Decompress = .init(&fb, .gzip);
797 var decompress_br = decompress.readable(&.{});795 var decompress_br = decompress.readable(&.{});
798 _ = try decompress_br.readRemaining(&aw.buffered_writer);796 _ = try decompress_br.readRemaining(&aw.interface);
799 try testing.expectEqualStrings(c.out, aw.getWritten());797 try testing.expectEqualStrings(c.out, aw.getWritten());
800 }798 }
801}799}
...@@ -818,13 +816,12 @@ test "zlib decompress" {...@@ -818,13 +816,12 @@ test "zlib decompress" {
818 };816 };
819 for (cases) |c| {817 for (cases) |c| {
820 var fb: std.io.Reader = .fixed(c.in);818 var fb: std.io.Reader = .fixed(c.in);
821 var aw: std.io.AllocatingWriter = undefined;819 var aw: std.io.Writer.Allocating = .init(testing.allocator);
822 aw.init(testing.allocator);
823 defer aw.deinit();820 defer aw.deinit();
824821
825 var decompress: Decompress = .init(&fb, .zlib);822 var decompress: Decompress = .init(&fb, .zlib);
826 var decompress_br = decompress.readable(&.{});823 var decompress_br = decompress.readable(&.{});
827 _ = try decompress_br.readRemaining(&aw.buffered_writer);824 _ = try decompress_br.readRemaining(&aw.interface);
828 try testing.expectEqualStrings(c.out, aw.getWritten());825 try testing.expectEqualStrings(c.out, aw.getWritten());
829 }826 }
830}827}
...@@ -879,18 +876,17 @@ test "fuzzing tests" {...@@ -879,18 +876,17 @@ test "fuzzing tests" {
879876
880 inline for (cases, 0..) |c, case_no| {877 inline for (cases, 0..) |c, case_no| {
881 var in: std.io.Reader = .fixed(@embedFile("testdata/fuzz/" ++ c.input ++ ".input"));878 var in: std.io.Reader = .fixed(@embedFile("testdata/fuzz/" ++ c.input ++ ".input"));
882 var aw: std.io.AllocatingWriter = undefined;879 var aw: std.io.Writer.Allocating = .init(testing.allocator);
883 aw.init(testing.allocator);
884 defer aw.deinit();880 defer aw.deinit();
885 errdefer std.debug.print("test case failed {}\n", .{case_no});881 errdefer std.debug.print("test case failed {}\n", .{case_no});
886882
887 var decompress: Decompress = .init(&in, .raw);883 var decompress: Decompress = .init(&in, .raw);
888 var decompress_br = decompress.readable(&.{});884 var decompress_br = decompress.readable(&.{});
889 if (c.err) |expected_err| {885 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));
891 try testing.expectError(expected_err, decompress.read_err.?);887 try testing.expectError(expected_err, decompress.read_err.?);
892 } else {888 } else {
893 _ = try decompress_br.readRemaining(&aw.buffered_writer);889 _ = try decompress_br.readRemaining(&aw.interface);
894 try testing.expectEqualStrings(c.out, aw.getWritten());890 try testing.expectEqualStrings(c.out, aw.getWritten());
895 }891 }
896 }892 }
...@@ -901,13 +897,12 @@ test "bug 18966" {...@@ -901,13 +897,12 @@ test "bug 18966" {
901 const expect = @embedFile("testdata/fuzz/bug_18966.expect");897 const expect = @embedFile("testdata/fuzz/bug_18966.expect");
902898
903 var in: std.io.Reader = .fixed(input);899 var in: std.io.Reader = .fixed(input);
904 var aw: std.io.AllocatingWriter = undefined;900 var aw: std.io.Writer.Allocating = .init(testing.allocator);
905 aw.init(testing.allocator);
906 defer aw.deinit();901 defer aw.deinit();
907902
908 var decompress: Decompress = .init(&in, .gzip);903 var decompress: Decompress = .init(&in, .gzip);
909 var decompress_br = decompress.readable(&.{});904 var decompress_br = decompress.readable(&.{});
910 _ = try decompress_br.readRemaining(&aw.buffered_writer);905 _ = try decompress_br.readRemaining(&aw.interface);
911 try testing.expectEqualStrings(expect, aw.getWritten());906 try testing.expectEqualStrings(expect, aw.getWritten());
912}907}
913908
lib/std/compress/lzma2.zig+2-3
...@@ -278,9 +278,8 @@ test decompress {...@@ -278,9 +278,8 @@ test decompress {
278 0x00, 0x06, 0x57, 0x6F, 0x72, 0x6C, 0x64, 0x21, 0x0A, 0x00,278 0x00, 0x06, 0x57, 0x6F, 0x72, 0x6C, 0x64, 0x21, 0x0A, 0x00,
279 };279 };
280 var stream: std.io.Reader = .fixed(&compressed);280 var stream: std.io.Reader = .fixed(&compressed);
281 var decomp: std.io.AllocatingWriter = undefined;281 var decomp: std.io.Writer.Allocating = .init(std.testing.allocator);
282 const decomp_bw = decomp.init(std.testing.allocator);
283 defer decomp.deinit();282 defer decomp.deinit();
284 try decompress(std.testing.allocator, &stream, decomp_bw);283 try decompress(std.testing.allocator, &stream, &decomp.interface);
285 try std.testing.expectEqualSlices(u8, expected, decomp.getWritten());284 try std.testing.expectEqualSlices(u8, expected, decomp.getWritten());
286}285}
lib/std/debug.zig+2-3
...@@ -304,11 +304,10 @@ pub fn dumpHexFallible(bw: *Writer, ttyconf: std.io.tty.Config, bytes: []const u...@@ -304,11 +304,10 @@ pub fn dumpHexFallible(bw: *Writer, ttyconf: std.io.tty.Config, bytes: []const u
304304
305test dumpHexFallible {305test dumpHexFallible {
306 const bytes: []const u8 = &.{ 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x01, 0x12, 0x13 };306 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;307 var aw: std.io.Writer.Allocating = .init(std.testing.allocator);
308 var bw = aw.init(std.testing.allocator);
309 defer aw.deinit();308 defer aw.deinit();
310309
311 try dumpHexFallible(&bw, .no_color, bytes);310 try dumpHexFallible(&aw.interface, .no_color, bytes);
312 const expected = try std.fmt.allocPrint(std.testing.allocator,311 const expected = try std.fmt.allocPrint(std.testing.allocator,
313 \\{x:0>[2]} 00 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF .."3DUfw........312 \\{x:0>[2]} 00 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF .."3DUfw........
314 \\{x:0>[2]} 01 12 13 ...313 \\{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 {...@@ -853,10 +853,9 @@ pub fn count(comptime fmt: []const u8, args: anytype) usize {
853}853}
854854
855pub fn allocPrint(gpa: Allocator, comptime fmt: []const u8, args: anytype) Allocator.Error![]u8 {855pub fn allocPrint(gpa: Allocator, comptime fmt: []const u8, args: anytype) Allocator.Error![]u8 {
856 var aw: std.io.AllocatingWriter = undefined;856 var aw = try std.io.Writer.Allocating.initCapacity(gpa, fmt.len);
857 try aw.initCapacity(gpa, fmt.len);
858 defer aw.deinit();857 defer aw.deinit();
859 aw.buffered_writer.print(fmt, args) catch |err| switch (err) {858 aw.interface.print(fmt, args) catch |err| switch (err) {
860 error.WriteFailed => return error.OutOfMemory,859 error.WriteFailed => return error.OutOfMemory,
861 };860 };
862 return aw.toOwnedSlice();861 return aw.toOwnedSlice();
...@@ -868,10 +867,9 @@ pub fn allocPrintSentinel(...@@ -868,10 +867,9 @@ pub fn allocPrintSentinel(
868 args: anytype,867 args: anytype,
869 comptime sentinel: u8,868 comptime sentinel: u8,
870) Allocator.Error![:sentinel]u8 {869) Allocator.Error![:sentinel]u8 {
871 var aw: std.io.AllocatingWriter = undefined;870 var aw = try std.io.Writer.Allocating.initCapacity(gpa, fmt.len);
872 try aw.initCapacity(gpa, fmt.len);
873 defer aw.deinit();871 defer aw.deinit();
874 aw.buffered_writer.print(fmt, args) catch |err| switch (err) {872 aw.interface.print(fmt, args) catch |err| switch (err) {
875 error.WriteFailed => return error.OutOfMemory,873 error.WriteFailed => return error.OutOfMemory,
876 };874 };
877 return aw.toOwnedSliceSentinel(sentinel);875 return aw.toOwnedSliceSentinel(sentinel);
lib/std/json.zig+2-2
...@@ -42,9 +42,9 @@ test Value {...@@ -42,9 +42,9 @@ test Value {
42}42}
4343
44test Stringify {44test Stringify {
45 var out: std.io.AllocatingWriter = undefined;45 var out: std.io.Writer.Allocating = .init(testing.allocator);
46 var write_stream: Stringify = .{46 var write_stream: Stringify = .{
47 .writer = out.init(testing.allocator),47 .writer = &out.interface,
48 .options = .{ .whitespace = .indent_2 },48 .options = .{ .whitespace = .indent_2 },
49 };49 };
50 defer out.deinit();50 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 {...@@ -576,8 +576,8 @@ pub fn value(v: anytype, options: Options, writer: *Writer) Error!void {
576}576}
577577
578test value {578test value {
579 var out: std.io.AllocatingWriter = undefined;579 var out: std.io.Writer.Allocating = .init(std.testing.allocator);
580 const writer = out.init(std.testing.allocator);580 const writer = &out.interface;
581 defer out.deinit();581 defer out.deinit();
582582
583 const T = struct { a: i32, b: []const u8 };583 const T = struct { a: i32, b: []const u8 };
...@@ -616,8 +616,8 @@ test value {...@@ -616,8 +616,8 @@ test value {
616///616///
617/// Caller owns returned memory.617/// Caller owns returned memory.
618pub fn valueAlloc(gpa: Allocator, v: anytype, options: Options) error{OutOfMemory}![]u8 {618pub fn valueAlloc(gpa: Allocator, v: anytype, options: Options) error{OutOfMemory}![]u8 {
619 var aw: std.io.AllocatingWriter = undefined;619 var aw: std.io.Writer.Allocating = .init(gpa);
620 const writer = aw.init(gpa);620 const writer = &aw.interface;
621 defer aw.deinit();621 defer aw.deinit();
622 value(v, options, writer) catch return error.OutOfMemory;622 value(v, options, writer) catch return error.OutOfMemory;
623 return aw.toOwnedSlice();623 return aw.toOwnedSlice();
lib/std/tar/Writer.zig+4-5
...@@ -433,8 +433,8 @@ test "write files" {...@@ -433,8 +433,8 @@ test "write files" {
433 {433 {
434 const root = "root";434 const root = "root";
435435
436 var output: std.io.AllocatingWriter = .init(testing.allocator);436 var output: std.io.Writer.Allocating = .init(testing.allocator);
437 var wrt: Writer = .{ .underlying_writer = &output.buffered_writer };437 var wrt: Writer = .{ .underlying_writer = &output.interface };
438 defer output.deinit();438 defer output.deinit();
439 try wrt.setRoot(root);439 try wrt.setRoot(root);
440 for (files) |file|440 for (files) |file|
...@@ -469,9 +469,8 @@ test "write files" {...@@ -469,9 +469,8 @@ test "write files" {
469 }469 }
470 // without root470 // without root
471 {471 {
472 var output: std.io.AllocatingWriter = undefined;472 var output: std.io.Writer.Allocating = .init(testing.allocator);
473 output.init(testing.allocator);473 var wrt: Writer = .{ .underlying_writer = &output.interface };
474 var wrt: Writer = .{ .underlying_writer = &output.buffered_writer };
475 defer output.deinit();474 defer output.deinit();
476 for (files) |file| {475 for (files) |file| {
477 var content: std.io.Reader = .fixed(file.content);476 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...@@ -204,10 +204,9 @@ pub fn parse(gpa: Allocator, source: [:0]const u8, mode: Mode) Allocator.Error!A
204/// `gpa` is used for allocating the resulting formatted source code.204/// `gpa` is used for allocating the resulting formatted source code.
205/// Caller owns the returned slice of bytes, allocated with `gpa`.205/// Caller owns the returned slice of bytes, allocated with `gpa`.
206pub fn renderAlloc(tree: Ast, gpa: Allocator) error{OutOfMemory}![]u8 {206pub fn renderAlloc(tree: Ast, gpa: Allocator) error{OutOfMemory}![]u8 {
207 var aw: std.io.AllocatingWriter = undefined;207 var aw: std.io.Writer.Allocating = .init(gpa);
208 const bw = aw.init(gpa);
209 errdefer aw.deinit();208 errdefer aw.deinit();
210 render(tree, gpa, bw, .{}) catch |err| switch (err) {209 render(tree, gpa, &aw.interface, .{}) catch |err| switch (err) {
211 error.WriteFailed => return error.OutOfMemory,210 error.WriteFailed => return error.OutOfMemory,
212 };211 };
213 return aw.toOwnedSlice();212 return aw.toOwnedSlice();
lib/std/zig/Ast/Render.zig+2-3
...@@ -2142,14 +2142,13 @@ fn renderArrayInit(...@@ -2142,14 +2142,13 @@ fn renderArrayInit(
21422142
2143 const section_exprs = row_exprs[0..section_end];2143 const section_exprs = row_exprs[0..section_end];
21442144
2145 var sub_expr_buffer: std.io.AllocatingWriter = undefined;2145 var sub_expr_buffer: std.io.Writer.Allocating = .init(gpa);
2146 sub_expr_buffer.init(gpa);
2147 defer sub_expr_buffer.deinit();2146 defer sub_expr_buffer.deinit();
21482147
2149 const sub_expr_buffer_starts = try gpa.alloc(usize, section_exprs.len + 1);2148 const sub_expr_buffer_starts = try gpa.alloc(usize, section_exprs.len + 1);
2150 defer gpa.free(sub_expr_buffer_starts);2149 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);
2153 defer auto_indenting_stream.deinit();2152 defer auto_indenting_stream.deinit();
2154 var sub_render: Render = .{2153 var sub_render: Render = .{
2155 .gpa = r.gpa,2154 .gpa = r.gpa,
lib/std/zig/AstGen.zig+4-6
...@@ -11442,10 +11442,9 @@ fn parseStrLit(...@@ -11442,10 +11442,9 @@ fn parseStrLit(
11442) InnerError!void {11442) InnerError!void {
11443 const raw_string = bytes[offset..];11443 const raw_string = bytes[offset..];
11444 const result = r: {11444 const result = r: {
11445 var aw: std.io.AllocatingWriter = undefined;11445 var aw: std.io.Writer.Allocating = .fromArrayList(astgen.gpa, buf);
11446 const bw = aw.fromArrayList(astgen.gpa, buf);
11447 defer buf.* = aw.toArrayList();11446 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) {
11449 error.WriteFailed => return error.OutOfMemory,11448 error.WriteFailed => return error.OutOfMemory,
11450 };11449 };
11451 };11450 };
...@@ -13899,10 +13898,9 @@ fn lowerAstErrors(astgen: *AstGen) error{OutOfMemory}!void {...@@ -13899,10 +13898,9 @@ fn lowerAstErrors(astgen: *AstGen) error{OutOfMemory}!void {
13899 const tree = astgen.tree;13898 const tree = astgen.tree;
13900 assert(tree.errors.len > 0);13899 assert(tree.errors.len > 0);
1390113900
13902 var msg: std.io.AllocatingWriter = undefined;13901 var msg: std.io.Writer.Allocating = .init(gpa);
13903 msg.init(gpa);
13904 defer msg.deinit();13902 defer msg.deinit();
13905 const msg_bw = &msg.buffered_writer;13903 const msg_bw = &msg.interface;
1390613904
13907 var notes: std.ArrayListUnmanaged(u32) = .empty;13905 var notes: std.ArrayListUnmanaged(u32) = .empty;
13908 defer notes.deinit(gpa);13906 defer notes.deinit(gpa);
lib/std/zig/ErrorBundle.zig+4-4
...@@ -788,8 +788,8 @@ pub const Wip = struct {...@@ -788,8 +788,8 @@ pub const Wip = struct {
788788
789 const ttyconf: std.io.tty.Config = .no_color;789 const ttyconf: std.io.tty.Config = .no_color;
790790
791 var bundle_buf: std.io.AllocatingWriter = undefined;791 var bundle_buf: std.io.Writer.Allocating = .init(std.testing.allocator);
792 const bundle_bw = bundle_buf.init(std.testing.allocator);792 const bundle_bw = &bundle_buf.interface;
793 defer bundle_buf.deinit();793 defer bundle_buf.deinit();
794 try bundle.renderToWriter(.{ .ttyconf = ttyconf }, bundle_bw);794 try bundle.renderToWriter(.{ .ttyconf = ttyconf }, bundle_bw);
795795
...@@ -804,8 +804,8 @@ pub const Wip = struct {...@@ -804,8 +804,8 @@ pub const Wip = struct {
804 };804 };
805 defer copy.deinit(std.testing.allocator);805 defer copy.deinit(std.testing.allocator);
806806
807 var copy_buf: std.io.AllocatingWriter = undefined;807 var copy_buf: std.io.Writer.Allocating = .init(std.testing.allocator);
808 const copy_bw = copy_buf.init(std.testing.allocator);808 const copy_bw = &copy_buf.interface;
809 defer copy_buf.deinit();809 defer copy_buf.deinit();
810 try copy.renderToWriter(.{ .ttyconf = ttyconf }, copy_bw);810 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,...@@ -467,10 +467,9 @@ fn appendIdentStr(zg: *ZonGen, ident_token: Ast.TokenIndex) error{ OutOfMemory,
467 const raw_string = zg.tree.tokenSlice(ident_token)[offset..];467 const raw_string = zg.tree.tokenSlice(ident_token)[offset..];
468 try zg.string_bytes.ensureUnusedCapacity(gpa, raw_string.len);468 try zg.string_bytes.ensureUnusedCapacity(gpa, raw_string.len);
469 const result = r: {469 const result = r: {
470 var aw: std.io.AllocatingWriter = undefined;470 var aw: std.io.Writer.Allocating = .fromArrayList(gpa, &zg.string_bytes);
471 const bw = aw.fromArrayList(gpa, &zg.string_bytes);
472 defer zg.string_bytes = aw.toArrayList();471 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) {
474 error.WriteFailed => return error.OutOfMemory,473 error.WriteFailed => return error.OutOfMemory,
475 };474 };
476 };475 };
...@@ -566,10 +565,9 @@ fn strLitAsString(zg: *ZonGen, str_node: Ast.Node.Index) error{ OutOfMemory, Bad...@@ -566,10 +565,9 @@ fn strLitAsString(zg: *ZonGen, str_node: Ast.Node.Index) error{ OutOfMemory, Bad
566 const size_hint = strLitSizeHint(zg.tree, str_node);565 const size_hint = strLitSizeHint(zg.tree, str_node);
567 try string_bytes.ensureUnusedCapacity(gpa, size_hint);566 try string_bytes.ensureUnusedCapacity(gpa, size_hint);
568 const result = r: {567 const result = r: {
569 var aw: std.io.AllocatingWriter = undefined;568 var aw: std.io.Writer.Allocating = .fromArrayList(gpa, &zg.string_bytes);
570 const bw = aw.fromArrayList(gpa, &zg.string_bytes);
571 defer zg.string_bytes = aw.toArrayList();569 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) {
573 error.WriteFailed => return error.OutOfMemory,571 error.WriteFailed => return error.OutOfMemory,
574 };572 };
575 };573 };
...@@ -888,10 +886,9 @@ fn lowerAstErrors(zg: *ZonGen) Allocator.Error!void {...@@ -888,10 +886,9 @@ fn lowerAstErrors(zg: *ZonGen) Allocator.Error!void {
888 const tree = zg.tree;886 const tree = zg.tree;
889 assert(tree.errors.len > 0);887 assert(tree.errors.len > 0);
890888
891 var msg: std.io.AllocatingWriter = undefined;889 var msg: std.io.Writer.Allocating = .init(gpa);
892 msg.init(gpa);
893 defer msg.deinit();890 defer msg.deinit();
894 const msg_bw = &msg.buffered_writer;891 const msg_bw = &msg.interface;
895892
896 var notes: std.ArrayListUnmanaged(Zoir.CompileError.Note) = .empty;893 var notes: std.ArrayListUnmanaged(Zoir.CompileError.Note) = .empty;
897 defer notes.deinit(gpa);894 defer notes.deinit(gpa);
lib/std/zig/llvm/Builder.zig+3-12
...@@ -8619,16 +8619,7 @@ pub fn deinit(self: *Builder) void {...@@ -8619,16 +8619,7 @@ pub fn deinit(self: *Builder) void {
8619 self.* = undefined;8619 self.* = undefined;
8620}8620}
86218621
8622pub fn setModuleAsm(self: *Builder, aw: *std.io.AllocatingWriter) *Writer {8622pub fn finishModuleAsm(self: *Builder, aw: *std.io.Writer.Allocating) Allocator.Error!void {
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 {
8632 self.module_asm = aw.toArrayList();8623 self.module_asm = aw.toArrayList();
8633 if (self.module_asm.getLastOrNull()) |last| if (last != '\n')8624 if (self.module_asm.getLastOrNull()) |last| if (last != '\n')
8634 try self.module_asm.append(self.gpa, '\n');8625 try self.module_asm.append(self.gpa, '\n');
...@@ -8938,8 +8929,8 @@ pub fn getIntrinsic(...@@ -8938,8 +8929,8 @@ pub fn getIntrinsic(
89388929
8939 const name = name: {8930 const name = name: {
8940 {8931 {
8941 var aw: std.io.AllocatingWriter = undefined;8932 var aw: std.io.Writer.Allocating = .fromArrayList(self.gpa, &self.strtab_string_bytes);
8942 const bw = aw.fromArrayList(self.gpa, &self.strtab_string_bytes);8933 const bw = &aw.interface;
8943 defer self.strtab_string_bytes = aw.toArrayList();8934 defer self.strtab_string_bytes = aw.toArrayList();
8944 bw.print("llvm.{s}", .{@tagName(id)}) catch return error.OutOfMemory;8935 bw.print("llvm.{s}", .{@tagName(id)}) catch return error.OutOfMemory;
8945 for (overload) |ty| bw.print(".{fm}", .{ty.fmt(self)}) catch return error.OutOfMemory;8936 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 {...@@ -358,10 +358,9 @@ pub fn parseWrite(writer: *Writer, bytes: []const u8) Writer.Error!Result {
358/// Higher level API. Does not return extra info about parse errors.358/// Higher level API. Does not return extra info about parse errors.
359/// Caller owns returned memory.359/// Caller owns returned memory.
360pub fn parseAlloc(allocator: std.mem.Allocator, bytes: []const u8) ParseError![]u8 {360pub fn parseAlloc(allocator: std.mem.Allocator, bytes: []const u8) ParseError![]u8 {
361 var aw: std.io.AllocatingWriter = undefined;361 var aw: std.io.Writer.Allocating = .init(allocator);
362 aw.init(allocator);
363 defer aw.deinit();362 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) {
365 error.WriteFailed => return error.OutOfMemory,364 error.WriteFailed => return error.OutOfMemory,
366 };365 };
367 switch (result) {366 switch (result) {
lib/std/zon/parse.zig+2-3
...@@ -638,10 +638,9 @@ const Parser = struct {...@@ -638,10 +638,9 @@ const Parser = struct {
638 if (pointer.sentinel() != null) size_hint += 1;638 if (pointer.sentinel() != null) size_hint += 1;
639 const gpa = self.gpa;639 const gpa = self.gpa;
640640
641 var aw: std.io.AllocatingWriter = undefined;641 var aw = try std.io.Writer.Allocating.initCapacity(gpa, size_hint);
642 try aw.initCapacity(gpa, size_hint);
643 defer aw.deinit();642 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) {
645 error.WriteFailed => return error.OutOfMemory,644 error.WriteFailed => return error.OutOfMemory,
646 };645 };
647 switch (parsed) {646 switch (parsed) {
lib/std/zon/stringify.zig+20-30
...@@ -1054,9 +1054,8 @@ fn expectSerializeEqual(...@@ -1054,9 +1054,8 @@ fn expectSerializeEqual(
1054 value: anytype,1054 value: anytype,
1055 options: SerializeOptions,1055 options: SerializeOptions,
1056) !void {1056) !void {
1057 var aw: std.io.AllocatingWriter = undefined;1057 var aw: std.io.Writer.Allocating = .init(std.testing.allocator);
1058 aw.init(std.testing.allocator);1058 const bw = &aw.interface;
1059 const bw = &aw.buffered_writer;
1060 defer aw.deinit();1059 defer aw.deinit();
10611060
1062 try serialize(value, options, bw);1061 try serialize(value, options, bw);
...@@ -1157,9 +1156,8 @@ test "std.zon stringify whitespace, high level API" {...@@ -1157,9 +1156,8 @@ test "std.zon stringify whitespace, high level API" {
1157}1156}
11581157
1159test "std.zon stringify whitespace, low level API" {1158test "std.zon stringify whitespace, low level API" {
1160 var aw: std.io.AllocatingWriter = undefined;1159 var aw: std.io.Writer.Allocating = .init(std.testing.allocator);
1161 aw.init(std.testing.allocator);1160 var s: Serializer = .{ .writer = &aw.interface };
1162 var s: Serializer = .{ .writer = &aw.buffered_writer };
1163 defer aw.deinit();1161 defer aw.deinit();
11641162
1165 for ([2]bool{ true, false }) |whitespace| {1163 for ([2]bool{ true, false }) |whitespace| {
...@@ -1515,9 +1513,8 @@ test "std.zon stringify whitespace, low level API" {...@@ -1515,9 +1513,8 @@ test "std.zon stringify whitespace, low level API" {
1515}1513}
15161514
1517test "std.zon stringify utf8 codepoints" {1515test "std.zon stringify utf8 codepoints" {
1518 var aw: std.io.AllocatingWriter = undefined;1516 var aw: std.io.Writer.Allocating = .init(std.testing.allocator);
1519 aw.init(std.testing.allocator);1517 var s: Serializer = .{ .writer = &aw.interface };
1520 var s: Serializer = .{ .writer = &aw.buffered_writer };
1521 defer aw.deinit();1518 defer aw.deinit();
15221519
1523 // Printable ASCII1520 // Printable ASCII
...@@ -1626,9 +1623,8 @@ test "std.zon stringify utf8 codepoints" {...@@ -1626,9 +1623,8 @@ test "std.zon stringify utf8 codepoints" {
1626}1623}
16271624
1628test "std.zon stringify strings" {1625test "std.zon stringify strings" {
1629 var aw: std.io.AllocatingWriter = undefined;1626 var aw: std.io.Writer.Allocating = .init(std.testing.allocator);
1630 aw.init(std.testing.allocator);1627 var s: Serializer = .{ .writer = &aw.interface };
1631 var s: Serializer = .{ .writer = &aw.buffered_writer };
1632 defer aw.deinit();1628 defer aw.deinit();
16331629
1634 // Minimal case1630 // Minimal case
...@@ -1697,9 +1693,8 @@ test "std.zon stringify strings" {...@@ -1697,9 +1693,8 @@ test "std.zon stringify strings" {
1697}1693}
16981694
1699test "std.zon stringify multiline strings" {1695test "std.zon stringify multiline strings" {
1700 var aw: std.io.AllocatingWriter = undefined;1696 var aw: std.io.Writer.Allocating = .init(std.testing.allocator);
1701 aw.init(std.testing.allocator);1697 var s: Serializer = .{ .writer = &aw.interface };
1702 var s: Serializer = .{ .writer = &aw.buffered_writer };
1703 defer aw.deinit();1698 defer aw.deinit();
17041699
1705 inline for (.{ true, false }) |whitespace| {1700 inline for (.{ true, false }) |whitespace| {
...@@ -1918,9 +1913,8 @@ test "std.zon stringify skip default fields" {...@@ -1918,9 +1913,8 @@ test "std.zon stringify skip default fields" {
1918}1913}
19191914
1920test "std.zon depth limits" {1915test "std.zon depth limits" {
1921 var aw: std.io.AllocatingWriter = undefined;1916 var aw: std.io.Writer.Allocating = .init(std.testing.allocator);
1922 aw.init(std.testing.allocator);1917 const bw = &aw.interface;
1923 const bw = &aw.buffered_writer;
1924 defer aw.deinit();1918 defer aw.deinit();
19251919
1926 const Recurse = struct { r: []const @This() };1920 const Recurse = struct { r: []const @This() };
...@@ -2180,9 +2174,8 @@ test "std.zon stringify primitives" {...@@ -2180,9 +2174,8 @@ test "std.zon stringify primitives" {
2180}2174}
21812175
2182test "std.zon stringify ident" {2176test "std.zon stringify ident" {
2183 var aw: std.io.AllocatingWriter = undefined;2177 var aw: std.io.Writer.Allocating = .init(std.testing.allocator);
2184 aw.init(std.testing.allocator);2178 var s: Serializer = .{ .writer = &aw.interface };
2185 var s: Serializer = .{ .writer = &aw.buffered_writer };
2186 defer aw.deinit();2179 defer aw.deinit();
21872180
2188 try expectSerializeEqual(".{ .a = 0 }", .{ .a = 0 }, .{});2181 try expectSerializeEqual(".{ .a = 0 }", .{ .a = 0 }, .{});
...@@ -2228,9 +2221,8 @@ test "std.zon stringify ident" {...@@ -2228,9 +2221,8 @@ test "std.zon stringify ident" {
2228}2221}
22292222
2230test "std.zon stringify as tuple" {2223test "std.zon stringify as tuple" {
2231 var aw: std.io.AllocatingWriter = undefined;2224 var aw: std.io.Writer.Allocating = .init(std.testing.allocator);
2232 aw.init(std.testing.allocator);2225 var s: Serializer = .{ .writer = &aw.interface };
2233 var s: Serializer = .{ .writer = &aw.buffered_writer };
2234 defer aw.deinit();2226 defer aw.deinit();
22352227
2236 // Tuples2228 // Tuples
...@@ -2250,9 +2242,8 @@ test "std.zon stringify as tuple" {...@@ -2250,9 +2242,8 @@ test "std.zon stringify as tuple" {
2250}2242}
22512243
2252test "std.zon stringify as float" {2244test "std.zon stringify as float" {
2253 var aw: std.io.AllocatingWriter = undefined;2245 var aw: std.io.Writer.Allocating = .init(std.testing.allocator);
2254 aw.init(std.testing.allocator);2246 var s: Serializer = .{ .writer = &aw.interface };
2255 var s: Serializer = .{ .writer = &aw.buffered_writer };
2256 defer aw.deinit();2247 defer aw.deinit();
22572248
2258 // Comptime float2249 // Comptime float
...@@ -2355,9 +2346,8 @@ test "std.zon pointers" {...@@ -2355,9 +2346,8 @@ test "std.zon pointers" {
2355}2346}
23562347
2357test "std.zon tuple/struct field" {2348test "std.zon tuple/struct field" {
2358 var aw: std.io.AllocatingWriter = undefined;2349 var aw: std.io.Writer.Allocating = .init(std.testing.allocator);
2359 aw.init(std.testing.allocator);2350 var s: Serializer = .{ .writer = &aw.interface };
2360 var s: Serializer = .{ .writer = &aw.buffered_writer };
2361 defer aw.deinit();2351 defer aw.deinit();
23622352
2363 // Test on structs2353 // Test on structs
src/Package/Fetch/git.zig+4-4
...@@ -857,8 +857,8 @@ pub const Session = struct {...@@ -857,8 +857,8 @@ pub const Session = struct {
857 upload_pack_uri.query = null;857 upload_pack_uri.query = null;
858 upload_pack_uri.fragment = null;858 upload_pack_uri.fragment = null;
859859
860 var body: std.io.AllocatingWriter = undefined;860 var body: std.io.Writer.Allocating = .init(session.allocator);
861 const body_writer = body.init(session.allocator);861 const body_writer = &body.interface;
862 defer body.deinit();862 defer body.deinit();
863 try Packet.write(.{ .data = "command=ls-refs\n" }, body_writer);863 try Packet.write(.{ .data = "command=ls-refs\n" }, body_writer);
864 if (session.supports_agent) {864 if (session.supports_agent) {
...@@ -974,9 +974,9 @@ pub const Session = struct {...@@ -974,9 +974,9 @@ pub const Session = struct {
974 upload_pack_uri.query = null;974 upload_pack_uri.query = null;
975 upload_pack_uri.fragment = null;975 upload_pack_uri.fragment = null;
976976
977 var body: std.io.AllocatingWriter = undefined;977 var body: std.io.Writer.Allocating = .init(session.allocator);
978 const body_writer = body.init(session.allocator);
979 defer body.deinit();978 defer body.deinit();
979 const body_writer = &body.interface;
980 try Packet.write(.{ .data = "command=fetch\n" }, body_writer);980 try Packet.write(.{ .data = "command=fetch\n" }, body_writer);
981 if (session.supports_agent) {981 if (session.supports_agent) {
982 try Packet.write(.{ .data = agent_capability }, body_writer);982 try Packet.write(.{ .data = agent_capability }, body_writer);
src/Package/Manifest.zig+2-3
...@@ -471,9 +471,8 @@ const Parse = struct {...@@ -471,9 +471,8 @@ const Parse = struct {
471 offset: u32,471 offset: u32,
472 ) InnerError!void {472 ) InnerError!void {
473 const raw_string = bytes[offset..];473 const raw_string = bytes[offset..];
474 var aw: std.io.AllocatingWriter = undefined;474 var aw: std.io.Writer.Allocating = .fromArrayList(p.gpa, buf);
475 const bw = aw.fromArrayList(p.gpa, buf);475 const result = std.zig.string_literal.parseWrite(&aw.interface, raw_string);
476 const result = std.zig.string_literal.parseWrite(bw, raw_string);
477 buf.* = aw.toArrayList();476 buf.* = aw.toArrayList();
478 switch (result catch return error.OutOfMemory) {477 switch (result catch return error.OutOfMemory) {
479 .success => {},478 .success => {},
src/Sema.zig+6-8
...@@ -3028,10 +3028,9 @@ pub fn createTypeName(...@@ -3028,10 +3028,9 @@ pub fn createTypeName(
3028 const fn_info = sema.code.getFnInfo(ip.funcZirBodyInst(sema.func_index).resolve(ip) orelse return error.AnalysisFail);3028 const fn_info = sema.code.getFnInfo(ip.funcZirBodyInst(sema.func_index).resolve(ip) orelse return error.AnalysisFail);
3029 const zir_tags = sema.code.instructions.items(.tag);3029 const zir_tags = sema.code.instructions.items(.tag);
30303030
3031 var aw: std.io.AllocatingWriter = undefined;3031 var aw: std.io.Writer.Allocating = .init(gpa);
3032 aw.init(gpa);
3033 defer aw.deinit();3032 defer aw.deinit();
3034 const bw = &aw.buffered_writer;3033 const bw = &aw.interface;
3035 bw.print("{f}(", .{block.type_name_ctx.fmt(ip)}) catch return error.OutOfMemory;3034 bw.print("{f}(", .{block.type_name_ctx.fmt(ip)}) catch return error.OutOfMemory;
30363035
3037 var arg_i: usize = 0;3036 var arg_i: usize = 0;
...@@ -5911,9 +5910,9 @@ fn zirCompileLog(...@@ -5911,9 +5910,9 @@ fn zirCompileLog(
5911 const zcu = pt.zcu;5910 const zcu = pt.zcu;
5912 const gpa = zcu.gpa;5911 const gpa = zcu.gpa;
59135912
5914 var aw: std.io.AllocatingWriter = undefined;5913 var aw: std.io.Writer.Allocating = .init(gpa);
5915 defer aw.deinit();5914 defer aw.deinit();
5916 const bw = &aw.buffered_writer;5915 const bw = &aw.interface;
59175916
5918 const extra = sema.code.extraData(Zir.Inst.NodeMultiOp, extended.operand);5917 const extra = sema.code.extraData(Zir.Inst.NodeMultiOp, extended.operand);
5919 const src_node = extra.data.src_node;5918 const src_node = extra.data.src_node;
...@@ -37369,13 +37368,12 @@ fn notePathToComptimeAllocPtr(sema: *Sema, msg: *Zcu.ErrorMsg, src: LazySrcLoc,...@@ -37369,13 +37368,12 @@ fn notePathToComptimeAllocPtr(sema: *Sema, msg: *Zcu.ErrorMsg, src: LazySrcLoc,
37369 error.AnalysisFail => unreachable,37368 error.AnalysisFail => unreachable,
37370 };37369 };
3737137370
37372 var second_path_aw: std.io.AllocatingWriter = undefined;37371 var second_path_aw: std.io.Writer.Allocating = .init(arena);
37373 second_path_aw.init(arena);
37374 defer second_path_aw.deinit();37372 defer second_path_aw.deinit();
37375 const inter_name = try std.fmt.allocPrint(arena, "v{d}", .{intermediate_value_count});37373 const inter_name = try std.fmt.allocPrint(arena, "v{d}", .{intermediate_value_count});
37376 const deriv_start = @import("print_value.zig").printPtrDerivation(37374 const deriv_start = @import("print_value.zig").printPtrDerivation(
37377 derivation,37375 derivation,
37378 &second_path_aw.buffered_writer,37376 &second_path_aw.interface,
37379 pt,37377 pt,
37380 .lvalue,37378 .lvalue,
37381 .{ .str = inter_name },37379 .{ .str = inter_name },
src/arch/aarch64/Emit.zig+2-2
...@@ -452,8 +452,8 @@ fn dbgAdvancePCAndLine(emit: *Emit, line: u32, column: u32) InnerError!void {...@@ -452,8 +452,8 @@ fn dbgAdvancePCAndLine(emit: *Emit, line: u32, column: u32) InnerError!void {
452 .plan9 => |dbg_out| {452 .plan9 => |dbg_out| {
453 if (delta_pc <= 0) return; // only do this when the pc changes453 if (delta_pc <= 0) return; // only do this when the pc changes
454454
455 var aw: std.io.AllocatingWriter = undefined;455 var aw: std.io.Writer.Allocating = .fromArrayList(emit.bin_file.comp.gpa, &dbg_out.dbg_line);
456 const bw = aw.fromArrayList(emit.bin_file.comp.gpa, &dbg_out.dbg_line);456 const bw = &aw.interface;
457 defer dbg_out.dbg_line = aw.toArrayList();457 defer dbg_out.dbg_line = aw.toArrayList();
458458
459 // increasing the line number459 // increasing the line number
src/arch/arm/Emit.zig+2-2
...@@ -368,8 +368,8 @@ fn dbgAdvancePCAndLine(self: *Emit, line: u32, column: u32) !void {...@@ -368,8 +368,8 @@ fn dbgAdvancePCAndLine(self: *Emit, line: u32, column: u32) !void {
368 .plan9 => |dbg_out| {368 .plan9 => |dbg_out| {
369 if (delta_pc <= 0) return; // only do this when the pc changes369 if (delta_pc <= 0) return; // only do this when the pc changes
370370
371 var aw: std.io.AllocatingWriter = undefined;371 var aw: std.io.Writer.Allocating = .fromArrayList(self.bin_file.comp.gpa, &dbg_out.dbg_line);
372 const bw = aw.fromArrayList(self.bin_file.comp.gpa, &dbg_out.dbg_line);372 const bw = &aw.interface;
373 defer dbg_out.dbg_line = aw.toArrayList();373 defer dbg_out.dbg_line = aw.toArrayList();
374374
375 // increasing the line number375 // increasing the line number
src/arch/riscv64/Emit.zig+2-2
...@@ -19,8 +19,8 @@ pub const Error = Lower.Error || error{...@@ -19,8 +19,8 @@ pub const Error = Lower.Error || error{
1919
20pub fn emitMir(emit: *Emit) Error!void {20pub fn emitMir(emit: *Emit) Error!void {
21 const gpa = emit.bin_file.comp.gpa;21 const gpa = emit.bin_file.comp.gpa;
22 var aw: std.io.AllocatingWriter = undefined;22 var aw: std.io.Writer.Allocating = .fromArrayList(gpa, emit.code);
23 const bw = aw.fromArrayList(gpa, emit.code);23 const bw = &aw.interface;
24 defer emit.code.* = aw.toArrayList();24 defer emit.code.* = aw.toArrayList();
2525
26 log.debug("mir instruction len: {}", .{emit.lower.mir.instructions.len});26 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 {...@@ -924,8 +924,8 @@ fn dbgAdvancePCAndLine(emit: *Emit, loc: Loc, pc: usize) Error!void {
924 .plan9 => |dbg_out| {924 .plan9 => |dbg_out| {
925 if (delta_pc <= 0) return; // only do this when the pc changes925 if (delta_pc <= 0) return; // only do this when the pc changes
926926
927 var aw: std.io.AllocatingWriter = undefined;927 var aw: std.io.Writer.Allocating = .fromArrayList(emit.lower.bin_file.comp.gpa, &dbg_out.dbg_line);
928 const bw = aw.fromArrayList(emit.lower.bin_file.comp.gpa, &dbg_out.dbg_line);928 const bw = &aw.interface;
929 defer dbg_out.dbg_line = aw.toArrayList();929 defer dbg_out.dbg_line = aw.toArrayList();
930930
931 // increasing the line number931 // increasing the line number
src/codegen.zig+2-3
...@@ -314,10 +314,9 @@ pub fn generateSymbol(...@@ -314,10 +314,9 @@ pub fn generateSymbol(
314 const tracy = trace(@src());314 const tracy = trace(@src());
315 defer tracy.end();315 defer tracy.end();
316316
317 var aw: std.io.AllocatingWriter = undefined;317 var aw: std.io.Writer.Allocating = .fromArrayList(pt.zcu.gpa, code);
318 const bw = aw.fromArrayList(pt.zcu.gpa, code);
319 defer code.* = aw.toArrayList();318 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) {
321 error.WriteFailed => return error.OutOfMemory,320 error.WriteFailed => return error.OutOfMemory,
322 else => |e| return e,321 else => |e| return e,
323 };322 };
src/codegen/c.zig+3-3
...@@ -694,8 +694,8 @@ pub const Function = struct {...@@ -694,8 +694,8 @@ pub const Function = struct {
694/// It is not available when generating .h file.694/// It is not available when generating .h file.
695pub const Object = struct {695pub const Object = struct {
696 dg: DeclGen,696 dg: DeclGen,
697 code_header: std.io.AllocatingWriter,697 code_header: std.io.Writer.Allocating,
698 code: std.io.AllocatingWriter,698 code: std.io.Writer.Allocating,
699 indent_counter: usize,699 indent_counter: usize,
700700
701 const indent_width = 1;701 const indent_width = 1;
...@@ -731,7 +731,7 @@ pub const DeclGen = struct {...@@ -731,7 +731,7 @@ pub const DeclGen = struct {
731 pass: Pass,731 pass: Pass,
732 is_naked_fn: bool,732 is_naked_fn: bool,
733 expected_block: ?u32,733 expected_block: ?u32,
734 fwd_decl: std.io.AllocatingWriter,734 fwd_decl: std.io.Writer.Allocating,
735 error_msg: ?*Zcu.ErrorMsg,735 error_msg: ?*Zcu.ErrorMsg,
736 ctype_pool: CType.Pool,736 ctype_pool: CType.Pool,
737 scratch: std.ArrayListUnmanaged(u32),737 scratch: std.ArrayListUnmanaged(u32),
src/codegen/llvm.zig+11-8
...@@ -747,13 +747,17 @@ pub const Object = struct {...@@ -747,13 +747,17 @@ pub const Object = struct {
747 }747 }
748748
749 fn genModuleLevelAssembly(object: *Object) Allocator.Error!void {749 fn genModuleLevelAssembly(object: *Object) Allocator.Error!void {
750 var aw: std.io.AllocatingWriter = undefined;750 const b = &object.builder;
751 const bw = object.builder.setModuleAsm(&aw);751 const gpa = b.gpa;
752 errdefer aw.deinit();752 b.module_asm.clearRetainingCapacity();
753 for (object.pt.zcu.global_assembly.values()) |assembly| {753 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');
755 }760 }
756 try object.builder.finishModuleAsm(&aw);
757 }761 }
758762
759 pub const EmitOptions = struct {763 pub const EmitOptions = struct {
...@@ -2678,10 +2682,9 @@ pub const Object = struct {...@@ -2678,10 +2682,9 @@ pub const Object = struct {
2678 }2682 }
26792683
2680 fn allocTypeName(o: *Object, ty: Type) Allocator.Error![:0]const u8 {2684 fn allocTypeName(o: *Object, ty: Type) Allocator.Error![:0]const u8 {
2681 var aw: std.io.AllocatingWriter = undefined;2685 var aw: std.io.Writer.Allocating = .init(o.gpa);
2682 aw.init(o.gpa);
2683 defer aw.deinit();2686 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;
2685 return aw.toOwnedSliceSentinel(0);2688 return aw.toOwnedSliceSentinel(0);
2686 }2689 }
26872690
src/codegen/spirv.zig+2-3
...@@ -1260,10 +1260,9 @@ const NavGen = struct {...@@ -1260,10 +1260,9 @@ const NavGen = struct {
12601260
1261 // Turn a Zig type's name into a cache reference.1261 // Turn a Zig type's name into a cache reference.
1262 fn resolveTypeName(self: *NavGen, ty: Type) Allocator.Error![]const u8 {1262 fn resolveTypeName(self: *NavGen, ty: Type) Allocator.Error![]const u8 {
1263 var aw: std.io.AllocatingWriter = undefined;1263 var aw: std.io.Writer.Allocating = .init(self.gpa);
1264 aw.init(self.gpa);
1265 defer aw.deinit();1264 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;
1267 return aw.toOwnedSlice();1266 return aw.toOwnedSlice();
1268 }1267 }
12691268
src/fmt.zig+3-4
...@@ -142,7 +142,7 @@ pub fn run(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {...@@ -142,7 +142,7 @@ pub fn run(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
142 try std.zig.printAstErrorsToStderr(gpa, tree, "<stdin>", color);142 try std.zig.printAstErrorsToStderr(gpa, tree, "<stdin>", color);
143 process.exit(2);143 process.exit(2);
144 }144 }
145 var aw: std.io.AllocatingWriter = .init(gpa);145 var aw: std.io.Writer.Allocating = .init(gpa);
146 defer aw.deinit();146 defer aw.deinit();
147 try tree.render(gpa, &aw.interface, .{});147 try tree.render(gpa, &aw.interface, .{});
148 const formatted = aw.getWritten();148 const formatted = aw.getWritten();
...@@ -336,10 +336,9 @@ fn fmtPathFile(...@@ -336,10 +336,9 @@ fn fmtPathFile(
336 try fmt.out_buffer.ensureTotalCapacity(gpa, source_code.len);336 try fmt.out_buffer.ensureTotalCapacity(gpa, source_code.len);
337337
338 {338 {
339 var aw: std.io.AllocatingWriter = undefined;339 var aw: std.io.Writer.Allocating = .fromArrayList(gpa, &fmt.out_buffer);
340 const bw = aw.fromArrayList(gpa, &fmt.out_buffer);
341 defer fmt.out_buffer = aw.toArrayList();340 defer fmt.out_buffer = aw.toArrayList();
342 try tree.render(gpa, bw, .{});341 try tree.render(gpa, &aw.interface, .{});
343 }342 }
344 if (mem.eql(u8, fmt.out_buffer.items, source_code))343 if (mem.eql(u8, fmt.out_buffer.items, source_code))
345 return;344 return;
src/libs/mingw.zig+5-6
...@@ -400,8 +400,7 @@ fn findDef(...@@ -400,8 +400,7 @@ fn findDef(
400 else => unreachable,400 else => unreachable,
401 };401 };
402402
403 var override_path: std.io.AllocatingWriter = undefined;403 var override_path: std.io.Writer.Allocating = .init(gpa);
404 override_path.init(gpa);
405 defer override_path.deinit();404 defer override_path.deinit();
406405
407 const s = path.sep_str;406 const s = path.sep_str;
...@@ -410,9 +409,9 @@ fn findDef(...@@ -410,9 +409,9 @@ fn findDef(
410 // Try the archtecture-specific path first.409 // Try the archtecture-specific path first.
411 const fmt_path = "libc" ++ s ++ "mingw" ++ s ++ "{s}" ++ s ++ "{s}.def";410 const fmt_path = "libc" ++ s ++ "mingw" ++ s ++ "{s}" ++ s ++ "{s}.def";
412 if (zig_lib_directory.path) |p| {411 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 });
414 } else {413 } 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 });
416 }415 }
417 if (std.fs.cwd().access(override_path.getWritten(), .{})) |_| {416 if (std.fs.cwd().access(override_path.getWritten(), .{})) |_| {
418 return override_path.toOwnedSlice();417 return override_path.toOwnedSlice();
...@@ -444,9 +443,9 @@ fn findDef(...@@ -444,9 +443,9 @@ fn findDef(
444 override_path.clearRetainingCapacity();443 override_path.clearRetainingCapacity();
445 const fmt_path = "libc" ++ s ++ "mingw" ++ s ++ "lib-common" ++ s ++ "{s}.def.in";444 const fmt_path = "libc" ++ s ++ "mingw" ++ s ++ "lib-common" ++ s ++ "{s}.def.in";
446 if (zig_lib_directory.path) |p| {445 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 });
448 } else {447 } else {
449 try override_path.buffered_writer.print(fmt_path, .{lib_name});448 try override_path.interface.print(fmt_path, .{lib_name});
450 }449 }
451 if (std.fs.cwd().access(override_path.getWritten(), .{})) |_| {450 if (std.fs.cwd().access(override_path.getWritten(), .{})) |_| {
452 return override_path.toOwnedSlice();451 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...@@ -115,8 +115,7 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro
115 var c_source_files = std.ArrayList(Compilation.CSourceFile).init(comp.gpa);115 var c_source_files = std.ArrayList(Compilation.CSourceFile).init(comp.gpa);
116 defer c_source_files.deinit();116 defer c_source_files.deinit();
117117
118 var override_path: std.io.AllocatingWriter = undefined;118 var override_path: std.io.Writer.Allocating = .init(comp.gpa);
119 override_path.init(comp.gpa);
120 defer override_path.deinit();119 defer override_path.deinit();
121120
122 const s = path.sep_str;121 const s = path.sep_str;
...@@ -141,19 +140,19 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro...@@ -141,19 +140,19 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro
141 if (!is_arch_specific) {140 if (!is_arch_specific) {
142 // Look for an arch specific override.141 // Look for an arch specific override.
143 override_path.clearRetainingCapacity();142 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", .{
145 dirname, arch_name, noextbasename,144 dirname, arch_name, noextbasename,
146 });145 });
147 if (source_table.contains(override_path.getWritten())) continue;146 if (source_table.contains(override_path.getWritten())) continue;
148147
149 override_path.clearRetainingCapacity();148 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", .{
151 dirname, arch_name, noextbasename,150 dirname, arch_name, noextbasename,
152 });151 });
153 if (source_table.contains(override_path.getWritten())) continue;152 if (source_table.contains(override_path.getWritten())) continue;
154153
155 override_path.clearRetainingCapacity();154 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", .{
157 dirname, arch_name, noextbasename,156 dirname, arch_name, noextbasename,
158 });157 });
159 if (source_table.contains(override_path.getWritten())) continue;158 if (source_table.contains(override_path.getWritten())) continue;
src/link/Dwarf.zig+6-7
...@@ -1446,10 +1446,10 @@ pub const WipNav = struct {...@@ -1446,10 +1446,10 @@ pub const WipNav = struct {
1446 loc: u32,1446 loc: u32,
1447 cfa: Cfa.RegOff,1447 cfa: Cfa.RegOff,
1448 },1448 },
1449 debug_frame: std.io.AllocatingWriter,1449 debug_frame: std.io.Writer.Allocating,
1450 debug_info: std.io.AllocatingWriter,1450 debug_info: std.io.Writer.Allocating,
1451 debug_line: std.io.AllocatingWriter,1451 debug_line: std.io.Writer.Allocating,
1452 debug_loclists: std.io.AllocatingWriter,1452 debug_loclists: std.io.Writer.Allocating,
1453 pending_lazy: PendingLazy,1453 pending_lazy: PendingLazy,
14541454
1455 pub fn init(wip_nav: *WipNav) void {1455 pub fn init(wip_nav: *WipNav) void {
...@@ -4494,10 +4494,9 @@ fn refAbbrevCode(dwarf: *Dwarf, abbrev_code: AbbrevCode) UpdateError!@typeInfo(A...@@ -4494,10 +4494,9 @@ fn refAbbrevCode(dwarf: *Dwarf, abbrev_code: AbbrevCode) UpdateError!@typeInfo(A
4494 assert(abbrev_code != .null);4494 assert(abbrev_code != .null);
4495 const entry: Entry.Index = @enumFromInt(@intFromEnum(abbrev_code));4495 const entry: Entry.Index = @enumFromInt(@intFromEnum(abbrev_code));
4496 if (dwarf.debug_abbrev.section.getUnit(DebugAbbrev.unit).getEntry(entry).len > 0) return @intFromEnum(abbrev_code);4496 if (dwarf.debug_abbrev.section.getUnit(DebugAbbrev.unit).getEntry(entry).len > 0) return @intFromEnum(abbrev_code);
4497 var daaw: std.io.AllocatingWriter = undefined;4497 var daaw: std.io.Writer.Allocating = .init(dwarf.gpa);
4498 daaw.init(dwarf.gpa);
4499 defer daaw.deinit();4498 defer daaw.deinit();
4500 const dabw = &daaw.buffered_writer;4499 const dabw = &daaw.interface;
4501 const abbrev = AbbrevCode.abbrevs.get(abbrev_code);4500 const abbrev = AbbrevCode.abbrevs.get(abbrev_code);
4502 try dabw.writeLeb128(@intFromEnum(abbrev_code));4501 try dabw.writeLeb128(@intFromEnum(abbrev_code));
4503 try dabw.writeLeb128(@intFromEnum(abbrev.tag));4502 try dabw.writeLeb128(@intFromEnum(abbrev.tag));
src/link/MachO/CodeSignature.zig+4-6
...@@ -304,11 +304,10 @@ pub fn writeAdhocSignature(...@@ -304,11 +304,10 @@ pub fn writeAdhocSignature(
304 var hash: [hash_size]u8 = undefined;304 var hash: [hash_size]u8 = undefined;
305305
306 if (self.requirements) |*req| {306 if (self.requirements) |*req| {
307 var aw: std.io.AllocatingWriter = undefined;307 var aw: std.io.Writer.Allocating = .init(allocator);
308 aw.init(allocator);
309 defer aw.deinit();308 defer aw.deinit();
310309
311 try req.write(&aw.buffered_writer);310 try req.write(&aw.interface);
312 Sha256.hash(aw.getWritten(), &hash, .{});311 Sha256.hash(aw.getWritten(), &hash, .{});
313 self.code_directory.addSpecialHash(req.slotType(), hash);312 self.code_directory.addSpecialHash(req.slotType(), hash);
314313
...@@ -318,11 +317,10 @@ pub fn writeAdhocSignature(...@@ -318,11 +317,10 @@ pub fn writeAdhocSignature(
318 }317 }
319318
320 if (self.entitlements) |*ents| {319 if (self.entitlements) |*ents| {
321 var aw: std.io.AllocatingWriter = undefined;320 var aw: std.io.Writer.Allocating = .init(allocator);
322 aw.init(allocator);
323 defer aw.deinit();321 defer aw.deinit();
324322
325 try ents.write(&aw.buffered_writer);323 try ents.write(&aw.interface);
326 Sha256.hash(aw.getWritten(), &hash, .{});324 Sha256.hash(aw.getWritten(), &hash, .{});
327 self.code_directory.addSpecialHash(ents.slotType(), hash);325 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 {...@@ -110,8 +110,8 @@ pub fn updateSize(rebase: *Rebase, macho_file: *MachO) !void {
110fn finalize(rebase: *Rebase, gpa: Allocator) !void {110fn finalize(rebase: *Rebase, gpa: Allocator) !void {
111 if (rebase.entries.items.len == 0) return;111 if (rebase.entries.items.len == 0) return;
112112
113 var aw: std.io.AllocatingWriter = undefined;113 var aw: std.io.Writer.Allocating = .fromArrayList(gpa, &rebase.buffer);
114 const bw = aw.fromArrayList(gpa, &rebase.buffer);114 const bw = &aw.interface;
115 defer rebase.buffer = aw.toArrayList();115 defer rebase.buffer = aw.toArrayList();
116116
117 log.debug("rebase opcodes", .{});117 log.debug("rebase opcodes", .{});
src/link/MachO/dyld_info/bind.zig+6-6
...@@ -118,8 +118,8 @@ pub const Bind = struct {...@@ -118,8 +118,8 @@ pub const Bind = struct {
118 fn finalize(bind: *Bind, gpa: Allocator, ctx: *MachO) !void {118 fn finalize(bind: *Bind, gpa: Allocator, ctx: *MachO) !void {
119 if (bind.entries.items.len == 0) return;119 if (bind.entries.items.len == 0) return;
120120
121 var aw: std.io.AllocatingWriter = undefined;121 var aw: std.io.Writer.Allocating = .fromArrayList(gpa, &bind.buffer);
122 const bw = aw.fromArrayList(gpa, &bind.buffer);122 const bw = &aw.interface;
123 defer bind.buffer = aw.toArrayList();123 defer bind.buffer = aw.toArrayList();
124124
125 log.debug("bind opcodes", .{});125 log.debug("bind opcodes", .{});
...@@ -359,8 +359,8 @@ pub const WeakBind = struct {...@@ -359,8 +359,8 @@ pub const WeakBind = struct {
359 fn finalize(bind: *WeakBind, gpa: Allocator, ctx: *MachO) !void {359 fn finalize(bind: *WeakBind, gpa: Allocator, ctx: *MachO) !void {
360 if (bind.entries.items.len == 0) return;360 if (bind.entries.items.len == 0) return;
361361
362 var aw: std.io.AllocatingWriter = undefined;362 var aw: std.io.Writer.Allocating = .fromArrayList(gpa, &bind.buffer);
363 const bw = aw.fromArrayList(gpa, &bind.buffer);363 const bw = &aw.interface;
364 defer bind.buffer = aw.toArrayList();364 defer bind.buffer = aw.toArrayList();
365365
366 log.debug("weak bind opcodes", .{});366 log.debug("weak bind opcodes", .{});
...@@ -526,8 +526,8 @@ pub const LazyBind = struct {...@@ -526,8 +526,8 @@ pub const LazyBind = struct {
526 fn finalize(bind: *LazyBind, gpa: Allocator, ctx: *MachO) !void {526 fn finalize(bind: *LazyBind, gpa: Allocator, ctx: *MachO) !void {
527 try bind.offsets.ensureTotalCapacityPrecise(gpa, bind.entries.items.len);527 try bind.offsets.ensureTotalCapacityPrecise(gpa, bind.entries.items.len);
528528
529 var aw: std.io.AllocatingWriter = undefined;529 var aw: std.io.Writer.Allocating = .fromArrayList(gpa, &bind.buffer);
530 const bw = aw.fromArrayList(gpa, &bind.buffer);530 const bw = &aw.interface;
531 defer bind.buffer = aw.toArrayList();531 defer bind.buffer = aw.toArrayList();
532532
533 log.debug("lazy bind opcodes", .{});533 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...@@ -337,7 +337,7 @@ fn putFn(self: *Plan9, nav_index: InternPool.Nav.Index, out: FnNavOutput) !void
337 };337 };
338 try fn_map_res.value_ptr.functions.put(gpa, nav_index, out);338 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);
341 defer aw.deinit();341 defer aw.deinit();
342 const w = &aw.interface;342 const w = &aw.interface;
343343
...@@ -646,12 +646,11 @@ pub fn flush(...@@ -646,12 +646,11 @@ pub fn flush(
646 var iovecs_i: usize = 1;646 var iovecs_i: usize = 1;
647 var text_i: u64 = 0;647 var text_i: u64 = 0;
648648
649 var linecountinfo_aw: std.io.AllocatingWriter = undefined;649 var linecountinfo_aw: std.io.Writer.Allocating = .init(gpa);
650 linecountinfo_aw.init(gpa);
651 defer linecountinfo_aw.deinit();650 defer linecountinfo_aw.deinit();
652 // text651 // text
653 {652 {
654 const linecountinfo_bw = &linecountinfo_aw.buffered_writer;653 const linecountinfo_bw = &linecountinfo_aw.interface;
655 var linecount: i64 = -1;654 var linecount: i64 = -1;
656 var it_file = self.fn_nav_table.iterator();655 var it_file = self.fn_nav_table.iterator();
657 while (it_file.next()) |fentry| {656 while (it_file.next()) |fentry| {
...@@ -819,10 +818,9 @@ pub fn flush(...@@ -819,10 +818,9 @@ pub fn flush(
819 }818 }
820 }819 }
821 }820 }
822 var syms_aw: std.io.AllocatingWriter = undefined;821 var syms_aw: std.io.Writer.Allocating = .init(gpa);
823 syms_aw.init(gpa);
824 defer syms_aw.deinit();822 defer syms_aw.deinit();
825 try self.writeSyms(&syms_aw.buffered_writer);823 try self.writeSyms(&syms_aw.interface);
826 const syms = syms_aw.getWritten();824 const syms = syms_aw.getWritten();
827 assert(2 + self.atomCount() - self.externCount() == iovecs_i); // we didn't write all the decls825 assert(2 + self.atomCount() - self.externCount() == iovecs_i); // we didn't write all the decls
828 iovecs[iovecs_i] = .{ .base = syms.ptr, .len = syms.len };826 iovecs[iovecs_i] = .{ .base = syms.ptr, .len = syms.len };
src/link/SpirV.zig+4-5
...@@ -203,11 +203,10 @@ pub fn flush(...@@ -203,11 +203,10 @@ pub fn flush(
203 // We need to export the list of error names somewhere so that we can pretty-print them in the203 // We need to export the list of error names somewhere so that we can pretty-print them in the
204 // executor. This is not really an important thing though, so we can just dump it in any old204 // executor. This is not really an important thing though, so we can just dump it in any old
205 // nonsemantic instruction. For now, just put it in OpSourceExtension with a special name.205 // nonsemantic instruction. For now, just put it in OpSourceExtension with a special name.
206 var error_info: std.io.AllocatingWriter = undefined;206 var error_info: std.io.Writer.Allocating = .init(self.object.gpa);
207 error_info.init(self.object.gpa);
208 defer error_info.deinit();207 defer error_info.deinit();
209208
210 try error_info.buffered_writer.writeAll("zig_errors:");209 try error_info.interface.writeAll("zig_errors:");
211 const ip = &self.base.comp.zcu.?.intern_pool;210 const ip = &self.base.comp.zcu.?.intern_pool;
212 for (ip.global_error_set.getNamesFromMainThread()) |name| {211 for (ip.global_error_set.getNamesFromMainThread()) |name| {
213 // Errors can contain pretty much any character - to encode them in a string we must escape212 // Errors can contain pretty much any character - to encode them in a string we must escape
...@@ -215,9 +214,9 @@ pub fn flush(...@@ -215,9 +214,9 @@ pub fn flush(
215 // name if it contains no strange characters is nice for debugging. URI encoding fits the bill.214 // name if it contains no strange characters is nice for debugging. URI encoding fits the bill.
216 // We're using : as separator, which is a reserved character.215 // We're using : as separator, which is a reserved character.
217216
218 try error_info.buffered_writer.writeByte(':');217 try error_info.interface.writeByte(':');
219 try std.Uri.Component.percentEncode(218 try std.Uri.Component.percentEncode(
220 &error_info.buffered_writer,219 &error_info.interface,
221 name.toSlice(ip),220 name.toSlice(ip),
222 struct {221 struct {
223 fn isValidChar(c: u8) bool {222 fn isValidChar(c: u8) bool {
src/link/Wasm/Flush.zig+9-9
...@@ -558,7 +558,7 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void {...@@ -558,7 +558,7 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void {
558 var data_section_index: ?u32 = null;558 var data_section_index: ?u32 = null;
559559
560 assert(f.binary_bytes.items.len == 0);560 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);
562 defer f.binary_bytes = aw.toArrayList();562 defer f.binary_bytes = aw.toArrayList();
563 const w = &aw.interface;563 const w = &aw.interface;
564564
...@@ -1064,7 +1064,7 @@ const VirtualAddrs = struct {...@@ -1064,7 +1064,7 @@ const VirtualAddrs = struct {
10641064
1065fn emitNameSection(1065fn emitNameSection(
1066 wasm: *Wasm,1066 wasm: *Wasm,
1067 aw: *std.io.AllocatingWriter,1067 aw: *std.io.Writer.Allocating,
1068 data_segment_groups: []const DataSegmentGroup,1068 data_segment_groups: []const DataSegmentGroup,
1069) !void {1069) !void {
1070 const f = &wasm.flush_buffer;1070 const f = &wasm.flush_buffer;
...@@ -1128,7 +1128,7 @@ fn emitNameSection(...@@ -1128,7 +1128,7 @@ fn emitNameSection(
1128 }1128 }
1129}1129}
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 {
1132 const feature_count = target.cpu.features.count();1132 const feature_count = target.cpu.features.count();
1133 if (feature_count == 0) return;1133 if (feature_count == 0) return;
11341134
...@@ -1155,7 +1155,7 @@ fn emitFeaturesSection(aw: *std.io.AllocatingWriter, target: *const std.Target)...@@ -1155,7 +1155,7 @@ fn emitFeaturesSection(aw: *std.io.AllocatingWriter, target: *const std.Target)
1155 assert(safety_count == 0);1155 assert(safety_count == 0);
1156}1156}
11571157
1158fn emitBuildIdSection(aw: *std.io.AllocatingWriter, build_id: []const u8) !void {1158fn emitBuildIdSection(aw: *std.io.Writer.Allocating, build_id: []const u8) !void {
1159 const w = &aw.interface;1159 const w = &aw.interface;
1160 const header_offset = try reserveSectionHeader(w);1160 const header_offset = try reserveSectionHeader(w);
1161 defer replaceSectionHeader(aw, header_offset, @intFromEnum(std.wasm.Section.custom));1161 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...@@ -1169,7 +1169,7 @@ fn emitBuildIdSection(aw: *std.io.AllocatingWriter, build_id: []const u8) !void
1169 try w.writeAll(build_id);1169 try w.writeAll(build_id);
1170}1170}
11711171
1172fn emitProducerSection(aw: *std.io.AllocatingWriter) !void {1172fn emitProducerSection(aw: *std.io.Writer.Allocating) !void {
1173 const w = &aw.interface;1173 const w = &aw.interface;
1174 const header_offset = try reserveSectionHeader(w);1174 const header_offset = try reserveSectionHeader(w);
1175 defer replaceSectionHeader(aw, header_offset, @intFromEnum(std.wasm.Section.custom));1175 defer replaceSectionHeader(aw, header_offset, @intFromEnum(std.wasm.Section.custom));
...@@ -1259,7 +1259,7 @@ fn reserveVecSectionHeader(w: *Writer) Writer.Error!u32 {...@@ -1259,7 +1259,7 @@ fn reserveVecSectionHeader(w: *Writer) Writer.Error!u32 {
1259}1259}
12601260
1261fn replaceVecSectionHeader(1261fn replaceVecSectionHeader(
1262 aw: *std.io.AllocatingWriter,1262 aw: *std.io.Writer.Allocating,
1263 offset: u32,1263 offset: u32,
1264 section: std.wasm.Section,1264 section: std.wasm.Section,
1265 n_items: u32,1265 n_items: u32,
...@@ -1278,7 +1278,7 @@ fn reserveSectionHeader(w: *Writer) Writer.Error!u32 {...@@ -1278,7 +1278,7 @@ fn reserveSectionHeader(w: *Writer) Writer.Error!u32 {
1278 return @intCast(offset);1278 return @intCast(offset);
1279}1279}
12801280
1281fn replaceSectionHeader(aw: *std.io.AllocatingWriter, offset: u32, section: u8) void {1281fn replaceSectionHeader(aw: *std.io.Writer.Allocating, offset: u32, section: u8) void {
1282 const header = aw.getWritten()[offset..][0..section_header_size];1282 const header = aw.getWritten()[offset..][0..section_header_size];
1283 header[0] = section;1283 header[0] = section;
1284 std.leb.writeUnsignedFixed(5, header[1..6], @intCast(aw.interface.count - offset - section_header_size));1284 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 {...@@ -1292,7 +1292,7 @@ fn reserveSizeHeader(w: *Writer) Writer.Error!u32 {
1292 return @intCast(offset);1292 return @intCast(offset);
1293}1293}
12941294
1295fn replaceSizeHeader(aw: *std.io.AllocatingWriter, offset: u32) void {1295fn replaceSizeHeader(aw: *std.io.Writer.Allocating, offset: u32) void {
1296 const header = aw.getWritten()[offset..][0..size_header_size];1296 const header = aw.getWritten()[offset..][0..size_header_size];
1297 std.leb.writeUnsignedFixed(5, header[0..5], @intCast(aw.interface.count - offset - size_header_size));1297 std.leb.writeUnsignedFixed(5, header[0..5], @intCast(aw.interface.count - offset - size_header_size));
1298}1298}
...@@ -1764,7 +1764,7 @@ fn emitInitTlsFunction(wasm: *const Wasm, w: *Writer) Writer.Error!void {...@@ -1764,7 +1764,7 @@ fn emitInitTlsFunction(wasm: *const Wasm, w: *Writer) Writer.Error!void {
1764 try w.writeByte(@intFromEnum(std.wasm.Opcode.end));1764 try w.writeByte(@intFromEnum(std.wasm.Opcode.end));
1765}1765}
17661766
1767fn emitStartSection(aw: *std.io.AllocatingWriter, i: Wasm.OutputFunctionIndex) !void {1767fn emitStartSection(aw: *std.io.Writer.Allocating, i: Wasm.OutputFunctionIndex) !void {
1768 const header_offset = try reserveVecSectionHeader(&aw.interface);1768 const header_offset = try reserveVecSectionHeader(&aw.interface);
1769 defer replaceVecSectionHeader(aw, header_offset, .start, @intFromEnum(i));1769 defer replaceVecSectionHeader(aw, header_offset, .start, @intFromEnum(i));
1770}1770}