| author | |
| committer | |
| log | 0b3f0124dc33403d329fb8ee63a93215d9af1f1e |
| tree | 3a94c321398ab21810b73c55411523d005b503fa |
| parent | 7c42517151cf06b67268aec3be715b3e303e014a |
preparing to rearrange std.io namespace into an interface
how to upgrade:
std.io.getStdIn() -> std.fs.File.stdin()
std.io.getStdOut() -> std.fs.File.stdout()
std.io.getStdErr() -> std.fs.File.stderr()46 files changed, 175 insertions(+), 222 deletions(-)
lib/compiler/aro/aro/Diagnostics.zig+1-1| ... | @@ -541,7 +541,7 @@ const MsgWriter = struct { | ... | @@ -541,7 +541,7 @@ const MsgWriter = struct { |
| 541 | fn init(config: std.io.tty.Config) MsgWriter { | 541 | fn init(config: std.io.tty.Config) MsgWriter { |
| 542 | std.debug.lockStdErr(); | 542 | std.debug.lockStdErr(); |
| 543 | return .{ | 543 | return .{ |
| 544 | .w = std.io.bufferedWriter(std.io.getStdErr().writer()), | 544 | .w = std.io.bufferedWriter(std.fs.File.stderr().writer()), |
| 545 | .config = config, | 545 | .config = config, |
| 546 | }; | 546 | }; |
| 547 | } | 547 | } |
lib/compiler/aro/aro/Driver.zig+7-7| ... | @@ -519,7 +519,7 @@ fn option(arg: []const u8, name: []const u8) ?[]const u8 { | ... | @@ -519,7 +519,7 @@ fn option(arg: []const u8, name: []const u8) ?[]const u8 { |
| 519 | 519 | ||
| 520 | fn addSource(d: *Driver, path: []const u8) !Source { | 520 | fn addSource(d: *Driver, path: []const u8) !Source { |
| 521 | if (mem.eql(u8, "-", path)) { | 521 | if (mem.eql(u8, "-", path)) { |
| 522 | const stdin = std.io.getStdIn().reader(); | 522 | const stdin = std.fs.File.stdin().reader(); |
| 523 | const input = try stdin.readAllAlloc(d.comp.gpa, std.math.maxInt(u32)); | 523 | const input = try stdin.readAllAlloc(d.comp.gpa, std.math.maxInt(u32)); |
| 524 | defer d.comp.gpa.free(input); | 524 | defer d.comp.gpa.free(input); |
| 525 | return d.comp.addSourceFromBuffer("<stdin>", input); | 525 | return d.comp.addSourceFromBuffer("<stdin>", input); |
| ... | @@ -541,7 +541,7 @@ pub fn fatal(d: *Driver, comptime fmt: []const u8, args: anytype) error{ FatalEr | ... | @@ -541,7 +541,7 @@ pub fn fatal(d: *Driver, comptime fmt: []const u8, args: anytype) error{ FatalEr |
| 541 | } | 541 | } |
| 542 | 542 | ||
| 543 | pub fn renderErrors(d: *Driver) void { | 543 | pub fn renderErrors(d: *Driver) void { |
| 544 | Diagnostics.render(d.comp, d.detectConfig(std.io.getStdErr())); | 544 | Diagnostics.render(d.comp, d.detectConfig(std.fs.File.stderr())); |
| 545 | } | 545 | } |
| 546 | 546 | ||
| 547 | pub fn detectConfig(d: *Driver, file: std.fs.File) std.io.tty.Config { | 547 | pub fn detectConfig(d: *Driver, file: std.fs.File) std.io.tty.Config { |
| ... | @@ -591,7 +591,7 @@ pub fn main(d: *Driver, tc: *Toolchain, args: []const []const u8, comptime fast_ | ... | @@ -591,7 +591,7 @@ pub fn main(d: *Driver, tc: *Toolchain, args: []const []const u8, comptime fast_ |
| 591 | var macro_buf = std.ArrayList(u8).init(d.comp.gpa); | 591 | var macro_buf = std.ArrayList(u8).init(d.comp.gpa); |
| 592 | defer macro_buf.deinit(); | 592 | defer macro_buf.deinit(); |
| 593 | 593 | ||
| 594 | const std_out = std.io.getStdOut().writer(); | 594 | const std_out = std.fs.File.stdout().writer(); |
| 595 | if (try parseArgs(d, std_out, macro_buf.writer(), args)) return; | 595 | if (try parseArgs(d, std_out, macro_buf.writer(), args)) return; |
| 596 | 596 | ||
| 597 | const linking = !(d.only_preprocess or d.only_syntax or d.only_compile or d.only_preprocess_and_compile); | 597 | const linking = !(d.only_preprocess or d.only_syntax or d.only_compile or d.only_preprocess_and_compile); |
| ... | @@ -686,7 +686,7 @@ fn processSource( | ... | @@ -686,7 +686,7 @@ fn processSource( |
| 686 | std.fs.cwd().createFile(some, .{}) catch |er| | 686 | std.fs.cwd().createFile(some, .{}) catch |er| |
| 687 | return d.fatal("unable to create output file '{s}': {s}", .{ some, errorDescription(er) }) | 687 | return d.fatal("unable to create output file '{s}': {s}", .{ some, errorDescription(er) }) |
| 688 | else | 688 | else |
| 689 | std.io.getStdOut(); | 689 | std.fs.File.stdout(); |
| 690 | defer if (d.output_name != null) file.close(); | 690 | defer if (d.output_name != null) file.close(); |
| 691 | 691 | ||
| 692 | var buf_w = std.io.bufferedWriter(file.writer()); | 692 | var buf_w = std.io.bufferedWriter(file.writer()); |
| ... | @@ -704,7 +704,7 @@ fn processSource( | ... | @@ -704,7 +704,7 @@ fn processSource( |
| 704 | defer tree.deinit(); | 704 | defer tree.deinit(); |
| 705 | 705 | ||
| 706 | if (d.verbose_ast) { | 706 | if (d.verbose_ast) { |
| 707 | const stdout = std.io.getStdOut(); | 707 | const stdout = std.fs.File.stdout(); |
| 708 | var buf_writer = std.io.bufferedWriter(stdout.writer()); | 708 | var buf_writer = std.io.bufferedWriter(stdout.writer()); |
| 709 | tree.dump(d.detectConfig(stdout), buf_writer.writer()) catch {}; | 709 | tree.dump(d.detectConfig(stdout), buf_writer.writer()) catch {}; |
| 710 | buf_writer.flush() catch {}; | 710 | buf_writer.flush() catch {}; |
| ... | @@ -734,7 +734,7 @@ fn processSource( | ... | @@ -734,7 +734,7 @@ fn processSource( |
| 734 | defer ir.deinit(d.comp.gpa); | 734 | defer ir.deinit(d.comp.gpa); |
| 735 | 735 | ||
| 736 | if (d.verbose_ir) { | 736 | if (d.verbose_ir) { |
| 737 | const stdout = std.io.getStdOut(); | 737 | const stdout = std.fs.File.stdout(); |
| 738 | var buf_writer = std.io.bufferedWriter(stdout.writer()); | 738 | var buf_writer = std.io.bufferedWriter(stdout.writer()); |
| 739 | ir.dump(d.comp.gpa, d.detectConfig(stdout), buf_writer.writer()) catch {}; | 739 | ir.dump(d.comp.gpa, d.detectConfig(stdout), buf_writer.writer()) catch {}; |
| 740 | buf_writer.flush() catch {}; | 740 | buf_writer.flush() catch {}; |
| ... | @@ -806,7 +806,7 @@ fn processSource( | ... | @@ -806,7 +806,7 @@ fn processSource( |
| 806 | } | 806 | } |
| 807 | 807 | ||
| 808 | fn dumpLinkerArgs(items: []const []const u8) !void { | 808 | fn dumpLinkerArgs(items: []const []const u8) !void { |
| 809 | const stdout = std.io.getStdOut().writer(); | 809 | const stdout = std.fs.File.stdout().writer(); |
| 810 | for (items, 0..) |item, i| { | 810 | for (items, 0..) |item, i| { |
| 811 | if (i > 0) try stdout.writeByte(' '); | 811 | if (i > 0) try stdout.writeByte(' '); |
| 812 | try stdout.print("\"{}\"", .{std.zig.fmtEscapes(item)}); | 812 | try stdout.print("\"{}\"", .{std.zig.fmtEscapes(item)}); |
lib/compiler/aro/aro/Preprocessor.zig+1-1| ... | @@ -811,7 +811,7 @@ fn verboseLog(pp: *Preprocessor, raw: RawToken, comptime fmt: []const u8, args: | ... | @@ -811,7 +811,7 @@ fn verboseLog(pp: *Preprocessor, raw: RawToken, comptime fmt: []const u8, args: |
| 811 | const source = pp.comp.getSource(raw.source); | 811 | const source = pp.comp.getSource(raw.source); |
| 812 | const line_col = source.lineCol(.{ .id = raw.source, .line = raw.line, .byte_offset = raw.start }); | 812 | const line_col = source.lineCol(.{ .id = raw.source, .line = raw.line, .byte_offset = raw.start }); |
| 813 | 813 | ||
| 814 | const stderr = std.io.getStdErr().writer(); | 814 | const stderr = std.fs.File.stderr().writer(); |
| 815 | var buf_writer = std.io.bufferedWriter(stderr); | 815 | var buf_writer = std.io.bufferedWriter(stderr); |
| 816 | const writer = buf_writer.writer(); | 816 | const writer = buf_writer.writer(); |
| 817 | defer buf_writer.flush() catch {}; | 817 | defer buf_writer.flush() catch {}; |
lib/compiler/aro_translate_c.zig+2-2| ... | @@ -1781,7 +1781,7 @@ test "Macro matching" { | ... | @@ -1781,7 +1781,7 @@ test "Macro matching" { |
| 1781 | fn renderErrorsAndExit(comp: *aro.Compilation) noreturn { | 1781 | fn renderErrorsAndExit(comp: *aro.Compilation) noreturn { |
| 1782 | defer std.process.exit(1); | 1782 | defer std.process.exit(1); |
| 1783 | 1783 | ||
| 1784 | var writer = aro.Diagnostics.defaultMsgWriter(std.io.tty.detectConfig(std.io.getStdErr())); | 1784 | var writer = aro.Diagnostics.defaultMsgWriter(std.io.tty.detectConfig(std.fs.File.stderr())); |
| 1785 | defer writer.deinit(); // writer deinit must run *before* exit so that stderr is flushed | 1785 | defer writer.deinit(); // writer deinit must run *before* exit so that stderr is flushed |
| 1786 | 1786 | ||
| 1787 | var saw_error = false; | 1787 | var saw_error = false; |
| ... | @@ -1824,6 +1824,6 @@ pub fn main() !void { | ... | @@ -1824,6 +1824,6 @@ pub fn main() !void { |
| 1824 | defer tree.deinit(gpa); | 1824 | defer tree.deinit(gpa); |
| 1825 | 1825 | ||
| 1826 | const formatted = try tree.render(arena); | 1826 | const formatted = try tree.render(arena); |
| 1827 | try std.io.getStdOut().writeAll(formatted); | 1827 | try std.fs.File.stdout().writeAll(formatted); |
| 1828 | return std.process.cleanExit(); | 1828 | return std.process.cleanExit(); |
| 1829 | } | 1829 | } |
lib/compiler/build_runner.zig+2-2| ... | @@ -330,7 +330,7 @@ pub fn main() !void { | ... | @@ -330,7 +330,7 @@ pub fn main() !void { |
| 330 | } | 330 | } |
| 331 | } | 331 | } |
| 332 | 332 | ||
| 333 | const stderr = std.io.getStdErr(); | 333 | const stderr = std.fs.File.stderr(); |
| 334 | const ttyconf = get_tty_conf(color, stderr); | 334 | const ttyconf = get_tty_conf(color, stderr); |
| 335 | switch (ttyconf) { | 335 | switch (ttyconf) { |
| 336 | .no_color => try graph.env_map.put("NO_COLOR", "1"), | 336 | .no_color => try graph.env_map.put("NO_COLOR", "1"), |
| ... | @@ -378,7 +378,7 @@ pub fn main() !void { | ... | @@ -378,7 +378,7 @@ pub fn main() !void { |
| 378 | 378 | ||
| 379 | validateSystemLibraryOptions(builder); | 379 | validateSystemLibraryOptions(builder); |
| 380 | 380 | ||
| 381 | const stdout_writer = io.getStdOut().writer(); | 381 | const stdout_writer = std.fs.File.stdout().writer(); |
| 382 | 382 | ||
| 383 | if (help_menu) | 383 | if (help_menu) |
| 384 | return usage(builder, stdout_writer); | 384 | return usage(builder, stdout_writer); |
lib/compiler/libc.zig+3-3| ... | @@ -40,7 +40,7 @@ pub fn main() !void { | ... | @@ -40,7 +40,7 @@ pub fn main() !void { |
| 40 | const arg = args[i]; | 40 | const arg = args[i]; |
| 41 | if (mem.startsWith(u8, arg, "-")) { | 41 | if (mem.startsWith(u8, arg, "-")) { |
| 42 | if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) { | 42 | if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) { |
| 43 | const stdout = std.io.getStdOut().writer(); | 43 | const stdout = std.fs.File.stdout().writer(); |
| 44 | try stdout.writeAll(usage_libc); | 44 | try stdout.writeAll(usage_libc); |
| 45 | return std.process.cleanExit(); | 45 | return std.process.cleanExit(); |
| 46 | } else if (mem.eql(u8, arg, "-target")) { | 46 | } else if (mem.eql(u8, arg, "-target")) { |
| ... | @@ -97,7 +97,7 @@ pub fn main() !void { | ... | @@ -97,7 +97,7 @@ pub fn main() !void { |
| 97 | fatal("no include dirs detected for target {s}", .{zig_target}); | 97 | fatal("no include dirs detected for target {s}", .{zig_target}); |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | var bw = std.io.bufferedWriter(std.io.getStdOut().writer()); | 100 | var bw = std.io.bufferedWriter(std.fs.File.stdout().writer()); |
| 101 | var writer = bw.writer(); | 101 | var writer = bw.writer(); |
| 102 | for (libc_dirs.libc_include_dir_list) |include_dir| { | 102 | for (libc_dirs.libc_include_dir_list) |include_dir| { |
| 103 | try writer.writeAll(include_dir); | 103 | try writer.writeAll(include_dir); |
| ... | @@ -125,7 +125,7 @@ pub fn main() !void { | ... | @@ -125,7 +125,7 @@ pub fn main() !void { |
| 125 | }; | 125 | }; |
| 126 | defer libc.deinit(gpa); | 126 | defer libc.deinit(gpa); |
| 127 | 127 | ||
| 128 | var bw = std.io.bufferedWriter(std.io.getStdOut().writer()); | 128 | var bw = std.io.bufferedWriter(std.fs.File.stdout().writer()); |
| 129 | try libc.render(bw.writer()); | 129 | try libc.render(bw.writer()); |
| 130 | try bw.flush(); | 130 | try bw.flush(); |
| 131 | } | 131 | } |
lib/compiler/objcopy.zig+3-3| ... | @@ -54,7 +54,7 @@ fn cmdObjCopy( | ... | @@ -54,7 +54,7 @@ fn cmdObjCopy( |
| 54 | fatal("unexpected positional argument: '{s}'", .{arg}); | 54 | fatal("unexpected positional argument: '{s}'", .{arg}); |
| 55 | } | 55 | } |
| 56 | } else if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) { | 56 | } else if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) { |
| 57 | return std.io.getStdOut().writeAll(usage); | 57 | return std.fs.File.stdout().writeAll(usage); |
| 58 | } else if (mem.eql(u8, arg, "-O") or mem.eql(u8, arg, "--output-target")) { | 58 | } else if (mem.eql(u8, arg, "-O") or mem.eql(u8, arg, "--output-target")) { |
| 59 | i += 1; | 59 | i += 1; |
| 60 | if (i >= args.len) fatal("expected another argument after '{s}'", .{arg}); | 60 | if (i >= args.len) fatal("expected another argument after '{s}'", .{arg}); |
| ... | @@ -227,8 +227,8 @@ fn cmdObjCopy( | ... | @@ -227,8 +227,8 @@ fn cmdObjCopy( |
| 227 | if (listen) { | 227 | if (listen) { |
| 228 | var server = try Server.init(.{ | 228 | var server = try Server.init(.{ |
| 229 | .gpa = gpa, | 229 | .gpa = gpa, |
| 230 | .in = std.io.getStdIn(), | 230 | .in = .stdin(), |
| 231 | .out = std.io.getStdOut(), | 231 | .out = .stdout(), |
| 232 | .zig_version = builtin.zig_version_string, | 232 | .zig_version = builtin.zig_version_string, |
| 233 | }); | 233 | }); |
| 234 | defer server.deinit(); | 234 | defer server.deinit(); |
lib/compiler/reduce.zig+1-1| ... | @@ -68,7 +68,7 @@ pub fn main() !void { | ... | @@ -68,7 +68,7 @@ pub fn main() !void { |
| 68 | const arg = args[i]; | 68 | const arg = args[i]; |
| 69 | if (mem.startsWith(u8, arg, "-")) { | 69 | if (mem.startsWith(u8, arg, "-")) { |
| 70 | if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) { | 70 | if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) { |
| 71 | const stdout = std.io.getStdOut().writer(); | 71 | const stdout = std.fs.File.stdout().writer(); |
| 72 | try stdout.writeAll(usage); | 72 | try stdout.writeAll(usage); |
| 73 | return std.process.cleanExit(); | 73 | return std.process.cleanExit(); |
| 74 | } else if (mem.eql(u8, arg, "--")) { | 74 | } else if (mem.eql(u8, arg, "--")) { |
lib/compiler/resinator/cli.zig+1-1| ... | @@ -127,7 +127,7 @@ pub const Diagnostics = struct { | ... | @@ -127,7 +127,7 @@ pub const Diagnostics = struct { |
| 127 | pub fn renderToStdErr(self: *Diagnostics, args: []const []const u8, config: std.io.tty.Config) void { | 127 | pub fn renderToStdErr(self: *Diagnostics, args: []const []const u8, config: std.io.tty.Config) void { |
| 128 | std.debug.lockStdErr(); | 128 | std.debug.lockStdErr(); |
| 129 | defer std.debug.unlockStdErr(); | 129 | defer std.debug.unlockStdErr(); |
| 130 | const stderr = std.io.getStdErr().writer(); | 130 | const stderr = std.fs.File.stderr().writer(); |
| 131 | self.renderToWriter(args, stderr, config) catch return; | 131 | self.renderToWriter(args, stderr, config) catch return; |
| 132 | } | 132 | } |
| 133 | 133 |
lib/compiler/resinator/errors.zig+2-2| ... | @@ -63,14 +63,14 @@ pub const Diagnostics = struct { | ... | @@ -63,14 +63,14 @@ pub const Diagnostics = struct { |
| 63 | pub fn renderToStdErr(self: *Diagnostics, cwd: std.fs.Dir, source: []const u8, tty_config: std.io.tty.Config, source_mappings: ?SourceMappings) void { | 63 | pub fn renderToStdErr(self: *Diagnostics, cwd: std.fs.Dir, source: []const u8, tty_config: std.io.tty.Config, source_mappings: ?SourceMappings) void { |
| 64 | std.debug.lockStdErr(); | 64 | std.debug.lockStdErr(); |
| 65 | defer std.debug.unlockStdErr(); | 65 | defer std.debug.unlockStdErr(); |
| 66 | const stderr = std.io.getStdErr().writer(); | 66 | const stderr = std.fs.File.stderr().writer(); |
| 67 | for (self.errors.items) |err_details| { | 67 | for (self.errors.items) |err_details| { |
| 68 | renderErrorMessage(stderr, tty_config, cwd, err_details, source, self.strings.items, source_mappings) catch return; | 68 | renderErrorMessage(stderr, tty_config, cwd, err_details, source, self.strings.items, source_mappings) catch return; |
| 69 | } | 69 | } |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | pub fn renderToStdErrDetectTTY(self: *Diagnostics, cwd: std.fs.Dir, source: []const u8, source_mappings: ?SourceMappings) void { | 72 | pub fn renderToStdErrDetectTTY(self: *Diagnostics, cwd: std.fs.Dir, source: []const u8, source_mappings: ?SourceMappings) void { |
| 73 | const tty_config = std.io.tty.detectConfig(std.io.getStdErr()); | 73 | const tty_config = std.io.tty.detectConfig(std.fs.File.stderr()); |
| 74 | return self.renderToStdErr(cwd, source, tty_config, source_mappings); | 74 | return self.renderToStdErr(cwd, source, tty_config, source_mappings); |
| 75 | } | 75 | } |
| 76 | 76 |
lib/compiler/resinator/main.zig+6-6| ... | @@ -22,7 +22,7 @@ pub fn main() !void { | ... | @@ -22,7 +22,7 @@ pub fn main() !void { |
| 22 | defer arena_state.deinit(); | 22 | defer arena_state.deinit(); |
| 23 | const arena = arena_state.allocator(); | 23 | const arena = arena_state.allocator(); |
| 24 | 24 | ||
| 25 | const stderr = std.io.getStdErr(); | 25 | const stderr = std.fs.File.stderr(); |
| 26 | const stderr_config = std.io.tty.detectConfig(stderr); | 26 | const stderr_config = std.io.tty.detectConfig(stderr); |
| 27 | 27 | ||
| 28 | const args = try std.process.argsAlloc(allocator); | 28 | const args = try std.process.argsAlloc(allocator); |
| ... | @@ -44,7 +44,7 @@ pub fn main() !void { | ... | @@ -44,7 +44,7 @@ pub fn main() !void { |
| 44 | var error_handler: ErrorHandler = switch (zig_integration) { | 44 | var error_handler: ErrorHandler = switch (zig_integration) { |
| 45 | true => .{ | 45 | true => .{ |
| 46 | .server = .{ | 46 | .server = .{ |
| 47 | .out = std.io.getStdOut(), | 47 | .out = std.fs.File.stdout(), |
| 48 | .in = undefined, // won't be receiving messages | 48 | .in = undefined, // won't be receiving messages |
| 49 | .receive_fifo = undefined, // won't be receiving messages | 49 | .receive_fifo = undefined, // won't be receiving messages |
| 50 | }, | 50 | }, |
| ... | @@ -81,7 +81,7 @@ pub fn main() !void { | ... | @@ -81,7 +81,7 @@ pub fn main() !void { |
| 81 | defer options.deinit(); | 81 | defer options.deinit(); |
| 82 | 82 | ||
| 83 | if (options.print_help_and_exit) { | 83 | if (options.print_help_and_exit) { |
| 84 | const stdout = std.io.getStdOut(); | 84 | const stdout = std.fs.File.stdout(); |
| 85 | try cli.writeUsage(stdout.writer(), "zig rc"); | 85 | try cli.writeUsage(stdout.writer(), "zig rc"); |
| 86 | return; | 86 | return; |
| 87 | } | 87 | } |
| ... | @@ -89,7 +89,7 @@ pub fn main() !void { | ... | @@ -89,7 +89,7 @@ pub fn main() !void { |
| 89 | // Don't allow verbose when integrating with Zig via stdout | 89 | // Don't allow verbose when integrating with Zig via stdout |
| 90 | options.verbose = false; | 90 | options.verbose = false; |
| 91 | 91 | ||
| 92 | const stdout_writer = std.io.getStdOut().writer(); | 92 | const stdout_writer = std.fs.File.stdout().writer(); |
| 93 | if (options.verbose) { | 93 | if (options.verbose) { |
| 94 | try options.dumpVerbose(stdout_writer); | 94 | try options.dumpVerbose(stdout_writer); |
| 95 | try stdout_writer.writeByte('\n'); | 95 | try stdout_writer.writeByte('\n'); |
| ... | @@ -645,7 +645,7 @@ const ErrorHandler = union(enum) { | ... | @@ -645,7 +645,7 @@ const ErrorHandler = union(enum) { |
| 645 | }, | 645 | }, |
| 646 | .tty => { | 646 | .tty => { |
| 647 | // extra newline to separate this line from the aro errors | 647 | // extra newline to separate this line from the aro errors |
| 648 | try renderErrorMessage(std.io.getStdErr().writer(), self.tty, .err, "{s}\n", .{fail_msg}); | 648 | try renderErrorMessage(std.fs.File.stderr().writer(), self.tty, .err, "{s}\n", .{fail_msg}); |
| 649 | aro.Diagnostics.render(comp, self.tty); | 649 | aro.Diagnostics.render(comp, self.tty); |
| 650 | }, | 650 | }, |
| 651 | } | 651 | } |
| ... | @@ -690,7 +690,7 @@ const ErrorHandler = union(enum) { | ... | @@ -690,7 +690,7 @@ const ErrorHandler = union(enum) { |
| 690 | try server.serveErrorBundle(error_bundle); | 690 | try server.serveErrorBundle(error_bundle); |
| 691 | }, | 691 | }, |
| 692 | .tty => { | 692 | .tty => { |
| 693 | try renderErrorMessage(std.io.getStdErr().writer(), self.tty, msg_type, format, args); | 693 | try renderErrorMessage(std.fs.File.stderr().writer(), self.tty, msg_type, format, args); |
| 694 | }, | 694 | }, |
| 695 | } | 695 | } |
| 696 | } | 696 | } |
lib/compiler/std-docs.zig+2-2| ... | @@ -7,7 +7,7 @@ const assert = std.debug.assert; | ... | @@ -7,7 +7,7 @@ const assert = std.debug.assert; |
| 7 | const Cache = std.Build.Cache; | 7 | const Cache = std.Build.Cache; |
| 8 | 8 | ||
| 9 | fn usage() noreturn { | 9 | fn usage() noreturn { |
| 10 | io.getStdOut().writeAll( | 10 | std.fs.File.stdout().writeAll( |
| 11 | \\Usage: zig std [options] | 11 | \\Usage: zig std [options] |
| 12 | \\ | 12 | \\ |
| 13 | \\Options: | 13 | \\Options: |
| ... | @@ -63,7 +63,7 @@ pub fn main() !void { | ... | @@ -63,7 +63,7 @@ pub fn main() !void { |
| 63 | var http_server = try address.listen(.{}); | 63 | var http_server = try address.listen(.{}); |
| 64 | const port = http_server.listen_address.in.getPort(); | 64 | const port = http_server.listen_address.in.getPort(); |
| 65 | const url_with_newline = try std.fmt.allocPrint(arena, "http://127.0.0.1:{d}/\n", .{port}); | 65 | const url_with_newline = try std.fmt.allocPrint(arena, "http://127.0.0.1:{d}/\n", .{port}); |
| 66 | std.io.getStdOut().writeAll(url_with_newline) catch {}; | 66 | std.fs.File.stdout().writeAll(url_with_newline) catch {}; |
| 67 | if (should_open_browser) { | 67 | if (should_open_browser) { |
| 68 | openBrowserTab(gpa, url_with_newline[0 .. url_with_newline.len - 1 :'\n']) catch |err| { | 68 | openBrowserTab(gpa, url_with_newline[0 .. url_with_newline.len - 1 :'\n']) catch |err| { |
| 69 | std.log.err("unable to open browser: {s}", .{@errorName(err)}); | 69 | std.log.err("unable to open browser: {s}", .{@errorName(err)}); |
lib/compiler/test_runner.zig+4-4| ... | @@ -69,8 +69,8 @@ fn mainServer() !void { | ... | @@ -69,8 +69,8 @@ fn mainServer() !void { |
| 69 | @disableInstrumentation(); | 69 | @disableInstrumentation(); |
| 70 | var server = try std.zig.Server.init(.{ | 70 | var server = try std.zig.Server.init(.{ |
| 71 | .gpa = fba.allocator(), | 71 | .gpa = fba.allocator(), |
| 72 | .in = std.io.getStdIn(), | 72 | .in = .stdin(), |
| 73 | .out = std.io.getStdOut(), | 73 | .out = .stdout(), |
| 74 | .zig_version = builtin.zig_version_string, | 74 | .zig_version = builtin.zig_version_string, |
| 75 | }); | 75 | }); |
| 76 | defer server.deinit(); | 76 | defer server.deinit(); |
| ... | @@ -191,7 +191,7 @@ fn mainTerminal() void { | ... | @@ -191,7 +191,7 @@ fn mainTerminal() void { |
| 191 | .root_name = "Test", | 191 | .root_name = "Test", |
| 192 | .estimated_total_items = test_fn_list.len, | 192 | .estimated_total_items = test_fn_list.len, |
| 193 | }); | 193 | }); |
| 194 | const have_tty = std.io.getStdErr().isTty(); | 194 | const have_tty = std.fs.File.stderr().isTty(); |
| 195 | 195 | ||
| 196 | var async_frame_buffer: []align(builtin.target.stackAlignment()) u8 = undefined; | 196 | var async_frame_buffer: []align(builtin.target.stackAlignment()) u8 = undefined; |
| 197 | // TODO this is on the next line (using `undefined` above) because otherwise zig incorrectly | 197 | // TODO this is on the next line (using `undefined` above) because otherwise zig incorrectly |
| ... | @@ -301,7 +301,7 @@ pub fn mainSimple() anyerror!void { | ... | @@ -301,7 +301,7 @@ pub fn mainSimple() anyerror!void { |
| 301 | var failed: u64 = 0; | 301 | var failed: u64 = 0; |
| 302 | 302 | ||
| 303 | // we don't want to bring in File and Writer if the backend doesn't support it | 303 | // we don't want to bring in File and Writer if the backend doesn't support it |
| 304 | const stderr = if (comptime enable_print) std.io.getStdErr() else {}; | 304 | const stderr = if (comptime enable_print) std.fs.File.stderr() else {}; |
| 305 | 305 | ||
| 306 | for (builtin.test_functions) |test_fn| { | 306 | for (builtin.test_functions) |test_fn| { |
| 307 | if (test_fn.func()) |_| { | 307 | if (test_fn.func()) |_| { |
lib/docs/wasm/markdown.zig+2-2| ... | @@ -145,7 +145,7 @@ fn mainImpl() !void { | ... | @@ -145,7 +145,7 @@ fn mainImpl() !void { |
| 145 | var parser = try Parser.init(gpa); | 145 | var parser = try Parser.init(gpa); |
| 146 | defer parser.deinit(); | 146 | defer parser.deinit(); |
| 147 | 147 | ||
| 148 | var stdin_buf = std.io.bufferedReader(std.io.getStdIn().reader()); | 148 | var stdin_buf = std.io.bufferedReader(std.fs.File.stdin().reader()); |
| 149 | var line_buf = std.ArrayList(u8).init(gpa); | 149 | var line_buf = std.ArrayList(u8).init(gpa); |
| 150 | defer line_buf.deinit(); | 150 | defer line_buf.deinit(); |
| 151 | while (stdin_buf.reader().streamUntilDelimiter(line_buf.writer(), '\n', null)) { | 151 | while (stdin_buf.reader().streamUntilDelimiter(line_buf.writer(), '\n', null)) { |
| ... | @@ -160,7 +160,7 @@ fn mainImpl() !void { | ... | @@ -160,7 +160,7 @@ fn mainImpl() !void { |
| 160 | var doc = try parser.endInput(); | 160 | var doc = try parser.endInput(); |
| 161 | defer doc.deinit(gpa); | 161 | defer doc.deinit(gpa); |
| 162 | 162 | ||
| 163 | var stdout_buf = std.io.bufferedWriter(std.io.getStdOut().writer()); | 163 | var stdout_buf = std.io.bufferedWriter(std.fs.File.stdout().writer()); |
| 164 | try doc.render(stdout_buf.writer()); | 164 | try doc.render(stdout_buf.writer()); |
| 165 | try stdout_buf.flush(); | 165 | try stdout_buf.flush(); |
| 166 | } | 166 | } |
lib/init/src/root.zig+1-1| ... | @@ -5,7 +5,7 @@ pub fn bufferedPrint() !void { | ... | @@ -5,7 +5,7 @@ pub fn bufferedPrint() !void { |
| 5 | // Stdout is for the actual output of your application, for example if you | 5 | // Stdout is for the actual output of your application, for example if you |
| 6 | // are implementing gzip, then only the compressed bytes should be sent to | 6 | // are implementing gzip, then only the compressed bytes should be sent to |
| 7 | // stdout, not any debugging messages. | 7 | // stdout, not any debugging messages. |
| 8 | const stdout_file = std.io.getStdOut().writer(); | 8 | const stdout_file = std.fs.File.stdout().writer(); |
| 9 | // Buffering can improve performance significantly in print-heavy programs. | 9 | // Buffering can improve performance significantly in print-heavy programs. |
| 10 | var bw = std.io.bufferedWriter(stdout_file); | 10 | var bw = std.io.bufferedWriter(stdout_file); |
| 11 | const stdout = bw.writer(); | 11 | const stdout = bw.writer(); |
lib/std/Build.zig+3-3| ... | @@ -2467,7 +2467,7 @@ pub const GeneratedFile = struct { | ... | @@ -2467,7 +2467,7 @@ pub const GeneratedFile = struct { |
| 2467 | pub fn getPath2(gen: GeneratedFile, src_builder: *Build, asking_step: ?*Step) []const u8 { | 2467 | pub fn getPath2(gen: GeneratedFile, src_builder: *Build, asking_step: ?*Step) []const u8 { |
| 2468 | return gen.path orelse { | 2468 | return gen.path orelse { |
| 2469 | std.debug.lockStdErr(); | 2469 | std.debug.lockStdErr(); |
| 2470 | const stderr = std.io.getStdErr(); | 2470 | const stderr = std.fs.File.stderr(); |
| 2471 | dumpBadGetPathHelp(gen.step, stderr, src_builder, asking_step) catch {}; | 2471 | dumpBadGetPathHelp(gen.step, stderr, src_builder, asking_step) catch {}; |
| 2472 | std.debug.unlockStdErr(); | 2472 | std.debug.unlockStdErr(); |
| 2473 | @panic("misconfigured build script"); | 2473 | @panic("misconfigured build script"); |
| ... | @@ -2677,7 +2677,7 @@ pub const LazyPath = union(enum) { | ... | @@ -2677,7 +2677,7 @@ pub const LazyPath = union(enum) { |
| 2677 | .root_dir = Cache.Directory.cwd(), | 2677 | .root_dir = Cache.Directory.cwd(), |
| 2678 | .sub_path = gen.file.path orelse { | 2678 | .sub_path = gen.file.path orelse { |
| 2679 | std.debug.lockStdErr(); | 2679 | std.debug.lockStdErr(); |
| 2680 | const stderr = std.io.getStdErr(); | 2680 | const stderr: fs.File = .stderr(); |
| 2681 | dumpBadGetPathHelp(gen.file.step, stderr, src_builder, asking_step) catch {}; | 2681 | dumpBadGetPathHelp(gen.file.step, stderr, src_builder, asking_step) catch {}; |
| 2682 | std.debug.unlockStdErr(); | 2682 | std.debug.unlockStdErr(); |
| 2683 | @panic("misconfigured build script"); | 2683 | @panic("misconfigured build script"); |
| ... | @@ -2769,7 +2769,7 @@ fn dumpBadDirnameHelp( | ... | @@ -2769,7 +2769,7 @@ fn dumpBadDirnameHelp( |
| 2769 | debug.lockStdErr(); | 2769 | debug.lockStdErr(); |
| 2770 | defer debug.unlockStdErr(); | 2770 | defer debug.unlockStdErr(); |
| 2771 | 2771 | ||
| 2772 | const stderr = io.getStdErr(); | 2772 | const stderr: fs.File = .stderr(); |
| 2773 | const w = stderr.writer(); | 2773 | const w = stderr.writer(); |
| 2774 | try w.print(msg, args); | 2774 | try w.print(msg, args); |
| 2775 | 2775 |
lib/std/Build/Cache/DepTokenizer.zig+1-1| ... | @@ -1072,7 +1072,7 @@ fn depTokenizer(input: []const u8, expect: []const u8) !void { | ... | @@ -1072,7 +1072,7 @@ fn depTokenizer(input: []const u8, expect: []const u8) !void { |
| 1072 | return; | 1072 | return; |
| 1073 | } | 1073 | } |
| 1074 | 1074 | ||
| 1075 | const out = std.io.getStdErr().writer(); | 1075 | const out = std.fs.File.stderr().writer(); |
| 1076 | 1076 | ||
| 1077 | try out.writeAll("\n"); | 1077 | try out.writeAll("\n"); |
| 1078 | try printSection(out, "<<<< input", input); | 1078 | try printSection(out, "<<<< input", input); |
lib/std/Build/Fuzz.zig+2-2| ... | @@ -112,7 +112,7 @@ fn rebuildTestsWorkerRun(run: *Step.Run, ttyconf: std.io.tty.Config, parent_prog | ... | @@ -112,7 +112,7 @@ fn rebuildTestsWorkerRun(run: *Step.Run, ttyconf: std.io.tty.Config, parent_prog |
| 112 | 112 | ||
| 113 | fn rebuildTestsWorkerRunFallible(run: *Step.Run, ttyconf: std.io.tty.Config, parent_prog_node: std.Progress.Node) !void { | 113 | fn rebuildTestsWorkerRunFallible(run: *Step.Run, ttyconf: std.io.tty.Config, parent_prog_node: std.Progress.Node) !void { |
| 114 | const gpa = run.step.owner.allocator; | 114 | const gpa = run.step.owner.allocator; |
| 115 | const stderr = std.io.getStdErr(); | 115 | const stderr = std.fs.File.stderr(); |
| 116 | 116 | ||
| 117 | const compile = run.producer.?; | 117 | const compile = run.producer.?; |
| 118 | const prog_node = parent_prog_node.start(compile.step.name, 0); | 118 | const prog_node = parent_prog_node.start(compile.step.name, 0); |
| ... | @@ -152,7 +152,7 @@ fn fuzzWorkerRun( | ... | @@ -152,7 +152,7 @@ fn fuzzWorkerRun( |
| 152 | 152 | ||
| 153 | run.rerunInFuzzMode(web_server, unit_test_index, prog_node) catch |err| switch (err) { | 153 | run.rerunInFuzzMode(web_server, unit_test_index, prog_node) catch |err| switch (err) { |
| 154 | error.MakeFailed => { | 154 | error.MakeFailed => { |
| 155 | const stderr = std.io.getStdErr(); | 155 | const stderr = std.fs.File.stderr(); |
| 156 | std.debug.lockStdErr(); | 156 | std.debug.lockStdErr(); |
| 157 | defer std.debug.unlockStdErr(); | 157 | defer std.debug.unlockStdErr(); |
| 158 | build_runner.printErrorMessages(gpa, &run.step, .{ .ttyconf = ttyconf }, stderr, false) catch {}; | 158 | build_runner.printErrorMessages(gpa, &run.step, .{ .ttyconf = ttyconf }, stderr, false) catch {}; |
lib/std/Build/Step/Compile.zig+2-2| ... | @@ -1018,7 +1018,7 @@ fn getGeneratedFilePath(compile: *Compile, comptime tag_name: []const u8, asking | ... | @@ -1018,7 +1018,7 @@ fn getGeneratedFilePath(compile: *Compile, comptime tag_name: []const u8, asking |
| 1018 | 1018 | ||
| 1019 | const generated_file = maybe_path orelse { | 1019 | const generated_file = maybe_path orelse { |
| 1020 | std.debug.lockStdErr(); | 1020 | std.debug.lockStdErr(); |
| 1021 | const stderr = std.io.getStdErr(); | 1021 | const stderr: fs.File = .stderr(); |
| 1022 | 1022 | ||
| 1023 | std.Build.dumpBadGetPathHelp(&compile.step, stderr, compile.step.owner, asking_step) catch {}; | 1023 | std.Build.dumpBadGetPathHelp(&compile.step, stderr, compile.step.owner, asking_step) catch {}; |
| 1024 | 1024 | ||
| ... | @@ -1027,7 +1027,7 @@ fn getGeneratedFilePath(compile: *Compile, comptime tag_name: []const u8, asking | ... | @@ -1027,7 +1027,7 @@ fn getGeneratedFilePath(compile: *Compile, comptime tag_name: []const u8, asking |
| 1027 | 1027 | ||
| 1028 | const path = generated_file.path orelse { | 1028 | const path = generated_file.path orelse { |
| 1029 | std.debug.lockStdErr(); | 1029 | std.debug.lockStdErr(); |
| 1030 | const stderr = std.io.getStdErr(); | 1030 | const stderr: fs.File = .stderr(); |
| 1031 | 1031 | ||
| 1032 | std.Build.dumpBadGetPathHelp(&compile.step, stderr, compile.step.owner, asking_step) catch {}; | 1032 | std.Build.dumpBadGetPathHelp(&compile.step, stderr, compile.step.owner, asking_step) catch {}; |
| 1033 | 1033 |
lib/std/Progress.zig+1-1| ... | @@ -451,7 +451,7 @@ pub fn start(options: Options) Node { | ... | @@ -451,7 +451,7 @@ pub fn start(options: Options) Node { |
| 451 | if (options.disable_printing) { | 451 | if (options.disable_printing) { |
| 452 | return Node.none; | 452 | return Node.none; |
| 453 | } | 453 | } |
| 454 | const stderr = std.io.getStdErr(); | 454 | const stderr: std.fs.File = .stderr(); |
| 455 | global_progress.terminal = stderr; | 455 | global_progress.terminal = stderr; |
| 456 | if (stderr.getOrEnableAnsiEscapeSupport()) { | 456 | if (stderr.getOrEnableAnsiEscapeSupport()) { |
| 457 | global_progress.terminal_mode = .ansi_escape_codes; | 457 | global_progress.terminal_mode = .ansi_escape_codes; |
lib/std/Random/benchmark.zig+1-1| ... | @@ -122,7 +122,7 @@ fn mode(comptime x: comptime_int) comptime_int { | ... | @@ -122,7 +122,7 @@ fn mode(comptime x: comptime_int) comptime_int { |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | pub fn main() !void { | 124 | pub fn main() !void { |
| 125 | const stdout = std.io.getStdOut().writer(); | 125 | const stdout = std.fs.File.stdout().writer(); |
| 126 | 126 | ||
| 127 | var buffer: [1024]u8 = undefined; | 127 | var buffer: [1024]u8 = undefined; |
| 128 | var fixed = std.heap.FixedBufferAllocator.init(buffer[0..]); | 128 | var fixed = std.heap.FixedBufferAllocator.init(buffer[0..]); |
lib/std/builtin.zig+1-1| ... | @@ -51,7 +51,7 @@ pub const StackTrace = struct { | ... | @@ -51,7 +51,7 @@ pub const StackTrace = struct { |
| 51 | const debug_info = std.debug.getSelfDebugInfo() catch |err| { | 51 | const debug_info = std.debug.getSelfDebugInfo() catch |err| { |
| 52 | return writer.print("\nUnable to print stack trace: Unable to open debug info: {s}\n", .{@errorName(err)}); | 52 | return writer.print("\nUnable to print stack trace: Unable to open debug info: {s}\n", .{@errorName(err)}); |
| 53 | }; | 53 | }; |
| 54 | const tty_config = std.io.tty.detectConfig(std.io.getStdErr()); | 54 | const tty_config = std.io.tty.detectConfig(std.fs.File.stderr()); |
| 55 | try writer.writeAll("\n"); | 55 | try writer.writeAll("\n"); |
| 56 | std.debug.writeStackTrace(self, writer, debug_info, tty_config) catch |err| { | 56 | std.debug.writeStackTrace(self, writer, debug_info, tty_config) catch |err| { |
| 57 | try writer.print("Unable to print stack trace: {s}\n", .{@errorName(err)}); | 57 | try writer.print("Unable to print stack trace: {s}\n", .{@errorName(err)}); |
lib/std/crypto/benchmark.zig+1-1| ... | @@ -458,7 +458,7 @@ fn mode(comptime x: comptime_int) comptime_int { | ... | @@ -458,7 +458,7 @@ fn mode(comptime x: comptime_int) comptime_int { |
| 458 | } | 458 | } |
| 459 | 459 | ||
| 460 | pub fn main() !void { | 460 | pub fn main() !void { |
| 461 | const stdout = std.io.getStdOut().writer(); | 461 | const stdout = std.fs.File.stdout().writer(); |
| 462 | 462 | ||
| 463 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); | 463 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); |
| 464 | defer arena.deinit(); | 464 | defer arena.deinit(); |
lib/std/debug.zig+19-19| ... | @@ -209,7 +209,7 @@ pub fn unlockStdErr() void { | ... | @@ -209,7 +209,7 @@ pub fn unlockStdErr() void { |
| 209 | pub fn print(comptime fmt: []const u8, args: anytype) void { | 209 | pub fn print(comptime fmt: []const u8, args: anytype) void { |
| 210 | lockStdErr(); | 210 | lockStdErr(); |
| 211 | defer unlockStdErr(); | 211 | defer unlockStdErr(); |
| 212 | const stderr = io.getStdErr().writer(); | 212 | const stderr = fs.File.stderr().writer(); |
| 213 | nosuspend stderr.print(fmt, args) catch return; | 213 | nosuspend stderr.print(fmt, args) catch return; |
| 214 | } | 214 | } |
| 215 | 215 | ||
| ... | @@ -239,7 +239,7 @@ pub fn dumpHex(bytes: []const u8) void { | ... | @@ -239,7 +239,7 @@ pub fn dumpHex(bytes: []const u8) void { |
| 239 | 239 | ||
| 240 | /// Prints a hexadecimal view of the bytes, unbuffered, returning any error that occurs. | 240 | /// Prints a hexadecimal view of the bytes, unbuffered, returning any error that occurs. |
| 241 | pub fn dumpHexFallible(bytes: []const u8) !void { | 241 | pub fn dumpHexFallible(bytes: []const u8) !void { |
| 242 | const stderr = std.io.getStdErr(); | 242 | const stderr: fs.File = .stderr(); |
| 243 | const ttyconf = std.io.tty.detectConfig(stderr); | 243 | const ttyconf = std.io.tty.detectConfig(stderr); |
| 244 | const writer = stderr.writer(); | 244 | const writer = stderr.writer(); |
| 245 | try dumpHexInternal(bytes, ttyconf, writer); | 245 | try dumpHexInternal(bytes, ttyconf, writer); |
| ... | @@ -318,12 +318,12 @@ pub fn dumpCurrentStackTrace(start_addr: ?usize) void { | ... | @@ -318,12 +318,12 @@ pub fn dumpCurrentStackTrace(start_addr: ?usize) void { |
| 318 | nosuspend { | 318 | nosuspend { |
| 319 | if (builtin.target.cpu.arch.isWasm()) { | 319 | if (builtin.target.cpu.arch.isWasm()) { |
| 320 | if (native_os == .wasi) { | 320 | if (native_os == .wasi) { |
| 321 | const stderr = io.getStdErr().writer(); | 321 | const stderr = fs.File.stderr().writer(); |
| 322 | stderr.print("Unable to dump stack trace: not implemented for Wasm\n", .{}) catch return; | 322 | stderr.print("Unable to dump stack trace: not implemented for Wasm\n", .{}) catch return; |
| 323 | } | 323 | } |
| 324 | return; | 324 | return; |
| 325 | } | 325 | } |
| 326 | const stderr = io.getStdErr().writer(); | 326 | const stderr = fs.File.stderr().writer(); |
| 327 | if (builtin.strip_debug_info) { | 327 | if (builtin.strip_debug_info) { |
| 328 | stderr.print("Unable to dump stack trace: debug info stripped\n", .{}) catch return; | 328 | stderr.print("Unable to dump stack trace: debug info stripped\n", .{}) catch return; |
| 329 | return; | 329 | return; |
| ... | @@ -332,7 +332,7 @@ pub fn dumpCurrentStackTrace(start_addr: ?usize) void { | ... | @@ -332,7 +332,7 @@ pub fn dumpCurrentStackTrace(start_addr: ?usize) void { |
| 332 | stderr.print("Unable to dump stack trace: Unable to open debug info: {s}\n", .{@errorName(err)}) catch return; | 332 | stderr.print("Unable to dump stack trace: Unable to open debug info: {s}\n", .{@errorName(err)}) catch return; |
| 333 | return; | 333 | return; |
| 334 | }; | 334 | }; |
| 335 | writeCurrentStackTrace(stderr, debug_info, io.tty.detectConfig(io.getStdErr()), start_addr) catch |err| { | 335 | writeCurrentStackTrace(stderr, debug_info, io.tty.detectConfig(fs.File.stderr()), start_addr) catch |err| { |
| 336 | stderr.print("Unable to dump stack trace: {s}\n", .{@errorName(err)}) catch return; | 336 | stderr.print("Unable to dump stack trace: {s}\n", .{@errorName(err)}) catch return; |
| 337 | return; | 337 | return; |
| 338 | }; | 338 | }; |
| ... | @@ -406,12 +406,12 @@ pub fn dumpStackTraceFromBase(context: *ThreadContext) void { | ... | @@ -406,12 +406,12 @@ pub fn dumpStackTraceFromBase(context: *ThreadContext) void { |
| 406 | nosuspend { | 406 | nosuspend { |
| 407 | if (builtin.target.cpu.arch.isWasm()) { | 407 | if (builtin.target.cpu.arch.isWasm()) { |
| 408 | if (native_os == .wasi) { | 408 | if (native_os == .wasi) { |
| 409 | const stderr = io.getStdErr().writer(); | 409 | const stderr = fs.File.stderr().writer(); |
| 410 | stderr.print("Unable to dump stack trace: not implemented for Wasm\n", .{}) catch return; | 410 | stderr.print("Unable to dump stack trace: not implemented for Wasm\n", .{}) catch return; |
| 411 | } | 411 | } |
| 412 | return; | 412 | return; |
| 413 | } | 413 | } |
| 414 | const stderr = io.getStdErr().writer(); | 414 | const stderr = fs.File.stderr().writer(); |
| 415 | if (builtin.strip_debug_info) { | 415 | if (builtin.strip_debug_info) { |
| 416 | stderr.print("Unable to dump stack trace: debug info stripped\n", .{}) catch return; | 416 | stderr.print("Unable to dump stack trace: debug info stripped\n", .{}) catch return; |
| 417 | return; | 417 | return; |
| ... | @@ -420,7 +420,7 @@ pub fn dumpStackTraceFromBase(context: *ThreadContext) void { | ... | @@ -420,7 +420,7 @@ pub fn dumpStackTraceFromBase(context: *ThreadContext) void { |
| 420 | stderr.print("Unable to dump stack trace: Unable to open debug info: {s}\n", .{@errorName(err)}) catch return; | 420 | stderr.print("Unable to dump stack trace: Unable to open debug info: {s}\n", .{@errorName(err)}) catch return; |
| 421 | return; | 421 | return; |
| 422 | }; | 422 | }; |
| 423 | const tty_config = io.tty.detectConfig(io.getStdErr()); | 423 | const tty_config = io.tty.detectConfig(fs.File.stderr()); |
| 424 | if (native_os == .windows) { | 424 | if (native_os == .windows) { |
| 425 | // On x86_64 and aarch64, the stack will be unwound using RtlVirtualUnwind using the context | 425 | // On x86_64 and aarch64, the stack will be unwound using RtlVirtualUnwind using the context |
| 426 | // provided by the exception handler. On x86, RtlVirtualUnwind doesn't exist. Instead, a new backtrace | 426 | // provided by the exception handler. On x86, RtlVirtualUnwind doesn't exist. Instead, a new backtrace |
| ... | @@ -510,12 +510,12 @@ pub fn dumpStackTrace(stack_trace: std.builtin.StackTrace) void { | ... | @@ -510,12 +510,12 @@ pub fn dumpStackTrace(stack_trace: std.builtin.StackTrace) void { |
| 510 | nosuspend { | 510 | nosuspend { |
| 511 | if (builtin.target.cpu.arch.isWasm()) { | 511 | if (builtin.target.cpu.arch.isWasm()) { |
| 512 | if (native_os == .wasi) { | 512 | if (native_os == .wasi) { |
| 513 | const stderr = io.getStdErr().writer(); | 513 | const stderr = fs.File.stderr().writer(); |
| 514 | stderr.print("Unable to dump stack trace: not implemented for Wasm\n", .{}) catch return; | 514 | stderr.print("Unable to dump stack trace: not implemented for Wasm\n", .{}) catch return; |
| 515 | } | 515 | } |
| 516 | return; | 516 | return; |
| 517 | } | 517 | } |
| 518 | const stderr = io.getStdErr().writer(); | 518 | const stderr = fs.File.stderr().writer(); |
| 519 | if (builtin.strip_debug_info) { | 519 | if (builtin.strip_debug_info) { |
| 520 | stderr.print("Unable to dump stack trace: debug info stripped\n", .{}) catch return; | 520 | stderr.print("Unable to dump stack trace: debug info stripped\n", .{}) catch return; |
| 521 | return; | 521 | return; |
| ... | @@ -524,7 +524,7 @@ pub fn dumpStackTrace(stack_trace: std.builtin.StackTrace) void { | ... | @@ -524,7 +524,7 @@ pub fn dumpStackTrace(stack_trace: std.builtin.StackTrace) void { |
| 524 | stderr.print("Unable to dump stack trace: Unable to open debug info: {s}\n", .{@errorName(err)}) catch return; | 524 | stderr.print("Unable to dump stack trace: Unable to open debug info: {s}\n", .{@errorName(err)}) catch return; |
| 525 | return; | 525 | return; |
| 526 | }; | 526 | }; |
| 527 | writeStackTrace(stack_trace, stderr, debug_info, io.tty.detectConfig(io.getStdErr())) catch |err| { | 527 | writeStackTrace(stack_trace, stderr, debug_info, io.tty.detectConfig(fs.File.stderr())) catch |err| { |
| 528 | stderr.print("Unable to dump stack trace: {s}\n", .{@errorName(err)}) catch return; | 528 | stderr.print("Unable to dump stack trace: {s}\n", .{@errorName(err)}) catch return; |
| 529 | return; | 529 | return; |
| 530 | }; | 530 | }; |
| ... | @@ -678,7 +678,7 @@ pub fn defaultPanic( | ... | @@ -678,7 +678,7 @@ pub fn defaultPanic( |
| 678 | lockStdErr(); | 678 | lockStdErr(); |
| 679 | defer unlockStdErr(); | 679 | defer unlockStdErr(); |
| 680 | 680 | ||
| 681 | const stderr = io.getStdErr().writer(); | 681 | const stderr = fs.File.stderr().writer(); |
| 682 | if (builtin.single_threaded) { | 682 | if (builtin.single_threaded) { |
| 683 | stderr.print("panic: ", .{}) catch posix.abort(); | 683 | stderr.print("panic: ", .{}) catch posix.abort(); |
| 684 | } else { | 684 | } else { |
| ... | @@ -699,7 +699,7 @@ pub fn defaultPanic( | ... | @@ -699,7 +699,7 @@ pub fn defaultPanic( |
| 699 | // A panic happened while trying to print a previous panic message. | 699 | // A panic happened while trying to print a previous panic message. |
| 700 | // We're still holding the mutex but that's fine as we're going to | 700 | // We're still holding the mutex but that's fine as we're going to |
| 701 | // call abort(). | 701 | // call abort(). |
| 702 | io.getStdErr().writeAll("aborting due to recursive panic\n") catch {}; | 702 | fs.File.stderr().writeAll("aborting due to recursive panic\n") catch {}; |
| 703 | }, | 703 | }, |
| 704 | else => {}, // Panicked while printing the recursive panic message. | 704 | else => {}, // Panicked while printing the recursive panic message. |
| 705 | }; | 705 | }; |
| ... | @@ -1461,7 +1461,7 @@ fn handleSegfaultPosix(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopa | ... | @@ -1461,7 +1461,7 @@ fn handleSegfaultPosix(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopa |
| 1461 | } | 1461 | } |
| 1462 | 1462 | ||
| 1463 | fn dumpSegfaultInfoPosix(sig: i32, code: i32, addr: usize, ctx_ptr: ?*anyopaque) void { | 1463 | fn dumpSegfaultInfoPosix(sig: i32, code: i32, addr: usize, ctx_ptr: ?*anyopaque) void { |
| 1464 | const stderr = io.getStdErr().writer(); | 1464 | const stderr = fs.File.stderr().writer(); |
| 1465 | _ = switch (sig) { | 1465 | _ = switch (sig) { |
| 1466 | posix.SIG.SEGV => if (native_arch == .x86_64 and native_os == .linux and code == 128) // SI_KERNEL | 1466 | posix.SIG.SEGV => if (native_arch == .x86_64 and native_os == .linux and code == 128) // SI_KERNEL |
| 1467 | // x86_64 doesn't have a full 64-bit virtual address space. | 1467 | // x86_64 doesn't have a full 64-bit virtual address space. |
| ... | @@ -1549,7 +1549,7 @@ fn handleSegfaultWindowsExtra(info: *windows.EXCEPTION_POINTERS, msg: u8, label: | ... | @@ -1549,7 +1549,7 @@ fn handleSegfaultWindowsExtra(info: *windows.EXCEPTION_POINTERS, msg: u8, label: |
| 1549 | }, | 1549 | }, |
| 1550 | 1 => { | 1550 | 1 => { |
| 1551 | panic_stage = 2; | 1551 | panic_stage = 2; |
| 1552 | io.getStdErr().writeAll("aborting due to recursive panic\n") catch {}; | 1552 | fs.File.stderr().writeAll("aborting due to recursive panic\n") catch {}; |
| 1553 | }, | 1553 | }, |
| 1554 | else => {}, | 1554 | else => {}, |
| 1555 | }; | 1555 | }; |
| ... | @@ -1557,7 +1557,7 @@ fn handleSegfaultWindowsExtra(info: *windows.EXCEPTION_POINTERS, msg: u8, label: | ... | @@ -1557,7 +1557,7 @@ fn handleSegfaultWindowsExtra(info: *windows.EXCEPTION_POINTERS, msg: u8, label: |
| 1557 | } | 1557 | } |
| 1558 | 1558 | ||
| 1559 | fn dumpSegfaultInfoWindows(info: *windows.EXCEPTION_POINTERS, msg: u8, label: ?[]const u8) void { | 1559 | fn dumpSegfaultInfoWindows(info: *windows.EXCEPTION_POINTERS, msg: u8, label: ?[]const u8) void { |
| 1560 | const stderr = io.getStdErr().writer(); | 1560 | const stderr = fs.File.stderr().writer(); |
| 1561 | _ = switch (msg) { | 1561 | _ = switch (msg) { |
| 1562 | 0 => stderr.print("{s}\n", .{label.?}), | 1562 | 0 => stderr.print("{s}\n", .{label.?}), |
| 1563 | 1 => stderr.print("Segmentation fault at address 0x{x}\n", .{info.ExceptionRecord.ExceptionInformation[1]}), | 1563 | 1 => stderr.print("Segmentation fault at address 0x{x}\n", .{info.ExceptionRecord.ExceptionInformation[1]}), |
| ... | @@ -1591,7 +1591,7 @@ test "manage resources correctly" { | ... | @@ -1591,7 +1591,7 @@ test "manage resources correctly" { |
| 1591 | const writer = std.io.null_writer; | 1591 | const writer = std.io.null_writer; |
| 1592 | var di = try SelfInfo.open(testing.allocator); | 1592 | var di = try SelfInfo.open(testing.allocator); |
| 1593 | defer di.deinit(); | 1593 | defer di.deinit(); |
| 1594 | try printSourceAtAddress(&di, writer, showMyTrace(), io.tty.detectConfig(std.io.getStdErr())); | 1594 | try printSourceAtAddress(&di, writer, showMyTrace(), io.tty.detectConfig(std.fs.File.stderr())); |
| 1595 | } | 1595 | } |
| 1596 | 1596 | ||
| 1597 | noinline fn showMyTrace() usize { | 1597 | noinline fn showMyTrace() usize { |
| ... | @@ -1657,8 +1657,8 @@ pub fn ConfigurableTrace(comptime size: usize, comptime stack_frame_count: usize | ... | @@ -1657,8 +1657,8 @@ pub fn ConfigurableTrace(comptime size: usize, comptime stack_frame_count: usize |
| 1657 | pub fn dump(t: @This()) void { | 1657 | pub fn dump(t: @This()) void { |
| 1658 | if (!enabled) return; | 1658 | if (!enabled) return; |
| 1659 | 1659 | ||
| 1660 | const tty_config = io.tty.detectConfig(std.io.getStdErr()); | 1660 | const tty_config = io.tty.detectConfig(std.fs.File.stderr()); |
| 1661 | const stderr = io.getStdErr().writer(); | 1661 | const stderr = fs.File.stderr().writer(); |
| 1662 | const end = @min(t.index, size); | 1662 | const end = @min(t.index, size); |
| 1663 | const debug_info = getSelfDebugInfo() catch |err| { | 1663 | const debug_info = getSelfDebugInfo() catch |err| { |
| 1664 | stderr.print( | 1664 | stderr.print( |
lib/std/debug/simple_panic.zig+1-1| ... | @@ -15,7 +15,7 @@ pub fn call(msg: []const u8, ra: ?usize) noreturn { | ... | @@ -15,7 +15,7 @@ pub fn call(msg: []const u8, ra: ?usize) noreturn { |
| 15 | @branchHint(.cold); | 15 | @branchHint(.cold); |
| 16 | _ = ra; | 16 | _ = ra; |
| 17 | std.debug.lockStdErr(); | 17 | std.debug.lockStdErr(); |
| 18 | const stderr = std.io.getStdErr(); | 18 | const stderr: std.fs.File = .stderr(); |
| 19 | stderr.writeAll(msg) catch {}; | 19 | stderr.writeAll(msg) catch {}; |
| 20 | @trap(); | 20 | @trap(); |
| 21 | } | 21 | } |
lib/std/hash/benchmark.zig+1-1| ... | @@ -346,7 +346,7 @@ fn mode(comptime x: comptime_int) comptime_int { | ... | @@ -346,7 +346,7 @@ fn mode(comptime x: comptime_int) comptime_int { |
| 346 | } | 346 | } |
| 347 | 347 | ||
| 348 | pub fn main() !void { | 348 | pub fn main() !void { |
| 349 | const stdout = std.io.getStdOut().writer(); | 349 | const stdout = std.fs.File.stdout().writer(); |
| 350 | 350 | ||
| 351 | var buffer: [1024]u8 = undefined; | 351 | var buffer: [1024]u8 = undefined; |
| 352 | var fixed = std.heap.FixedBufferAllocator.init(buffer[0..]); | 352 | var fixed = std.heap.FixedBufferAllocator.init(buffer[0..]); |
lib/std/io.zig-48| ... | @@ -77,54 +77,6 @@ pub const Limit = enum(usize) { | ... | @@ -77,54 +77,6 @@ pub const Limit = enum(usize) { |
| 77 | pub const Reader = @import("io/Reader.zig"); | 77 | pub const Reader = @import("io/Reader.zig"); |
| 78 | pub const Writer = @import("io/Writer.zig"); | 78 | pub const Writer = @import("io/Writer.zig"); |
| 79 | 79 | ||
| 80 | fn getStdOutHandle() posix.fd_t { | ||
| 81 | if (is_windows) { | ||
| 82 | return windows.peb().ProcessParameters.hStdOutput; | ||
| 83 | } | ||
| 84 | |||
| 85 | if (@hasDecl(root, "os") and @hasDecl(root.os, "io") and @hasDecl(root.os.io, "getStdOutHandle")) { | ||
| 86 | return root.os.io.getStdOutHandle(); | ||
| 87 | } | ||
| 88 | |||
| 89 | return posix.STDOUT_FILENO; | ||
| 90 | } | ||
| 91 | |||
| 92 | pub fn getStdOut() File { | ||
| 93 | return .{ .handle = getStdOutHandle() }; | ||
| 94 | } | ||
| 95 | |||
| 96 | fn getStdErrHandle() posix.fd_t { | ||
| 97 | if (is_windows) { | ||
| 98 | return windows.peb().ProcessParameters.hStdError; | ||
| 99 | } | ||
| 100 | |||
| 101 | if (@hasDecl(root, "os") and @hasDecl(root.os, "io") and @hasDecl(root.os.io, "getStdErrHandle")) { | ||
| 102 | return root.os.io.getStdErrHandle(); | ||
| 103 | } | ||
| 104 | |||
| 105 | return posix.STDERR_FILENO; | ||
| 106 | } | ||
| 107 | |||
| 108 | pub fn getStdErr() File { | ||
| 109 | return .{ .handle = getStdErrHandle() }; | ||
| 110 | } | ||
| 111 | |||
| 112 | fn getStdInHandle() posix.fd_t { | ||
| 113 | if (is_windows) { | ||
| 114 | return windows.peb().ProcessParameters.hStdInput; | ||
| 115 | } | ||
| 116 | |||
| 117 | if (@hasDecl(root, "os") and @hasDecl(root.os, "io") and @hasDecl(root.os.io, "getStdInHandle")) { | ||
| 118 | return root.os.io.getStdInHandle(); | ||
| 119 | } | ||
| 120 | |||
| 121 | return posix.STDIN_FILENO; | ||
| 122 | } | ||
| 123 | |||
| 124 | pub fn getStdIn() File { | ||
| 125 | return .{ .handle = getStdInHandle() }; | ||
| 126 | } | ||
| 127 | |||
| 128 | /// Deprecated in favor of `Reader`. | 80 | /// Deprecated in favor of `Reader`. |
| 129 | pub fn GenericReader( | 81 | pub fn GenericReader( |
| 130 | comptime Context: type, | 82 | comptime Context: type, |
lib/std/json/dynamic.zig+1-1| ... | @@ -56,7 +56,7 @@ pub const Value = union(enum) { | ... | @@ -56,7 +56,7 @@ pub const Value = union(enum) { |
| 56 | std.debug.lockStdErr(); | 56 | std.debug.lockStdErr(); |
| 57 | defer std.debug.unlockStdErr(); | 57 | defer std.debug.unlockStdErr(); |
| 58 | 58 | ||
| 59 | const stderr = std.io.getStdErr().writer(); | 59 | const stderr = std.fs.File.stderr().writer(); |
| 60 | stringify(self, .{}, stderr) catch return; | 60 | stringify(self, .{}, stderr) catch return; |
| 61 | } | 61 | } |
| 62 | 62 |
lib/std/log.zig+2-2| ... | @@ -47,7 +47,7 @@ | ... | @@ -47,7 +47,7 @@ |
| 47 | //! // Print the message to stderr, silently ignoring any errors | 47 | //! // Print the message to stderr, silently ignoring any errors |
| 48 | //! std.debug.lockStdErr(); | 48 | //! std.debug.lockStdErr(); |
| 49 | //! defer std.debug.unlockStdErr(); | 49 | //! defer std.debug.unlockStdErr(); |
| 50 | //! const stderr = std.io.getStdErr().writer(); | 50 | //! const stderr = std.fs.File.stderr().writer(); |
| 51 | //! nosuspend stderr.print(prefix ++ format ++ "\n", args) catch return; | 51 | //! nosuspend stderr.print(prefix ++ format ++ "\n", args) catch return; |
| 52 | //! } | 52 | //! } |
| 53 | //! | 53 | //! |
| ... | @@ -148,7 +148,7 @@ pub fn defaultLog( | ... | @@ -148,7 +148,7 @@ pub fn defaultLog( |
| 148 | ) void { | 148 | ) void { |
| 149 | const level_txt = comptime message_level.asText(); | 149 | const level_txt = comptime message_level.asText(); |
| 150 | const prefix2 = if (scope == .default) ": " else "(" ++ @tagName(scope) ++ "): "; | 150 | const prefix2 = if (scope == .default) ": " else "(" ++ @tagName(scope) ++ "): "; |
| 151 | const stderr = std.io.getStdErr().writer(); | 151 | const stderr = std.fs.File.stderr().writer(); |
| 152 | var bw = std.io.bufferedWriter(stderr); | 152 | var bw = std.io.bufferedWriter(stderr); |
| 153 | const writer = bw.writer(); | 153 | const writer = bw.writer(); |
| 154 | 154 |
lib/std/testing.zig+1-1| ... | @@ -390,7 +390,7 @@ pub fn expectEqualSlices(comptime T: type, expected: []const T, actual: []const | ... | @@ -390,7 +390,7 @@ pub fn expectEqualSlices(comptime T: type, expected: []const T, actual: []const |
| 390 | const actual_window = actual[window_start..@min(actual.len, window_start + max_window_size)]; | 390 | const actual_window = actual[window_start..@min(actual.len, window_start + max_window_size)]; |
| 391 | const actual_truncated = window_start + actual_window.len < actual.len; | 391 | const actual_truncated = window_start + actual_window.len < actual.len; |
| 392 | 392 | ||
| 393 | const stderr = std.io.getStdErr(); | 393 | const stderr: std.fs.File = .stderr(); |
| 394 | const ttyconf = std.io.tty.detectConfig(stderr); | 394 | const ttyconf = std.io.tty.detectConfig(stderr); |
| 395 | var differ = if (T == u8) BytesDiffer{ | 395 | var differ = if (T == u8) BytesDiffer{ |
| 396 | .expected = expected_window, | 396 | .expected = expected_window, |
lib/std/unicode/throughput_test.zig+1-1| ... | @@ -39,7 +39,7 @@ fn benchmarkCodepointCount(buf: []const u8) !ResultCount { | ... | @@ -39,7 +39,7 @@ fn benchmarkCodepointCount(buf: []const u8) !ResultCount { |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | pub fn main() !void { | 41 | pub fn main() !void { |
| 42 | const stdout = std.io.getStdOut().writer(); | 42 | const stdout = std.fs.File.stdout().writer(); |
| 43 | 43 | ||
| 44 | try stdout.print("short ASCII strings\n", .{}); | 44 | try stdout.print("short ASCII strings\n", .{}); |
| 45 | { | 45 | { |
lib/std/zig.zig+1-1| ... | @@ -48,7 +48,7 @@ pub const Color = enum { | ... | @@ -48,7 +48,7 @@ pub const Color = enum { |
| 48 | 48 | ||
| 49 | pub fn get_tty_conf(color: Color) std.io.tty.Config { | 49 | pub fn get_tty_conf(color: Color) std.io.tty.Config { |
| 50 | return switch (color) { | 50 | return switch (color) { |
| 51 | .auto => std.io.tty.detectConfig(std.io.getStdErr()), | 51 | .auto => std.io.tty.detectConfig(std.fs.File.stderr()), |
| 52 | .on => .escape_codes, | 52 | .on => .escape_codes, |
| 53 | .off => .no_color, | 53 | .off => .no_color, |
| 54 | }; | 54 | }; |
lib/std/zig/ErrorBundle.zig+6-6| ... | @@ -7,6 +7,11 @@ | ... | @@ -7,6 +7,11 @@ |
| 7 | //! empty, it means there are no errors. This special encoding exists so that | 7 | //! empty, it means there are no errors. This special encoding exists so that |
| 8 | //! heap allocation is not needed in the common case of no errors. | 8 | //! heap allocation is not needed in the common case of no errors. |
| 9 | 9 | ||
| 10 | const std = @import("std"); | ||
| 11 | const ErrorBundle = @This(); | ||
| 12 | const Allocator = std.mem.Allocator; | ||
| 13 | const assert = std.debug.assert; | ||
| 14 | |||
| 10 | string_bytes: []const u8, | 15 | string_bytes: []const u8, |
| 11 | /// The first thing in this array is an `ErrorMessageList`. | 16 | /// The first thing in this array is an `ErrorMessageList`. |
| 12 | extra: []const u32, | 17 | extra: []const u32, |
| ... | @@ -159,7 +164,7 @@ pub const RenderOptions = struct { | ... | @@ -159,7 +164,7 @@ pub const RenderOptions = struct { |
| 159 | pub fn renderToStdErr(eb: ErrorBundle, options: RenderOptions) void { | 164 | pub fn renderToStdErr(eb: ErrorBundle, options: RenderOptions) void { |
| 160 | std.debug.lockStdErr(); | 165 | std.debug.lockStdErr(); |
| 161 | defer std.debug.unlockStdErr(); | 166 | defer std.debug.unlockStdErr(); |
| 162 | const stderr = std.io.getStdErr(); | 167 | const stderr: std.fs.File = .stderr(); |
| 163 | return renderToWriter(eb, options, stderr.writer()) catch return; | 168 | return renderToWriter(eb, options, stderr.writer()) catch return; |
| 164 | } | 169 | } |
| 165 | 170 | ||
| ... | @@ -305,11 +310,6 @@ fn writeMsg(eb: ErrorBundle, err_msg: ErrorMessage, stderr: anytype, indent: usi | ... | @@ -305,11 +310,6 @@ fn writeMsg(eb: ErrorBundle, err_msg: ErrorMessage, stderr: anytype, indent: usi |
| 305 | } | 310 | } |
| 306 | } | 311 | } |
| 307 | 312 | ||
| 308 | const std = @import("std"); | ||
| 309 | const ErrorBundle = @This(); | ||
| 310 | const Allocator = std.mem.Allocator; | ||
| 311 | const assert = std.debug.assert; | ||
| 312 | |||
| 313 | pub const Wip = struct { | 313 | pub const Wip = struct { |
| 314 | gpa: Allocator, | 314 | gpa: Allocator, |
| 315 | string_bytes: std.ArrayListUnmanaged(u8), | 315 | string_bytes: std.ArrayListUnmanaged(u8), |
lib/std/zig/llvm/Builder.zig+2-1| ... | @@ -9493,7 +9493,8 @@ pub fn asmValue( | ... | @@ -9493,7 +9493,8 @@ pub fn asmValue( |
| 9493 | } | 9493 | } |
| 9494 | 9494 | ||
| 9495 | pub fn dump(self: *Builder) void { | 9495 | pub fn dump(self: *Builder) void { |
| 9496 | self.print(std.io.getStdErr().writer()) catch {}; | 9496 | const stderr: std.fs.File = .stderr(); |
| 9497 | self.print(stderr.writer()) catch {}; | ||
| 9497 | } | 9498 | } |
| 9498 | 9499 | ||
| 9499 | pub fn printToFile(self: *Builder, path: []const u8) Allocator.Error!bool { | 9500 | pub fn printToFile(self: *Builder, path: []const u8) Allocator.Error!bool { |
lib/std/zig/parser_test.zig+7-7| ... | @@ -1,3 +1,9 @@ | ... | @@ -1,3 +1,9 @@ |
| 1 | const std = @import("std"); | ||
| 2 | const mem = std.mem; | ||
| 3 | const print = std.debug.print; | ||
| 4 | const io = std.io; | ||
| 5 | const maxInt = std.math.maxInt; | ||
| 6 | |||
| 1 | test "zig fmt: remove extra whitespace at start and end of file with comment between" { | 7 | test "zig fmt: remove extra whitespace at start and end of file with comment between" { |
| 2 | try testTransform( | 8 | try testTransform( |
| 3 | \\ | 9 | \\ |
| ... | @@ -6315,16 +6321,10 @@ test "ampersand" { | ... | @@ -6315,16 +6321,10 @@ test "ampersand" { |
| 6315 | , &.{}); | 6321 | , &.{}); |
| 6316 | } | 6322 | } |
| 6317 | 6323 | ||
| 6318 | const std = @import("std"); | ||
| 6319 | const mem = std.mem; | ||
| 6320 | const print = std.debug.print; | ||
| 6321 | const io = std.io; | ||
| 6322 | const maxInt = std.math.maxInt; | ||
| 6323 | |||
| 6324 | var fixed_buffer_mem: [100 * 1024]u8 = undefined; | 6324 | var fixed_buffer_mem: [100 * 1024]u8 = undefined; |
| 6325 | 6325 | ||
| 6326 | fn testParse(source: [:0]const u8, allocator: mem.Allocator, anything_changed: *bool) ![]u8 { | 6326 | fn testParse(source: [:0]const u8, allocator: mem.Allocator, anything_changed: *bool) ![]u8 { |
| 6327 | const stderr = io.getStdErr().writer(); | 6327 | const stderr = std.fs.File.stderr().writer(); |
| 6328 | 6328 | ||
| 6329 | var tree = try std.zig.Ast.parse(allocator, source, .zig); | 6329 | var tree = try std.zig.Ast.parse(allocator, source, .zig); |
| 6330 | defer tree.deinit(allocator); | 6330 | defer tree.deinit(allocator); |
lib/std/zig/perf_test.zig+1-1| ... | @@ -22,7 +22,7 @@ pub fn main() !void { | ... | @@ -22,7 +22,7 @@ pub fn main() !void { |
| 22 | const bytes_per_sec_float = @as(f64, @floatFromInt(source.len * iterations)) / elapsed_s; | 22 | const bytes_per_sec_float = @as(f64, @floatFromInt(source.len * iterations)) / elapsed_s; |
| 23 | const bytes_per_sec = @as(u64, @intFromFloat(@floor(bytes_per_sec_float))); | 23 | const bytes_per_sec = @as(u64, @intFromFloat(@floor(bytes_per_sec_float))); |
| 24 | 24 | ||
| 25 | var stdout_file = std.io.getStdOut(); | 25 | var stdout_file: std.fs.File = .stdout(); |
| 26 | const stdout = stdout_file.writer(); | 26 | const stdout = stdout_file.writer(); |
| 27 | try stdout.print("parsing speed: {:.2}/s, {:.2} used \n", .{ | 27 | try stdout.print("parsing speed: {:.2}/s, {:.2} used \n", .{ |
| 28 | fmtIntSizeBin(bytes_per_sec), | 28 | fmtIntSizeBin(bytes_per_sec), |
src/Air/print.zig+2-2| ... | @@ -73,11 +73,11 @@ pub fn writeInst( | ... | @@ -73,11 +73,11 @@ pub fn writeInst( |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | pub fn dump(air: Air, pt: Zcu.PerThread, liveness: ?Air.Liveness) void { | 75 | pub fn dump(air: Air, pt: Zcu.PerThread, liveness: ?Air.Liveness) void { |
| 76 | air.write(std.io.getStdErr().writer(), pt, liveness); | 76 | air.write(std.fs.File.stderr().writer(), pt, liveness); |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | pub fn dumpInst(air: Air, inst: Air.Inst.Index, pt: Zcu.PerThread, liveness: ?Air.Liveness) void { | 79 | pub fn dumpInst(air: Air, inst: Air.Inst.Index, pt: Zcu.PerThread, liveness: ?Air.Liveness) void { |
| 80 | air.writeInst(std.io.getStdErr().writer(), inst, pt, liveness); | 80 | air.writeInst(std.fs.File.stderr().writer(), inst, pt, liveness); |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | const Writer = struct { | 83 | const Writer = struct { |
src/Compilation.zig+3-3| ... | @@ -1875,7 +1875,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil | ... | @@ -1875,7 +1875,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil |
| 1875 | if (options.root_mod.resolved_target.llvm_cpu_features) |cf| print: { | 1875 | if (options.root_mod.resolved_target.llvm_cpu_features) |cf| print: { |
| 1876 | std.debug.lockStdErr(); | 1876 | std.debug.lockStdErr(); |
| 1877 | defer std.debug.unlockStdErr(); | 1877 | defer std.debug.unlockStdErr(); |
| 1878 | const stderr = std.io.getStdErr().writer(); | 1878 | const stderr = std.fs.File.stderr().writer(); |
| 1879 | nosuspend { | 1879 | nosuspend { |
| 1880 | stderr.print("compilation: {s}\n", .{options.root_name}) catch break :print; | 1880 | stderr.print("compilation: {s}\n", .{options.root_name}) catch break :print; |
| 1881 | stderr.print(" target: {s}\n", .{try target.zigTriple(arena)}) catch break :print; | 1881 | stderr.print(" target: {s}\n", .{try target.zigTriple(arena)}) catch break :print; |
| ... | @@ -3932,7 +3932,7 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle { | ... | @@ -3932,7 +3932,7 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle { |
| 3932 | // This AU is referenced and has a transitive compile error, meaning it referenced something with a compile error. | 3932 | // This AU is referenced and has a transitive compile error, meaning it referenced something with a compile error. |
| 3933 | // However, we haven't reported any such error. | 3933 | // However, we haven't reported any such error. |
| 3934 | // This is a compiler bug. | 3934 | // This is a compiler bug. |
| 3935 | const stderr = std.io.getStdErr().writer(); | 3935 | const stderr = std.fs.File.stderr().writer(); |
| 3936 | try stderr.writeAll("referenced transitive analysis errors, but none actually emitted\n"); | 3936 | try stderr.writeAll("referenced transitive analysis errors, but none actually emitted\n"); |
| 3937 | try stderr.print("{} [transitive failure]\n", .{zcu.fmtAnalUnit(failed_unit)}); | 3937 | try stderr.print("{} [transitive failure]\n", .{zcu.fmtAnalUnit(failed_unit)}); |
| 3938 | while (ref) |r| { | 3938 | while (ref) |r| { |
| ... | @@ -7214,7 +7214,7 @@ pub fn lockAndSetMiscFailure( | ... | @@ -7214,7 +7214,7 @@ pub fn lockAndSetMiscFailure( |
| 7214 | pub fn dump_argv(argv: []const []const u8) void { | 7214 | pub fn dump_argv(argv: []const []const u8) void { |
| 7215 | std.debug.lockStdErr(); | 7215 | std.debug.lockStdErr(); |
| 7216 | defer std.debug.unlockStdErr(); | 7216 | defer std.debug.unlockStdErr(); |
| 7217 | const stderr = std.io.getStdErr().writer(); | 7217 | const stderr = std.fs.File.stderr().writer(); |
| 7218 | for (argv[0 .. argv.len - 1]) |arg| { | 7218 | for (argv[0 .. argv.len - 1]) |arg| { |
| 7219 | nosuspend stderr.print("{s} ", .{arg}) catch return; | 7219 | nosuspend stderr.print("{s} ", .{arg}) catch return; |
| 7220 | } | 7220 | } |
src/InternPool.zig+2-2| ... | @@ -11259,7 +11259,7 @@ fn dumpStatsFallible(ip: *const InternPool, arena: Allocator) anyerror!void { | ... | @@ -11259,7 +11259,7 @@ fn dumpStatsFallible(ip: *const InternPool, arena: Allocator) anyerror!void { |
| 11259 | } | 11259 | } |
| 11260 | 11260 | ||
| 11261 | fn dumpAllFallible(ip: *const InternPool) anyerror!void { | 11261 | fn dumpAllFallible(ip: *const InternPool) anyerror!void { |
| 11262 | var bw = std.io.bufferedWriter(std.io.getStdErr().writer()); | 11262 | var bw = std.io.bufferedWriter(std.fs.File.stderr().writer()); |
| 11263 | const w = bw.writer(); | 11263 | const w = bw.writer(); |
| 11264 | for (ip.locals, 0..) |*local, tid| { | 11264 | for (ip.locals, 0..) |*local, tid| { |
| 11265 | const items = local.shared.items.view(); | 11265 | const items = local.shared.items.view(); |
| ... | @@ -11369,7 +11369,7 @@ pub fn dumpGenericInstancesFallible(ip: *const InternPool, allocator: Allocator) | ... | @@ -11369,7 +11369,7 @@ pub fn dumpGenericInstancesFallible(ip: *const InternPool, allocator: Allocator) |
| 11369 | defer arena_allocator.deinit(); | 11369 | defer arena_allocator.deinit(); |
| 11370 | const arena = arena_allocator.allocator(); | 11370 | const arena = arena_allocator.allocator(); |
| 11371 | 11371 | ||
| 11372 | var bw = std.io.bufferedWriter(std.io.getStdErr().writer()); | 11372 | var bw = std.io.bufferedWriter(std.fs.File.stderr().writer()); |
| 11373 | const w = bw.writer(); | 11373 | const w = bw.writer(); |
| 11374 | 11374 | ||
| 11375 | var instances: std.AutoArrayHashMapUnmanaged(Index, std.ArrayListUnmanaged(Index)) = .empty; | 11375 | var instances: std.AutoArrayHashMapUnmanaged(Index, std.ArrayListUnmanaged(Index)) = .empty; |
src/Package/Fetch.zig+23-23| ... | @@ -27,6 +27,22 @@ | ... | @@ -27,6 +27,22 @@ |
| 27 | //! All of this must be done with only referring to the state inside this struct | 27 | //! All of this must be done with only referring to the state inside this struct |
| 28 | //! because this work will be done in a dedicated thread. | 28 | //! because this work will be done in a dedicated thread. |
| 29 | 29 | ||
| 30 | const builtin = @import("builtin"); | ||
| 31 | const std = @import("std"); | ||
| 32 | const fs = std.fs; | ||
| 33 | const assert = std.debug.assert; | ||
| 34 | const ascii = std.ascii; | ||
| 35 | const Allocator = std.mem.Allocator; | ||
| 36 | const Cache = std.Build.Cache; | ||
| 37 | const ThreadPool = std.Thread.Pool; | ||
| 38 | const WaitGroup = std.Thread.WaitGroup; | ||
| 39 | const Fetch = @This(); | ||
| 40 | const git = @import("Fetch/git.zig"); | ||
| 41 | const Package = @import("../Package.zig"); | ||
| 42 | const Manifest = Package.Manifest; | ||
| 43 | const ErrorBundle = std.zig.ErrorBundle; | ||
| 44 | const native_os = builtin.os.tag; | ||
| 45 | |||
| 30 | arena: std.heap.ArenaAllocator, | 46 | arena: std.heap.ArenaAllocator, |
| 31 | location: Location, | 47 | location: Location, |
| 32 | location_tok: std.zig.Ast.TokenIndex, | 48 | location_tok: std.zig.Ast.TokenIndex, |
| ... | @@ -1638,7 +1654,7 @@ fn computeHash(f: *Fetch, pkg_path: Cache.Path, filter: Filter) RunError!Compute | ... | @@ -1638,7 +1654,7 @@ fn computeHash(f: *Fetch, pkg_path: Cache.Path, filter: Filter) RunError!Compute |
| 1638 | } | 1654 | } |
| 1639 | 1655 | ||
| 1640 | fn dumpHashInfo(all_files: []const *const HashedFile) !void { | 1656 | fn dumpHashInfo(all_files: []const *const HashedFile) !void { |
| 1641 | const stdout = std.io.getStdOut(); | 1657 | const stdout: std.fs.File = .stdout(); |
| 1642 | var bw = std.io.bufferedWriter(stdout.writer()); | 1658 | var bw = std.io.bufferedWriter(stdout.writer()); |
| 1643 | const w = bw.writer(); | 1659 | const w = bw.writer(); |
| 1644 | 1660 | ||
| ... | @@ -1817,28 +1833,6 @@ pub fn depDigest(pkg_root: Cache.Path, cache_root: Cache.Directory, dep: Manifes | ... | @@ -1817,28 +1833,6 @@ pub fn depDigest(pkg_root: Cache.Path, cache_root: Cache.Directory, dep: Manifes |
| 1817 | } | 1833 | } |
| 1818 | } | 1834 | } |
| 1819 | 1835 | ||
| 1820 | const builtin = @import("builtin"); | ||
| 1821 | const std = @import("std"); | ||
| 1822 | const fs = std.fs; | ||
| 1823 | const assert = std.debug.assert; | ||
| 1824 | const ascii = std.ascii; | ||
| 1825 | const Allocator = std.mem.Allocator; | ||
| 1826 | const Cache = std.Build.Cache; | ||
| 1827 | const ThreadPool = std.Thread.Pool; | ||
| 1828 | const WaitGroup = std.Thread.WaitGroup; | ||
| 1829 | const Fetch = @This(); | ||
| 1830 | const git = @import("Fetch/git.zig"); | ||
| 1831 | const Package = @import("../Package.zig"); | ||
| 1832 | const Manifest = Package.Manifest; | ||
| 1833 | const ErrorBundle = std.zig.ErrorBundle; | ||
| 1834 | const native_os = builtin.os.tag; | ||
| 1835 | |||
| 1836 | test { | ||
| 1837 | _ = Filter; | ||
| 1838 | _ = FileType; | ||
| 1839 | _ = UnpackResult; | ||
| 1840 | } | ||
| 1841 | |||
| 1842 | // Detects executable header: ELF or Macho-O magic header or shebang line. | 1836 | // Detects executable header: ELF or Macho-O magic header or shebang line. |
| 1843 | const FileHeader = struct { | 1837 | const FileHeader = struct { |
| 1844 | header: [4]u8 = undefined, | 1838 | header: [4]u8 = undefined, |
| ... | @@ -2437,3 +2431,9 @@ const TestFetchBuilder = struct { | ... | @@ -2437,3 +2431,9 @@ const TestFetchBuilder = struct { |
| 2437 | try std.testing.expectEqualStrings(msg, al.items); | 2431 | try std.testing.expectEqualStrings(msg, al.items); |
| 2438 | } | 2432 | } |
| 2439 | }; | 2433 | }; |
| 2434 | |||
| 2435 | test { | ||
| 2436 | _ = Filter; | ||
| 2437 | _ = FileType; | ||
| 2438 | _ = UnpackResult; | ||
| 2439 | } |
src/Zcu/PerThread.zig+1-1| ... | @@ -4378,7 +4378,7 @@ fn runCodegenInner(pt: Zcu.PerThread, func_index: InternPool.Index, air: *Air) e | ... | @@ -4378,7 +4378,7 @@ fn runCodegenInner(pt: Zcu.PerThread, func_index: InternPool.Index, air: *Air) e |
| 4378 | if (build_options.enable_debug_extensions and comp.verbose_air) { | 4378 | if (build_options.enable_debug_extensions and comp.verbose_air) { |
| 4379 | std.debug.lockStdErr(); | 4379 | std.debug.lockStdErr(); |
| 4380 | defer std.debug.unlockStdErr(); | 4380 | defer std.debug.unlockStdErr(); |
| 4381 | const stderr = std.io.getStdErr().writer(); | 4381 | const stderr = std.fs.File.stderr().writer(); |
| 4382 | stderr.print("# Begin Function AIR: {}:\n", .{fqn.fmt(ip)}) catch {}; | 4382 | stderr.print("# Begin Function AIR: {}:\n", .{fqn.fmt(ip)}) catch {}; |
| 4383 | air.write(stderr, pt, liveness); | 4383 | air.write(stderr, pt, liveness); |
| 4384 | stderr.print("# End Function AIR: {}\n\n", .{fqn.fmt(ip)}) catch {}; | 4384 | stderr.print("# End Function AIR: {}\n\n", .{fqn.fmt(ip)}) catch {}; |
src/crash_report.zig+7-7| ... | @@ -80,7 +80,7 @@ fn dumpStatusReport() !void { | ... | @@ -80,7 +80,7 @@ fn dumpStatusReport() !void { |
| 80 | var fba = std.heap.FixedBufferAllocator.init(&crash_heap); | 80 | var fba = std.heap.FixedBufferAllocator.init(&crash_heap); |
| 81 | const allocator = fba.allocator(); | 81 | const allocator = fba.allocator(); |
| 82 | 82 | ||
| 83 | const stderr = io.getStdErr().writer(); | 83 | const stderr = std.fs.File.stderr().writer(); |
| 84 | const block: *Sema.Block = anal.block; | 84 | const block: *Sema.Block = anal.block; |
| 85 | const zcu = anal.sema.pt.zcu; | 85 | const zcu = anal.sema.pt.zcu; |
| 86 | 86 | ||
| ... | @@ -271,7 +271,7 @@ const StackContext = union(enum) { | ... | @@ -271,7 +271,7 @@ const StackContext = union(enum) { |
| 271 | debug.dumpStackTraceFromBase(context); | 271 | debug.dumpStackTraceFromBase(context); |
| 272 | }, | 272 | }, |
| 273 | .not_supported => { | 273 | .not_supported => { |
| 274 | const stderr = io.getStdErr().writer(); | 274 | const stderr = std.fs.File.stderr().writer(); |
| 275 | stderr.writeAll("Stack trace not supported on this platform.\n") catch {}; | 275 | stderr.writeAll("Stack trace not supported on this platform.\n") catch {}; |
| 276 | }, | 276 | }, |
| 277 | } | 277 | } |
| ... | @@ -379,7 +379,7 @@ const PanicSwitch = struct { | ... | @@ -379,7 +379,7 @@ const PanicSwitch = struct { |
| 379 | 379 | ||
| 380 | state.recover_stage = .release_mutex; | 380 | state.recover_stage = .release_mutex; |
| 381 | 381 | ||
| 382 | const stderr = io.getStdErr().writer(); | 382 | const stderr = std.fs.File.stderr().writer(); |
| 383 | if (builtin.single_threaded) { | 383 | if (builtin.single_threaded) { |
| 384 | stderr.print("panic: ", .{}) catch goTo(releaseMutex, .{state}); | 384 | stderr.print("panic: ", .{}) catch goTo(releaseMutex, .{state}); |
| 385 | } else { | 385 | } else { |
| ... | @@ -406,7 +406,7 @@ const PanicSwitch = struct { | ... | @@ -406,7 +406,7 @@ const PanicSwitch = struct { |
| 406 | recover(state, trace, stack, msg); | 406 | recover(state, trace, stack, msg); |
| 407 | 407 | ||
| 408 | state.recover_stage = .release_mutex; | 408 | state.recover_stage = .release_mutex; |
| 409 | const stderr = io.getStdErr().writer(); | 409 | const stderr = std.fs.File.stderr().writer(); |
| 410 | stderr.writeAll("\nOriginal Error:\n") catch {}; | 410 | stderr.writeAll("\nOriginal Error:\n") catch {}; |
| 411 | goTo(reportStack, .{state}); | 411 | goTo(reportStack, .{state}); |
| 412 | } | 412 | } |
| ... | @@ -477,7 +477,7 @@ const PanicSwitch = struct { | ... | @@ -477,7 +477,7 @@ const PanicSwitch = struct { |
| 477 | recover(state, trace, stack, msg); | 477 | recover(state, trace, stack, msg); |
| 478 | 478 | ||
| 479 | state.recover_stage = .silent_abort; | 479 | state.recover_stage = .silent_abort; |
| 480 | const stderr = io.getStdErr().writer(); | 480 | const stderr = std.fs.File.stderr().writer(); |
| 481 | stderr.writeAll("Aborting...\n") catch {}; | 481 | stderr.writeAll("Aborting...\n") catch {}; |
| 482 | goTo(abort, .{}); | 482 | goTo(abort, .{}); |
| 483 | } | 483 | } |
| ... | @@ -505,7 +505,7 @@ const PanicSwitch = struct { | ... | @@ -505,7 +505,7 @@ const PanicSwitch = struct { |
| 505 | // lower the verbosity, and restore it at the end if we don't panic. | 505 | // lower the verbosity, and restore it at the end if we don't panic. |
| 506 | state.recover_verbosity = .message_only; | 506 | state.recover_verbosity = .message_only; |
| 507 | 507 | ||
| 508 | const stderr = io.getStdErr().writer(); | 508 | const stderr = std.fs.File.stderr().writer(); |
| 509 | stderr.writeAll("\nPanicked during a panic: ") catch {}; | 509 | stderr.writeAll("\nPanicked during a panic: ") catch {}; |
| 510 | stderr.writeAll(msg) catch {}; | 510 | stderr.writeAll(msg) catch {}; |
| 511 | stderr.writeAll("\nInner panic stack:\n") catch {}; | 511 | stderr.writeAll("\nInner panic stack:\n") catch {}; |
| ... | @@ -519,7 +519,7 @@ const PanicSwitch = struct { | ... | @@ -519,7 +519,7 @@ const PanicSwitch = struct { |
| 519 | .message_only => { | 519 | .message_only => { |
| 520 | state.recover_verbosity = .silent; | 520 | state.recover_verbosity = .silent; |
| 521 | 521 | ||
| 522 | const stderr = io.getStdErr().writer(); | 522 | const stderr = std.fs.File.stderr().writer(); |
| 523 | stderr.writeAll("\nPanicked while dumping inner panic stack: ") catch {}; | 523 | stderr.writeAll("\nPanicked while dumping inner panic stack: ") catch {}; |
| 524 | stderr.writeAll(msg) catch {}; | 524 | stderr.writeAll(msg) catch {}; |
| 525 | stderr.writeAll("\n") catch {}; | 525 | stderr.writeAll("\n") catch {}; |
src/fmt.zig+13-13| ... | @@ -1,3 +1,11 @@ | ... | @@ -1,3 +1,11 @@ |
| 1 | const std = @import("std"); | ||
| 2 | const mem = std.mem; | ||
| 3 | const fs = std.fs; | ||
| 4 | const process = std.process; | ||
| 5 | const Allocator = std.mem.Allocator; | ||
| 6 | const Color = std.zig.Color; | ||
| 7 | const fatal = std.process.fatal; | ||
| 8 | |||
| 1 | const usage_fmt = | 9 | const usage_fmt = |
| 2 | \\Usage: zig fmt [file]... | 10 | \\Usage: zig fmt [file]... |
| 3 | \\ | 11 | \\ |
| ... | @@ -52,7 +60,7 @@ pub fn run( | ... | @@ -52,7 +60,7 @@ pub fn run( |
| 52 | const arg = args[i]; | 60 | const arg = args[i]; |
| 53 | if (mem.startsWith(u8, arg, "-")) { | 61 | if (mem.startsWith(u8, arg, "-")) { |
| 54 | if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) { | 62 | if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) { |
| 55 | const stdout = std.io.getStdOut().writer(); | 63 | const stdout = std.fs.File.stdout().writer(); |
| 56 | try stdout.writeAll(usage_fmt); | 64 | try stdout.writeAll(usage_fmt); |
| 57 | return process.cleanExit(); | 65 | return process.cleanExit(); |
| 58 | } else if (mem.eql(u8, arg, "--color")) { | 66 | } else if (mem.eql(u8, arg, "--color")) { |
| ... | @@ -93,7 +101,7 @@ pub fn run( | ... | @@ -93,7 +101,7 @@ pub fn run( |
| 93 | fatal("cannot use --stdin with positional arguments", .{}); | 101 | fatal("cannot use --stdin with positional arguments", .{}); |
| 94 | } | 102 | } |
| 95 | 103 | ||
| 96 | const stdin = std.io.getStdIn(); | 104 | const stdin: fs.File = .stdin(); |
| 97 | const source_code = std.zig.readSourceFileToEndAlloc(gpa, stdin, null) catch |err| { | 105 | const source_code = std.zig.readSourceFileToEndAlloc(gpa, stdin, null) catch |err| { |
| 98 | fatal("unable to read stdin: {}", .{err}); | 106 | fatal("unable to read stdin: {}", .{err}); |
| 99 | }; | 107 | }; |
| ... | @@ -146,7 +154,7 @@ pub fn run( | ... | @@ -146,7 +154,7 @@ pub fn run( |
| 146 | process.exit(code); | 154 | process.exit(code); |
| 147 | } | 155 | } |
| 148 | 156 | ||
| 149 | return std.io.getStdOut().writeAll(formatted); | 157 | return std.fs.File.stdout().writeAll(formatted); |
| 150 | } | 158 | } |
| 151 | 159 | ||
| 152 | if (input_files.items.len == 0) { | 160 | if (input_files.items.len == 0) { |
| ... | @@ -363,7 +371,7 @@ fn fmtPathFile( | ... | @@ -363,7 +371,7 @@ fn fmtPathFile( |
| 363 | return; | 371 | return; |
| 364 | 372 | ||
| 365 | if (check_mode) { | 373 | if (check_mode) { |
| 366 | const stdout = std.io.getStdOut().writer(); | 374 | const stdout = std.fs.File.stdout().writer(); |
| 367 | try stdout.print("{s}\n", .{file_path}); | 375 | try stdout.print("{s}\n", .{file_path}); |
| 368 | fmt.any_error = true; | 376 | fmt.any_error = true; |
| 369 | } else { | 377 | } else { |
| ... | @@ -372,15 +380,7 @@ fn fmtPathFile( | ... | @@ -372,15 +380,7 @@ fn fmtPathFile( |
| 372 | 380 | ||
| 373 | try af.file.writeAll(fmt.out_buffer.items); | 381 | try af.file.writeAll(fmt.out_buffer.items); |
| 374 | try af.finish(); | 382 | try af.finish(); |
| 375 | const stdout = std.io.getStdOut().writer(); | 383 | const stdout = std.fs.File.stdout().writer(); |
| 376 | try stdout.print("{s}\n", .{file_path}); | 384 | try stdout.print("{s}\n", .{file_path}); |
| 377 | } | 385 | } |
| 378 | } | 386 | } |
| 379 | |||
| 380 | const std = @import("std"); | ||
| 381 | const mem = std.mem; | ||
| 382 | const fs = std.fs; | ||
| 383 | const process = std.process; | ||
| 384 | const Allocator = std.mem.Allocator; | ||
| 385 | const Color = std.zig.Color; | ||
| 386 | const fatal = std.process.fatal; |
src/libs/mingw.zig+2-2| ... | @@ -306,7 +306,7 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void { | ... | @@ -306,7 +306,7 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void { |
| 306 | if (comp.verbose_cc) print: { | 306 | if (comp.verbose_cc) print: { |
| 307 | std.debug.lockStdErr(); | 307 | std.debug.lockStdErr(); |
| 308 | defer std.debug.unlockStdErr(); | 308 | defer std.debug.unlockStdErr(); |
| 309 | const stderr = std.io.getStdErr().writer(); | 309 | const stderr = std.fs.File.stderr().writer(); |
| 310 | nosuspend stderr.print("def file: {s}\n", .{def_file_path}) catch break :print; | 310 | nosuspend stderr.print("def file: {s}\n", .{def_file_path}) catch break :print; |
| 311 | nosuspend stderr.print("include dir: {s}\n", .{include_dir}) catch break :print; | 311 | nosuspend stderr.print("include dir: {s}\n", .{include_dir}) catch break :print; |
| 312 | nosuspend stderr.print("output path: {s}\n", .{def_final_path}) catch break :print; | 312 | nosuspend stderr.print("output path: {s}\n", .{def_final_path}) catch break :print; |
| ... | @@ -326,7 +326,7 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void { | ... | @@ -326,7 +326,7 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void { |
| 326 | 326 | ||
| 327 | for (aro_comp.diagnostics.list.items) |diagnostic| { | 327 | for (aro_comp.diagnostics.list.items) |diagnostic| { |
| 328 | if (diagnostic.kind == .@"fatal error" or diagnostic.kind == .@"error") { | 328 | if (diagnostic.kind == .@"fatal error" or diagnostic.kind == .@"error") { |
| 329 | aro.Diagnostics.render(&aro_comp, std.io.tty.detectConfig(std.io.getStdErr())); | 329 | aro.Diagnostics.render(&aro_comp, std.io.tty.detectConfig(std.fs.File.stderr())); |
| 330 | return error.AroPreprocessorFailed; | 330 | return error.AroPreprocessorFailed; |
| 331 | } | 331 | } |
| 332 | } | 332 | } |
src/link/Elf/gc.zig+1-1| ... | @@ -163,7 +163,7 @@ fn prune(elf_file: *Elf) void { | ... | @@ -163,7 +163,7 @@ fn prune(elf_file: *Elf) void { |
| 163 | } | 163 | } |
| 164 | 164 | ||
| 165 | pub fn dumpPrunedAtoms(elf_file: *Elf) !void { | 165 | pub fn dumpPrunedAtoms(elf_file: *Elf) !void { |
| 166 | const stderr = std.io.getStdErr().writer(); | 166 | const stderr = std.fs.File.stderr().writer(); |
| 167 | for (elf_file.objects.items) |index| { | 167 | for (elf_file.objects.items) |index| { |
| 168 | const file = elf_file.file(index).?; | 168 | const file = elf_file.file(index).?; |
| 169 | for (file.atoms()) |atom_index| { | 169 | for (file.atoms()) |atom_index| { |
src/main.zig+28-28| ... | @@ -340,11 +340,11 @@ fn mainArgs(gpa: Allocator, arena: Allocator, args: []const []const u8) !void { | ... | @@ -340,11 +340,11 @@ fn mainArgs(gpa: Allocator, arena: Allocator, args: []const []const u8) !void { |
| 340 | } else if (mem.eql(u8, cmd, "targets")) { | 340 | } else if (mem.eql(u8, cmd, "targets")) { |
| 341 | dev.check(.targets_command); | 341 | dev.check(.targets_command); |
| 342 | const host = std.zig.resolveTargetQueryOrFatal(.{}); | 342 | const host = std.zig.resolveTargetQueryOrFatal(.{}); |
| 343 | const stdout = io.getStdOut().writer(); | 343 | const stdout = fs.File.stdout().writer(); |
| 344 | return @import("print_targets.zig").cmdTargets(arena, cmd_args, stdout, &host); | 344 | return @import("print_targets.zig").cmdTargets(arena, cmd_args, stdout, &host); |
| 345 | } else if (mem.eql(u8, cmd, "version")) { | 345 | } else if (mem.eql(u8, cmd, "version")) { |
| 346 | dev.check(.version_command); | 346 | dev.check(.version_command); |
| 347 | try std.io.getStdOut().writeAll(build_options.version ++ "\n"); | 347 | try fs.File.stdout().writeAll(build_options.version ++ "\n"); |
| 348 | // Check libc++ linkage to make sure Zig was built correctly, but only | 348 | // Check libc++ linkage to make sure Zig was built correctly, but only |
| 349 | // for "env" and "version" to avoid affecting the startup time for | 349 | // for "env" and "version" to avoid affecting the startup time for |
| 350 | // build-critical commands (check takes about ~10 μs) | 350 | // build-critical commands (check takes about ~10 μs) |
| ... | @@ -352,7 +352,7 @@ fn mainArgs(gpa: Allocator, arena: Allocator, args: []const []const u8) !void { | ... | @@ -352,7 +352,7 @@ fn mainArgs(gpa: Allocator, arena: Allocator, args: []const []const u8) !void { |
| 352 | } else if (mem.eql(u8, cmd, "env")) { | 352 | } else if (mem.eql(u8, cmd, "env")) { |
| 353 | dev.check(.env_command); | 353 | dev.check(.env_command); |
| 354 | verifyLibcxxCorrectlyLinked(); | 354 | verifyLibcxxCorrectlyLinked(); |
| 355 | return @import("print_env.zig").cmdEnv(arena, cmd_args, io.getStdOut().writer()); | 355 | return @import("print_env.zig").cmdEnv(arena, cmd_args, fs.File.stdout().writer()); |
| 356 | } else if (mem.eql(u8, cmd, "reduce")) { | 356 | } else if (mem.eql(u8, cmd, "reduce")) { |
| 357 | return jitCmd(gpa, arena, cmd_args, .{ | 357 | return jitCmd(gpa, arena, cmd_args, .{ |
| 358 | .cmd_name = "reduce", | 358 | .cmd_name = "reduce", |
| ... | @@ -360,10 +360,10 @@ fn mainArgs(gpa: Allocator, arena: Allocator, args: []const []const u8) !void { | ... | @@ -360,10 +360,10 @@ fn mainArgs(gpa: Allocator, arena: Allocator, args: []const []const u8) !void { |
| 360 | }); | 360 | }); |
| 361 | } else if (mem.eql(u8, cmd, "zen")) { | 361 | } else if (mem.eql(u8, cmd, "zen")) { |
| 362 | dev.check(.zen_command); | 362 | dev.check(.zen_command); |
| 363 | return io.getStdOut().writeAll(info_zen); | 363 | return fs.File.stdout().writeAll(info_zen); |
| 364 | } else if (mem.eql(u8, cmd, "help") or mem.eql(u8, cmd, "-h") or mem.eql(u8, cmd, "--help")) { | 364 | } else if (mem.eql(u8, cmd, "help") or mem.eql(u8, cmd, "-h") or mem.eql(u8, cmd, "--help")) { |
| 365 | dev.check(.help_command); | 365 | dev.check(.help_command); |
| 366 | return io.getStdOut().writeAll(usage); | 366 | return fs.File.stdout().writeAll(usage); |
| 367 | } else if (mem.eql(u8, cmd, "ast-check")) { | 367 | } else if (mem.eql(u8, cmd, "ast-check")) { |
| 368 | return cmdAstCheck(arena, cmd_args); | 368 | return cmdAstCheck(arena, cmd_args); |
| 369 | } else if (mem.eql(u8, cmd, "detect-cpu")) { | 369 | } else if (mem.eql(u8, cmd, "detect-cpu")) { |
| ... | @@ -1038,7 +1038,7 @@ fn buildOutputType( | ... | @@ -1038,7 +1038,7 @@ fn buildOutputType( |
| 1038 | }; | 1038 | }; |
| 1039 | } else if (mem.startsWith(u8, arg, "-")) { | 1039 | } else if (mem.startsWith(u8, arg, "-")) { |
| 1040 | if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) { | 1040 | if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) { |
| 1041 | try io.getStdOut().writeAll(usage_build_generic); | 1041 | try fs.File.stdout().writeAll(usage_build_generic); |
| 1042 | return cleanExit(); | 1042 | return cleanExit(); |
| 1043 | } else if (mem.eql(u8, arg, "--")) { | 1043 | } else if (mem.eql(u8, arg, "--")) { |
| 1044 | if (arg_mode == .run) { | 1044 | if (arg_mode == .run) { |
| ... | @@ -2766,9 +2766,9 @@ fn buildOutputType( | ... | @@ -2766,9 +2766,9 @@ fn buildOutputType( |
| 2766 | } else if (mem.eql(u8, arg, "-V")) { | 2766 | } else if (mem.eql(u8, arg, "-V")) { |
| 2767 | warn("ignoring request for supported emulations: unimplemented", .{}); | 2767 | warn("ignoring request for supported emulations: unimplemented", .{}); |
| 2768 | } else if (mem.eql(u8, arg, "-v")) { | 2768 | } else if (mem.eql(u8, arg, "-v")) { |
| 2769 | try std.io.getStdOut().writeAll("zig ld " ++ build_options.version ++ "\n"); | 2769 | try fs.File.stdout().writeAll("zig ld " ++ build_options.version ++ "\n"); |
| 2770 | } else if (mem.eql(u8, arg, "--version")) { | 2770 | } else if (mem.eql(u8, arg, "--version")) { |
| 2771 | try std.io.getStdOut().writeAll("zig ld " ++ build_options.version ++ "\n"); | 2771 | try fs.File.stdout().writeAll("zig ld " ++ build_options.version ++ "\n"); |
| 2772 | process.exit(0); | 2772 | process.exit(0); |
| 2773 | } else { | 2773 | } else { |
| 2774 | fatal("unsupported linker arg: {s}", .{arg}); | 2774 | fatal("unsupported linker arg: {s}", .{arg}); |
| ... | @@ -3328,7 +3328,7 @@ fn buildOutputType( | ... | @@ -3328,7 +3328,7 @@ fn buildOutputType( |
| 3328 | var hasher = Cache.Hasher.init("0123456789abcdef"); | 3328 | var hasher = Cache.Hasher.init("0123456789abcdef"); |
| 3329 | var w = io.multiWriter(.{ f.writer(), hasher.writer() }); | 3329 | var w = io.multiWriter(.{ f.writer(), hasher.writer() }); |
| 3330 | var fifo = std.fifo.LinearFifo(u8, .{ .Static = 4096 }).init(); | 3330 | var fifo = std.fifo.LinearFifo(u8, .{ .Static = 4096 }).init(); |
| 3331 | try fifo.pump(io.getStdIn().reader(), w.writer()); | 3331 | try fifo.pump(fs.File.stdin().reader(), w.writer()); |
| 3332 | 3332 | ||
| 3333 | var bin_digest: Cache.BinDigest = undefined; | 3333 | var bin_digest: Cache.BinDigest = undefined; |
| 3334 | hasher.final(&bin_digest); | 3334 | hasher.final(&bin_digest); |
| ... | @@ -3546,15 +3546,15 @@ fn buildOutputType( | ... | @@ -3546,15 +3546,15 @@ fn buildOutputType( |
| 3546 | if (show_builtin) { | 3546 | if (show_builtin) { |
| 3547 | const builtin_opts = comp.root_mod.getBuiltinOptions(comp.config); | 3547 | const builtin_opts = comp.root_mod.getBuiltinOptions(comp.config); |
| 3548 | const source = try builtin_opts.generate(arena); | 3548 | const source = try builtin_opts.generate(arena); |
| 3549 | return std.io.getStdOut().writeAll(source); | 3549 | return fs.File.stdout().writeAll(source); |
| 3550 | } | 3550 | } |
| 3551 | switch (listen) { | 3551 | switch (listen) { |
| 3552 | .none => {}, | 3552 | .none => {}, |
| 3553 | .stdio => { | 3553 | .stdio => { |
| 3554 | try serve( | 3554 | try serve( |
| 3555 | comp, | 3555 | comp, |
| 3556 | std.io.getStdIn(), | 3556 | .stdin(), |
| 3557 | std.io.getStdOut(), | 3557 | .stdout(), |
| 3558 | test_exec_args.items, | 3558 | test_exec_args.items, |
| 3559 | self_exe_path, | 3559 | self_exe_path, |
| 3560 | arg_mode, | 3560 | arg_mode, |
| ... | @@ -4606,7 +4606,7 @@ fn cmdTranslateC( | ... | @@ -4606,7 +4606,7 @@ fn cmdTranslateC( |
| 4606 | fatal("unable to open cached translated zig file '{s}{s}{s}': {s}", .{ path, fs.path.sep_str, out_zig_path, @errorName(err) }); | 4606 | fatal("unable to open cached translated zig file '{s}{s}{s}': {s}", .{ path, fs.path.sep_str, out_zig_path, @errorName(err) }); |
| 4607 | }; | 4607 | }; |
| 4608 | defer zig_file.close(); | 4608 | defer zig_file.close(); |
| 4609 | try io.getStdOut().writeFileAll(zig_file, .{}); | 4609 | try fs.File.stdout().writeFileAll(zig_file, .{}); |
| 4610 | return cleanExit(); | 4610 | return cleanExit(); |
| 4611 | } | 4611 | } |
| 4612 | } | 4612 | } |
| ... | @@ -4636,7 +4636,7 @@ fn cmdInit(gpa: Allocator, arena: Allocator, args: []const []const u8) !void { | ... | @@ -4636,7 +4636,7 @@ fn cmdInit(gpa: Allocator, arena: Allocator, args: []const []const u8) !void { |
| 4636 | if (mem.eql(u8, arg, "-s") or mem.eql(u8, arg, "--strip")) { | 4636 | if (mem.eql(u8, arg, "-s") or mem.eql(u8, arg, "--strip")) { |
| 4637 | strip = true; | 4637 | strip = true; |
| 4638 | } else if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) { | 4638 | } else if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) { |
| 4639 | try io.getStdOut().writeAll(usage_init); | 4639 | try fs.File.stdout().writeAll(usage_init); |
| 4640 | return cleanExit(); | 4640 | return cleanExit(); |
| 4641 | } else { | 4641 | } else { |
| 4642 | fatal("unrecognized parameter: '{s}'", .{arg}); | 4642 | fatal("unrecognized parameter: '{s}'", .{arg}); |
| ... | @@ -5482,7 +5482,7 @@ fn jitCmd( | ... | @@ -5482,7 +5482,7 @@ fn jitCmd( |
| 5482 | 5482 | ||
| 5483 | if (options.server) { | 5483 | if (options.server) { |
| 5484 | var server = std.zig.Server{ | 5484 | var server = std.zig.Server{ |
| 5485 | .out = std.io.getStdOut(), | 5485 | .out = fs.File.stdout(), |
| 5486 | .in = undefined, // won't be receiving messages | 5486 | .in = undefined, // won't be receiving messages |
| 5487 | .receive_fifo = undefined, // won't be receiving messages | 5487 | .receive_fifo = undefined, // won't be receiving messages |
| 5488 | }; | 5488 | }; |
| ... | @@ -6015,7 +6015,7 @@ fn cmdAstCheck( | ... | @@ -6015,7 +6015,7 @@ fn cmdAstCheck( |
| 6015 | const arg = args[i]; | 6015 | const arg = args[i]; |
| 6016 | if (mem.startsWith(u8, arg, "-")) { | 6016 | if (mem.startsWith(u8, arg, "-")) { |
| 6017 | if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) { | 6017 | if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) { |
| 6018 | try io.getStdOut().writeAll(usage_ast_check); | 6018 | try fs.File.stdout().writeAll(usage_ast_check); |
| 6019 | return cleanExit(); | 6019 | return cleanExit(); |
| 6020 | } else if (mem.eql(u8, arg, "-t")) { | 6020 | } else if (mem.eql(u8, arg, "-t")) { |
| 6021 | want_output_text = true; | 6021 | want_output_text = true; |
| ... | @@ -6046,7 +6046,7 @@ fn cmdAstCheck( | ... | @@ -6046,7 +6046,7 @@ fn cmdAstCheck( |
| 6046 | break :file fs.cwd().openFile(p, .{}) catch |err| { | 6046 | break :file fs.cwd().openFile(p, .{}) catch |err| { |
| 6047 | fatal("unable to open file '{s}' for ast-check: {s}", .{ display_path, @errorName(err) }); | 6047 | fatal("unable to open file '{s}' for ast-check: {s}", .{ display_path, @errorName(err) }); |
| 6048 | }; | 6048 | }; |
| 6049 | } else io.getStdIn(); | 6049 | } else fs.File.stdin(); |
| 6050 | defer if (zig_source_path != null) f.close(); | 6050 | defer if (zig_source_path != null) f.close(); |
| 6051 | break :s std.zig.readSourceFileToEndAlloc(arena, f, null) catch |err| { | 6051 | break :s std.zig.readSourceFileToEndAlloc(arena, f, null) catch |err| { |
| 6052 | fatal("unable to load file '{s}' for ast-check: {s}", .{ display_path, @errorName(err) }); | 6052 | fatal("unable to load file '{s}' for ast-check: {s}", .{ display_path, @errorName(err) }); |
| ... | @@ -6107,7 +6107,7 @@ fn cmdAstCheck( | ... | @@ -6107,7 +6107,7 @@ fn cmdAstCheck( |
| 6107 | const extra_bytes = zir.extra.len * @sizeOf(u32); | 6107 | const extra_bytes = zir.extra.len * @sizeOf(u32); |
| 6108 | const total_bytes = @sizeOf(Zir) + instruction_bytes + extra_bytes + | 6108 | const total_bytes = @sizeOf(Zir) + instruction_bytes + extra_bytes + |
| 6109 | zir.string_bytes.len * @sizeOf(u8); | 6109 | zir.string_bytes.len * @sizeOf(u8); |
| 6110 | const stdout = io.getStdOut(); | 6110 | const stdout = fs.File.stdout(); |
| 6111 | const fmtIntSizeBin = std.fmt.fmtIntSizeBin; | 6111 | const fmtIntSizeBin = std.fmt.fmtIntSizeBin; |
| 6112 | // zig fmt: off | 6112 | // zig fmt: off |
| 6113 | try stdout.writer().print( | 6113 | try stdout.writer().print( |
| ... | @@ -6131,7 +6131,7 @@ fn cmdAstCheck( | ... | @@ -6131,7 +6131,7 @@ fn cmdAstCheck( |
| 6131 | // zig fmt: on | 6131 | // zig fmt: on |
| 6132 | } | 6132 | } |
| 6133 | 6133 | ||
| 6134 | try @import("print_zir.zig").renderAsTextToFile(arena, tree, zir, io.getStdOut()); | 6134 | try @import("print_zir.zig").renderAsTextToFile(arena, tree, zir, fs.File.stdout()); |
| 6135 | 6135 | ||
| 6136 | if (zir.hasCompileErrors()) { | 6136 | if (zir.hasCompileErrors()) { |
| 6137 | process.exit(1); | 6137 | process.exit(1); |
| ... | @@ -6158,7 +6158,7 @@ fn cmdAstCheck( | ... | @@ -6158,7 +6158,7 @@ fn cmdAstCheck( |
| 6158 | fatal("-t option only available in builds of zig with debug extensions", .{}); | 6158 | fatal("-t option only available in builds of zig with debug extensions", .{}); |
| 6159 | } | 6159 | } |
| 6160 | 6160 | ||
| 6161 | try @import("print_zoir.zig").renderToFile(zoir, arena, io.getStdOut()); | 6161 | try @import("print_zoir.zig").renderToFile(zoir, arena, fs.File.stdout()); |
| 6162 | return cleanExit(); | 6162 | return cleanExit(); |
| 6163 | }, | 6163 | }, |
| 6164 | } | 6164 | } |
| ... | @@ -6186,7 +6186,7 @@ fn cmdDetectCpu(args: []const []const u8) !void { | ... | @@ -6186,7 +6186,7 @@ fn cmdDetectCpu(args: []const []const u8) !void { |
| 6186 | const arg = args[i]; | 6186 | const arg = args[i]; |
| 6187 | if (mem.startsWith(u8, arg, "-")) { | 6187 | if (mem.startsWith(u8, arg, "-")) { |
| 6188 | if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) { | 6188 | if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) { |
| 6189 | const stdout = io.getStdOut().writer(); | 6189 | const stdout = fs.File.stdout().writer(); |
| 6190 | try stdout.writeAll(detect_cpu_usage); | 6190 | try stdout.writeAll(detect_cpu_usage); |
| 6191 | return cleanExit(); | 6191 | return cleanExit(); |
| 6192 | } else if (mem.eql(u8, arg, "--llvm")) { | 6192 | } else if (mem.eql(u8, arg, "--llvm")) { |
| ... | @@ -6279,7 +6279,7 @@ fn detectNativeCpuWithLLVM( | ... | @@ -6279,7 +6279,7 @@ fn detectNativeCpuWithLLVM( |
| 6279 | } | 6279 | } |
| 6280 | 6280 | ||
| 6281 | fn printCpu(cpu: std.Target.Cpu) !void { | 6281 | fn printCpu(cpu: std.Target.Cpu) !void { |
| 6282 | var bw = io.bufferedWriter(io.getStdOut().writer()); | 6282 | var bw = io.bufferedWriter(fs.File.stdout().writer()); |
| 6283 | const stdout = bw.writer(); | 6283 | const stdout = bw.writer(); |
| 6284 | 6284 | ||
| 6285 | if (cpu.model.llvm_name) |llvm_name| { | 6285 | if (cpu.model.llvm_name) |llvm_name| { |
| ... | @@ -6328,7 +6328,7 @@ fn cmdDumpLlvmInts( | ... | @@ -6328,7 +6328,7 @@ fn cmdDumpLlvmInts( |
| 6328 | const dl = tm.createTargetDataLayout(); | 6328 | const dl = tm.createTargetDataLayout(); |
| 6329 | const context = llvm.Context.create(); | 6329 | const context = llvm.Context.create(); |
| 6330 | 6330 | ||
| 6331 | var bw = io.bufferedWriter(io.getStdOut().writer()); | 6331 | var bw = io.bufferedWriter(fs.File.stdout().writer()); |
| 6332 | const stdout = bw.writer(); | 6332 | const stdout = bw.writer(); |
| 6333 | 6333 | ||
| 6334 | for ([_]u16{ 1, 8, 16, 32, 64, 128, 256 }) |bits| { | 6334 | for ([_]u16{ 1, 8, 16, 32, 64, 128, 256 }) |bits| { |
| ... | @@ -6368,7 +6368,7 @@ fn cmdDumpZir( | ... | @@ -6368,7 +6368,7 @@ fn cmdDumpZir( |
| 6368 | const extra_bytes = zir.extra.len * @sizeOf(u32); | 6368 | const extra_bytes = zir.extra.len * @sizeOf(u32); |
| 6369 | const total_bytes = @sizeOf(Zir) + instruction_bytes + extra_bytes + | 6369 | const total_bytes = @sizeOf(Zir) + instruction_bytes + extra_bytes + |
| 6370 | zir.string_bytes.len * @sizeOf(u8); | 6370 | zir.string_bytes.len * @sizeOf(u8); |
| 6371 | const stdout = io.getStdOut(); | 6371 | const stdout = fs.File.stdout(); |
| 6372 | const fmtIntSizeBin = std.fmt.fmtIntSizeBin; | 6372 | const fmtIntSizeBin = std.fmt.fmtIntSizeBin; |
| 6373 | // zig fmt: off | 6373 | // zig fmt: off |
| 6374 | try stdout.writer().print( | 6374 | try stdout.writer().print( |
| ... | @@ -6386,7 +6386,7 @@ fn cmdDumpZir( | ... | @@ -6386,7 +6386,7 @@ fn cmdDumpZir( |
| 6386 | // zig fmt: on | 6386 | // zig fmt: on |
| 6387 | } | 6387 | } |
| 6388 | 6388 | ||
| 6389 | return @import("print_zir.zig").renderAsTextToFile(arena, null, zir, io.getStdOut()); | 6389 | return @import("print_zir.zig").renderAsTextToFile(arena, null, zir, fs.File.stdout()); |
| 6390 | } | 6390 | } |
| 6391 | 6391 | ||
| 6392 | /// This is only enabled for debug builds. | 6392 | /// This is only enabled for debug builds. |
| ... | @@ -6444,7 +6444,7 @@ fn cmdChangelist( | ... | @@ -6444,7 +6444,7 @@ fn cmdChangelist( |
| 6444 | var inst_map: std.AutoHashMapUnmanaged(Zir.Inst.Index, Zir.Inst.Index) = .empty; | 6444 | var inst_map: std.AutoHashMapUnmanaged(Zir.Inst.Index, Zir.Inst.Index) = .empty; |
| 6445 | try Zcu.mapOldZirToNew(arena, old_zir, new_zir, &inst_map); | 6445 | try Zcu.mapOldZirToNew(arena, old_zir, new_zir, &inst_map); |
| 6446 | 6446 | ||
| 6447 | var bw = io.bufferedWriter(io.getStdOut().writer()); | 6447 | var bw = io.bufferedWriter(fs.File.stdout().writer()); |
| 6448 | const stdout = bw.writer(); | 6448 | const stdout = bw.writer(); |
| 6449 | { | 6449 | { |
| 6450 | try stdout.print("Instruction mappings:\n", .{}); | 6450 | try stdout.print("Instruction mappings:\n", .{}); |
| ... | @@ -6794,7 +6794,7 @@ fn cmdFetch( | ... | @@ -6794,7 +6794,7 @@ fn cmdFetch( |
| 6794 | const arg = args[i]; | 6794 | const arg = args[i]; |
| 6795 | if (mem.startsWith(u8, arg, "-")) { | 6795 | if (mem.startsWith(u8, arg, "-")) { |
| 6796 | if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) { | 6796 | if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) { |
| 6797 | const stdout = io.getStdOut().writer(); | 6797 | const stdout = fs.File.stdout().writer(); |
| 6798 | try stdout.writeAll(usage_fetch); | 6798 | try stdout.writeAll(usage_fetch); |
| 6799 | return cleanExit(); | 6799 | return cleanExit(); |
| 6800 | } else if (mem.eql(u8, arg, "--global-cache-dir")) { | 6800 | } else if (mem.eql(u8, arg, "--global-cache-dir")) { |
| ... | @@ -6908,7 +6908,7 @@ fn cmdFetch( | ... | @@ -6908,7 +6908,7 @@ fn cmdFetch( |
| 6908 | 6908 | ||
| 6909 | const name = switch (save) { | 6909 | const name = switch (save) { |
| 6910 | .no => { | 6910 | .no => { |
| 6911 | try io.getStdOut().writer().print("{s}\n", .{package_hash_slice}); | 6911 | try fs.File.stdout().writer().print("{s}\n", .{package_hash_slice}); |
| 6912 | return cleanExit(); | 6912 | return cleanExit(); |
| 6913 | }, | 6913 | }, |
| 6914 | .yes, .exact => |name| name: { | 6914 | .yes, .exact => |name| name: { |