authorgravatar for jay@jayschwa.netJay Petacat <jay@jayschwa.net> 2021-01-05 20:57:18-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-01-07 23:48:58-08:00
loga9b505fa7774e2e8451bedfa7bea27d7227572e7
tree408a88da61e15d5ace79ecefebfe868c09f80d35
parent8e9a1ac364360b160438af0b96132d5aacf39a71

Reduce use of deprecated IO types

Related: #4917

43 files changed, 159 insertions(+), 159 deletions(-)

doc/docgen.zig+4-4
......@@ -40,9 +40,9 @@ pub fn main() !void {
4040 var out_file = try fs.cwd().createFile(out_file_name, .{});
4141 defer out_file.close();
4242
43 const input_file_bytes = try in_file.inStream().readAllAlloc(allocator, max_doc_file_size);
43 const input_file_bytes = try in_file.reader().readAllAlloc(allocator, max_doc_file_size);
4444
45 var buffered_out_stream = io.bufferedOutStream(out_file.writer());
45 var buffered_writer = io.bufferedWriter(out_file.writer());
4646
4747 var tokenizer = Tokenizer.init(in_file_name, input_file_bytes);
4848 var toc = try genToc(allocator, &tokenizer);
......@@ -50,8 +50,8 @@ pub fn main() !void {
5050 try fs.cwd().makePath(tmp_dir_name);
5151 defer fs.cwd().deleteTree(tmp_dir_name) catch {};
5252
53 try genHtml(allocator, &tokenizer, &toc, buffered_out_stream.writer(), zig_exe);
54 try buffered_out_stream.flush();
53 try genHtml(allocator, &tokenizer, &toc, buffered_writer.writer(), zig_exe);
54 try buffered_writer.flush();
5555}
5656
5757const Token = struct {
lib/std/Progress.zig+1-1
......@@ -271,7 +271,7 @@ fn refreshWithHeldLock(self: *Progress) void {
271271pub fn log(self: *Progress, comptime format: []const u8, args: anytype) void {
272272 const file = self.terminal orelse return;
273273 self.refresh();
274 file.outStream().print(format, args) catch {
274 file.writer().print(format, args) catch {
275275 self.terminal = null;
276276 return;
277277 };
lib/std/atomic/queue.zig+4-4
......@@ -122,7 +122,7 @@ pub fn Queue(comptime T: type) type {
122122
123123 /// Dumps the contents of the queue to `stderr`.
124124 pub fn dump(self: *Self) void {
125 self.dumpToStream(std.io.getStdErr().outStream()) catch return;
125 self.dumpToStream(std.io.getStdErr().writer()) catch return;
126126 }
127127
128128 /// Dumps the contents of the queue to `stream`.
......@@ -351,7 +351,7 @@ test "std.atomic.Queue dump" {
351351
352352 // Test empty stream
353353 fbs.reset();
354 try queue.dumpToStream(fbs.outStream());
354 try queue.dumpToStream(fbs.writer());
355355 expect(mem.eql(u8, buffer[0..fbs.pos],
356356 \\head: (null)
357357 \\tail: (null)
......@@ -367,7 +367,7 @@ test "std.atomic.Queue dump" {
367367 queue.put(&node_0);
368368
369369 fbs.reset();
370 try queue.dumpToStream(fbs.outStream());
370 try queue.dumpToStream(fbs.writer());
371371
372372 var expected = try std.fmt.bufPrint(expected_buffer[0..],
373373 \\head: 0x{x}=1
......@@ -387,7 +387,7 @@ test "std.atomic.Queue dump" {
387387 queue.put(&node_1);
388388
389389 fbs.reset();
390 try queue.dumpToStream(fbs.outStream());
390 try queue.dumpToStream(fbs.writer());
391391
392392 expected = try std.fmt.bufPrint(expected_buffer[0..],
393393 \\head: 0x{x}=1
lib/std/build.zig+5-5
......@@ -1042,7 +1042,7 @@ pub const Builder = struct {
10421042
10431043 try child.spawn();
10441044
1045 const stdout = try child.stdout.?.inStream().readAllAlloc(self.allocator, max_output_size);
1045 const stdout = try child.stdout.?.reader().readAllAlloc(self.allocator, max_output_size);
10461046 errdefer self.allocator.free(stdout);
10471047
10481048 const term = try child.wait();
......@@ -1849,7 +1849,7 @@ pub const LibExeObjStep = struct {
18491849 }
18501850
18511851 pub fn addBuildOption(self: *LibExeObjStep, comptime T: type, name: []const u8, value: T) void {
1852 const out = self.build_options_contents.outStream();
1852 const out = self.build_options_contents.writer();
18531853 switch (T) {
18541854 []const []const u8 => {
18551855 out.print("pub const {z}: []const []const u8 = &[_][]const u8{{\n", .{name}) catch unreachable;
......@@ -2295,16 +2295,16 @@ pub const LibExeObjStep = struct {
22952295 } else {
22962296 var mcpu_buffer = std.ArrayList(u8).init(builder.allocator);
22972297
2298 try mcpu_buffer.outStream().print("-mcpu={s}", .{cross.cpu.model.name});
2298 try mcpu_buffer.writer().print("-mcpu={s}", .{cross.cpu.model.name});
22992299
23002300 for (all_features) |feature, i_usize| {
23012301 const i = @intCast(std.Target.Cpu.Feature.Set.Index, i_usize);
23022302 const in_cpu_set = populated_cpu_features.isEnabled(i);
23032303 const in_actual_set = cross.cpu.features.isEnabled(i);
23042304 if (in_cpu_set and !in_actual_set) {
2305 try mcpu_buffer.outStream().print("-{s}", .{feature.name});
2305 try mcpu_buffer.writer().print("-{s}", .{feature.name});
23062306 } else if (!in_cpu_set and in_actual_set) {
2307 try mcpu_buffer.outStream().print("+{s}", .{feature.name});
2307 try mcpu_buffer.writer().print("+{s}", .{feature.name});
23082308 }
23092309 }
23102310
lib/std/build/run.zig+2-2
......@@ -200,7 +200,7 @@ pub const RunStep = struct {
200200
201201 switch (self.stdout_action) {
202202 .expect_exact, .expect_matches => {
203 stdout = child.stdout.?.inStream().readAllAlloc(self.builder.allocator, max_stdout_size) catch unreachable;
203 stdout = child.stdout.?.reader().readAllAlloc(self.builder.allocator, max_stdout_size) catch unreachable;
204204 },
205205 .inherit, .ignore => {},
206206 }
......@@ -210,7 +210,7 @@ pub const RunStep = struct {
210210
211211 switch (self.stderr_action) {
212212 .expect_exact, .expect_matches => {
213 stderr = child.stderr.?.inStream().readAllAlloc(self.builder.allocator, max_stdout_size) catch unreachable;
213 stderr = child.stderr.?.reader().readAllAlloc(self.builder.allocator, max_stdout_size) catch unreachable;
214214 },
215215 .inherit, .ignore => {},
216216 }
lib/std/child_process.zig+1-1
......@@ -922,7 +922,7 @@ fn writeIntFd(fd: i32, value: ErrInt) !void {
922922 .capable_io_mode = .blocking,
923923 .intended_io_mode = .blocking,
924924 };
925 file.outStream().writeIntNative(u64, @intCast(u64, value)) catch return error.SystemResources;
925 file.writer().writeIntNative(u64, @intCast(u64, value)) catch return error.SystemResources;
926926}
927927
928928fn readIntFd(fd: i32) !ErrInt {
lib/std/coff.zig+4-4
......@@ -127,7 +127,7 @@ pub const Coff = struct {
127127 pub fn loadHeader(self: *Coff) !void {
128128 const pe_pointer_offset = 0x3C;
129129
130 const in = self.in_file.inStream();
130 const in = self.in_file.reader();
131131
132132 var magic: [2]u8 = undefined;
133133 try in.readNoEof(magic[0..]);
......@@ -163,7 +163,7 @@ pub const Coff = struct {
163163 }
164164
165165 fn loadOptionalHeader(self: *Coff) !void {
166 const in = self.in_file.inStream();
166 const in = self.in_file.reader();
167167 self.pe_header.magic = try in.readIntLittle(u16);
168168 // For now we're only interested in finding the reference to the .pdb,
169169 // so we'll skip most of this header, which size is different in 32
......@@ -206,7 +206,7 @@ pub const Coff = struct {
206206 const debug_dir = &self.pe_header.data_directory[DEBUG_DIRECTORY];
207207 const file_offset = debug_dir.virtual_address - header.virtual_address + header.pointer_to_raw_data;
208208
209 const in = self.in_file.inStream();
209 const in = self.in_file.reader();
210210 try self.in_file.seekTo(file_offset);
211211
212212 // Find the correct DebugDirectoryEntry, and where its data is stored.
......@@ -257,7 +257,7 @@ pub const Coff = struct {
257257
258258 try self.sections.ensureCapacity(self.coff_header.number_of_sections);
259259
260 const in = self.in_file.inStream();
260 const in = self.in_file.reader();
261261
262262 var name: [8]u8 = undefined;
263263
lib/std/crypto/benchmark.zig+1-1
......@@ -314,7 +314,7 @@ fn mode(comptime x: comptime_int) comptime_int {
314314}
315315
316316pub fn main() !void {
317 const stdout = std.io.getStdOut().outStream();
317 const stdout = std.io.getStdOut().writer();
318318
319319 var buffer: [1024]u8 = undefined;
320320 var fixed = std.heap.FixedBufferAllocator.init(buffer[0..]);
lib/std/debug.zig+18-18
......@@ -517,15 +517,15 @@ fn populateModule(di: *ModuleDebugInfo, mod: *Module) !void {
517517
518518 const modi = di.pdb.getStreamById(mod.mod_info.ModuleSymStream) orelse return error.MissingDebugInfo;
519519
520 const signature = try modi.inStream().readIntLittle(u32);
520 const signature = try modi.reader().readIntLittle(u32);
521521 if (signature != 4)
522522 return error.InvalidDebugInfo;
523523
524524 mod.symbols = try allocator.alloc(u8, mod.mod_info.SymByteSize - 4);
525 try modi.inStream().readNoEof(mod.symbols);
525 try modi.reader().readNoEof(mod.symbols);
526526
527527 mod.subsect_info = try allocator.alloc(u8, mod.mod_info.C13ByteSize);
528 try modi.inStream().readNoEof(mod.subsect_info);
528 try modi.reader().readNoEof(mod.subsect_info);
529529
530530 var sect_offset: usize = 0;
531531 var skip_len: usize = undefined;
......@@ -704,11 +704,11 @@ fn readCoffDebugInfo(allocator: *mem.Allocator, coff_file: File) !ModuleDebugInf
704704 try di.pdb.openFile(di.coff, path);
705705
706706 var pdb_stream = di.pdb.getStream(pdb.StreamType.Pdb) orelse return error.InvalidDebugInfo;
707 const version = try pdb_stream.inStream().readIntLittle(u32);
708 const signature = try pdb_stream.inStream().readIntLittle(u32);
709 const age = try pdb_stream.inStream().readIntLittle(u32);
707 const version = try pdb_stream.reader().readIntLittle(u32);
708 const signature = try pdb_stream.reader().readIntLittle(u32);
709 const age = try pdb_stream.reader().readIntLittle(u32);
710710 var guid: [16]u8 = undefined;
711 try pdb_stream.inStream().readNoEof(&guid);
711 try pdb_stream.reader().readNoEof(&guid);
712712 if (version != 20000404) // VC70, only value observed by LLVM team
713713 return error.UnknownPDBVersion;
714714 if (!mem.eql(u8, &di.coff.guid, &guid) or di.coff.age != age)
......@@ -716,9 +716,9 @@ fn readCoffDebugInfo(allocator: *mem.Allocator, coff_file: File) !ModuleDebugInf
716716 // We validated the executable and pdb match.
717717
718718 const string_table_index = str_tab_index: {
719 const name_bytes_len = try pdb_stream.inStream().readIntLittle(u32);
719 const name_bytes_len = try pdb_stream.reader().readIntLittle(u32);
720720 const name_bytes = try allocator.alloc(u8, name_bytes_len);
721 try pdb_stream.inStream().readNoEof(name_bytes);
721 try pdb_stream.reader().readNoEof(name_bytes);
722722
723723 const HashTableHeader = packed struct {
724724 Size: u32,
......@@ -728,17 +728,17 @@ fn readCoffDebugInfo(allocator: *mem.Allocator, coff_file: File) !ModuleDebugInf
728728 return cap * 2 / 3 + 1;
729729 }
730730 };
731 const hash_tbl_hdr = try pdb_stream.inStream().readStruct(HashTableHeader);
731 const hash_tbl_hdr = try pdb_stream.reader().readStruct(HashTableHeader);
732732 if (hash_tbl_hdr.Capacity == 0)
733733 return error.InvalidDebugInfo;
734734
735735 if (hash_tbl_hdr.Size > HashTableHeader.maxLoad(hash_tbl_hdr.Capacity))
736736 return error.InvalidDebugInfo;
737737
738 const present = try readSparseBitVector(&pdb_stream.inStream(), allocator);
738 const present = try readSparseBitVector(&pdb_stream.reader(), allocator);
739739 if (present.len != hash_tbl_hdr.Size)
740740 return error.InvalidDebugInfo;
741 const deleted = try readSparseBitVector(&pdb_stream.inStream(), allocator);
741 const deleted = try readSparseBitVector(&pdb_stream.reader(), allocator);
742742
743743 const Bucket = struct {
744744 first: u32,
......@@ -746,8 +746,8 @@ fn readCoffDebugInfo(allocator: *mem.Allocator, coff_file: File) !ModuleDebugInf
746746 };
747747 const bucket_list = try allocator.alloc(Bucket, present.len);
748748 for (present) |_| {
749 const name_offset = try pdb_stream.inStream().readIntLittle(u32);
750 const name_index = try pdb_stream.inStream().readIntLittle(u32);
749 const name_offset = try pdb_stream.reader().readIntLittle(u32);
750 const name_index = try pdb_stream.reader().readIntLittle(u32);
751751 const name = mem.spanZ(std.meta.assumeSentinel(name_bytes.ptr + name_offset, 0));
752752 if (mem.eql(u8, name, "/names")) {
753753 break :str_tab_index name_index;
......@@ -762,7 +762,7 @@ fn readCoffDebugInfo(allocator: *mem.Allocator, coff_file: File) !ModuleDebugInf
762762 const dbi = di.pdb.dbi;
763763
764764 // Dbi Header
765 const dbi_stream_header = try dbi.inStream().readStruct(pdb.DbiStreamHeader);
765 const dbi_stream_header = try dbi.reader().readStruct(pdb.DbiStreamHeader);
766766 if (dbi_stream_header.VersionHeader != 19990903) // V70, only value observed by LLVM team
767767 return error.UnknownPDBVersion;
768768 if (dbi_stream_header.Age != age)
......@@ -776,7 +776,7 @@ fn readCoffDebugInfo(allocator: *mem.Allocator, coff_file: File) !ModuleDebugInf
776776 // Module Info Substream
777777 var mod_info_offset: usize = 0;
778778 while (mod_info_offset != mod_info_size) {
779 const mod_info = try dbi.inStream().readStruct(pdb.ModInfo);
779 const mod_info = try dbi.reader().readStruct(pdb.ModInfo);
780780 var this_record_len: usize = @sizeOf(pdb.ModInfo);
781781
782782 const module_name = try dbi.readNullTermString(allocator);
......@@ -814,14 +814,14 @@ fn readCoffDebugInfo(allocator: *mem.Allocator, coff_file: File) !ModuleDebugInf
814814 var sect_contribs = ArrayList(pdb.SectionContribEntry).init(allocator);
815815 var sect_cont_offset: usize = 0;
816816 if (section_contrib_size != 0) {
817 const ver = @intToEnum(pdb.SectionContrSubstreamVersion, try dbi.inStream().readIntLittle(u32));
817 const ver = @intToEnum(pdb.SectionContrSubstreamVersion, try dbi.reader().readIntLittle(u32));
818818 if (ver != pdb.SectionContrSubstreamVersion.Ver60)
819819 return error.InvalidDebugInfo;
820820 sect_cont_offset += @sizeOf(u32);
821821 }
822822 while (sect_cont_offset != section_contrib_size) {
823823 const entry = try sect_contribs.addOne();
824 entry.* = try dbi.inStream().readStruct(pdb.SectionContribEntry);
824 entry.* = try dbi.reader().readStruct(pdb.SectionContribEntry);
825825 sect_cont_offset += @sizeOf(pdb.SectionContribEntry);
826826
827827 if (sect_cont_offset > section_contrib_size)
lib/std/dwarf.zig+5-5
......@@ -408,7 +408,7 @@ pub const DwarfInfo = struct {
408408
409409 fn scanAllFunctions(di: *DwarfInfo) !void {
410410 var stream = io.fixedBufferStream(di.debug_info);
411 const in = &stream.inStream();
411 const in = &stream.reader();
412412 const seekable = &stream.seekableStream();
413413 var this_unit_offset: u64 = 0;
414414
......@@ -512,7 +512,7 @@ pub const DwarfInfo = struct {
512512
513513 fn scanAllCompileUnits(di: *DwarfInfo) !void {
514514 var stream = io.fixedBufferStream(di.debug_info);
515 const in = &stream.inStream();
515 const in = &stream.reader();
516516 const seekable = &stream.seekableStream();
517517 var this_unit_offset: u64 = 0;
518518
......@@ -585,7 +585,7 @@ pub const DwarfInfo = struct {
585585 if (di.debug_ranges) |debug_ranges| {
586586 if (compile_unit.die.getAttrSecOffset(AT_ranges)) |ranges_offset| {
587587 var stream = io.fixedBufferStream(debug_ranges);
588 const in = &stream.inStream();
588 const in = &stream.reader();
589589 const seekable = &stream.seekableStream();
590590
591591 // All the addresses in the list are relative to the value
......@@ -640,7 +640,7 @@ pub const DwarfInfo = struct {
640640
641641 fn parseAbbrevTable(di: *DwarfInfo, offset: u64) !AbbrevTable {
642642 var stream = io.fixedBufferStream(di.debug_abbrev);
643 const in = &stream.inStream();
643 const in = &stream.reader();
644644 const seekable = &stream.seekableStream();
645645
646646 try seekable.seekTo(offset);
......@@ -691,7 +691,7 @@ pub const DwarfInfo = struct {
691691
692692 pub fn getLineNumberInfo(di: *DwarfInfo, compile_unit: CompileUnit, target_address: usize) !debug.LineInfo {
693693 var stream = io.fixedBufferStream(di.debug_line);
694 const in = &stream.inStream();
694 const in = &stream.reader();
695695 const seekable = &stream.seekableStream();
696696
697697 const compile_unit_cwd = try compile_unit.die.getAttrString(di, AT_comp_dir);
lib/std/heap/logging_allocator.zig+1-1
......@@ -89,7 +89,7 @@ test "LoggingAllocator" {
8989
9090 var allocator_buf: [10]u8 = undefined;
9191 var fixedBufferAllocator = std.mem.validationWrap(std.heap.FixedBufferAllocator.init(&allocator_buf));
92 const allocator = &loggingAllocator(&fixedBufferAllocator.allocator, fbs.outStream()).allocator;
92 const allocator = &loggingAllocator(&fixedBufferAllocator.allocator, fbs.writer()).allocator;
9393
9494 var a = try allocator.alloc(u8, 10);
9595 a = allocator.shrink(a, 5);
lib/std/io/buffered_atomic_file.zig+1-1
......@@ -38,7 +38,7 @@ pub const BufferedAtomicFile = struct {
3838 self.atomic_file = try dir.atomicFile(dest_path, atomic_file_options);
3939 errdefer self.atomic_file.deinit();
4040
41 self.file_stream = self.atomic_file.file.outStream();
41 self.file_stream = self.atomic_file.file.writer();
4242 self.buffered_stream = .{ .unbuffered_writer = self.file_stream };
4343 return self;
4444 }
lib/std/io/fixed_buffer_stream.zig+1-1
......@@ -45,7 +45,7 @@ pub fn FixedBufferStream(comptime Buffer: type) type {
4545 return .{ .context = self };
4646 }
4747
48 /// Deprecated: use `inStream`
48 /// Deprecated: use `reader`
4949 pub fn inStream(self: *Self) InStream {
5050 return .{ .context = self };
5151 }
lib/std/io/test.zig+3-3
......@@ -30,8 +30,8 @@ test "write a file, read it, then delete it" {
3030 var file = try tmp.dir.createFile(tmp_file_name, .{});
3131 defer file.close();
3232
33 var buf_stream = io.bufferedOutStream(file.outStream());
34 const st = buf_stream.outStream();
33 var buf_stream = io.bufferedWriter(file.writer());
34 const st = buf_stream.writer();
3535 try st.print("begin", .{});
3636 try st.writeAll(data[0..]);
3737 try st.print("end", .{});
......@@ -72,7 +72,7 @@ test "BitStreams with File Stream" {
7272 var file = try tmp.dir.createFile(tmp_file_name, .{});
7373 defer file.close();
7474
75 var bit_stream = io.bitOutStream(builtin.endian, file.outStream());
75 var bit_stream = io.bitWriter(builtin.endian, file.writer());
7676
7777 try bit_stream.writeBits(@as(u2, 1), 1);
7878 try bit_stream.writeBits(@as(u5, 2), 2);
lib/std/json.zig+8-8
......@@ -1323,31 +1323,31 @@ test "Value.jsonStringify" {
13231323 {
13241324 var buffer: [10]u8 = undefined;
13251325 var fbs = std.io.fixedBufferStream(&buffer);
1326 try @as(Value, .Null).jsonStringify(.{}, fbs.outStream());
1326 try @as(Value, .Null).jsonStringify(.{}, fbs.writer());
13271327 testing.expectEqualSlices(u8, fbs.getWritten(), "null");
13281328 }
13291329 {
13301330 var buffer: [10]u8 = undefined;
13311331 var fbs = std.io.fixedBufferStream(&buffer);
1332 try (Value{ .Bool = true }).jsonStringify(.{}, fbs.outStream());
1332 try (Value{ .Bool = true }).jsonStringify(.{}, fbs.writer());
13331333 testing.expectEqualSlices(u8, fbs.getWritten(), "true");
13341334 }
13351335 {
13361336 var buffer: [10]u8 = undefined;
13371337 var fbs = std.io.fixedBufferStream(&buffer);
1338 try (Value{ .Integer = 42 }).jsonStringify(.{}, fbs.outStream());
1338 try (Value{ .Integer = 42 }).jsonStringify(.{}, fbs.writer());
13391339 testing.expectEqualSlices(u8, fbs.getWritten(), "42");
13401340 }
13411341 {
13421342 var buffer: [10]u8 = undefined;
13431343 var fbs = std.io.fixedBufferStream(&buffer);
1344 try (Value{ .Float = 42 }).jsonStringify(.{}, fbs.outStream());
1344 try (Value{ .Float = 42 }).jsonStringify(.{}, fbs.writer());
13451345 testing.expectEqualSlices(u8, fbs.getWritten(), "4.2e+01");
13461346 }
13471347 {
13481348 var buffer: [10]u8 = undefined;
13491349 var fbs = std.io.fixedBufferStream(&buffer);
1350 try (Value{ .String = "weeee" }).jsonStringify(.{}, fbs.outStream());
1350 try (Value{ .String = "weeee" }).jsonStringify(.{}, fbs.writer());
13511351 testing.expectEqualSlices(u8, fbs.getWritten(), "\"weeee\"");
13521352 }
13531353 {
......@@ -1360,7 +1360,7 @@ test "Value.jsonStringify" {
13601360 };
13611361 try (Value{
13621362 .Array = Array.fromOwnedSlice(undefined, &vals),
1363 }).jsonStringify(.{}, fbs.outStream());
1363 }).jsonStringify(.{}, fbs.writer());
13641364 testing.expectEqualSlices(u8, fbs.getWritten(), "[1,2,3]");
13651365 }
13661366 {
......@@ -1369,7 +1369,7 @@ test "Value.jsonStringify" {
13691369 var obj = ObjectMap.init(testing.allocator);
13701370 defer obj.deinit();
13711371 try obj.putNoClobber("a", .{ .String = "b" });
1372 try (Value{ .Object = obj }).jsonStringify(.{}, fbs.outStream());
1372 try (Value{ .Object = obj }).jsonStringify(.{}, fbs.writer());
13731373 testing.expectEqualSlices(u8, fbs.getWritten(), "{\"a\":\"b\"}");
13741374 }
13751375}
......@@ -2223,7 +2223,7 @@ test "write json then parse it" {
22232223 var out_buffer: [1000]u8 = undefined;
22242224
22252225 var fixed_buffer_stream = std.io.fixedBufferStream(&out_buffer);
2226 const out_stream = fixed_buffer_stream.outStream();
2226 const out_stream = fixed_buffer_stream.writer();
22272227 var jw = writeStream(out_stream, 4);
22282228
22292229 try jw.beginObject();
lib/std/json/write_stream.zig+1-1
......@@ -238,7 +238,7 @@ pub fn writeStream(
238238test "json write stream" {
239239 var out_buf: [1024]u8 = undefined;
240240 var slice_stream = std.io.fixedBufferStream(&out_buf);
241 const out = slice_stream.outStream();
241 const out = slice_stream.writer();
242242
243243 var arena_allocator = std.heap.ArenaAllocator.init(std.testing.allocator);
244244 defer arena_allocator.deinit();
lib/std/net.zig+2-2
......@@ -1106,7 +1106,7 @@ fn linuxLookupNameFromHosts(
11061106 };
11071107 defer file.close();
11081108
1109 const stream = std.io.bufferedInStream(file.inStream()).inStream();
1109 const stream = std.io.bufferedReader(file.reader()).reader();
11101110 var line_buf: [512]u8 = undefined;
11111111 while (stream.readUntilDelimiterOrEof(&line_buf, '\n') catch |err| switch (err) {
11121112 error.StreamTooLong => blk: {
......@@ -1304,7 +1304,7 @@ fn getResolvConf(allocator: *mem.Allocator, rc: *ResolvConf) !void {
13041304 };
13051305 defer file.close();
13061306
1307 const stream = std.io.bufferedInStream(file.inStream()).inStream();
1307 const stream = std.io.bufferedReader(file.reader()).reader();
13081308 var line_buf: [512]u8 = undefined;
13091309 while (stream.readUntilDelimiterOrEof(&line_buf, '\n') catch |err| switch (err) {
13101310 error.StreamTooLong => blk: {
lib/std/net/test.zig+1-1
......@@ -249,6 +249,6 @@ fn testServer(server: *net.StreamServer) anyerror!void {
249249
250250 var client = try server.accept();
251251
252 const stream = client.file.outStream();
252 const stream = client.file.writer();
253253 try stream.print("hello from server\n", .{});
254254}
lib/std/os.zig+1-1
......@@ -191,7 +191,7 @@ fn getRandomBytesDevURandom(buf: []u8) !void {
191191 .capable_io_mode = .blocking,
192192 .intended_io_mode = .blocking,
193193 };
194 const stream = file.inStream();
194 const stream = file.reader();
195195 stream.readNoEof(buf) catch return error.Unexpected;
196196}
197197
lib/std/os/test.zig+3-3
......@@ -475,7 +475,7 @@ test "mmap" {
475475 const file = try tmp.dir.createFile(test_out_file, .{});
476476 defer file.close();
477477
478 const stream = file.outStream();
478 const stream = file.writer();
479479
480480 var i: u32 = 0;
481481 while (i < alloc_size / @sizeOf(u32)) : (i += 1) {
......@@ -499,7 +499,7 @@ test "mmap" {
499499 defer os.munmap(data);
500500
501501 var mem_stream = io.fixedBufferStream(data);
502 const stream = mem_stream.inStream();
502 const stream = mem_stream.reader();
503503
504504 var i: u32 = 0;
505505 while (i < alloc_size / @sizeOf(u32)) : (i += 1) {
......@@ -523,7 +523,7 @@ test "mmap" {
523523 defer os.munmap(data);
524524
525525 var mem_stream = io.fixedBufferStream(data);
526 const stream = mem_stream.inStream();
526 const stream = mem_stream.reader();
527527
528528 var i: u32 = alloc_size / 2 / @sizeOf(u32);
529529 while (i < alloc_size / @sizeOf(u32)) : (i += 1) {
lib/std/special/build_runner.zig+2-2
......@@ -57,8 +57,8 @@ pub fn main() !void {
5757
5858 var targets = ArrayList([]const u8).init(allocator);
5959
60 const stderr_stream = io.getStdErr().outStream();
61 const stdout_stream = io.getStdOut().outStream();
60 const stderr_stream = io.getStdErr().writer();
61 const stdout_stream = io.getStdOut().writer();
6262
6363 while (nextArg(args, &arg_idx)) |arg| {
6464 if (mem.startsWith(u8, arg, "-D")) {
lib/std/unicode/throughput_test.zig+1-1
......@@ -45,7 +45,7 @@ fn benchmarkCodepointCount(buf: []const u8) !ResultCount {
4545}
4646
4747pub fn main() !void {
48 const stdout = std.io.getStdOut().outStream();
48 const stdout = std.io.getStdOut().writer();
4949
5050 const args = try std.process.argsAlloc(std.heap.page_allocator);
5151
lib/std/zig/cross_target.zig+7-7
......@@ -519,29 +519,29 @@ pub const CrossTarget = struct {
519519 var result = std.ArrayList(u8).init(allocator);
520520 defer result.deinit();
521521
522 try result.outStream().print("{s}-{s}", .{ arch_name, os_name });
522 try result.writer().print("{s}-{s}", .{ arch_name, os_name });
523523
524524 // The zig target syntax does not allow specifying a max os version with no min, so
525525 // if either are present, we need the min.
526526 if (self.os_version_min != null or self.os_version_max != null) {
527527 switch (self.getOsVersionMin()) {
528528 .none => {},
529 .semver => |v| try result.outStream().print(".{}", .{v}),
530 .windows => |v| try result.outStream().print("{s}", .{v}),
529 .semver => |v| try result.writer().print(".{}", .{v}),
530 .windows => |v| try result.writer().print("{s}", .{v}),
531531 }
532532 }
533533 if (self.os_version_max) |max| {
534534 switch (max) {
535535 .none => {},
536 .semver => |v| try result.outStream().print("...{}", .{v}),
537 .windows => |v| try result.outStream().print("..{s}", .{v}),
536 .semver => |v| try result.writer().print("...{}", .{v}),
537 .windows => |v| try result.writer().print("..{s}", .{v}),
538538 }
539539 }
540540
541541 if (self.glibc_version) |v| {
542 try result.outStream().print("-{s}.{}", .{ @tagName(self.getAbi()), v });
542 try result.writer().print("-{s}.{}", .{ @tagName(self.getAbi()), v });
543543 } else if (self.abi) |abi| {
544 try result.outStream().print("-{s}", .{@tagName(abi)});
544 try result.writer().print("-{s}", .{@tagName(abi)});
545545 }
546546
547547 return result.toOwnedSlice();
lib/std/zig/parser_test.zig+3-3
......@@ -3734,7 +3734,7 @@ const maxInt = std.math.maxInt;
37343734var fixed_buffer_mem: [100 * 1024]u8 = undefined;
37353735
37363736fn testParse(source: []const u8, allocator: *mem.Allocator, anything_changed: *bool) ![]u8 {
3737 const stderr = io.getStdErr().outStream();
3737 const stderr = io.getStdErr().writer();
37383738
37393739 const tree = try std.zig.parse(allocator, source);
37403740 defer tree.deinit();
......@@ -3767,8 +3767,8 @@ fn testParse(source: []const u8, allocator: *mem.Allocator, anything_changed: *b
37673767 var buffer = std.ArrayList(u8).init(allocator);
37683768 errdefer buffer.deinit();
37693769
3770 const outStream = buffer.outStream();
3771 anything_changed.* = try std.zig.render(allocator, outStream, tree);
3770 const writer = buffer.writer();
3771 anything_changed.* = try std.zig.render(allocator, writer, tree);
37723772 return buffer.toOwnedSlice();
37733773}
37743774fn testTransform(source: []const u8, expected_source: []const u8) !void {
lib/std/zig/perf_test.zig+1-1
......@@ -29,7 +29,7 @@ pub fn main() !void {
2929 const mb_per_sec = bytes_per_sec / (1024 * 1024);
3030
3131 var stdout_file = std.io.getStdOut();
32 const stdout = stdout_file.outStream();
32 const stdout = stdout_file.writer();
3333 try stdout.print("{:.3} MiB/s, {} KiB used \n", .{ mb_per_sec, memory_used / 1024 });
3434}
3535
lib/std/zig/render.zig+2-2
......@@ -790,7 +790,7 @@ fn renderExpression(
790790 const section_exprs = row_exprs[0..section_end];
791791
792792 // Null stream for counting the printed length of each expression
793 var line_find_stream = std.io.findByteOutStream('\n', std.io.null_out_stream);
793 var line_find_stream = std.io.findByteOutStream('\n', std.io.null_writer);
794794 var counting_stream = std.io.countingOutStream(line_find_stream.writer());
795795 var auto_indenting_stream = std.io.autoIndentingStream(indent_delta, counting_stream.writer());
796796
......@@ -954,7 +954,7 @@ fn renderExpression(
954954 const expr_outputs_one_line = blk: {
955955 // render field expressions until a LF is found
956956 for (field_inits) |field_init| {
957 var find_stream = std.io.findByteOutStream('\n', std.io.null_out_stream);
957 var find_stream = std.io.findByteOutStream('\n', std.io.null_writer);
958958 var auto_indenting_stream = std.io.autoIndentingStream(indent_delta, find_stream.writer());
959959
960960 try renderExpression(allocator, &auto_indenting_stream, tree, field_init, Space.None);
src/Cache.zig+1-1
......@@ -285,7 +285,7 @@ pub const Manifest = struct {
285285 };
286286 }
287287
288 const file_contents = try self.manifest_file.?.inStream().readAllAlloc(self.cache.gpa, manifest_file_size_max);
288 const file_contents = try self.manifest_file.?.reader().readAllAlloc(self.cache.gpa, manifest_file_size_max);
289289 defer self.cache.gpa.free(file_contents);
290290
291291 const input_file_count = self.files.items.len;
src/Compilation.zig+4-4
......@@ -1820,7 +1820,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult {
18201820 var out_zig_file = try o_dir.createFile(cimport_zig_basename, .{});
18211821 defer out_zig_file.close();
18221822
1823 var bos = std.io.bufferedOutStream(out_zig_file.writer());
1823 var bos = std.io.bufferedWriter(out_zig_file.writer());
18241824 _ = try std.zig.render(comp.gpa, bos.writer(), tree);
18251825 try bos.flush();
18261826
......@@ -2750,7 +2750,7 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: *Allocator) ![]u8
27502750
27512751 switch (target.os.getVersionRange()) {
27522752 .none => try buffer.appendSlice(" .none = {} }\n"),
2753 .semver => |semver| try buffer.outStream().print(
2753 .semver => |semver| try buffer.writer().print(
27542754 \\ .semver = .{{
27552755 \\ .min = .{{
27562756 \\ .major = {},
......@@ -2773,7 +2773,7 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: *Allocator) ![]u8
27732773 semver.max.minor,
27742774 semver.max.patch,
27752775 }),
2776 .linux => |linux| try buffer.outStream().print(
2776 .linux => |linux| try buffer.writer().print(
27772777 \\ .linux = .{{
27782778 \\ .range = .{{
27792779 \\ .min = .{{
......@@ -2807,7 +2807,7 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: *Allocator) ![]u8
28072807 linux.glibc.minor,
28082808 linux.glibc.patch,
28092809 }),
2810 .windows => |windows| try buffer.outStream().print(
2810 .windows => |windows| try buffer.writer().print(
28112811 \\ .windows = .{{
28122812 \\ .min = {s},
28132813 \\ .max = {s},
src/DepTokenizer.zig+1-1
......@@ -910,7 +910,7 @@ fn depTokenizer(input: []const u8, expect: []const u8) !void {
910910 },
911911 else => {
912912 try buffer.appendSlice("ERROR: ");
913 try token.printError(buffer.outStream());
913 try token.printError(buffer.writer());
914914 break;
915915 },
916916 }
src/Module.zig+1-1
......@@ -1649,7 +1649,7 @@ pub fn getAstTree(self: *Module, root_scope: *Scope.File) !*ast.Tree {
16491649 var msg = std.ArrayList(u8).init(self.gpa);
16501650 defer msg.deinit();
16511651
1652 try parse_err.render(tree.token_ids, msg.outStream());
1652 try parse_err.render(tree.token_ids, msg.writer());
16531653 const err_msg = try self.gpa.create(Compilation.ErrorMsg);
16541654 err_msg.* = .{
16551655 .msg = msg.toOwnedSlice(),
src/codegen/llvm.zig+4-4
......@@ -200,7 +200,7 @@ pub const LLVMIRModule = struct {
200200 if (llvm.Target.getFromTriple(llvm_target_triple.ptr, &target, &error_message)) {
201201 defer llvm.disposeMessage(error_message);
202202
203 const stderr = std.io.getStdErr().outStream();
203 const stderr = std.io.getStdErr().writer();
204204 try stderr.print(
205205 \\Zig is expecting LLVM to understand this target: '{s}'
206206 \\However LLVM responded with: "{s}"
......@@ -268,7 +268,7 @@ pub const LLVMIRModule = struct {
268268 const dump = self.llvm_module.printToString();
269269 defer llvm.disposeMessage(dump);
270270
271 const stderr = std.io.getStdErr().outStream();
271 const stderr = std.io.getStdErr().writer();
272272 try stderr.writeAll(std.mem.spanZ(dump));
273273 }
274274
......@@ -278,7 +278,7 @@ pub const LLVMIRModule = struct {
278278 defer llvm.disposeMessage(error_message);
279279
280280 if (self.llvm_module.verify(.ReturnStatus, &error_message)) {
281 const stderr = std.io.getStdErr().outStream();
281 const stderr = std.io.getStdErr().writer();
282282 try stderr.print("broken LLVM module found: {s}\nThis is a bug in the Zig compiler.", .{error_message});
283283 return error.BrokenLLVMModule;
284284 }
......@@ -296,7 +296,7 @@ pub const LLVMIRModule = struct {
296296 )) {
297297 defer llvm.disposeMessage(error_message);
298298
299 const stderr = std.io.getStdErr().outStream();
299 const stderr = std.io.getStdErr().writer();
300300 try stderr.print("LLVM failed to emit file: {s}\n", .{error_message});
301301 return error.FailedToEmit;
302302 }
src/libc_installation.zig+3-3
......@@ -338,7 +338,7 @@ pub const LibCInstallation = struct {
338338
339339 for (searches) |search| {
340340 result_buf.shrinkAndFree(0);
341 try result_buf.outStream().print("{s}\\Include\\{s}\\ucrt", .{ search.path, search.version });
341 try result_buf.writer().print("{s}\\Include\\{s}\\ucrt", .{ search.path, search.version });
342342
343343 var dir = fs.cwd().openDir(result_buf.items, .{}) catch |err| switch (err) {
344344 error.FileNotFound,
......@@ -384,7 +384,7 @@ pub const LibCInstallation = struct {
384384
385385 for (searches) |search| {
386386 result_buf.shrinkAndFree(0);
387 try result_buf.outStream().print("{s}\\Lib\\{s}\\ucrt\\{s}", .{ search.path, search.version, arch_sub_dir });
387 try result_buf.writer().print("{s}\\Lib\\{s}\\ucrt\\{s}", .{ search.path, search.version, arch_sub_dir });
388388
389389 var dir = fs.cwd().openDir(result_buf.items, .{}) catch |err| switch (err) {
390390 error.FileNotFound,
......@@ -438,7 +438,7 @@ pub const LibCInstallation = struct {
438438
439439 for (searches) |search| {
440440 result_buf.shrinkAndFree(0);
441 const stream = result_buf.outStream();
441 const stream = result_buf.writer();
442442 try stream.print("{s}\\Lib\\{s}\\um\\{s}", .{ search.path, search.version, arch_sub_dir });
443443
444444 var dir = fs.cwd().openDir(result_buf.items, .{}) catch |err| switch (err) {
src/main.zig+19-19
......@@ -196,7 +196,7 @@ pub fn mainArgs(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v
196196 return cmdInit(gpa, arena, cmd_args, .Lib);
197197 } else if (mem.eql(u8, cmd, "targets")) {
198198 const info = try detectNativeTargetInfo(arena, .{});
199 const stdout = io.getStdOut().outStream();
199 const stdout = io.getStdOut().writer();
200200 return @import("print_targets.zig").cmdTargets(arena, cmd_args, stdout, info.target);
201201 } else if (mem.eql(u8, cmd, "version")) {
202202 try std.io.getStdOut().writeAll(build_options.version ++ "\n");
......@@ -1944,8 +1944,8 @@ fn buildOutputType(
19441944 }
19451945 }
19461946
1947 const stdin = std.io.getStdIn().inStream();
1948 const stderr = std.io.getStdErr().outStream();
1947 const stdin = std.io.getStdIn().reader();
1948 const stderr = std.io.getStdErr().writer();
19491949 var repl_buf: [1024]u8 = undefined;
19501950
19511951 while (watch) {
......@@ -2114,9 +2114,9 @@ fn cmdTranslateC(comp: *Compilation, arena: *Allocator, enable_cache: bool) !voi
21142114 var zig_file = try o_dir.createFile(translated_zig_basename, .{});
21152115 defer zig_file.close();
21162116
2117 var bos = io.bufferedOutStream(zig_file.writer());
2118 _ = try std.zig.render(comp.gpa, bos.writer(), tree);
2119 try bos.flush();
2117 var bw = io.bufferedWriter(zig_file.writer());
2118 _ = try std.zig.render(comp.gpa, bw.writer(), tree);
2119 try bw.flush();
21202120
21212121 man.writeManifest() catch |err| warn("failed to write cache manifest: {s}", .{@errorName(err)});
21222122
......@@ -2187,9 +2187,9 @@ pub fn cmdLibC(gpa: *Allocator, args: []const []const u8) !void {
21872187 };
21882188 defer libc.deinit(gpa);
21892189
2190 var bos = io.bufferedOutStream(io.getStdOut().writer());
2191 try libc.render(bos.writer());
2192 try bos.flush();
2190 var bw = io.bufferedWriter(io.getStdOut().writer());
2191 try libc.render(bw.writer());
2192 try bw.flush();
21932193 }
21942194}
21952195
......@@ -2570,7 +2570,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void {
25702570 const arg = args[i];
25712571 if (mem.startsWith(u8, arg, "-")) {
25722572 if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) {
2573 const stdout = io.getStdOut().outStream();
2573 const stdout = io.getStdOut().writer();
25742574 try stdout.writeAll(usage_fmt);
25752575 return cleanExit();
25762576 } else if (mem.eql(u8, arg, "--color")) {
......@@ -2600,7 +2600,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void {
26002600 fatal("cannot use --stdin with positional arguments", .{});
26012601 }
26022602
2603 const stdin = io.getStdIn().inStream();
2603 const stdin = io.getStdIn().reader();
26042604
26052605 const source_code = try stdin.readAllAlloc(gpa, max_src_size);
26062606 defer gpa.free(source_code);
......@@ -2617,14 +2617,14 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void {
26172617 process.exit(1);
26182618 }
26192619 if (check_flag) {
2620 const anything_changed = try std.zig.render(gpa, io.null_out_stream, tree);
2620 const anything_changed = try std.zig.render(gpa, io.null_writer, tree);
26212621 const code = if (anything_changed) @as(u8, 1) else @as(u8, 0);
26222622 process.exit(code);
26232623 }
26242624
2625 var bos = io.bufferedOutStream(io.getStdOut().writer());
2626 _ = try std.zig.render(gpa, bos.writer(), tree);
2627 try bos.flush();
2625 var bw = io.bufferedWriter(io.getStdOut().writer());
2626 _ = try std.zig.render(gpa, bw.writer(), tree);
2627 try bw.flush();
26282628 return;
26292629 }
26302630
......@@ -2774,7 +2774,7 @@ fn fmtPathFile(
27742774 }
27752775
27762776 if (check_mode) {
2777 const anything_changed = try std.zig.render(fmt.gpa, io.null_out_stream, tree);
2777 const anything_changed = try std.zig.render(fmt.gpa, io.null_writer, tree);
27782778 if (anything_changed) {
27792779 const stdout = io.getStdOut().writer();
27802780 try stdout.print("{s}\n", .{file_path});
......@@ -2823,11 +2823,11 @@ fn printErrMsgToFile(
28232823
28242824 var text_buf = std.ArrayList(u8).init(gpa);
28252825 defer text_buf.deinit();
2826 const out_stream = text_buf.outStream();
2827 try parse_error.render(tree.token_ids, out_stream);
2826 const writer = text_buf.writer();
2827 try parse_error.render(tree.token_ids, writer);
28282828 const text = text_buf.items;
28292829
2830 const stream = file.outStream();
2830 const stream = file.writer();
28312831 try stream.print("{s}:{d}:{d}: error: {s}\n", .{ path, start_loc.line + 1, start_loc.column + 1, text });
28322832
28332833 if (!color_on) return;
src/print_env.zig+5-5
......@@ -20,10 +20,10 @@ pub fn cmdEnv(gpa: *Allocator, args: []const []const u8, stdout: std.fs.File.Wri
2020 const global_cache_dir = try introspect.resolveGlobalCacheDir(gpa);
2121 defer gpa.free(global_cache_dir);
2222
23 var bos = std.io.bufferedOutStream(stdout);
24 const bos_stream = bos.outStream();
23 var bw = std.io.bufferedWriter(stdout);
24 const w = bw.writer();
2525
26 var jws = std.json.WriteStream(@TypeOf(bos_stream), 6).init(bos_stream);
26 var jws = std.json.WriteStream(@TypeOf(w), 6).init(w);
2727 try jws.beginObject();
2828
2929 try jws.objectField("zig_exe");
......@@ -42,6 +42,6 @@ pub fn cmdEnv(gpa: *Allocator, args: []const []const u8, stdout: std.fs.File.Wri
4242 try jws.emitString(build_options.version);
4343
4444 try jws.endObject();
45 try bos_stream.writeByte('\n');
46 try bos.flush();
45 try w.writeByte('\n');
46 try bw.flush();
4747}
src/print_targets.zig+5-5
......@@ -26,9 +26,9 @@ pub fn cmdTargets(
2626 const glibc_abi = try glibc.loadMetaData(allocator, zig_lib_directory.handle);
2727 defer glibc_abi.destroy(allocator);
2828
29 var bos = io.bufferedOutStream(stdout);
30 const bos_stream = bos.outStream();
31 var jws = std.json.WriteStream(@TypeOf(bos_stream), 6).init(bos_stream);
29 var bw = io.bufferedWriter(stdout);
30 const w = bw.writer();
31 var jws = std.json.WriteStream(@TypeOf(w), 6).init(w);
3232
3333 try jws.beginObject();
3434
......@@ -156,6 +156,6 @@ pub fn cmdTargets(
156156
157157 try jws.endObject();
158158
159 try bos_stream.writeByte('\n');
160 return bos.flush();
159 try w.writeByte('\n');
160 return bw.flush();
161161}
src/test.zig+1-1
......@@ -738,7 +738,7 @@ pub const TestContext = struct {
738738 write_node.activate();
739739 var out_zir = std.ArrayList(u8).init(allocator);
740740 defer out_zir.deinit();
741 try new_zir_module.writeToStream(allocator, out_zir.outStream());
741 try new_zir_module.writeToStream(allocator, out_zir.writer());
742742 write_node.end();
743743
744744 var test_node = update_node.start("assert", 0);
src/translate_c.zig+1-1
......@@ -5268,7 +5268,7 @@ fn appendTokenFmt(c: *Context, token_id: Token.Id, comptime format: []const u8,
52685268 try c.token_locs.ensureCapacity(c.gpa, c.token_locs.items.len + 1);
52695269
52705270 const start_index = c.source_buffer.items.len;
5271 try c.source_buffer.outStream().print(format ++ " ", args);
5271 try c.source_buffer.writer().print(format ++ " ", args);
52725272
52735273 c.token_ids.appendAssumeCapacity(token_id);
52745274 c.token_locs.appendAssumeCapacity(.{
src/zir.zig+2-2
......@@ -1116,7 +1116,7 @@ pub const Module = struct {
11161116
11171117 /// This is a debugging utility for rendering the tree to stderr.
11181118 pub fn dump(self: Module) void {
1119 self.writeToStream(std.heap.page_allocator, std.io.getStdErr().outStream()) catch {};
1119 self.writeToStream(std.heap.page_allocator, std.io.getStdErr().writer()) catch {};
11201120 }
11211121
11221122 const DeclAndIndex = struct {
......@@ -3254,7 +3254,7 @@ pub fn dumpZir(allocator: *Allocator, kind: []const u8, decl_name: [*:0]const u8
32543254
32553255 try write.inst_table.ensureCapacity(@intCast(u32, instructions.len));
32563256
3257 const stderr = std.io.getStdErr().outStream();
3257 const stderr = std.io.getStdErr().writer();
32583258 try stderr.print("{s} {s} {{ // unanalyzed\n", .{ kind, decl_name });
32593259
32603260 for (instructions) |inst| {
test/compare_output.zig+15-15
......@@ -22,7 +22,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
2222 \\
2323 \\pub fn main() void {
2424 \\ privateFunction();
25 \\ const stdout = getStdOut().outStream();
25 \\ const stdout = getStdOut().writer();
2626 \\ stdout.print("OK 2\n", .{}) catch unreachable;
2727 \\}
2828 \\
......@@ -37,7 +37,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
3737 \\// purposefully conflicting function with main.zig
3838 \\// but it's private so it should be OK
3939 \\fn privateFunction() void {
40 \\ const stdout = getStdOut().outStream();
40 \\ const stdout = getStdOut().writer();
4141 \\ stdout.print("OK 1\n", .{}) catch unreachable;
4242 \\}
4343 \\
......@@ -63,7 +63,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
6363 tc.addSourceFile("foo.zig",
6464 \\usingnamespace @import("std").io;
6565 \\pub fn foo_function() void {
66 \\ const stdout = getStdOut().outStream();
66 \\ const stdout = getStdOut().writer();
6767 \\ stdout.print("OK\n", .{}) catch unreachable;
6868 \\}
6969 );
......@@ -74,7 +74,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
7474 \\
7575 \\pub fn bar_function() void {
7676 \\ if (foo_function()) {
77 \\ const stdout = getStdOut().outStream();
77 \\ const stdout = getStdOut().writer();
7878 \\ stdout.print("OK\n", .{}) catch unreachable;
7979 \\ }
8080 \\}
......@@ -106,7 +106,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
106106 \\pub const a_text = "OK\n";
107107 \\
108108 \\pub fn ok() void {
109 \\ const stdout = io.getStdOut().outStream();
109 \\ const stdout = io.getStdOut().writer();
110110 \\ stdout.print(b_text, .{}) catch unreachable;
111111 \\}
112112 );
......@@ -124,7 +124,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
124124 \\const io = @import("std").io;
125125 \\
126126 \\pub fn main() void {
127 \\ const stdout = io.getStdOut().outStream();
127 \\ const stdout = io.getStdOut().writer();
128128 \\ stdout.print("Hello, world!\n{d:4} {x:3} {c}\n", .{@as(u32, 12), @as(u16, 0x12), @as(u8, 'a')}) catch unreachable;
129129 \\}
130130 , "Hello, world!\n 12 12 a\n");
......@@ -267,7 +267,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
267267 \\ var x_local : i32 = print_ok(x);
268268 \\}
269269 \\fn print_ok(val: @TypeOf(x)) @TypeOf(foo) {
270 \\ const stdout = io.getStdOut().outStream();
270 \\ const stdout = io.getStdOut().writer();
271271 \\ stdout.print("OK\n", .{}) catch unreachable;
272272 \\ return 0;
273273 \\}
......@@ -349,7 +349,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
349349 \\pub fn main() void {
350350 \\ const bar = Bar {.field2 = 13,};
351351 \\ const foo = Foo {.field1 = bar,};
352 \\ const stdout = io.getStdOut().outStream();
352 \\ const stdout = io.getStdOut().writer();
353353 \\ if (!foo.method()) {
354354 \\ stdout.print("BAD\n", .{}) catch unreachable;
355355 \\ }
......@@ -363,7 +363,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
363363 cases.add("defer with only fallthrough",
364364 \\const io = @import("std").io;
365365 \\pub fn main() void {
366 \\ const stdout = io.getStdOut().outStream();
366 \\ const stdout = io.getStdOut().writer();
367367 \\ stdout.print("before\n", .{}) catch unreachable;
368368 \\ defer stdout.print("defer1\n", .{}) catch unreachable;
369369 \\ defer stdout.print("defer2\n", .{}) catch unreachable;
......@@ -376,7 +376,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
376376 \\const io = @import("std").io;
377377 \\const os = @import("std").os;
378378 \\pub fn main() void {
379 \\ const stdout = io.getStdOut().outStream();
379 \\ const stdout = io.getStdOut().writer();
380380 \\ stdout.print("before\n", .{}) catch unreachable;
381381 \\ defer stdout.print("defer1\n", .{}) catch unreachable;
382382 \\ defer stdout.print("defer2\n", .{}) catch unreachable;
......@@ -393,7 +393,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
393393 \\ do_test() catch return;
394394 \\}
395395 \\fn do_test() !void {
396 \\ const stdout = io.getStdOut().outStream();
396 \\ const stdout = io.getStdOut().writer();
397397 \\ stdout.print("before\n", .{}) catch unreachable;
398398 \\ defer stdout.print("defer1\n", .{}) catch unreachable;
399399 \\ errdefer stdout.print("deferErr\n", .{}) catch unreachable;
......@@ -412,7 +412,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
412412 \\ do_test() catch return;
413413 \\}
414414 \\fn do_test() !void {
415 \\ const stdout = io.getStdOut().outStream();
415 \\ const stdout = io.getStdOut().writer();
416416 \\ stdout.print("before\n", .{}) catch unreachable;
417417 \\ defer stdout.print("defer1\n", .{}) catch unreachable;
418418 \\ errdefer stdout.print("deferErr\n", .{}) catch unreachable;
......@@ -429,7 +429,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
429429 \\const io = @import("std").io;
430430 \\
431431 \\pub fn main() void {
432 \\ const stdout = io.getStdOut().outStream();
432 \\ const stdout = io.getStdOut().writer();
433433 \\ stdout.print(foo_txt, .{}) catch unreachable;
434434 \\}
435435 , "1234\nabcd\n");
......@@ -448,7 +448,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
448448 \\
449449 \\pub fn main() !void {
450450 \\ var args_it = std.process.args();
451 \\ const stdout = io.getStdOut().outStream();
451 \\ const stdout = io.getStdOut().writer();
452452 \\ var index: usize = 0;
453453 \\ _ = args_it.skip();
454454 \\ while (args_it.next(allocator)) |arg_or_err| : (index += 1) {
......@@ -487,7 +487,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
487487 \\
488488 \\pub fn main() !void {
489489 \\ var args_it = std.process.args();
490 \\ const stdout = io.getStdOut().outStream();
490 \\ const stdout = io.getStdOut().writer();
491491 \\ var index: usize = 0;
492492 \\ _ = args_it.skip();
493493 \\ while (args_it.next(allocator)) |arg_or_err| : (index += 1) {
test/stage1/behavior/bugs/5487.zig+3-3
......@@ -3,10 +3,10 @@ const io = @import("std").io;
33pub fn write(_: void, bytes: []const u8) !usize {
44 return 0;
55}
6pub fn outStream() io.OutStream(void, @typeInfo(@typeInfo(@TypeOf(write)).Fn.return_type.?).ErrorUnion.error_set, write) {
7 return io.OutStream(void, @typeInfo(@typeInfo(@TypeOf(write)).Fn.return_type.?).ErrorUnion.error_set, write){ .context = {} };
6pub fn writer() io.Writer(void, @typeInfo(@typeInfo(@TypeOf(write)).Fn.return_type.?).ErrorUnion.error_set, write) {
7 return io.Writer(void, @typeInfo(@typeInfo(@TypeOf(write)).Fn.return_type.?).ErrorUnion.error_set, write){ .context = {} };
88}
99
1010test "crash" {
11 _ = io.multiOutStream(.{outStream()});
11 _ = io.multiWriter(.{writer()});
1212}
test/tests.zig+4-4
......@@ -652,9 +652,9 @@ pub const StackTracesContext = struct {
652652 }
653653 child.spawn() catch |err| debug.panic("Unable to spawn {s}: {s}\n", .{ full_exe_path, @errorName(err) });
654654
655 const stdout = child.stdout.?.inStream().readAllAlloc(b.allocator, max_stdout_size) catch unreachable;
655 const stdout = child.stdout.?.reader().readAllAlloc(b.allocator, max_stdout_size) catch unreachable;
656656 defer b.allocator.free(stdout);
657 const stderrFull = child.stderr.?.inStream().readAllAlloc(b.allocator, max_stdout_size) catch unreachable;
657 const stderrFull = child.stderr.?.reader().readAllAlloc(b.allocator, max_stdout_size) catch unreachable;
658658 defer b.allocator.free(stderrFull);
659659 var stderr = stderrFull;
660660
......@@ -875,8 +875,8 @@ pub const CompileErrorContext = struct {
875875 var stdout_buf = ArrayList(u8).init(b.allocator);
876876 var stderr_buf = ArrayList(u8).init(b.allocator);
877877
878 child.stdout.?.inStream().readAllArrayList(&stdout_buf, max_stdout_size) catch unreachable;
879 child.stderr.?.inStream().readAllArrayList(&stderr_buf, max_stdout_size) catch unreachable;
878 child.stdout.?.reader().readAllArrayList(&stdout_buf, max_stdout_size) catch unreachable;
879 child.stderr.?.reader().readAllArrayList(&stderr_buf, max_stdout_size) catch unreachable;
880880
881881 const term = child.wait() catch |err| {
882882 debug.panic("Unable to spawn {s}: {s}\n", .{ zig_args.items[0], @errorName(err) });
tools/update_clang_options.zig+4-4
......@@ -388,8 +388,8 @@ pub fn main() anyerror!void {
388388 // "W" and "Wl,". So we sort this list in order of descending priority.
389389 std.sort.sort(*json.ObjectMap, all_objects.items, {}, objectLessThan);
390390
391 var stdout_bos = std.io.bufferedOutStream(std.io.getStdOut().outStream());
392 const stdout = stdout_bos.outStream();
391 var buffered_stdout = std.io.bufferedWriter(std.io.getStdOut().writer());
392 const stdout = buffered_stdout.writer();
393393 try stdout.writeAll(
394394 \\// This file is generated by tools/update_clang_options.zig.
395395 \\// zig fmt: off
......@@ -469,7 +469,7 @@ pub fn main() anyerror!void {
469469 \\
470470 );
471471
472 try stdout_bos.flush();
472 try buffered_stdout.flush();
473473}
474474
475475// TODO we should be able to import clang_options.zig but currently this is problematic because it will
......@@ -611,7 +611,7 @@ fn objectLessThan(context: void, a: *json.ObjectMap, b: *json.ObjectMap) bool {
611611}
612612
613613fn usageAndExit(file: fs.File, arg0: []const u8, code: u8) noreturn {
614 file.outStream().print(
614 file.writer().print(
615615 \\Usage: {} /path/to/llvm-tblgen /path/to/git/llvm/llvm-project
616616 \\Alternative Usage: zig run /path/to/git/zig/tools/update_clang_options.zig -- /path/to/llvm-tblgen /path/to/git/llvm/llvm-project
617617 \\
tools/update_glibc.zig+3-3
......@@ -239,7 +239,7 @@ pub fn main() !void {
239239 const vers_txt_path = try fs.path.join(allocator, &[_][]const u8{ glibc_out_dir, "vers.txt" });
240240 const vers_txt_file = try fs.cwd().createFile(vers_txt_path, .{});
241241 defer vers_txt_file.close();
242 var buffered = std.io.bufferedOutStream(vers_txt_file.writer());
242 var buffered = std.io.bufferedWriter(vers_txt_file.writer());
243243 const vers_txt = buffered.writer();
244244 for (global_ver_list) |name, i| {
245245 _ = global_ver_set.put(name, i) catch unreachable;
......@@ -251,7 +251,7 @@ pub fn main() !void {
251251 const fns_txt_path = try fs.path.join(allocator, &[_][]const u8{ glibc_out_dir, "fns.txt" });
252252 const fns_txt_file = try fs.cwd().createFile(fns_txt_path, .{});
253253 defer fns_txt_file.close();
254 var buffered = std.io.bufferedOutStream(fns_txt_file.writer());
254 var buffered = std.io.bufferedWriter(fns_txt_file.writer());
255255 const fns_txt = buffered.writer();
256256 for (global_fn_list) |name, i| {
257257 const entry = global_fn_set.getEntry(name).?;
......@@ -282,7 +282,7 @@ pub fn main() !void {
282282 const abilist_txt_path = try fs.path.join(allocator, &[_][]const u8{ glibc_out_dir, "abi.txt" });
283283 const abilist_txt_file = try fs.cwd().createFile(abilist_txt_path, .{});
284284 defer abilist_txt_file.close();
285 var buffered = std.io.bufferedOutStream(abilist_txt_file.writer());
285 var buffered = std.io.bufferedWriter(abilist_txt_file.writer());
286286 const abilist_txt = buffered.writer();
287287
288288 // first iterate over the abi lists