authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-11-26 13:19:30+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-01-02 17:12:57-07:00
log1c13ca5a05978011283ff55a586443b10b69fc85
tree30a411c8e359467ba520d3f8e68ebf8500aceffa
parentdd973fb365dbbe11ce5beac8b4889bfab3fddc4d

stage2: Use {s} instead of {} when formatting strings


27 files changed, 503 insertions(+), 360 deletions(-)

lib/std/meta/trait.zig+14
......@@ -298,6 +298,20 @@ pub fn isNumber(comptime T: type) bool {
298298 };
299299}
300300
301pub fn isIntegerNumber(comptime T: type) bool {
302 return switch (@typeInfo(T)) {
303 .Int, .ComptimeInt => true,
304 else => false,
305 };
306}
307
308pub fn isFloatingNumber(comptime T: type) bool {
309 return switch (@typeInfo(T)) {
310 .Float, .ComptimeFloat => true,
311 else => false,
312 };
313}
314
301315test "std.meta.trait.isNumber" {
302316 const NotANumber = struct {
303317 number: u8,
src/Cache.zig+2-2
......@@ -549,7 +549,7 @@ pub const Manifest = struct {
549549 .target, .target_must_resolve, .prereq => {},
550550 else => |err| {
551551 try err.printError(error_buf.writer());
552 std.log.err("failed parsing {}: {}", .{ dep_file_basename, error_buf.items });
552 std.log.err("failed parsing {s}: {s}", .{ dep_file_basename, error_buf.items });
553553 return error.InvalidDepFile;
554554 },
555555 }
......@@ -561,7 +561,7 @@ pub const Manifest = struct {
561561 .prereq => |bytes| try self.addFilePost(bytes),
562562 else => |err| {
563563 try err.printError(error_buf.writer());
564 std.log.err("failed parsing {}: {}", .{ dep_file_basename, error_buf.items });
564 std.log.err("failed parsing {s}: {s}", .{ dep_file_basename, error_buf.items });
565565 return error.InvalidDepFile;
566566 },
567567 }
src/Compilation.zig+47-47
......@@ -1475,7 +1475,7 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor
14751475 // lifetime annotations in the ZIR.
14761476 var decl_arena = decl.typed_value.most_recent.arena.?.promote(module.gpa);
14771477 defer decl.typed_value.most_recent.arena.?.* = decl_arena.state;
1478 log.debug("analyze liveness of {}\n", .{decl.name});
1478 log.debug("analyze liveness of {s}\n", .{decl.name});
14791479 try liveness.analyze(module.gpa, &decl_arena.allocator, func.analysis.success);
14801480 }
14811481
......@@ -1492,7 +1492,7 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor
14921492 module.failed_decls.putAssumeCapacityNoClobber(decl, try ErrorMsg.create(
14931493 module.gpa,
14941494 decl.src(),
1495 "unable to codegen: {}",
1495 "unable to codegen: {s}",
14961496 .{@errorName(err)},
14971497 ));
14981498 decl.analysis = .codegen_failure_retryable;
......@@ -1535,7 +1535,7 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor
15351535 module.failed_decls.putAssumeCapacityNoClobber(decl, try ErrorMsg.create(
15361536 module.gpa,
15371537 decl.src(),
1538 "unable to update line number: {}",
1538 "unable to update line number: {s}",
15391539 .{@errorName(err)},
15401540 ));
15411541 decl.analysis = .codegen_failure_retryable;
......@@ -1544,50 +1544,50 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor
15441544 .glibc_crt_file => |crt_file| {
15451545 glibc.buildCRTFile(self, crt_file) catch |err| {
15461546 // TODO Expose this as a normal compile error rather than crashing here.
1547 fatal("unable to build glibc CRT file: {}", .{@errorName(err)});
1547 fatal("unable to build glibc CRT file: {s}", .{@errorName(err)});
15481548 };
15491549 },
15501550 .glibc_shared_objects => {
15511551 glibc.buildSharedObjects(self) catch |err| {
15521552 // TODO Expose this as a normal compile error rather than crashing here.
1553 fatal("unable to build glibc shared objects: {}", .{@errorName(err)});
1553 fatal("unable to build glibc shared objects: {s}", .{@errorName(err)});
15541554 };
15551555 },
15561556 .musl_crt_file => |crt_file| {
15571557 musl.buildCRTFile(self, crt_file) catch |err| {
15581558 // TODO Expose this as a normal compile error rather than crashing here.
1559 fatal("unable to build musl CRT file: {}", .{@errorName(err)});
1559 fatal("unable to build musl CRT file: {s}", .{@errorName(err)});
15601560 };
15611561 },
15621562 .mingw_crt_file => |crt_file| {
15631563 mingw.buildCRTFile(self, crt_file) catch |err| {
15641564 // TODO Expose this as a normal compile error rather than crashing here.
1565 fatal("unable to build mingw-w64 CRT file: {}", .{@errorName(err)});
1565 fatal("unable to build mingw-w64 CRT file: {s}", .{@errorName(err)});
15661566 };
15671567 },
15681568 .windows_import_lib => |index| {
15691569 const link_lib = self.bin_file.options.system_libs.items()[index].key;
15701570 mingw.buildImportLib(self, link_lib) catch |err| {
15711571 // TODO Expose this as a normal compile error rather than crashing here.
1572 fatal("unable to generate DLL import .lib file: {}", .{@errorName(err)});
1572 fatal("unable to generate DLL import .lib file: {s}", .{@errorName(err)});
15731573 };
15741574 },
15751575 .libunwind => {
15761576 libunwind.buildStaticLib(self) catch |err| {
15771577 // TODO Expose this as a normal compile error rather than crashing here.
1578 fatal("unable to build libunwind: {}", .{@errorName(err)});
1578 fatal("unable to build libunwind: {s}", .{@errorName(err)});
15791579 };
15801580 },
15811581 .libcxx => {
15821582 libcxx.buildLibCXX(self) catch |err| {
15831583 // TODO Expose this as a normal compile error rather than crashing here.
1584 fatal("unable to build libcxx: {}", .{@errorName(err)});
1584 fatal("unable to build libcxx: {s}", .{@errorName(err)});
15851585 };
15861586 },
15871587 .libcxxabi => {
15881588 libcxx.buildLibCXXABI(self) catch |err| {
15891589 // TODO Expose this as a normal compile error rather than crashing here.
1590 fatal("unable to build libcxxabi: {}", .{@errorName(err)});
1590 fatal("unable to build libcxxabi: {s}", .{@errorName(err)});
15911591 };
15921592 },
15931593 .libtsan => {
......@@ -1611,20 +1611,20 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor
16111611 .libssp => {
16121612 self.buildOutputFromZig("ssp.zig", .Lib, &self.libssp_static_lib) catch |err| {
16131613 // TODO Expose this as a normal compile error rather than crashing here.
1614 fatal("unable to build libssp: {}", .{@errorName(err)});
1614 fatal("unable to build libssp: {s}", .{@errorName(err)});
16151615 };
16161616 },
16171617 .zig_libc => {
16181618 self.buildOutputFromZig("c.zig", .Lib, &self.libc_static_lib) catch |err| {
16191619 // TODO Expose this as a normal compile error rather than crashing here.
1620 fatal("unable to build zig's multitarget libc: {}", .{@errorName(err)});
1620 fatal("unable to build zig's multitarget libc: {s}", .{@errorName(err)});
16211621 };
16221622 },
16231623 .generate_builtin_zig => {
16241624 // This Job is only queued up if there is a zig module.
16251625 self.updateBuiltinZigFile(self.bin_file.options.module.?) catch |err| {
16261626 // TODO Expose this as a normal compile error rather than crashing here.
1627 fatal("unable to update builtin.zig file: {}", .{@errorName(err)});
1627 fatal("unable to update builtin.zig file: {s}", .{@errorName(err)});
16281628 };
16291629 },
16301630 .stage1_module => {
......@@ -1704,11 +1704,11 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult {
17041704 const out_h_path = try comp.local_cache_directory.join(arena, &[_][]const u8{
17051705 tmp_dir_sub_path, cimport_basename,
17061706 });
1707 const out_dep_path = try std.fmt.allocPrint(arena, "{}.d", .{out_h_path});
1707 const out_dep_path = try std.fmt.allocPrint(arena, "{s}.d", .{out_h_path});
17081708
17091709 try zig_cache_tmp_dir.writeFile(cimport_basename, c_src);
17101710 if (comp.verbose_cimport) {
1711 log.info("C import source: {}", .{out_h_path});
1711 log.info("C import source: {s}", .{out_h_path});
17121712 }
17131713
17141714 var argv = std.ArrayList([]const u8).init(comp.gpa);
......@@ -1755,7 +1755,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult {
17551755 defer tree.deinit();
17561756
17571757 if (comp.verbose_cimport) {
1758 log.info("C import .d file: {}", .{out_dep_path});
1758 log.info("C import .d file: {s}", .{out_dep_path});
17591759 }
17601760
17611761 const dep_basename = std.fs.path.basename(out_dep_path);
......@@ -1775,7 +1775,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult {
17751775 try bos.flush();
17761776
17771777 man.writeManifest() catch |err| {
1778 log.warn("failed to write cache manifest for C import: {}", .{@errorName(err)});
1778 log.warn("failed to write cache manifest for C import: {s}", .{@errorName(err)});
17791779 };
17801780
17811781 break :digest digest;
......@@ -1785,7 +1785,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult {
17851785 "o", &digest, cimport_zig_basename,
17861786 });
17871787 if (comp.verbose_cimport) {
1788 log.info("C import output: {}\n", .{out_zig_path});
1788 log.info("C import output: {s}\n", .{out_zig_path});
17891789 }
17901790 return CImportResult{
17911791 .out_zig_path = out_zig_path,
......@@ -1946,7 +1946,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_comp_progress_node: *
19461946 child.stderr_behavior = .Inherit;
19471947
19481948 const term = child.spawnAndWait() catch |err| {
1949 return comp.failCObj(c_object, "unable to spawn {}: {}", .{ argv.items[0], @errorName(err) });
1949 return comp.failCObj(c_object, "unable to spawn {s}: {s}", .{ argv.items[0], @errorName(err) });
19501950 };
19511951 switch (term) {
19521952 .Exited => |code| {
......@@ -1974,7 +1974,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_comp_progress_node: *
19741974 const stderr = try stderr_reader.readAllAlloc(arena, 10 * 1024 * 1024);
19751975
19761976 const term = child.wait() catch |err| {
1977 return comp.failCObj(c_object, "unable to spawn {}: {}", .{ argv.items[0], @errorName(err) });
1977 return comp.failCObj(c_object, "unable to spawn {s}: {s}", .{ argv.items[0], @errorName(err) });
19781978 };
19791979
19801980 switch (term) {
......@@ -1982,12 +1982,12 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_comp_progress_node: *
19821982 if (code != 0) {
19831983 // TODO parse clang stderr and turn it into an error message
19841984 // and then call failCObjWithOwnedErrorMsg
1985 log.err("clang failed with stderr: {}", .{stderr});
1985 log.err("clang failed with stderr: {s}", .{stderr});
19861986 return comp.failCObj(c_object, "clang exited with code {}", .{code});
19871987 }
19881988 },
19891989 else => {
1990 log.err("clang terminated with stderr: {}", .{stderr});
1990 log.err("clang terminated with stderr: {s}", .{stderr});
19911991 return comp.failCObj(c_object, "clang terminated unexpectedly", .{});
19921992 },
19931993 }
......@@ -1999,7 +1999,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_comp_progress_node: *
19991999 try man.addDepFilePost(zig_cache_tmp_dir, dep_basename);
20002000 // Just to save disk space, we delete the file because it is never needed again.
20012001 zig_cache_tmp_dir.deleteFile(dep_basename) catch |err| {
2002 log.warn("failed to delete '{}': {}", .{ dep_file_path, @errorName(err) });
2002 log.warn("failed to delete '{s}': {s}", .{ dep_file_path, @errorName(err) });
20032003 };
20042004 }
20052005
......@@ -2015,7 +2015,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_comp_progress_node: *
20152015 try std.fs.rename(zig_cache_tmp_dir, tmp_basename, o_dir, o_basename);
20162016
20172017 man.writeManifest() catch |err| {
2018 log.warn("failed to write cache manifest when compiling '{}': {}", .{ c_object.src.src_path, @errorName(err) });
2018 log.warn("failed to write cache manifest when compiling '{s}': {s}", .{ c_object.src.src_path, @errorName(err) });
20192019 };
20202020 break :blk digest;
20212021 };
......@@ -2034,7 +2034,7 @@ pub fn tmpFilePath(comp: *Compilation, arena: *Allocator, suffix: []const u8) er
20342034 const s = std.fs.path.sep_str;
20352035 const rand_int = std.crypto.random.int(u64);
20362036 if (comp.local_cache_directory.path) |p| {
2037 return std.fmt.allocPrint(arena, "{}" ++ s ++ "tmp" ++ s ++ "{x}-{s}", .{ p, rand_int, suffix });
2037 return std.fmt.allocPrint(arena, "{s}" ++ s ++ "tmp" ++ s ++ "{x}-{s}", .{ p, rand_int, suffix });
20382038 } else {
20392039 return std.fmt.allocPrint(arena, "tmp" ++ s ++ "{x}-{s}", .{ rand_int, suffix });
20402040 }
......@@ -2144,7 +2144,7 @@ pub fn addCCArgs(
21442144 }
21452145 const mcmodel = comp.bin_file.options.machine_code_model;
21462146 if (mcmodel != .default) {
2147 try argv.append(try std.fmt.allocPrint(arena, "-mcmodel={}", .{@tagName(mcmodel)}));
2147 try argv.append(try std.fmt.allocPrint(arena, "-mcmodel={s}", .{@tagName(mcmodel)}));
21482148 }
21492149
21502150 switch (target.os.tag) {
......@@ -2497,22 +2497,22 @@ fn detectLibCIncludeDirs(
24972497 const s = std.fs.path.sep_str;
24982498 const arch_include_dir = try std.fmt.allocPrint(
24992499 arena,
2500 "{}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{}-{}-{}",
2500 "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{s}-{s}-{s}",
25012501 .{ zig_lib_dir, arch_name, os_name, abi_name },
25022502 );
25032503 const generic_include_dir = try std.fmt.allocPrint(
25042504 arena,
2505 "{}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "generic-{}",
2505 "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "generic-{s}",
25062506 .{ zig_lib_dir, generic_name },
25072507 );
25082508 const arch_os_include_dir = try std.fmt.allocPrint(
25092509 arena,
2510 "{}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{}-{}-any",
2510 "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{s}-{s}-any",
25112511 .{ zig_lib_dir, @tagName(target.cpu.arch), os_name },
25122512 );
25132513 const generic_os_include_dir = try std.fmt.allocPrint(
25142514 arena,
2515 "{}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "any-{}-any",
2515 "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "any-{s}-any",
25162516 .{ zig_lib_dir, os_name },
25172517 );
25182518
......@@ -2631,9 +2631,9 @@ fn updateBuiltinZigFile(comp: *Compilation, mod: *Module) !void {
26312631
26322632pub fn dump_argv(argv: []const []const u8) void {
26332633 for (argv[0 .. argv.len - 1]) |arg| {
2634 std.debug.print("{} ", .{arg});
2634 std.debug.print("{s} ", .{arg});
26352635 }
2636 std.debug.print("{}\n", .{argv[argv.len - 1]});
2636 std.debug.print("{s}\n", .{argv[argv.len - 1]});
26372637}
26382638
26392639pub fn generateBuiltinZigSource(comp: *Compilation, allocator: *Allocator) ![]u8 {
......@@ -2653,15 +2653,15 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: *Allocator) ![]u8
26532653 \\pub const arch = Target.current.cpu.arch;
26542654 \\/// Deprecated
26552655 \\pub const endian = Target.current.cpu.arch.endian();
2656 \\pub const output_mode = OutputMode.{};
2657 \\pub const link_mode = LinkMode.{};
2656 \\pub const output_mode = OutputMode.{s};
2657 \\pub const link_mode = LinkMode.{s};
26582658 \\pub const is_test = {};
26592659 \\pub const single_threaded = {};
2660 \\pub const abi = Abi.{};
2660 \\pub const abi = Abi.{s};
26612661 \\pub const cpu: Cpu = Cpu{{
2662 \\ .arch = .{},
2663 \\ .model = &Target.{}.cpu.{},
2664 \\ .features = Target.{}.featureSet(&[_]Target.{}.Feature{{
2662 \\ .arch = .{s},
2663 \\ .model = &Target.{s}.cpu.{s},
2664 \\ .features = Target.{s}.featureSet(&[_]Target.{s}.Feature{{
26652665 \\
26662666 , .{
26672667 @tagName(comp.bin_file.options.output_mode),
......@@ -2692,7 +2692,7 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: *Allocator) ![]u8
26922692 \\ }}),
26932693 \\}};
26942694 \\pub const os = Os{{
2695 \\ .tag = .{},
2695 \\ .tag = .{s},
26962696 \\ .version_range = .{{
26972697 ,
26982698 .{@tagName(target.os.tag)},
......@@ -2778,8 +2778,8 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: *Allocator) ![]u8
27782778 (comp.bin_file.options.skip_linker_dependencies and comp.bin_file.options.parent_compilation_link_libc);
27792779
27802780 try buffer.writer().print(
2781 \\pub const object_format = ObjectFormat.{};
2782 \\pub const mode = Mode.{};
2781 \\pub const object_format = ObjectFormat.{s};
2782 \\pub const mode = Mode.{s};
27832783 \\pub const link_libc = {};
27842784 \\pub const link_libcpp = {};
27852785 \\pub const have_error_return_tracing = {};
......@@ -2787,7 +2787,7 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: *Allocator) ![]u8
27872787 \\pub const position_independent_code = {};
27882788 \\pub const position_independent_executable = {};
27892789 \\pub const strip_debug_info = {};
2790 \\pub const code_model = CodeModel.{};
2790 \\pub const code_model = CodeModel.{s};
27912791 \\
27922792 , .{
27932793 @tagName(comp.bin_file.options.object_format),
......@@ -3013,7 +3013,7 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node
30133013 id_symlink_basename,
30143014 &prev_digest_buf,
30153015 ) catch |err| blk: {
3016 log.debug("stage1 {} new_digest={} error: {}", .{ mod.root_pkg.root_src_path, digest, @errorName(err) });
3016 log.debug("stage1 {} new_digest={} error: {s}", .{ mod.root_pkg.root_src_path, digest, @errorName(err) });
30173017 // Handle this as a cache miss.
30183018 break :blk prev_digest_buf[0..0];
30193019 };
......@@ -3189,7 +3189,7 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node
31893189 // Update the small file with the digest. If it fails we can continue; it only
31903190 // means that the next invocation will have an unnecessary cache miss.
31913191 const stage1_flags_byte = @bitCast(u8, mod.stage1_flags);
3192 log.debug("stage1 {} final digest={} flags={x}", .{
3192 log.debug("stage1 {s} final digest={} flags={x}", .{
31933193 mod.root_pkg.root_src_path, digest, stage1_flags_byte,
31943194 });
31953195 var digest_plus_flags: [digest.len + 2]u8 = undefined;
......@@ -3202,11 +3202,11 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node
32023202 digest_plus_flags, stage1_flags_byte, mod.stage1_flags.have_winmain_crt_startup,
32033203 });
32043204 Cache.writeSmallFile(directory.handle, id_symlink_basename, &digest_plus_flags) catch |err| {
3205 log.warn("failed to save stage1 hash digest file: {}", .{@errorName(err)});
3205 log.warn("failed to save stage1 hash digest file: {s}", .{@errorName(err)});
32063206 };
32073207 // Failure here only means an unnecessary cache miss.
32083208 man.writeManifest() catch |err| {
3209 log.warn("failed to write cache manifest when linking: {}", .{@errorName(err)});
3209 log.warn("failed to write cache manifest when linking: {s}", .{@errorName(err)});
32103210 };
32113211 // We hang on to this lock so that the output file path can be used without
32123212 // other processes clobbering it.
src/DepTokenizer.zig+3-3
......@@ -366,7 +366,7 @@ pub const Token = union(enum) {
366366 .incomplete_quoted_prerequisite,
367367 .incomplete_target,
368368 => |index_and_bytes| {
369 try writer.print("{} '", .{self.errStr()});
369 try writer.print("{s} '", .{self.errStr()});
370370 if (self == .incomplete_target) {
371371 const tmp = Token{ .target_must_resolve = index_and_bytes.bytes };
372372 try tmp.resolve(writer);
......@@ -383,7 +383,7 @@ pub const Token = union(enum) {
383383 => |index_and_char| {
384384 try writer.writeAll("illegal char ");
385385 try printUnderstandableChar(writer, index_and_char.char);
386 try writer.print(" at position {}: {}", .{ index_and_char.index, self.errStr() });
386 try writer.print(" at position {}: {s}", .{ index_and_char.index, self.errStr() });
387387 },
388388 }
389389 }
......@@ -943,7 +943,7 @@ fn printSection(out: anytype, label: []const u8, bytes: []const u8) !void {
943943
944944fn printLabel(out: anytype, label: []const u8, bytes: []const u8) !void {
945945 var buf: [80]u8 = undefined;
946 var text = try std.fmt.bufPrint(buf[0..], "{} {} bytes ", .{ label, bytes.len });
946 var text = try std.fmt.bufPrint(buf[0..], "{s} {} bytes ", .{ label, bytes.len });
947947 try out.writeAll(text);
948948 var i: usize = text.len;
949949 const end = 79;
src/Module.zig+8-8
......@@ -953,7 +953,7 @@ pub fn ensureDeclAnalyzed(self: *Module, decl: *Decl) InnerError!void {
953953 self.failed_decls.putAssumeCapacityNoClobber(decl, try Compilation.ErrorMsg.create(
954954 self.gpa,
955955 decl.src(),
956 "unable to analyze: {}",
956 "unable to analyze: {s}",
957957 .{@errorName(err)},
958958 ));
959959 decl.analysis = .sema_failure_retryable;
......@@ -1475,7 +1475,7 @@ fn getSrcModule(self: *Module, root_scope: *Scope.ZIRModule) !*zir.Module {
14751475 if (zir_module.error_msg) |src_err_msg| {
14761476 self.failed_files.putAssumeCapacityNoClobber(
14771477 &root_scope.base,
1478 try Compilation.ErrorMsg.create(self.gpa, src_err_msg.byte_offset, "{}", .{src_err_msg.msg}),
1478 try Compilation.ErrorMsg.create(self.gpa, src_err_msg.byte_offset, "{s}", .{src_err_msg.msg}),
14791479 );
14801480 root_scope.status = .unloaded_parse_failure;
14811481 return error.AnalysisFail;
......@@ -1581,7 +1581,7 @@ pub fn analyzeContainer(self: *Module, container_scope: *Scope.Container) !void
15811581 decl.src_index = decl_i;
15821582 if (deleted_decls.remove(decl) == null) {
15831583 decl.analysis = .sema_failure;
1584 const err_msg = try Compilation.ErrorMsg.create(self.gpa, tree.token_locs[name_tok].start, "redefinition of '{}'", .{decl.name});
1584 const err_msg = try Compilation.ErrorMsg.create(self.gpa, tree.token_locs[name_tok].start, "redefinition of '{s}'", .{decl.name});
15851585 errdefer err_msg.destroy(self.gpa);
15861586 try self.failed_decls.putNoClobber(self.gpa, decl, err_msg);
15871587 } else {
......@@ -1623,7 +1623,7 @@ pub fn analyzeContainer(self: *Module, container_scope: *Scope.Container) !void
16231623 decl.src_index = decl_i;
16241624 if (deleted_decls.remove(decl) == null) {
16251625 decl.analysis = .sema_failure;
1626 const err_msg = try Compilation.ErrorMsg.create(self.gpa, name_loc.start, "redefinition of '{}'", .{decl.name});
1626 const err_msg = try Compilation.ErrorMsg.create(self.gpa, name_loc.start, "redefinition of '{s}'", .{decl.name});
16271627 errdefer err_msg.destroy(self.gpa);
16281628 try self.failed_decls.putNoClobber(self.gpa, decl, err_msg);
16291629 } else if (!srcHashEql(decl.contents_hash, contents_hash)) {
......@@ -1991,7 +1991,7 @@ pub fn analyzeExport(
19911991 self.failed_exports.putAssumeCapacityNoClobber(new_export, try Compilation.ErrorMsg.create(
19921992 self.gpa,
19931993 src,
1994 "exported symbol collision: {}",
1994 "exported symbol collision: {s}",
19951995 .{symbol_name},
19961996 ));
19971997 // TODO: add a note
......@@ -2007,7 +2007,7 @@ pub fn analyzeExport(
20072007 self.failed_exports.putAssumeCapacityNoClobber(new_export, try Compilation.ErrorMsg.create(
20082008 self.gpa,
20092009 src,
2010 "unable to export: {}",
2010 "unable to export: {s}",
20112011 .{@errorName(err)},
20122012 ));
20132013 new_export.status = .failed_retryable;
......@@ -2277,7 +2277,7 @@ pub fn createAnonymousDecl(
22772277) !*Decl {
22782278 const name_index = self.getNextAnonNameIndex();
22792279 const scope_decl = scope.decl().?;
2280 const name = try std.fmt.allocPrint(self.gpa, "{}__anon_{}", .{ scope_decl.name, name_index });
2280 const name = try std.fmt.allocPrint(self.gpa, "{s}__anon_{}", .{ scope_decl.name, name_index });
22812281 defer self.gpa.free(name);
22822282 const name_hash = scope.namespace().fullyQualifiedNameHash(name);
22832283 const src_hash: std.zig.SrcHash = undefined;
......@@ -2384,7 +2384,7 @@ pub fn analyzeDeref(self: *Module, scope: *Scope, src: usize, ptr: *Inst, ptr_sr
23842384
23852385pub fn analyzeDeclRefByName(self: *Module, scope: *Scope, src: usize, decl_name: []const u8) InnerError!*Inst {
23862386 const decl = self.lookupDeclName(scope, decl_name) orelse
2387 return self.fail(scope, src, "decl '{}' not found", .{decl_name});
2387 return self.fail(scope, src, "decl '{s}' not found", .{decl_name});
23882388 return self.analyzeDeclRef(scope, src, decl);
23892389}
23902390
src/astgen.zig+4-4
......@@ -1955,7 +1955,7 @@ fn identifier(mod: *Module, scope: *Scope, rl: ResultLoc, ident: *ast.Node.OneTo
19551955 error.Overflow => return mod.failNode(
19561956 scope,
19571957 &ident.base,
1958 "primitive integer type '{}' exceeds maximum bit width of 65535",
1958 "primitive integer type '{s}' exceeds maximum bit width of 65535",
19591959 .{ident_name},
19601960 ),
19611961 error.InvalidCharacter => break :integer,
......@@ -2010,7 +2010,7 @@ fn identifier(mod: *Module, scope: *Scope, rl: ResultLoc, ident: *ast.Node.OneTo
20102010 return rlWrapPtr(mod, scope, rl, try addZIRInst(mod, scope, src, zir.Inst.DeclValInModule, .{ .decl = decl }, .{}));
20112011 }
20122012
2013 return mod.failNode(scope, &ident.base, "use of undeclared identifier '{}'", .{ident_name});
2013 return mod.failNode(scope, &ident.base, "use of undeclared identifier '{s}'", .{ident_name});
20142014}
20152015
20162016fn stringLiteral(mod: *Module, scope: *Scope, str_lit: *ast.Node.OneToken) InnerError!*zir.Inst {
......@@ -2204,7 +2204,7 @@ fn ensureBuiltinParamCount(mod: *Module, scope: *Scope, call: *ast.Node.BuiltinC
22042204 return;
22052205
22062206 const s = if (count == 1) "" else "s";
2207 return mod.failTok(scope, call.builtin_token, "expected {} parameter{}, found {}", .{ count, s, call.params_len });
2207 return mod.failTok(scope, call.builtin_token, "expected {} parameter{s}, found {}", .{ count, s, call.params_len });
22082208}
22092209
22102210fn simpleCast(
......@@ -2383,7 +2383,7 @@ fn builtinCall(mod: *Module, scope: *Scope, rl: ResultLoc, call: *ast.Node.Built
23832383 } else if (mem.eql(u8, builtin_name, "@compileError")) {
23842384 return compileError(mod, scope, call);
23852385 } else {
2386 return mod.failTok(scope, call.builtin_token, "invalid builtin function: '{}'", .{builtin_name});
2386 return mod.failTok(scope, call.builtin_token, "invalid builtin function: '{s}'", .{builtin_name});
23872387 }
23882388}
23892389
src/codegen.zig+19-19
......@@ -228,7 +228,7 @@ pub fn generateSymbol(
228228 .fail = try ErrorMsg.create(
229229 bin_file.allocator,
230230 src,
231 "TODO implement generateSymbol for type '{}'",
231 "TODO implement generateSymbol for type '{s}'",
232232 .{@tagName(t)},
233233 ),
234234 };
......@@ -2029,7 +2029,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
20292029 });
20302030 break :blk 0x84;
20312031 },
2032 else => return self.fail(inst.base.src, "TODO implement condbr {} when condition is {}", .{ self.target.cpu.arch, @tagName(cond) }),
2032 else => return self.fail(inst.base.src, "TODO implement condbr {s} when condition is {s}", .{ self.target.cpu.arch, @tagName(cond) }),
20332033 };
20342034 self.code.appendSliceAssumeCapacity(&[_]u8{ 0x0f, opcode });
20352035 const reloc = Reloc{ .rel32 = self.code.items.len };
......@@ -2376,11 +2376,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
23762376 .arm, .armeb => {
23772377 for (inst.inputs) |input, i| {
23782378 if (input.len < 3 or input[0] != '{' or input[input.len - 1] != '}') {
2379 return self.fail(inst.base.src, "unrecognized asm input constraint: '{}'", .{input});
2379 return self.fail(inst.base.src, "unrecognized asm input constraint: '{s}'", .{input});
23802380 }
23812381 const reg_name = input[1 .. input.len - 1];
23822382 const reg = parseRegName(reg_name) orelse
2383 return self.fail(inst.base.src, "unrecognized register: '{}'", .{reg_name});
2383 return self.fail(inst.base.src, "unrecognized register: '{s}'", .{reg_name});
23842384 const arg = try self.resolveInst(inst.args[i]);
23852385 try self.genSetReg(inst.base.src, reg, arg);
23862386 }
......@@ -2393,11 +2393,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
23932393
23942394 if (inst.output) |output| {
23952395 if (output.len < 4 or output[0] != '=' or output[1] != '{' or output[output.len - 1] != '}') {
2396 return self.fail(inst.base.src, "unrecognized asm output constraint: '{}'", .{output});
2396 return self.fail(inst.base.src, "unrecognized asm output constraint: '{s}'", .{output});
23972397 }
23982398 const reg_name = output[2 .. output.len - 1];
23992399 const reg = parseRegName(reg_name) orelse
2400 return self.fail(inst.base.src, "unrecognized register: '{}'", .{reg_name});
2400 return self.fail(inst.base.src, "unrecognized register: '{s}'", .{reg_name});
24012401 return MCValue{ .register = reg };
24022402 } else {
24032403 return MCValue.none;
......@@ -2406,11 +2406,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
24062406 .aarch64 => {
24072407 for (inst.inputs) |input, i| {
24082408 if (input.len < 3 or input[0] != '{' or input[input.len - 1] != '}') {
2409 return self.fail(inst.base.src, "unrecognized asm input constraint: '{}'", .{input});
2409 return self.fail(inst.base.src, "unrecognized asm input constraint: '{s}'", .{input});
24102410 }
24112411 const reg_name = input[1 .. input.len - 1];
24122412 const reg = parseRegName(reg_name) orelse
2413 return self.fail(inst.base.src, "unrecognized register: '{}'", .{reg_name});
2413 return self.fail(inst.base.src, "unrecognized register: '{s}'", .{reg_name});
24142414 const arg = try self.resolveInst(inst.args[i]);
24152415 try self.genSetReg(inst.base.src, reg, arg);
24162416 }
......@@ -2425,11 +2425,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
24252425
24262426 if (inst.output) |output| {
24272427 if (output.len < 4 or output[0] != '=' or output[1] != '{' or output[output.len - 1] != '}') {
2428 return self.fail(inst.base.src, "unrecognized asm output constraint: '{}'", .{output});
2428 return self.fail(inst.base.src, "unrecognized asm output constraint: '{s}'", .{output});
24292429 }
24302430 const reg_name = output[2 .. output.len - 1];
24312431 const reg = parseRegName(reg_name) orelse
2432 return self.fail(inst.base.src, "unrecognized register: '{}'", .{reg_name});
2432 return self.fail(inst.base.src, "unrecognized register: '{s}'", .{reg_name});
24332433 return MCValue{ .register = reg };
24342434 } else {
24352435 return MCValue.none;
......@@ -2438,11 +2438,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
24382438 .riscv64 => {
24392439 for (inst.inputs) |input, i| {
24402440 if (input.len < 3 or input[0] != '{' or input[input.len - 1] != '}') {
2441 return self.fail(inst.base.src, "unrecognized asm input constraint: '{}'", .{input});
2441 return self.fail(inst.base.src, "unrecognized asm input constraint: '{s}'", .{input});
24422442 }
24432443 const reg_name = input[1 .. input.len - 1];
24442444 const reg = parseRegName(reg_name) orelse
2445 return self.fail(inst.base.src, "unrecognized register: '{}'", .{reg_name});
2445 return self.fail(inst.base.src, "unrecognized register: '{s}'", .{reg_name});
24462446 const arg = try self.resolveInst(inst.args[i]);
24472447 try self.genSetReg(inst.base.src, reg, arg);
24482448 }
......@@ -2455,11 +2455,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
24552455
24562456 if (inst.output) |output| {
24572457 if (output.len < 4 or output[0] != '=' or output[1] != '{' or output[output.len - 1] != '}') {
2458 return self.fail(inst.base.src, "unrecognized asm output constraint: '{}'", .{output});
2458 return self.fail(inst.base.src, "unrecognized asm output constraint: '{s}'", .{output});
24592459 }
24602460 const reg_name = output[2 .. output.len - 1];
24612461 const reg = parseRegName(reg_name) orelse
2462 return self.fail(inst.base.src, "unrecognized register: '{}'", .{reg_name});
2462 return self.fail(inst.base.src, "unrecognized register: '{s}'", .{reg_name});
24632463 return MCValue{ .register = reg };
24642464 } else {
24652465 return MCValue.none;
......@@ -2468,11 +2468,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
24682468 .x86_64, .i386 => {
24692469 for (inst.inputs) |input, i| {
24702470 if (input.len < 3 or input[0] != '{' or input[input.len - 1] != '}') {
2471 return self.fail(inst.base.src, "unrecognized asm input constraint: '{}'", .{input});
2471 return self.fail(inst.base.src, "unrecognized asm input constraint: '{s}'", .{input});
24722472 }
24732473 const reg_name = input[1 .. input.len - 1];
24742474 const reg = parseRegName(reg_name) orelse
2475 return self.fail(inst.base.src, "unrecognized register: '{}'", .{reg_name});
2475 return self.fail(inst.base.src, "unrecognized register: '{s}'", .{reg_name});
24762476 const arg = try self.resolveInst(inst.args[i]);
24772477 try self.genSetReg(inst.base.src, reg, arg);
24782478 }
......@@ -2485,11 +2485,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
24852485
24862486 if (inst.output) |output| {
24872487 if (output.len < 4 or output[0] != '=' or output[1] != '{' or output[output.len - 1] != '}') {
2488 return self.fail(inst.base.src, "unrecognized asm output constraint: '{}'", .{output});
2488 return self.fail(inst.base.src, "unrecognized asm output constraint: '{s}'", .{output});
24892489 }
24902490 const reg_name = output[2 .. output.len - 1];
24912491 const reg = parseRegName(reg_name) orelse
2492 return self.fail(inst.base.src, "unrecognized register: '{}'", .{reg_name});
2492 return self.fail(inst.base.src, "unrecognized register: '{s}'", .{reg_name});
24932493 return MCValue{ .register = reg };
24942494 } else {
24952495 return MCValue.none;
......@@ -3417,7 +3417,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
34173417 next_int_reg += 1;
34183418 }
34193419 },
3420 else => return self.fail(src, "TODO implement function parameters of type {}", .{@tagName(ty.zigTypeTag())}),
3420 else => return self.fail(src, "TODO implement function parameters of type {s}", .{@tagName(ty.zigTypeTag())}),
34213421 }
34223422 }
34233423 result.stack_byte_count = next_stack_offset;
src/codegen/c.zig+8-7
......@@ -235,7 +235,7 @@ fn renderFunctionSignature(
235235 try writer.writeAll(", ");
236236 }
237237 try renderType(ctx, writer, tv.ty.fnParamType(index));
238 try writer.print(" arg{}", .{index});
238 try writer.print(" arg{d}", .{index});
239239 }
240240 }
241241 try writer.writeByte(')');
......@@ -481,8 +481,9 @@ fn genBinOp(ctx: *Context, file: *C, inst: *Inst.BinOp, operator: []const u8) !?
481481 const rhs = try ctx.resolveInst(inst.rhs);
482482 const writer = file.main.writer();
483483 const name = try ctx.name();
484 try renderTypeAndName(ctx, writer, inst.base.ty, name, .Const);
485 try writer.print(" = {s} {s} {s};\n", .{ lhs, operator, rhs });
484 try writer.writeAll(indentation ++ "const ");
485 try renderType(ctx, writer, inst.base.ty);
486 try writer.print(" {s} = {s} " ++ operator ++ " {s};\n", .{ name, lhs, rhs });
486487 return name;
487488}
488489
......@@ -587,7 +588,7 @@ fn genAsm(ctx: *Context, file: *C, as: *Inst.Assembly) !?[]u8 {
587588 const arg = as.args[index];
588589 try writer.writeAll("register ");
589590 try renderType(ctx, writer, arg.ty);
590 try writer.print(" {}_constant __asm__(\"{}\") = ", .{ reg, reg });
591 try writer.print(" {s}_constant __asm__(\"{s}\") = ", .{ reg, reg });
591592 // TODO merge constant handling into inst_map as well
592593 if (arg.castTag(.constant)) |c| {
593594 try renderValue(ctx, writer, arg.ty, c.val);
......@@ -597,13 +598,13 @@ fn genAsm(ctx: *Context, file: *C, as: *Inst.Assembly) !?[]u8 {
597598 if (!gop.found_existing) {
598599 return ctx.fail(ctx.decl.src(), "Internal error in C backend: asm argument not found in inst_map", .{});
599600 }
600 try writer.print("{};\n ", .{gop.entry.value});
601 try writer.print("{s};\n ", .{gop.entry.value});
601602 }
602603 } else {
603604 return ctx.fail(ctx.decl.src(), "TODO non-explicit inline asm regs", .{});
604605 }
605606 }
606 try writer.print("__asm {} (\"{}\"", .{ if (as.is_volatile) @as([]const u8, "volatile") else "", as.asm_source });
607 try writer.print("__asm {s} (\"{s}\"", .{ if (as.is_volatile) @as([]const u8, "volatile") else "", as.asm_source });
607608 if (as.output) |o| {
608609 return ctx.fail(ctx.decl.src(), "TODO inline asm output", .{});
609610 }
......@@ -619,7 +620,7 @@ fn genAsm(ctx: *Context, file: *C, as: *Inst.Assembly) !?[]u8 {
619620 if (index > 0) {
620621 try writer.writeAll(", ");
621622 }
622 try writer.print("\"\"({}_constant)", .{reg});
623 try writer.print("\"\"({s}_constant)", .{reg});
623624 } else {
624625 // This is blocked by the earlier test
625626 unreachable;
src/codegen/llvm.zig created+125
......@@ -0,0 +1,125 @@
1const std = @import("std");
2const Allocator = std.mem.Allocator;
3
4pub fn targetTriple(allocator: *Allocator, target: std.Target) ![]u8 {
5 const llvm_arch = switch (target.cpu.arch) {
6 .arm => "arm",
7 .armeb => "armeb",
8 .aarch64 => "aarch64",
9 .aarch64_be => "aarch64_be",
10 .aarch64_32 => "aarch64_32",
11 .arc => "arc",
12 .avr => "avr",
13 .bpfel => "bpfel",
14 .bpfeb => "bpfeb",
15 .hexagon => "hexagon",
16 .mips => "mips",
17 .mipsel => "mipsel",
18 .mips64 => "mips64",
19 .mips64el => "mips64el",
20 .msp430 => "msp430",
21 .powerpc => "powerpc",
22 .powerpc64 => "powerpc64",
23 .powerpc64le => "powerpc64le",
24 .r600 => "r600",
25 .amdgcn => "amdgcn",
26 .riscv32 => "riscv32",
27 .riscv64 => "riscv64",
28 .sparc => "sparc",
29 .sparcv9 => "sparcv9",
30 .sparcel => "sparcel",
31 .s390x => "s390x",
32 .tce => "tce",
33 .tcele => "tcele",
34 .thumb => "thumb",
35 .thumbeb => "thumbeb",
36 .i386 => "i386",
37 .x86_64 => "x86_64",
38 .xcore => "xcore",
39 .nvptx => "nvptx",
40 .nvptx64 => "nvptx64",
41 .le32 => "le32",
42 .le64 => "le64",
43 .amdil => "amdil",
44 .amdil64 => "amdil64",
45 .hsail => "hsail",
46 .hsail64 => "hsail64",
47 .spir => "spir",
48 .spir64 => "spir64",
49 .kalimba => "kalimba",
50 .shave => "shave",
51 .lanai => "lanai",
52 .wasm32 => "wasm32",
53 .wasm64 => "wasm64",
54 .renderscript32 => "renderscript32",
55 .renderscript64 => "renderscript64",
56 .ve => "ve",
57 .spu_2 => return error.LLVMBackendDoesNotSupportSPUMarkII,
58 };
59 // TODO Add a sub-arch for some architectures depending on CPU features.
60
61 const llvm_os = switch (target.os.tag) {
62 .freestanding => "unknown",
63 .ananas => "ananas",
64 .cloudabi => "cloudabi",
65 .dragonfly => "dragonfly",
66 .freebsd => "freebsd",
67 .fuchsia => "fuchsia",
68 .ios => "ios",
69 .kfreebsd => "kfreebsd",
70 .linux => "linux",
71 .lv2 => "lv2",
72 .macos => "macosx",
73 .netbsd => "netbsd",
74 .openbsd => "openbsd",
75 .solaris => "solaris",
76 .windows => "windows",
77 .haiku => "haiku",
78 .minix => "minix",
79 .rtems => "rtems",
80 .nacl => "nacl",
81 .cnk => "cnk",
82 .aix => "aix",
83 .cuda => "cuda",
84 .nvcl => "nvcl",
85 .amdhsa => "amdhsa",
86 .ps4 => "ps4",
87 .elfiamcu => "elfiamcu",
88 .tvos => "tvos",
89 .watchos => "watchos",
90 .mesa3d => "mesa3d",
91 .contiki => "contiki",
92 .amdpal => "amdpal",
93 .hermit => "hermit",
94 .hurd => "hurd",
95 .wasi => "wasi",
96 .emscripten => "emscripten",
97 .uefi => "windows",
98 .other => "unknown",
99 };
100
101 const llvm_abi = switch (target.abi) {
102 .none => "unknown",
103 .gnu => "gnu",
104 .gnuabin32 => "gnuabin32",
105 .gnuabi64 => "gnuabi64",
106 .gnueabi => "gnueabi",
107 .gnueabihf => "gnueabihf",
108 .gnux32 => "gnux32",
109 .code16 => "code16",
110 .eabi => "eabi",
111 .eabihf => "eabihf",
112 .android => "android",
113 .musl => "musl",
114 .musleabi => "musleabi",
115 .musleabihf => "musleabihf",
116 .msvc => "msvc",
117 .itanium => "itanium",
118 .cygnus => "cygnus",
119 .coreclr => "coreclr",
120 .simulator => "simulator",
121 .macabi => "macabi",
122 };
123
124 return std.fmt.allocPrint(allocator, "{s}-unknown-{s}-{s}", .{ llvm_arch, llvm_os, llvm_abi });
125}
src/glibc.zig+13-13
......@@ -72,7 +72,7 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError!
7272 errdefer version_table.deinit(gpa);
7373
7474 var glibc_dir = zig_lib_dir.openDir("libc" ++ path.sep_str ++ "glibc", .{}) catch |err| {
75 std.log.err("unable to open glibc dir: {}", .{@errorName(err)});
75 std.log.err("unable to open glibc dir: {s}", .{@errorName(err)});
7676 return error.ZigInstallationCorrupt;
7777 };
7878 defer glibc_dir.close();
......@@ -81,7 +81,7 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError!
8181 const vers_txt_contents = glibc_dir.readFileAlloc(gpa, "vers.txt", max_txt_size) catch |err| switch (err) {
8282 error.OutOfMemory => return error.OutOfMemory,
8383 else => {
84 std.log.err("unable to read vers.txt: {}", .{@errorName(err)});
84 std.log.err("unable to read vers.txt: {s}", .{@errorName(err)});
8585 return error.ZigInstallationCorrupt;
8686 },
8787 };
......@@ -91,7 +91,7 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError!
9191 const fns_txt_contents = glibc_dir.readFileAlloc(arena, "fns.txt", max_txt_size) catch |err| switch (err) {
9292 error.OutOfMemory => return error.OutOfMemory,
9393 else => {
94 std.log.err("unable to read fns.txt: {}", .{@errorName(err)});
94 std.log.err("unable to read fns.txt: {s}", .{@errorName(err)});
9595 return error.ZigInstallationCorrupt;
9696 },
9797 };
......@@ -99,7 +99,7 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError!
9999 const abi_txt_contents = glibc_dir.readFileAlloc(gpa, "abi.txt", max_txt_size) catch |err| switch (err) {
100100 error.OutOfMemory => return error.OutOfMemory,
101101 else => {
102 std.log.err("unable to read abi.txt: {}", .{@errorName(err)});
102 std.log.err("unable to read abi.txt: {s}", .{@errorName(err)});
103103 return error.ZigInstallationCorrupt;
104104 },
105105 };
......@@ -116,7 +116,7 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError!
116116 }
117117 const adjusted_line = line[prefix.len..];
118118 const ver = std.builtin.Version.parse(adjusted_line) catch |err| {
119 std.log.err("vers.txt:{}: unable to parse glibc version '{}': {}", .{ line_i, line, @errorName(err) });
119 std.log.err("vers.txt:{}: unable to parse glibc version '{s}': {s}", .{ line_i, line, @errorName(err) });
120120 return error.ZigInstallationCorrupt;
121121 };
122122 try all_versions.append(arena, ver);
......@@ -136,7 +136,7 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError!
136136 return error.ZigInstallationCorrupt;
137137 };
138138 const lib = findLib(lib_name) orelse {
139 std.log.err("fns.txt:{}: unknown library name: {}", .{ line_i, lib_name });
139 std.log.err("fns.txt:{}: unknown library name: {s}", .{ line_i, lib_name });
140140 return error.ZigInstallationCorrupt;
141141 };
142142 try all_functions.append(arena, .{
......@@ -170,15 +170,15 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError!
170170 return error.ZigInstallationCorrupt;
171171 };
172172 const arch_tag = std.meta.stringToEnum(std.Target.Cpu.Arch, arch_name) orelse {
173 std.log.err("abi.txt:{}: unrecognized arch: '{}'", .{ line_i, arch_name });
173 std.log.err("abi.txt:{}: unrecognized arch: '{s}'", .{ line_i, arch_name });
174174 return error.ZigInstallationCorrupt;
175175 };
176176 if (!mem.eql(u8, os_name, "linux")) {
177 std.log.err("abi.txt:{}: expected OS 'linux', found '{}'", .{ line_i, os_name });
177 std.log.err("abi.txt:{}: expected OS 'linux', found '{s}'", .{ line_i, os_name });
178178 return error.ZigInstallationCorrupt;
179179 }
180180 const abi_tag = std.meta.stringToEnum(std.Target.Abi, abi_name) orelse {
181 std.log.err("abi.txt:{}: unrecognized ABI: '{}'", .{ line_i, abi_name });
181 std.log.err("abi.txt:{}: unrecognized ABI: '{s}'", .{ line_i, abi_name });
182182 return error.ZigInstallationCorrupt;
183183 };
184184
......@@ -211,7 +211,7 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError!
211211 }
212212 const version_index = std.fmt.parseInt(u8, version_index_string, 10) catch |err| {
213213 // If this happens with legit data, increase the size of the integer type in the struct.
214 std.log.err("abi.txt:{}: unable to parse version: {}", .{ line_i, @errorName(err) });
214 std.log.err("abi.txt:{}: unable to parse version: {s}", .{ line_i, @errorName(err) });
215215 return error.ZigInstallationCorrupt;
216216 };
217217
......@@ -531,7 +531,7 @@ fn add_include_dirs(comp: *Compilation, arena: *Allocator, args: *std.ArrayList(
531531 try args.append(try path.join(arena, &[_][]const u8{ comp.zig_lib_directory.path.?, lib_libc ++ "glibc" }));
532532
533533 try args.append("-I");
534 try args.append(try std.fmt.allocPrint(arena, "{}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{}-{}-{}", .{
534 try args.append(try std.fmt.allocPrint(arena, "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{s}-{s}-{s}", .{
535535 comp.zig_lib_directory.path.?, @tagName(arch), @tagName(target.os.tag), @tagName(target.abi),
536536 }));
537537
......@@ -539,7 +539,7 @@ fn add_include_dirs(comp: *Compilation, arena: *Allocator, args: *std.ArrayList(
539539 try args.append(try lib_path(comp, arena, lib_libc ++ "include" ++ s ++ "generic-glibc"));
540540
541541 try args.append("-I");
542 try args.append(try std.fmt.allocPrint(arena, "{}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{}-linux-any", .{
542 try args.append(try std.fmt.allocPrint(arena, "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{s}-linux-any", .{
543543 comp.zig_lib_directory.path.?, @tagName(arch),
544544 }));
545545
......@@ -881,7 +881,7 @@ pub fn buildSharedObjects(comp: *Compilation) !void {
881881 if (o_directory.handle.createFile(ok_basename, .{})) |file| {
882882 file.close();
883883 } else |err| {
884 std.log.warn("glibc shared objects: failed to mark completion: {}", .{@errorName(err)});
884 std.log.warn("glibc shared objects: failed to mark completion: {s}", .{@errorName(err)});
885885 }
886886 }
887887
src/libc_installation.zig+16-16
......@@ -83,7 +83,7 @@ pub const LibCInstallation = struct {
8383 }
8484 inline for (fields) |field, i| {
8585 if (!found_keys[i].found) {
86 log.err("missing field: {}\n", .{field.name});
86 log.err("missing field: {s}\n", .{field.name});
8787 return error.ParseError;
8888 }
8989 }
......@@ -96,18 +96,18 @@ pub const LibCInstallation = struct {
9696 return error.ParseError;
9797 }
9898 if (self.crt_dir == null and !is_darwin) {
99 log.err("crt_dir may not be empty for {}\n", .{@tagName(Target.current.os.tag)});
99 log.err("crt_dir may not be empty for {s}\n", .{@tagName(Target.current.os.tag)});
100100 return error.ParseError;
101101 }
102102 if (self.msvc_lib_dir == null and is_windows and !is_gnu) {
103 log.err("msvc_lib_dir may not be empty for {}-{}\n", .{
103 log.err("msvc_lib_dir may not be empty for {s}-{s}\n", .{
104104 @tagName(Target.current.os.tag),
105105 @tagName(Target.current.abi),
106106 });
107107 return error.ParseError;
108108 }
109109 if (self.kernel32_lib_dir == null and is_windows and !is_gnu) {
110 log.err("kernel32_lib_dir may not be empty for {}-{}\n", .{
110 log.err("kernel32_lib_dir may not be empty for {s}-{s}\n", .{
111111 @tagName(Target.current.os.tag),
112112 @tagName(Target.current.abi),
113113 });
......@@ -128,25 +128,25 @@ pub const LibCInstallation = struct {
128128 try out.print(
129129 \\# The directory that contains `stdlib.h`.
130130 \\# On POSIX-like systems, include directories be found with: `cc -E -Wp,-v -xc /dev/null`
131 \\include_dir={}
131 \\include_dir={s}
132132 \\
133133 \\# The system-specific include directory. May be the same as `include_dir`.
134134 \\# On Windows it's the directory that includes `vcruntime.h`.
135135 \\# On POSIX it's the directory that includes `sys/errno.h`.
136 \\sys_include_dir={}
136 \\sys_include_dir={s}
137137 \\
138138 \\# The directory that contains `crt1.o` or `crt2.o`.
139139 \\# On POSIX, can be found with `cc -print-file-name=crt1.o`.
140140 \\# Not needed when targeting MacOS.
141 \\crt_dir={}
141 \\crt_dir={s}
142142 \\
143143 \\# The directory that contains `vcruntime.lib`.
144144 \\# Only needed when targeting MSVC on Windows.
145 \\msvc_lib_dir={}
145 \\msvc_lib_dir={s}
146146 \\
147147 \\# The directory that contains `kernel32.lib`.
148148 \\# Only needed when targeting MSVC on Windows.
149 \\kernel32_lib_dir={}
149 \\kernel32_lib_dir={s}
150150 \\
151151 , .{
152152 include_dir,
......@@ -338,7 +338,7 @@ pub const LibCInstallation = struct {
338338
339339 for (searches) |search| {
340340 result_buf.shrink(0);
341 try result_buf.outStream().print("{}\\Include\\{}\\ucrt", .{ search.path, search.version });
341 try result_buf.outStream().print("{s}\\Include\\{s}\\ucrt", .{ search.path, search.version });
342342
343343 var dir = fs.cwd().openDir(result_buf.items, .{}) catch |err| switch (err) {
344344 error.FileNotFound,
......@@ -384,7 +384,7 @@ pub const LibCInstallation = struct {
384384
385385 for (searches) |search| {
386386 result_buf.shrink(0);
387 try result_buf.outStream().print("{}\\Lib\\{}\\ucrt\\{}", .{ search.path, search.version, arch_sub_dir });
387 try result_buf.outStream().print("{s}\\Lib\\{s}\\ucrt\\{s}", .{ search.path, search.version, arch_sub_dir });
388388
389389 var dir = fs.cwd().openDir(result_buf.items, .{}) catch |err| switch (err) {
390390 error.FileNotFound,
......@@ -439,7 +439,7 @@ pub const LibCInstallation = struct {
439439 for (searches) |search| {
440440 result_buf.shrink(0);
441441 const stream = result_buf.outStream();
442 try stream.print("{}\\Lib\\{}\\um\\{}", .{ search.path, search.version, arch_sub_dir });
442 try stream.print("{s}\\Lib\\{s}\\um\\{s}", .{ search.path, search.version, arch_sub_dir });
443443
444444 var dir = fs.cwd().openDir(result_buf.items, .{}) catch |err| switch (err) {
445445 error.FileNotFound,
......@@ -520,7 +520,7 @@ fn ccPrintFileName(args: CCPrintFileNameOptions) ![:0]u8 {
520520 const allocator = args.allocator;
521521
522522 const cc_exe = std.os.getenvZ("CC") orelse default_cc_exe;
523 const arg1 = try std.fmt.allocPrint(allocator, "-print-file-name={}", .{args.search_basename});
523 const arg1 = try std.fmt.allocPrint(allocator, "-print-file-name={s}", .{args.search_basename});
524524 defer allocator.free(arg1);
525525 const argv = [_][]const u8{ cc_exe, arg1 };
526526
......@@ -584,17 +584,17 @@ fn printVerboseInvocation(
584584 if (!verbose) return;
585585
586586 if (search_basename) |s| {
587 std.debug.warn("Zig attempted to find the file '{}' by executing this command:\n", .{s});
587 std.debug.warn("Zig attempted to find the file '{s}' by executing this command:\n", .{s});
588588 } else {
589589 std.debug.warn("Zig attempted to find the path to native system libc headers by executing this command:\n", .{});
590590 }
591591 for (argv) |arg, i| {
592592 if (i != 0) std.debug.warn(" ", .{});
593 std.debug.warn("{}", .{arg});
593 std.debug.warn("{s}", .{arg});
594594 }
595595 std.debug.warn("\n", .{});
596596 if (stderr) |s| {
597 std.debug.warn("Output:\n==========\n{}\n==========\n", .{s});
597 std.debug.warn("Output:\n==========\n{s}\n==========\n", .{s});
598598 }
599599}
600600
src/link.zig+4-4
......@@ -560,9 +560,9 @@ pub const File = struct {
560560 const full_out_path_z = try arena.dupeZ(u8, full_out_path);
561561
562562 if (base.options.verbose_link) {
563 std.debug.print("ar rcs {}", .{full_out_path_z});
563 std.debug.print("ar rcs {s}", .{full_out_path_z});
564564 for (object_files.items) |arg| {
565 std.debug.print(" {}", .{arg});
565 std.debug.print(" {s}", .{arg});
566566 }
567567 std.debug.print("\n", .{});
568568 }
......@@ -574,11 +574,11 @@ pub const File = struct {
574574
575575 if (!base.options.disable_lld_caching) {
576576 Cache.writeSmallFile(directory.handle, id_symlink_basename, &digest) catch |err| {
577 log.warn("failed to save archive hash digest file: {}", .{@errorName(err)});
577 log.warn("failed to save archive hash digest file: {s}", .{@errorName(err)});
578578 };
579579
580580 man.writeManifest() catch |err| {
581 log.warn("failed to write cache manifest when archiving: {}", .{@errorName(err)});
581 log.warn("failed to write cache manifest when archiving: {s}", .{@errorName(err)});
582582 };
583583
584584 base.lock = man.toOwnedLock();
src/link/C.zig+4-1
......@@ -111,8 +111,11 @@ pub fn flushModule(self: *C, comp: *Compilation) !void {
111111 if (self.header.buf.items.len > 0) {
112112 try writer.writeByte('\n');
113113 }
114 if (self.header.items.len > 0) {
115 try writer.print("{s}\n", .{self.header.items});
116 }
114117 if (self.constants.items.len > 0) {
115 try writer.print("{}\n", .{self.constants.items});
118 try writer.print("{s}\n", .{self.constants.items});
116119 }
117120 if (self.main.items.len > 1) {
118121 const last_two = self.main.items[self.main.items.len - 2 ..];
src/link/Coff.zig+5-5
......@@ -686,7 +686,7 @@ pub fn updateDecl(self: *Coff, module: *Module, decl: *Module.Decl) !void {
686686 if (need_realloc) {
687687 const curr_vaddr = self.getDeclVAddr(decl);
688688 const vaddr = try self.growTextBlock(&decl.link.coff, code.len, required_alignment);
689 log.debug("growing {} from 0x{x} to 0x{x}\n", .{ decl.name, curr_vaddr, vaddr });
689 log.debug("growing {s} from 0x{x} to 0x{x}\n", .{ decl.name, curr_vaddr, vaddr });
690690 if (vaddr != curr_vaddr) {
691691 log.debug(" (writing new offset table entry)\n", .{});
692692 self.offset_table.items[decl.link.coff.offset_table_index] = vaddr;
......@@ -697,7 +697,7 @@ pub fn updateDecl(self: *Coff, module: *Module, decl: *Module.Decl) !void {
697697 }
698698 } else {
699699 const vaddr = try self.allocateTextBlock(&decl.link.coff, code.len, required_alignment);
700 log.debug("allocated text block for {} at 0x{x} (size: {Bi})\n", .{ mem.spanZ(decl.name), vaddr, code.len });
700 log.debug("allocated text block for {s} at 0x{x} (size: {Bi})\n", .{ mem.spanZ(decl.name), vaddr, code.len });
701701 errdefer self.freeTextBlock(&decl.link.coff);
702702 self.offset_table.items[decl.link.coff.offset_table_index] = vaddr;
703703 try self.writeOffsetTableEntry(decl.link.coff.offset_table_index);
......@@ -880,7 +880,7 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void {
880880 id_symlink_basename,
881881 &prev_digest_buf,
882882 ) catch |err| blk: {
883 log.debug("COFF LLD new_digest={} error: {}", .{ digest, @errorName(err) });
883 log.debug("COFF LLD new_digest={} error: {s}", .{ digest, @errorName(err) });
884884 // Handle this as a cache miss.
885885 break :blk prev_digest_buf[0..0];
886886 };
......@@ -1236,11 +1236,11 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void {
12361236 // Update the file with the digest. If it fails we can continue; it only
12371237 // means that the next invocation will have an unnecessary cache miss.
12381238 Cache.writeSmallFile(directory.handle, id_symlink_basename, &digest) catch |err| {
1239 log.warn("failed to save linking hash digest file: {}", .{@errorName(err)});
1239 log.warn("failed to save linking hash digest file: {s}", .{@errorName(err)});
12401240 };
12411241 // Again failure here only means an unnecessary cache miss.
12421242 man.writeManifest() catch |err| {
1243 log.warn("failed to write cache manifest when linking: {}", .{@errorName(err)});
1243 log.warn("failed to write cache manifest when linking: {s}", .{@errorName(err)});
12441244 };
12451245 // We hang on to this lock so that the output file path can be used without
12461246 // other processes clobbering it.
src/link/Elf.zig+9-9
......@@ -1362,7 +1362,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
13621362 id_symlink_basename,
13631363 &prev_digest_buf,
13641364 ) catch |err| blk: {
1365 log.debug("ELF LLD new_digest={} error: {}", .{ digest, @errorName(err) });
1365 log.debug("ELF LLD new_digest={} error: {s}", .{ digest, @errorName(err) });
13661366 // Handle this as a cache miss.
13671367 break :blk prev_digest_buf[0..0];
13681368 };
......@@ -1396,7 +1396,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
13961396
13971397 if (self.base.options.output_mode == .Exe) {
13981398 try argv.append("-z");
1399 try argv.append(try std.fmt.allocPrint(arena, "stack-size={}", .{stack_size}));
1399 try argv.append(try std.fmt.allocPrint(arena, "stack-size={d}", .{stack_size}));
14001400 }
14011401
14021402 if (self.base.options.image_base_override) |image_base| {
......@@ -1438,7 +1438,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
14381438 if (getLDMOption(target)) |ldm| {
14391439 // Any target ELF will use the freebsd osabi if suffixed with "_fbsd".
14401440 const arg = if (target.os.tag == .freebsd)
1441 try std.fmt.allocPrint(arena, "{}_fbsd", .{ldm})
1441 try std.fmt.allocPrint(arena, "{s}_fbsd", .{ldm})
14421442 else
14431443 ldm;
14441444 try argv.append("-m");
......@@ -1599,7 +1599,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
15991599 // (the check for that needs to be earlier), but they could be full paths to .so files, in which
16001600 // case we want to avoid prepending "-l".
16011601 const ext = Compilation.classifyFileExt(link_lib);
1602 const arg = if (ext == .shared_library) link_lib else try std.fmt.allocPrint(arena, "-l{}", .{link_lib});
1602 const arg = if (ext == .shared_library) link_lib else try std.fmt.allocPrint(arena, "-l{s}", .{link_lib});
16031603 argv.appendAssumeCapacity(arg);
16041604 }
16051605
......@@ -1733,11 +1733,11 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
17331733 // Update the file with the digest. If it fails we can continue; it only
17341734 // means that the next invocation will have an unnecessary cache miss.
17351735 Cache.writeSmallFile(directory.handle, id_symlink_basename, &digest) catch |err| {
1736 log.warn("failed to save linking hash digest file: {}", .{@errorName(err)});
1736 log.warn("failed to save linking hash digest file: {s}", .{@errorName(err)});
17371737 };
17381738 // Again failure here only means an unnecessary cache miss.
17391739 man.writeManifest() catch |err| {
1740 log.warn("failed to write cache manifest when linking: {}", .{@errorName(err)});
1740 log.warn("failed to write cache manifest when linking: {s}", .{@errorName(err)});
17411741 };
17421742 // We hang on to this lock so that the output file path can be used without
17431743 // other processes clobbering it.
......@@ -2082,10 +2082,10 @@ pub fn allocateDeclIndexes(self: *Elf, decl: *Module.Decl) !void {
20822082 try self.offset_table.ensureCapacity(self.base.allocator, self.offset_table.items.len + 1);
20832083
20842084 if (self.local_symbol_free_list.popOrNull()) |i| {
2085 log.debug("reusing symbol index {} for {}\n", .{ i, decl.name });
2085 log.debug("reusing symbol index {} for {s}\n", .{ i, decl.name });
20862086 decl.link.elf.local_sym_index = i;
20872087 } else {
2088 log.debug("allocating symbol index {} for {}\n", .{ self.local_symbols.items.len, decl.name });
2088 log.debug("allocating symbol index {} for {s}\n", .{ self.local_symbols.items.len, decl.name });
20892089 decl.link.elf.local_sym_index = @intCast(u32, self.local_symbols.items.len);
20902090 _ = self.local_symbols.addOneAssumeCapacity();
20912091 }
......@@ -2182,7 +2182,7 @@ pub fn updateDecl(self: *Elf, module: *Module, decl: *Module.Decl) !void {
21822182 if (zir_dumps.len != 0) {
21832183 for (zir_dumps) |fn_name| {
21842184 if (mem.eql(u8, mem.spanZ(decl.name), fn_name)) {
2185 std.debug.print("\n{}\n", .{decl.name});
2185 std.debug.print("\n{s}\n", .{decl.name});
21862186 typed_value.val.castTag(.function).?.data.dump(module.*);
21872187 }
21882188 }
src/link/MachO.zig+11-11
......@@ -520,7 +520,7 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void {
520520 id_symlink_basename,
521521 &prev_digest_buf,
522522 ) catch |err| blk: {
523 log.debug("MachO LLD new_digest={} error: {}", .{ digest, @errorName(err) });
523 log.debug("MachO LLD new_digest={} error: {s}", .{ digest, @errorName(err) });
524524 // Handle this as a cache miss.
525525 break :blk prev_digest_buf[0..0];
526526 };
......@@ -706,7 +706,7 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void {
706706 // (the check for that needs to be earlier), but they could be full paths to .dylib files, in which
707707 // case we want to avoid prepending "-l".
708708 const ext = Compilation.classifyFileExt(link_lib);
709 const arg = if (ext == .shared_library) link_lib else try std.fmt.allocPrint(arena, "-l{}", .{link_lib});
709 const arg = if (ext == .shared_library) link_lib else try std.fmt.allocPrint(arena, "-l{s}", .{link_lib});
710710 argv.appendAssumeCapacity(arg);
711711 }
712712
......@@ -759,15 +759,15 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void {
759759 self.base.allocator.free(result.stderr);
760760 }
761761 if (result.stdout.len != 0) {
762 log.warn("unexpected LD stdout: {}", .{result.stdout});
762 log.warn("unexpected LD stdout: {s}", .{result.stdout});
763763 }
764764 if (result.stderr.len != 0) {
765 log.warn("unexpected LD stderr: {}", .{result.stderr});
765 log.warn("unexpected LD stderr: {s}", .{result.stderr});
766766 }
767767 if (result.term != .Exited or result.term.Exited != 0) {
768768 // TODO parse this output and surface with the Compilation API rather than
769769 // directly outputting to stderr here.
770 log.err("{}", .{result.stderr});
770 log.err("{s}", .{result.stderr});
771771 return error.LDReportedFailure;
772772 }
773773 } else {
......@@ -980,11 +980,11 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void {
980980 // Update the file with the digest. If it fails we can continue; it only
981981 // means that the next invocation will have an unnecessary cache miss.
982982 Cache.writeSmallFile(directory.handle, id_symlink_basename, &digest) catch |err| {
983 log.warn("failed to save linking hash digest file: {}", .{@errorName(err)});
983 log.warn("failed to save linking hash digest file: {s}", .{@errorName(err)});
984984 };
985985 // Again failure here only means an unnecessary cache miss.
986986 man.writeManifest() catch |err| {
987 log.warn("failed to write cache manifest when linking: {}", .{@errorName(err)});
987 log.warn("failed to write cache manifest when linking: {s}", .{@errorName(err)});
988988 };
989989 // We hang on to this lock so that the output file path can be used without
990990 // other processes clobbering it.
......@@ -1088,10 +1088,10 @@ pub fn allocateDeclIndexes(self: *MachO, decl: *Module.Decl) !void {
10881088 try self.offset_table.ensureCapacity(self.base.allocator, self.offset_table.items.len + 1);
10891089
10901090 if (self.local_symbol_free_list.popOrNull()) |i| {
1091 log.debug("reusing symbol index {} for {}", .{ i, decl.name });
1091 log.debug("reusing symbol index {d} for {s}", .{ i, decl.name });
10921092 decl.link.macho.local_sym_index = i;
10931093 } else {
1094 log.debug("allocating symbol index {} for {}", .{ self.local_symbols.items.len, decl.name });
1094 log.debug("allocating symbol index {d} for {s}", .{ self.local_symbols.items.len, decl.name });
10951095 decl.link.macho.local_sym_index = @intCast(u32, self.local_symbols.items.len);
10961096 _ = self.local_symbols.addOneAssumeCapacity();
10971097 }
......@@ -1165,7 +1165,7 @@ pub fn updateDecl(self: *MachO, module: *Module, decl: *Module.Decl) !void {
11651165 const need_realloc = code.len > capacity or !mem.isAlignedGeneric(u64, symbol.n_value, required_alignment);
11661166 if (need_realloc) {
11671167 const vaddr = try self.growTextBlock(&decl.link.macho, code.len, required_alignment);
1168 log.debug("growing {} from 0x{x} to 0x{x}", .{ decl.name, symbol.n_value, vaddr });
1168 log.debug("growing {s} from 0x{x} to 0x{x}", .{ decl.name, symbol.n_value, vaddr });
11691169 if (vaddr != symbol.n_value) {
11701170 symbol.n_value = vaddr;
11711171 log.debug(" (writing new offset table entry)", .{});
......@@ -1188,7 +1188,7 @@ pub fn updateDecl(self: *MachO, module: *Module, decl: *Module.Decl) !void {
11881188 const decl_name = mem.spanZ(decl.name);
11891189 const name_str_index = try self.makeString(decl_name);
11901190 const addr = try self.allocateTextBlock(&decl.link.macho, code.len, required_alignment);
1191 log.debug("allocated text block for {} at 0x{x}", .{ decl_name, addr });
1191 log.debug("allocated text block for {s} at 0x{x}", .{ decl_name, addr });
11921192 errdefer self.freeTextBlock(&decl.link.macho);
11931193
11941194 symbol.* = .{
src/link/Wasm.zig+3-3
......@@ -321,7 +321,7 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void {
321321 id_symlink_basename,
322322 &prev_digest_buf,
323323 ) catch |err| blk: {
324 log.debug("WASM LLD new_digest={} error: {}", .{ digest, @errorName(err) });
324 log.debug("WASM LLD new_digest={} error: {s}", .{ digest, @errorName(err) });
325325 // Handle this as a cache miss.
326326 break :blk prev_digest_buf[0..0];
327327 };
......@@ -463,11 +463,11 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void {
463463 // Update the file with the digest. If it fails we can continue; it only
464464 // means that the next invocation will have an unnecessary cache miss.
465465 Cache.writeSmallFile(directory.handle, id_symlink_basename, &digest) catch |err| {
466 log.warn("failed to save linking hash digest symlink: {}", .{@errorName(err)});
466 log.warn("failed to save linking hash digest symlink: {s}", .{@errorName(err)});
467467 };
468468 // Again failure here only means an unnecessary cache miss.
469469 man.writeManifest() catch |err| {
470 log.warn("failed to write cache manifest when linking: {}", .{@errorName(err)});
470 log.warn("failed to write cache manifest when linking: {s}", .{@errorName(err)});
471471 };
472472 // We hang on to this lock so that the output file path can be used without
473473 // other processes clobbering it.
src/main.zig+118-118
......@@ -118,7 +118,7 @@ pub fn main() anyerror!void {
118118
119119pub fn mainArgs(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !void {
120120 if (args.len <= 1) {
121 std.log.info("{}", .{usage});
121 std.log.info("{s}", .{usage});
122122 fatal("expected command argument", .{});
123123 }
124124
......@@ -204,8 +204,8 @@ pub fn mainArgs(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v
204204 } else if (mem.eql(u8, cmd, "help") or mem.eql(u8, cmd, "-h") or mem.eql(u8, cmd, "--help")) {
205205 try io.getStdOut().writeAll(usage);
206206 } else {
207 std.log.info("{}", .{usage});
208 fatal("unknown command: {}", .{args[1]});
207 std.log.info("{s}", .{usage});
208 fatal("unknown command: {s}", .{args[1]});
209209 }
210210}
211211
......@@ -615,7 +615,7 @@ fn buildOutputType(
615615 fatal("unexpected end-of-parameter mark: --", .{});
616616 }
617617 } else if (mem.eql(u8, arg, "--pkg-begin")) {
618 if (i + 2 >= args.len) fatal("Expected 2 arguments after {}", .{arg});
618 if (i + 2 >= args.len) fatal("Expected 2 arguments after {s}", .{arg});
619619 i += 1;
620620 const pkg_name = args[i];
621621 i += 1;
......@@ -635,7 +635,7 @@ fn buildOutputType(
635635 cur_pkg = cur_pkg.parent orelse
636636 fatal("encountered --pkg-end with no matching --pkg-begin", .{});
637637 } else if (mem.eql(u8, arg, "--main-pkg-path")) {
638 if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg});
638 if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});
639639 i += 1;
640640 main_pkg_path = args[i];
641641 } else if (mem.eql(u8, arg, "-cflags")) {
......@@ -653,10 +653,10 @@ fn buildOutputType(
653653 i += 1;
654654 const next_arg = args[i];
655655 color = std.meta.stringToEnum(Color, next_arg) orelse {
656 fatal("expected [auto|on|off] after --color, found '{}'", .{next_arg});
656 fatal("expected [auto|on|off] after --color, found '{s}'", .{next_arg});
657657 };
658658 } else if (mem.eql(u8, arg, "--subsystem")) {
659 if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg});
659 if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});
660660 i += 1;
661661 if (mem.eql(u8, args[i], "console")) {
662662 subsystem = .Console;
......@@ -689,51 +689,51 @@ fn buildOutputType(
689689 });
690690 }
691691 } else if (mem.eql(u8, arg, "-O")) {
692 if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg});
692 if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});
693693 i += 1;
694694 optimize_mode_string = args[i];
695695 } else if (mem.eql(u8, arg, "--stack")) {
696 if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg});
696 if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});
697697 i += 1;
698698 stack_size_override = std.fmt.parseUnsigned(u64, args[i], 0) catch |err| {
699699 fatal("unable to parse '{}': {}", .{ arg, @errorName(err) });
700700 };
701701 } else if (mem.eql(u8, arg, "--image-base")) {
702 if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg});
702 if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});
703703 i += 1;
704704 image_base_override = std.fmt.parseUnsigned(u64, args[i], 0) catch |err| {
705705 fatal("unable to parse '{}': {}", .{ arg, @errorName(err) });
706706 };
707707 } else if (mem.eql(u8, arg, "--name")) {
708 if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg});
708 if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});
709709 i += 1;
710710 provided_name = args[i];
711711 } else if (mem.eql(u8, arg, "-rpath")) {
712 if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg});
712 if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});
713713 i += 1;
714714 try rpath_list.append(args[i]);
715715 } else if (mem.eql(u8, arg, "--library-directory") or mem.eql(u8, arg, "-L")) {
716 if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg});
716 if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});
717717 i += 1;
718718 try lib_dirs.append(args[i]);
719719 } else if (mem.eql(u8, arg, "-F")) {
720 if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg});
720 if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});
721721 i += 1;
722722 try framework_dirs.append(args[i]);
723723 } else if (mem.eql(u8, arg, "-framework")) {
724 if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg});
724 if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});
725725 i += 1;
726726 try frameworks.append(args[i]);
727727 } else if (mem.eql(u8, arg, "-T") or mem.eql(u8, arg, "--script")) {
728 if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg});
728 if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});
729729 i += 1;
730730 linker_script = args[i];
731731 } else if (mem.eql(u8, arg, "--version-script")) {
732 if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg});
732 if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});
733733 i += 1;
734734 version_script = args[i];
735735 } else if (mem.eql(u8, arg, "--library") or mem.eql(u8, arg, "-l")) {
736 if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg});
736 if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});
737737 // We don't know whether this library is part of libc or libc++ until we resolve the target.
738738 // So we simply append to the list for now.
739739 i += 1;
......@@ -743,7 +743,7 @@ fn buildOutputType(
743743 mem.eql(u8, arg, "-I") or
744744 mem.eql(u8, arg, "-dirafter"))
745745 {
746 if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg});
746 if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});
747747 i += 1;
748748 try clang_argv.append(arg);
749749 try clang_argv.append(args[i]);
......@@ -753,19 +753,19 @@ fn buildOutputType(
753753 }
754754 i += 1;
755755 version = std.builtin.Version.parse(args[i]) catch |err| {
756 fatal("unable to parse --version '{}': {}", .{ args[i], @errorName(err) });
756 fatal("unable to parse --version '{s}': {s}", .{ args[i], @errorName(err) });
757757 };
758758 have_version = true;
759759 } else if (mem.eql(u8, arg, "-target")) {
760 if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg});
760 if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});
761761 i += 1;
762762 target_arch_os_abi = args[i];
763763 } else if (mem.eql(u8, arg, "-mcpu")) {
764 if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg});
764 if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});
765765 i += 1;
766766 target_mcpu = args[i];
767767 } else if (mem.eql(u8, arg, "-mcmodel")) {
768 if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg});
768 if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});
769769 i += 1;
770770 machine_code_model = parseCodeModel(args[i]);
771771 } else if (mem.startsWith(u8, arg, "-ofmt=")) {
......@@ -777,35 +777,35 @@ fn buildOutputType(
777777 } else if (mem.startsWith(u8, arg, "-O")) {
778778 optimize_mode_string = arg["-O".len..];
779779 } else if (mem.eql(u8, arg, "--dynamic-linker")) {
780 if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg});
780 if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});
781781 i += 1;
782782 target_dynamic_linker = args[i];
783783 } else if (mem.eql(u8, arg, "--libc")) {
784 if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg});
784 if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});
785785 i += 1;
786786 libc_paths_file = args[i];
787787 } else if (mem.eql(u8, arg, "--test-filter")) {
788 if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg});
788 if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});
789789 i += 1;
790790 test_filter = args[i];
791791 } else if (mem.eql(u8, arg, "--test-name-prefix")) {
792 if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg});
792 if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});
793793 i += 1;
794794 test_name_prefix = args[i];
795795 } else if (mem.eql(u8, arg, "--test-cmd")) {
796 if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg});
796 if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});
797797 i += 1;
798798 try test_exec_args.append(args[i]);
799799 } else if (mem.eql(u8, arg, "--cache-dir")) {
800 if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg});
800 if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});
801801 i += 1;
802802 override_local_cache_dir = args[i];
803803 } else if (mem.eql(u8, arg, "--global-cache-dir")) {
804 if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg});
804 if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});
805805 i += 1;
806806 override_global_cache_dir = args[i];
807807 } else if (mem.eql(u8, arg, "--override-lib-dir")) {
808 if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg});
808 if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});
809809 i += 1;
810810 override_lib_dir = args[i];
811811 } else if (mem.eql(u8, arg, "-fcompiler-rt")) {
......@@ -968,7 +968,7 @@ fn buildOutputType(
968968 {
969969 try clang_argv.append(arg);
970970 } else {
971 fatal("unrecognized parameter: '{}'", .{arg});
971 fatal("unrecognized parameter: '{s}'", .{arg});
972972 }
973973 } else switch (Compilation.classifyFileExt(arg)) {
974974 .object, .static_library, .shared_library => {
......@@ -982,19 +982,19 @@ fn buildOutputType(
982982 },
983983 .zig, .zir => {
984984 if (root_src_file) |other| {
985 fatal("found another zig file '{}' after root source file '{}'", .{ arg, other });
985 fatal("found another zig file '{s}' after root source file '{s}'", .{ arg, other });
986986 } else {
987987 root_src_file = arg;
988988 }
989989 },
990990 .unknown => {
991 fatal("unrecognized file extension of parameter '{}'", .{arg});
991 fatal("unrecognized file extension of parameter '{s}'", .{arg});
992992 },
993993 }
994994 }
995995 if (optimize_mode_string) |s| {
996996 optimize_mode = std.meta.stringToEnum(std.builtin.Mode, s) orelse
997 fatal("unrecognized optimization mode: '{}'", .{s});
997 fatal("unrecognized optimization mode: '{s}'", .{s});
998998 }
999999 },
10001000 .cc, .cpp => {
......@@ -1018,7 +1018,7 @@ fn buildOutputType(
10181018 var it = ClangArgIterator.init(arena, all_args);
10191019 while (it.has_next) {
10201020 it.next() catch |err| {
1021 fatal("unable to parse command line parameters: {}", .{@errorName(err)});
1021 fatal("unable to parse command line parameters: {s}", .{@errorName(err)});
10221022 };
10231023 switch (it.zig_equivalent) {
10241024 .target => target_arch_os_abi = it.only_arg, // example: -target riscv64-linux-unknown
......@@ -1038,7 +1038,7 @@ fn buildOutputType(
10381038 },
10391039 .zig, .zir => {
10401040 if (root_src_file) |other| {
1041 fatal("found another zig file '{}' after root source file '{}'", .{ it.only_arg, other });
1041 fatal("found another zig file '{s}' after root source file '{s}'", .{ it.only_arg, other });
10421042 } else {
10431043 root_src_file = it.only_arg;
10441044 }
......@@ -1153,7 +1153,7 @@ fn buildOutputType(
11531153 if (mem.eql(u8, arg, "-soname")) {
11541154 i += 1;
11551155 if (i >= linker_args.items.len) {
1156 fatal("expected linker arg after '{}'", .{arg});
1156 fatal("expected linker arg after '{s}'", .{arg});
11571157 }
11581158 const name = linker_args.items[i];
11591159 soname = .{ .yes = name };
......@@ -1185,7 +1185,7 @@ fn buildOutputType(
11851185 } else if (mem.eql(u8, arg, "-rpath")) {
11861186 i += 1;
11871187 if (i >= linker_args.items.len) {
1188 fatal("expected linker arg after '{}'", .{arg});
1188 fatal("expected linker arg after '{s}'", .{arg});
11891189 }
11901190 try rpath_list.append(linker_args.items[i]);
11911191 } else if (mem.eql(u8, arg, "-I") or
......@@ -1194,7 +1194,7 @@ fn buildOutputType(
11941194 {
11951195 i += 1;
11961196 if (i >= linker_args.items.len) {
1197 fatal("expected linker arg after '{}'", .{arg});
1197 fatal("expected linker arg after '{s}'", .{arg});
11981198 }
11991199 target_dynamic_linker = linker_args.items[i];
12001200 } else if (mem.eql(u8, arg, "-E") or
......@@ -1205,7 +1205,7 @@ fn buildOutputType(
12051205 } else if (mem.eql(u8, arg, "--version-script")) {
12061206 i += 1;
12071207 if (i >= linker_args.items.len) {
1208 fatal("expected linker arg after '{}'", .{arg});
1208 fatal("expected linker arg after '{s}'", .{arg});
12091209 }
12101210 version_script = linker_args.items[i];
12111211 } else if (mem.startsWith(u8, arg, "-O")) {
......@@ -1227,7 +1227,7 @@ fn buildOutputType(
12271227 } else if (mem.eql(u8, arg, "-z")) {
12281228 i += 1;
12291229 if (i >= linker_args.items.len) {
1230 fatal("expected linker arg after '{}'", .{arg});
1230 fatal("expected linker arg after '{s}'", .{arg});
12311231 }
12321232 const z_arg = linker_args.items[i];
12331233 if (mem.eql(u8, z_arg, "nodelete")) {
......@@ -1235,44 +1235,44 @@ fn buildOutputType(
12351235 } else if (mem.eql(u8, z_arg, "defs")) {
12361236 linker_z_defs = true;
12371237 } else {
1238 warn("unsupported linker arg: -z {}", .{z_arg});
1238 warn("unsupported linker arg: -z {s}", .{z_arg});
12391239 }
12401240 } else if (mem.eql(u8, arg, "--major-image-version")) {
12411241 i += 1;
12421242 if (i >= linker_args.items.len) {
1243 fatal("expected linker arg after '{}'", .{arg});
1243 fatal("expected linker arg after '{s}'", .{arg});
12441244 }
12451245 version.major = std.fmt.parseUnsigned(u32, linker_args.items[i], 10) catch |err| {
1246 fatal("unable to parse '{}': {}", .{ arg, @errorName(err) });
1246 fatal("unable to parse '{s}': {s}", .{ arg, @errorName(err) });
12471247 };
12481248 have_version = true;
12491249 } else if (mem.eql(u8, arg, "--minor-image-version")) {
12501250 i += 1;
12511251 if (i >= linker_args.items.len) {
1252 fatal("expected linker arg after '{}'", .{arg});
1252 fatal("expected linker arg after '{s}'", .{arg});
12531253 }
12541254 version.minor = std.fmt.parseUnsigned(u32, linker_args.items[i], 10) catch |err| {
1255 fatal("unable to parse '{}': {}", .{ arg, @errorName(err) });
1255 fatal("unable to parse '{s}': {s}", .{ arg, @errorName(err) });
12561256 };
12571257 have_version = true;
12581258 } else if (mem.eql(u8, arg, "--stack")) {
12591259 i += 1;
12601260 if (i >= linker_args.items.len) {
1261 fatal("expected linker arg after '{}'", .{arg});
1261 fatal("expected linker arg after '{s}'", .{arg});
12621262 }
12631263 stack_size_override = std.fmt.parseUnsigned(u64, linker_args.items[i], 0) catch |err| {
1264 fatal("unable to parse '{}': {}", .{ arg, @errorName(err) });
1264 fatal("unable to parse '{s}': {s}", .{ arg, @errorName(err) });
12651265 };
12661266 } else if (mem.eql(u8, arg, "--image-base")) {
12671267 i += 1;
12681268 if (i >= linker_args.items.len) {
1269 fatal("expected linker arg after '{}'", .{arg});
1269 fatal("expected linker arg after '{s}'", .{arg});
12701270 }
12711271 image_base_override = std.fmt.parseUnsigned(u64, linker_args.items[i], 0) catch |err| {
1272 fatal("unable to parse '{}': {}", .{ arg, @errorName(err) });
1272 fatal("unable to parse '{s}': {s}", .{ arg, @errorName(err) });
12731273 };
12741274 } else {
1275 warn("unsupported linker arg: {}", .{arg});
1275 warn("unsupported linker arg: {s}", .{arg});
12761276 }
12771277 }
12781278
......@@ -1328,7 +1328,7 @@ fn buildOutputType(
13281328 }
13291329
13301330 if (arg_mode == .translate_c and c_source_files.items.len != 1) {
1331 fatal("translate-c expects exactly 1 source file (found {})", .{c_source_files.items.len});
1331 fatal("translate-c expects exactly 1 source file (found {d})", .{c_source_files.items.len});
13321332 }
13331333
13341334 if (root_src_file == null and arg_mode == .zig_test) {
......@@ -1373,25 +1373,25 @@ fn buildOutputType(
13731373 help: {
13741374 var help_text = std.ArrayList(u8).init(arena);
13751375 for (diags.arch.?.allCpuModels()) |cpu| {
1376 help_text.writer().print(" {}\n", .{cpu.name}) catch break :help;
1376 help_text.writer().print(" {s}\n", .{cpu.name}) catch break :help;
13771377 }
1378 std.log.info("Available CPUs for architecture '{}': {}", .{
1378 std.log.info("Available CPUs for architecture '{s}': {s}", .{
13791379 @tagName(diags.arch.?), help_text.items,
13801380 });
13811381 }
1382 fatal("Unknown CPU: '{}'", .{diags.cpu_name.?});
1382 fatal("Unknown CPU: '{s}'", .{diags.cpu_name.?});
13831383 },
13841384 error.UnknownCpuFeature => {
13851385 help: {
13861386 var help_text = std.ArrayList(u8).init(arena);
13871387 for (diags.arch.?.allFeaturesList()) |feature| {
1388 help_text.writer().print(" {}: {}\n", .{ feature.name, feature.description }) catch break :help;
1388 help_text.writer().print(" {s}: {s}\n", .{ feature.name, feature.description }) catch break :help;
13891389 }
1390 std.log.info("Available CPU features for architecture '{}': {}", .{
1390 std.log.info("Available CPU features for architecture '{s}': {s}", .{
13911391 @tagName(diags.arch.?), help_text.items,
13921392 });
13931393 }
1394 fatal("Unknown CPU feature: '{}'", .{diags.unknown_feature_name});
1394 fatal("Unknown CPU feature: '{s}'", .{diags.unknown_feature_name});
13951395 },
13961396 else => |e| return e,
13971397 };
......@@ -1431,10 +1431,10 @@ fn buildOutputType(
14311431
14321432 if (cross_target.isNativeOs() and (system_libs.items.len != 0 or want_native_include_dirs)) {
14331433 const paths = std.zig.system.NativePaths.detect(arena) catch |err| {
1434 fatal("unable to detect native system paths: {}", .{@errorName(err)});
1434 fatal("unable to detect native system paths: {s}", .{@errorName(err)});
14351435 };
14361436 for (paths.warnings.items) |warning| {
1437 warn("{}", .{warning});
1437 warn("{s}", .{warning});
14381438 }
14391439
14401440 const has_sysroot = if (comptime std.Target.current.isDarwin()) outer: {
......@@ -1492,7 +1492,7 @@ fn buildOutputType(
14921492 } else if (mem.eql(u8, ofmt, "raw")) {
14931493 break :blk .raw;
14941494 } else {
1495 fatal("unsupported object format: {}", .{ofmt});
1495 fatal("unsupported object format: {s}", .{ofmt});
14961496 }
14971497 };
14981498
......@@ -1562,7 +1562,7 @@ fn buildOutputType(
15621562 }
15631563 if (fs.path.dirname(full_path)) |dirname| {
15641564 const handle = fs.cwd().openDir(dirname, .{}) catch |err| {
1565 fatal("unable to open output directory '{}': {}", .{ dirname, @errorName(err) });
1565 fatal("unable to open output directory '{s}': {s}", .{ dirname, @errorName(err) });
15661566 };
15671567 cleanup_emit_bin_dir = handle;
15681568 break :b Compilation.EmitLoc{
......@@ -1585,19 +1585,19 @@ fn buildOutputType(
15851585 },
15861586 };
15871587
1588 const default_h_basename = try std.fmt.allocPrint(arena, "{}.h", .{root_name});
1588 const default_h_basename = try std.fmt.allocPrint(arena, "{s}.h", .{root_name});
15891589 var emit_h_resolved = try emit_h.resolve(default_h_basename);
15901590 defer emit_h_resolved.deinit();
15911591
1592 const default_asm_basename = try std.fmt.allocPrint(arena, "{}.s", .{root_name});
1592 const default_asm_basename = try std.fmt.allocPrint(arena, "{s}.s", .{root_name});
15931593 var emit_asm_resolved = try emit_asm.resolve(default_asm_basename);
15941594 defer emit_asm_resolved.deinit();
15951595
1596 const default_llvm_ir_basename = try std.fmt.allocPrint(arena, "{}.ll", .{root_name});
1596 const default_llvm_ir_basename = try std.fmt.allocPrint(arena, "{s}.ll", .{root_name});
15971597 var emit_llvm_ir_resolved = try emit_llvm_ir.resolve(default_llvm_ir_basename);
15981598 defer emit_llvm_ir_resolved.deinit();
15991599
1600 const default_analysis_basename = try std.fmt.allocPrint(arena, "{}-analysis.json", .{root_name});
1600 const default_analysis_basename = try std.fmt.allocPrint(arena, "{s}-analysis.json", .{root_name});
16011601 var emit_analysis_resolved = try emit_analysis.resolve(default_analysis_basename);
16021602 defer emit_analysis_resolved.deinit();
16031603
......@@ -1609,10 +1609,10 @@ fn buildOutputType(
16091609 .yes_default_path => blk: {
16101610 if (root_src_file) |rsf| {
16111611 if (mem.endsWith(u8, rsf, ".zir")) {
1612 break :blk try std.fmt.allocPrint(arena, "{}.out.zir", .{root_name});
1612 break :blk try std.fmt.allocPrint(arena, "{s}.out.zir", .{root_name});
16131613 }
16141614 }
1615 break :blk try std.fmt.allocPrint(arena, "{}.zir", .{root_name});
1615 break :blk try std.fmt.allocPrint(arena, "{s}.zir", .{root_name});
16161616 },
16171617 .yes => |p| p,
16181618 };
......@@ -1642,7 +1642,7 @@ fn buildOutputType(
16421642 }
16431643 else
16441644 introspect.findZigLibDirFromSelfExe(arena, self_exe_path) catch |err| {
1645 fatal("unable to find zig installation directory: {}", .{@errorName(err)});
1645 fatal("unable to find zig installation directory: {s}", .{@errorName(err)});
16461646 };
16471647 defer zig_lib_directory.handle.close();
16481648
......@@ -1655,7 +1655,7 @@ fn buildOutputType(
16551655
16561656 if (libc_paths_file) |paths_file| {
16571657 libc_installation = LibCInstallation.parse(gpa, paths_file) catch |err| {
1658 fatal("unable to parse libc paths file: {}", .{@errorName(err)});
1658 fatal("unable to parse libc paths file: {s}", .{@errorName(err)});
16591659 };
16601660 }
16611661
......@@ -1791,7 +1791,7 @@ fn buildOutputType(
17911791 .disable_lld_caching = !have_enable_cache,
17921792 .subsystem = subsystem,
17931793 }) catch |err| {
1794 fatal("unable to create compilation: {}", .{@errorName(err)});
1794 fatal("unable to create compilation: {s}", .{@errorName(err)});
17951795 };
17961796 var comp_destroyed = false;
17971797 defer if (!comp_destroyed) comp.destroy();
......@@ -1914,12 +1914,12 @@ fn buildOutputType(
19141914 if (!watch) return cleanExit();
19151915 } else {
19161916 const cmd = try argvCmd(arena, argv.items);
1917 fatal("the following test command failed with exit code {}:\n{}", .{ code, cmd });
1917 fatal("the following test command failed with exit code {}:\n{s}", .{ code, cmd });
19181918 }
19191919 },
19201920 else => {
19211921 const cmd = try argvCmd(arena, argv.items);
1922 fatal("the following test command crashed:\n{}", .{cmd});
1922 fatal("the following test command crashed:\n{s}", .{cmd});
19231923 },
19241924 }
19251925 },
......@@ -1936,7 +1936,7 @@ fn buildOutputType(
19361936 try stderr.print("(zig) ", .{});
19371937 try comp.makeBinFileExecutable();
19381938 if (stdin.readUntilDelimiterOrEof(&repl_buf, '\n') catch |err| {
1939 try stderr.print("\nUnable to parse command: {}\n", .{@errorName(err)});
1939 try stderr.print("\nUnable to parse command: {s}\n", .{@errorName(err)});
19401940 continue;
19411941 }) |line| {
19421942 const actual_line = mem.trimRight(u8, line, "\r\n ");
......@@ -1954,7 +1954,7 @@ fn buildOutputType(
19541954 } else if (mem.eql(u8, actual_line, "help")) {
19551955 try stderr.writeAll(repl_help);
19561956 } else {
1957 try stderr.print("unknown command: {}\n", .{actual_line});
1957 try stderr.print("unknown command: {s}\n", .{actual_line});
19581958 }
19591959 } else {
19601960 break;
......@@ -2012,14 +2012,14 @@ fn cmdTranslateC(comp: *Compilation, arena: *Allocator, enable_cache: bool) !voi
20122012 assert(comp.c_source_files.len == 1);
20132013 const c_source_file = comp.c_source_files[0];
20142014
2015 const translated_zig_basename = try std.fmt.allocPrint(arena, "{}.zig", .{comp.bin_file.options.root_name});
2015 const translated_zig_basename = try std.fmt.allocPrint(arena, "{s}.zig", .{comp.bin_file.options.root_name});
20162016
20172017 var man: Cache.Manifest = comp.obtainCObjectCacheManifest();
20182018 defer if (enable_cache) man.deinit();
20192019
20202020 man.hash.add(@as(u16, 0xb945)); // Random number to distinguish translate-c from compiling C objects
20212021 _ = man.addFile(c_source_file.src_path, null) catch |err| {
2022 fatal("unable to process '{}': {}", .{ c_source_file.src_path, @errorName(err) });
2022 fatal("unable to process '{s}': {s}", .{ c_source_file.src_path, @errorName(err) });
20232023 };
20242024
20252025 const digest = if (try man.hit()) man.final() else digest: {
......@@ -2034,7 +2034,7 @@ fn cmdTranslateC(comp: *Compilation, arena: *Allocator, enable_cache: bool) !voi
20342034 break :blk null;
20352035
20362036 const c_src_basename = fs.path.basename(c_source_file.src_path);
2037 const dep_basename = try std.fmt.allocPrint(arena, "{}.d", .{c_src_basename});
2037 const dep_basename = try std.fmt.allocPrint(arena, "{s}.d", .{c_src_basename});
20382038 const out_dep_path = try comp.tmpFilePath(arena, dep_basename);
20392039 break :blk out_dep_path;
20402040 };
......@@ -2069,7 +2069,7 @@ fn cmdTranslateC(comp: *Compilation, arena: *Allocator, enable_cache: bool) !voi
20692069 error.ASTUnitFailure => fatal("clang API returned errors but due to a clang bug, it is not exposing the errors for zig to see. For more details: https://github.com/ziglang/zig/issues/4455", .{}),
20702070 error.SemanticAnalyzeFail => {
20712071 for (clang_errors) |clang_err| {
2072 std.debug.print("{}:{}:{}: {}\n", .{
2072 std.debug.print("{s}:{}:{}: {s}\n", .{
20732073 if (clang_err.filename_ptr) |p| p[0..clang_err.filename_len] else "(no file)",
20742074 clang_err.line + 1,
20752075 clang_err.column + 1,
......@@ -2087,7 +2087,7 @@ fn cmdTranslateC(comp: *Compilation, arena: *Allocator, enable_cache: bool) !voi
20872087 try man.addDepFilePost(zig_cache_tmp_dir, dep_basename);
20882088 // Just to save disk space, we delete the file because it is never needed again.
20892089 zig_cache_tmp_dir.deleteFile(dep_basename) catch |err| {
2090 warn("failed to delete '{}': {}", .{ dep_file_path, @errorName(err) });
2090 warn("failed to delete '{s}': {s}", .{ dep_file_path, @errorName(err) });
20912091 };
20922092 }
20932093
......@@ -2102,7 +2102,7 @@ fn cmdTranslateC(comp: *Compilation, arena: *Allocator, enable_cache: bool) !voi
21022102 _ = try std.zig.render(comp.gpa, bos.writer(), tree);
21032103 try bos.flush();
21042104
2105 man.writeManifest() catch |err| warn("failed to write cache manifest: {}", .{@errorName(err)});
2105 man.writeManifest() catch |err| warn("failed to write cache manifest: {s}", .{@errorName(err)});
21062106
21072107 break :digest digest;
21082108 };
......@@ -2111,7 +2111,7 @@ fn cmdTranslateC(comp: *Compilation, arena: *Allocator, enable_cache: bool) !voi
21112111 const full_zig_path = try comp.local_cache_directory.join(arena, &[_][]const u8{
21122112 "o", &digest, translated_zig_basename,
21132113 });
2114 try io.getStdOut().writer().print("{}\n", .{full_zig_path});
2114 try io.getStdOut().writer().print("{s}\n", .{full_zig_path});
21152115 return cleanExit();
21162116 } else {
21172117 const out_zig_path = try fs.path.join(arena, &[_][]const u8{ "o", &digest, translated_zig_basename });
......@@ -2148,10 +2148,10 @@ pub fn cmdLibC(gpa: *Allocator, args: []const []const u8) !void {
21482148 try stdout.writeAll(usage_libc);
21492149 return cleanExit();
21502150 } else {
2151 fatal("unrecognized parameter: '{}'", .{arg});
2151 fatal("unrecognized parameter: '{s}'", .{arg});
21522152 }
21532153 } else if (input_file != null) {
2154 fatal("unexpected extra parameter: '{}'", .{arg});
2154 fatal("unexpected extra parameter: '{s}'", .{arg});
21552155 } else {
21562156 input_file = arg;
21572157 }
......@@ -2159,7 +2159,7 @@ pub fn cmdLibC(gpa: *Allocator, args: []const []const u8) !void {
21592159 }
21602160 if (input_file) |libc_file| {
21612161 var libc = LibCInstallation.parse(gpa, libc_file) catch |err| {
2162 fatal("unable to parse libc file: {}", .{@errorName(err)});
2162 fatal("unable to parse libc file: {s}", .{@errorName(err)});
21632163 };
21642164 defer libc.deinit(gpa);
21652165 } else {
......@@ -2167,7 +2167,7 @@ pub fn cmdLibC(gpa: *Allocator, args: []const []const u8) !void {
21672167 .allocator = gpa,
21682168 .verbose = true,
21692169 }) catch |err| {
2170 fatal("unable to detect native libc: {}", .{@errorName(err)});
2170 fatal("unable to detect native libc: {s}", .{@errorName(err)});
21712171 };
21722172 defer libc.deinit(gpa);
21732173
......@@ -2205,16 +2205,16 @@ pub fn cmdInit(
22052205 try io.getStdOut().writeAll(usage_init);
22062206 return cleanExit();
22072207 } else {
2208 fatal("unrecognized parameter: '{}'", .{arg});
2208 fatal("unrecognized parameter: '{s}'", .{arg});
22092209 }
22102210 } else {
2211 fatal("unexpected extra parameter: '{}'", .{arg});
2211 fatal("unexpected extra parameter: '{s}'", .{arg});
22122212 }
22132213 }
22142214 }
22152215 const self_exe_path = try fs.selfExePathAlloc(arena);
22162216 var zig_lib_directory = introspect.findZigLibDirFromSelfExe(arena, self_exe_path) catch |err| {
2217 fatal("unable to find zig installation directory: {}\n", .{@errorName(err)});
2217 fatal("unable to find zig installation directory: {s}\n", .{@errorName(err)});
22182218 };
22192219 defer zig_lib_directory.handle.close();
22202220
......@@ -2232,7 +2232,7 @@ pub fn cmdInit(
22322232
22332233 const max_bytes = 10 * 1024 * 1024;
22342234 const build_zig_contents = template_dir.readFileAlloc(arena, "build.zig", max_bytes) catch |err| {
2235 fatal("unable to read template file 'build.zig': {}", .{@errorName(err)});
2235 fatal("unable to read template file 'build.zig': {s}", .{@errorName(err)});
22362236 };
22372237 var modified_build_zig_contents = std.ArrayList(u8).init(arena);
22382238 try modified_build_zig_contents.ensureCapacity(build_zig_contents.len);
......@@ -2244,13 +2244,13 @@ pub fn cmdInit(
22442244 }
22452245 }
22462246 const main_zig_contents = template_dir.readFileAlloc(arena, "src" ++ s ++ "main.zig", max_bytes) catch |err| {
2247 fatal("unable to read template file 'main.zig': {}", .{@errorName(err)});
2247 fatal("unable to read template file 'main.zig': {s}", .{@errorName(err)});
22482248 };
22492249 if (fs.cwd().access("build.zig", .{})) |_| {
22502250 fatal("existing build.zig file would be overwritten", .{});
22512251 } else |err| switch (err) {
22522252 error.FileNotFound => {},
2253 else => fatal("unable to test existence of build.zig: {}\n", .{@errorName(err)}),
2253 else => fatal("unable to test existence of build.zig: {s}\n", .{@errorName(err)}),
22542254 }
22552255 var src_dir = try fs.cwd().makeOpenPath("src", .{});
22562256 defer src_dir.close();
......@@ -2311,23 +2311,23 @@ pub fn cmdBuild(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v
23112311 const arg = args[i];
23122312 if (mem.startsWith(u8, arg, "-")) {
23132313 if (mem.eql(u8, arg, "--build-file")) {
2314 if (i + 1 >= args.len) fatal("expected argument after '{}'", .{arg});
2314 if (i + 1 >= args.len) fatal("expected argument after '{s}'", .{arg});
23152315 i += 1;
23162316 build_file = args[i];
23172317 continue;
23182318 } else if (mem.eql(u8, arg, "--override-lib-dir")) {
2319 if (i + 1 >= args.len) fatal("expected argument after '{}'", .{arg});
2319 if (i + 1 >= args.len) fatal("expected argument after '{s}'", .{arg});
23202320 i += 1;
23212321 override_lib_dir = args[i];
23222322 try child_argv.appendSlice(&[_][]const u8{ arg, args[i] });
23232323 continue;
23242324 } else if (mem.eql(u8, arg, "--cache-dir")) {
2325 if (i + 1 >= args.len) fatal("expected argument after '{}'", .{arg});
2325 if (i + 1 >= args.len) fatal("expected argument after '{s}'", .{arg});
23262326 i += 1;
23272327 override_local_cache_dir = args[i];
23282328 continue;
23292329 } else if (mem.eql(u8, arg, "--global-cache-dir")) {
2330 if (i + 1 >= args.len) fatal("expected argument after '{}'", .{arg});
2330 if (i + 1 >= args.len) fatal("expected argument after '{s}'", .{arg});
23312331 i += 1;
23322332 override_global_cache_dir = args[i];
23332333 continue;
......@@ -2344,7 +2344,7 @@ pub fn cmdBuild(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v
23442344 }
23452345 else
23462346 introspect.findZigLibDirFromSelfExe(arena, self_exe_path) catch |err| {
2347 fatal("unable to find zig installation directory: {}", .{@errorName(err)});
2347 fatal("unable to find zig installation directory: {s}", .{@errorName(err)});
23482348 };
23492349 defer zig_lib_directory.handle.close();
23502350
......@@ -2385,7 +2385,7 @@ pub fn cmdBuild(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v
23852385 } else |err| switch (err) {
23862386 error.FileNotFound => {
23872387 dirname = fs.path.dirname(dirname) orelse {
2388 std.log.info("{}", .{
2388 std.log.info("{s}", .{
23892389 \\Initialize a 'build.zig' template file with `zig init-lib` or `zig init-exe`,
23902390 \\or see `zig --help` for more options.
23912391 });
......@@ -2467,7 +2467,7 @@ pub fn cmdBuild(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v
24672467 .self_exe_path = self_exe_path,
24682468 .thread_pool = &thread_pool,
24692469 }) catch |err| {
2470 fatal("unable to create compilation: {}", .{@errorName(err)});
2470 fatal("unable to create compilation: {s}", .{@errorName(err)});
24712471 };
24722472 defer comp.destroy();
24732473
......@@ -2493,11 +2493,11 @@ pub fn cmdBuild(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v
24932493 .Exited => |code| {
24942494 if (code == 0) return cleanExit();
24952495 const cmd = try argvCmd(arena, child_argv);
2496 fatal("the following build command failed with exit code {}:\n{}", .{ code, cmd });
2496 fatal("the following build command failed with exit code {}:\n{s}", .{ code, cmd });
24972497 },
24982498 else => {
24992499 const cmd = try argvCmd(arena, child_argv);
2500 fatal("the following build command crashed:\n{}", .{cmd});
2500 fatal("the following build command crashed:\n{s}", .{cmd});
25012501 },
25022502 }
25032503}
......@@ -2564,14 +2564,14 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void {
25642564 i += 1;
25652565 const next_arg = args[i];
25662566 color = std.meta.stringToEnum(Color, next_arg) orelse {
2567 fatal("expected [auto|on|off] after --color, found '{}'", .{next_arg});
2567 fatal("expected [auto|on|off] after --color, found '{s}'", .{next_arg});
25682568 };
25692569 } else if (mem.eql(u8, arg, "--stdin")) {
25702570 stdin_flag = true;
25712571 } else if (mem.eql(u8, arg, "--check")) {
25722572 check_flag = true;
25732573 } else {
2574 fatal("unrecognized parameter: '{}'", .{arg});
2574 fatal("unrecognized parameter: '{s}'", .{arg});
25752575 }
25762576 } else {
25772577 try input_files.append(arg);
......@@ -2590,7 +2590,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void {
25902590 defer gpa.free(source_code);
25912591
25922592 const tree = std.zig.parse(gpa, source_code) catch |err| {
2593 fatal("error parsing stdin: {}", .{err});
2593 fatal("error parsing stdin: {s}", .{err});
25942594 };
25952595 defer tree.deinit();
25962596
......@@ -2629,7 +2629,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void {
26292629 for (input_files.items) |file_path| {
26302630 // Get the real path here to avoid Windows failing on relative file paths with . or .. in them.
26312631 const real_path = fs.realpathAlloc(gpa, file_path) catch |err| {
2632 fatal("unable to open '{}': {}", .{ file_path, err });
2632 fatal("unable to open '{s}': {s}", .{ file_path, @errorName(err) });
26332633 };
26342634 defer gpa.free(real_path);
26352635
......@@ -2668,7 +2668,7 @@ fn fmtPath(fmt: *Fmt, file_path: []const u8, check_mode: bool, dir: fs.Dir, sub_
26682668 fmtPathFile(fmt, file_path, check_mode, dir, sub_path) catch |err| switch (err) {
26692669 error.IsDir, error.AccessDenied => return fmtPathDir(fmt, file_path, check_mode, dir, sub_path),
26702670 else => {
2671 warn("unable to format '{}': {}", .{ file_path, err });
2671 warn("unable to format '{s}': {s}", .{ file_path, @errorName(err) });
26722672 fmt.any_error = true;
26732673 return;
26742674 },
......@@ -2702,7 +2702,7 @@ fn fmtPathDir(
27022702 try fmtPathDir(fmt, full_path, check_mode, dir, entry.name);
27032703 } else {
27042704 fmtPathFile(fmt, full_path, check_mode, dir, entry.name) catch |err| {
2705 warn("unable to format '{}': {}", .{ full_path, err });
2705 warn("unable to format '{s}': {s}", .{ full_path, @errorName(err) });
27062706 fmt.any_error = true;
27072707 return;
27082708 };
......@@ -2761,7 +2761,7 @@ fn fmtPathFile(
27612761 const anything_changed = try std.zig.render(fmt.gpa, io.null_out_stream, tree);
27622762 if (anything_changed) {
27632763 const stdout = io.getStdOut().writer();
2764 try stdout.print("{}\n", .{file_path});
2764 try stdout.print("{s}\n", .{file_path});
27652765 fmt.any_error = true;
27662766 }
27672767 } else {
......@@ -2779,7 +2779,7 @@ fn fmtPathFile(
27792779 try af.file.writeAll(fmt.out_buffer.items);
27802780 try af.finish();
27812781 const stdout = io.getStdOut().writer();
2782 try stdout.print("{}\n", .{file_path});
2782 try stdout.print("{s}\n", .{file_path});
27832783 }
27842784}
27852785
......@@ -2812,7 +2812,7 @@ fn printErrMsgToFile(
28122812 const text = text_buf.items;
28132813
28142814 const stream = file.outStream();
2815 try stream.print("{}:{}:{}: error: {}\n", .{ path, start_loc.line + 1, start_loc.column + 1, text });
2815 try stream.print("{s}:{}:{}: error: {s}\n", .{ path, start_loc.line + 1, start_loc.column + 1, text });
28162816
28172817 if (!color_on) return;
28182818
......@@ -2984,7 +2984,7 @@ pub const ClangArgIterator = struct {
29842984 const max_bytes = 10 * 1024 * 1024; // 10 MiB of command line arguments is a reasonable limit
29852985 const resp_file_path = arg[1..];
29862986 const resp_contents = fs.cwd().readFileAlloc(allocator, resp_file_path, max_bytes) catch |err| {
2987 fatal("unable to read response file '{}': {}", .{ resp_file_path, @errorName(err) });
2987 fatal("unable to read response file '{s}': {s}", .{ resp_file_path, @errorName(err) });
29882988 };
29892989 defer allocator.free(resp_contents);
29902990 // TODO is there a specification for this file format? Let's find it and make this parsing more robust
......@@ -3057,7 +3057,7 @@ pub const ClangArgIterator = struct {
30573057 const prefix_len = clang_arg.matchStartsWith(arg);
30583058 if (prefix_len == arg.len) {
30593059 if (self.next_index >= self.argv.len) {
3060 fatal("Expected parameter after '{}'", .{arg});
3060 fatal("Expected parameter after '{s}'", .{arg});
30613061 }
30623062 self.only_arg = self.argv[self.next_index];
30633063 self.incrementArgIndex();
......@@ -3078,7 +3078,7 @@ pub const ClangArgIterator = struct {
30783078 if (prefix_len != 0) {
30793079 self.only_arg = arg[prefix_len..];
30803080 if (self.next_index >= self.argv.len) {
3081 fatal("Expected parameter after '{}'", .{arg});
3081 fatal("Expected parameter after '{s}'", .{arg});
30823082 }
30833083 self.second_arg = self.argv[self.next_index];
30843084 self.incrementArgIndex();
......@@ -3089,7 +3089,7 @@ pub const ClangArgIterator = struct {
30893089 },
30903090 .separate => if (clang_arg.matchEql(arg) > 0) {
30913091 if (self.next_index >= self.argv.len) {
3092 fatal("Expected parameter after '{}'", .{arg});
3092 fatal("Expected parameter after '{s}'", .{arg});
30933093 }
30943094 self.only_arg = self.argv[self.next_index];
30953095 self.incrementArgIndex();
......@@ -3115,7 +3115,7 @@ pub const ClangArgIterator = struct {
31153115 },
31163116 }
31173117 else {
3118 fatal("Unknown Clang option: '{}'", .{arg});
3118 fatal("Unknown Clang option: '{s}'", .{arg});
31193119 }
31203120 }
31213121
......@@ -3143,7 +3143,7 @@ pub const ClangArgIterator = struct {
31433143
31443144fn parseCodeModel(arg: []const u8) std.builtin.CodeModel {
31453145 return std.meta.stringToEnum(std.builtin.CodeModel, arg) orelse
3146 fatal("unsupported machine code model: '{}'", .{arg});
3146 fatal("unsupported machine code model: '{s}'", .{arg});
31473147}
31483148
31493149/// Raise the open file descriptor limit. Ask and ye shall receive.
......@@ -3263,7 +3263,7 @@ fn detectNativeTargetInfo(gpa: *Allocator, cross_target: std.zig.CrossTarget) !s
32633263 // CPU model & feature detection is todo so here we rely on LLVM.
32643264 // https://github.com/ziglang/zig/issues/4591
32653265 if (!build_options.have_llvm)
3266 fatal("CPU features detection is not yet available for {} without LLVM extensions", .{@tagName(arch)});
3266 fatal("CPU features detection is not yet available for {s} without LLVM extensions", .{@tagName(arch)});
32673267
32683268 const llvm = @import("llvm_bindings.zig");
32693269 const llvm_cpu_name = llvm.GetHostCPUName();
src/mingw.zig+2-2
......@@ -381,7 +381,7 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void {
381381
382382 const term = child.wait() catch |err| {
383383 // TODO surface a proper error here
384 log.err("unable to spawn {}: {}", .{ args[0], @errorName(err) });
384 log.err("unable to spawn {s}: {s}", .{ args[0], @errorName(err) });
385385 return error.ClangPreprocessorFailed;
386386 };
387387
......@@ -395,7 +395,7 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void {
395395 },
396396 else => {
397397 // TODO surface a proper error here
398 log.err("clang terminated unexpectedly with stderr: {}", .{stderr});
398 log.err("clang terminated unexpectedly with stderr: {s}", .{stderr});
399399 return error.ClangPreprocessorFailed;
400400 },
401401 }
src/musl.zig+4-4
......@@ -155,21 +155,21 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
155155 if (!is_arch_specific) {
156156 // Look for an arch specific override.
157157 override_path.shrinkRetainingCapacity(0);
158 try override_path.writer().print("{}" ++ s ++ "{}" ++ s ++ "{}.s", .{
158 try override_path.writer().print("{s}" ++ s ++ "{s}" ++ s ++ "{s}.s", .{
159159 dirname, arch_name, noextbasename,
160160 });
161161 if (source_table.contains(override_path.items))
162162 continue;
163163
164164 override_path.shrinkRetainingCapacity(0);
165 try override_path.writer().print("{}" ++ s ++ "{}" ++ s ++ "{}.S", .{
165 try override_path.writer().print("{s}" ++ s ++ "{s}" ++ s ++ "{s}.S", .{
166166 dirname, arch_name, noextbasename,
167167 });
168168 if (source_table.contains(override_path.items))
169169 continue;
170170
171171 override_path.shrinkRetainingCapacity(0);
172 try override_path.writer().print("{}" ++ s ++ "{}" ++ s ++ "{}.c", .{
172 try override_path.writer().print("{s}" ++ s ++ "{s}" ++ s ++ "{s}.c", .{
173173 dirname, arch_name, noextbasename,
174174 });
175175 if (source_table.contains(override_path.items))
......@@ -322,7 +322,7 @@ fn add_cc_args(
322322 const target = comp.getTarget();
323323 const arch_name = target_util.archMuslName(target.cpu.arch);
324324 const os_name = @tagName(target.os.tag);
325 const triple = try std.fmt.allocPrint(arena, "{}-{}-musl", .{ arch_name, os_name });
325 const triple = try std.fmt.allocPrint(arena, "{s}-{s}-musl", .{ arch_name, os_name });
326326 const o_arg = if (want_O3) "-O3" else "-Os";
327327
328328 try args.appendSlice(&[_][]const u8{
src/print_env.zig+1-1
......@@ -9,7 +9,7 @@ pub fn cmdEnv(gpa: *Allocator, args: []const []const u8, stdout: std.fs.File.Wri
99 defer gpa.free(self_exe_path);
1010
1111 var zig_lib_directory = introspect.findZigLibDirFromSelfExe(gpa, self_exe_path) catch |err| {
12 fatal("unable to find zig installation directory: {}\n", .{@errorName(err)});
12 fatal("unable to find zig installation directory: {s}\n", .{@errorName(err)});
1313 };
1414 defer gpa.free(zig_lib_directory.path.?);
1515 defer zig_lib_directory.handle.close();
src/print_targets.zig+2-2
......@@ -18,7 +18,7 @@ pub fn cmdTargets(
1818 native_target: Target,
1919) !void {
2020 var zig_lib_directory = introspect.findZigLibDir(allocator) catch |err| {
21 fatal("unable to find zig installation directory: {}\n", .{@errorName(err)});
21 fatal("unable to find zig installation directory: {s}\n", .{@errorName(err)});
2222 };
2323 defer zig_lib_directory.handle.close();
2424 defer allocator.free(zig_lib_directory.path.?);
......@@ -61,7 +61,7 @@ pub fn cmdTargets(
6161 try jws.objectField("libc");
6262 try jws.beginArray();
6363 for (target.available_libcs) |libc| {
64 const tmp = try std.fmt.allocPrint(allocator, "{}-{}-{}", .{
64 const tmp = try std.fmt.allocPrint(allocator, "{s}-{s}-{s}", .{
6565 @tagName(libc.arch), @tagName(libc.os), @tagName(libc.abi),
6666 });
6767 defer allocator.free(tmp);
src/stage1.zig+2-2
......@@ -37,14 +37,14 @@ pub export fn main(argc: c_int, argv: [*][*:0]u8) c_int {
3737 defer arena_instance.deinit();
3838 const arena = &arena_instance.allocator;
3939
40 const args = arena.alloc([]const u8, @intCast(usize, argc)) catch fatal("{}", .{"OutOfMemory"});
40 const args = arena.alloc([]const u8, @intCast(usize, argc)) catch fatal("{s}", .{"OutOfMemory"});
4141 for (args) |*arg, i| {
4242 arg.* = mem.spanZ(argv[i]);
4343 }
4444 if (std.builtin.mode == .Debug) {
4545 stage2.mainArgs(gpa, arena, args) catch unreachable;
4646 } else {
47 stage2.mainArgs(gpa, arena, args) catch |err| fatal("{}", .{@errorName(err)});
47 stage2.mainArgs(gpa, arena, args) catch |err| fatal("{s}", .{@errorName(err)});
4848 }
4949 return 0;
5050}
src/translate_c.zig+38-38
......@@ -136,7 +136,7 @@ const Scope = struct {
136136 var proposed_name = name_copy;
137137 while (scope.contains(proposed_name)) {
138138 scope.mangle_count += 1;
139 proposed_name = try std.fmt.allocPrint(c.arena, "{}_{}", .{ name, scope.mangle_count });
139 proposed_name = try std.fmt.allocPrint(c.arena, "{s}_{}", .{ name, scope.mangle_count });
140140 }
141141 try scope.variables.append(.{ .name = name_copy, .alias = proposed_name });
142142 return proposed_name;
......@@ -290,7 +290,7 @@ pub const Context = struct {
290290
291291 const line = c.source_manager.getSpellingLineNumber(spelling_loc);
292292 const column = c.source_manager.getSpellingColumnNumber(spelling_loc);
293 return std.fmt.allocPrint(c.arena, "{}:{}:{}", .{ filename, line, column });
293 return std.fmt.allocPrint(c.arena, "{s}:{d}:{d}", .{ filename, line, column });
294294 }
295295
296296 fn createCall(c: *Context, fn_expr: *ast.Node, params_len: ast.NodeIndex) !*ast.Node.Call {
......@@ -530,7 +530,7 @@ fn declVisitor(c: *Context, decl: *const clang.Decl) Error!void {
530530 },
531531 else => {
532532 const decl_name = try c.str(decl.getDeclKindName());
533 try emitWarning(c, decl.getLocation(), "ignoring {} declaration", .{decl_name});
533 try emitWarning(c, decl.getLocation(), "ignoring {s} declaration", .{decl_name});
534534 },
535535 }
536536}
......@@ -625,7 +625,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const clang.FunctionDecl) Error!void {
625625 const param_name = if (param.name_token) |name_tok|
626626 tokenSlice(c, name_tok)
627627 else
628 return failDecl(c, fn_decl_loc, fn_name, "function {} parameter has no name", .{fn_name});
628 return failDecl(c, fn_decl_loc, fn_name, "function {s} parameter has no name", .{fn_name});
629629
630630 const c_param = fn_decl.getParamDecl(param_id);
631631 const qual_type = c_param.getOriginalType();
......@@ -634,7 +634,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const clang.FunctionDecl) Error!void {
634634 const mangled_param_name = try block_scope.makeMangledName(c, param_name);
635635
636636 if (!is_const) {
637 const bare_arg_name = try std.fmt.allocPrint(c.arena, "arg_{}", .{mangled_param_name});
637 const bare_arg_name = try std.fmt.allocPrint(c.arena, "arg_{s}", .{mangled_param_name});
638638 const arg_name = try block_scope.makeMangledName(c, bare_arg_name);
639639
640640 const mut_tok = try appendToken(c, .Keyword_var, "var");
......@@ -727,7 +727,7 @@ fn visitVarDecl(c: *Context, var_decl: *const clang.VarDecl, mangled_name: ?[]co
727727
728728 // TODO https://github.com/ziglang/zig/issues/3756
729729 // TODO https://github.com/ziglang/zig/issues/1802
730 const checked_name = if (isZigPrimitiveType(var_name)) try std.fmt.allocPrint(c.arena, "{}_{}", .{ var_name, c.getMangle() }) else var_name;
730 const checked_name = if (isZigPrimitiveType(var_name)) try std.fmt.allocPrint(c.arena, "{s}_{d}", .{ var_name, c.getMangle() }) else var_name;
731731 const var_decl_loc = var_decl.getLocation();
732732
733733 const qual_type = var_decl.getTypeSourceInfo_getType();
......@@ -808,7 +808,7 @@ fn visitVarDecl(c: *Context, var_decl: *const clang.VarDecl, mangled_name: ?[]co
808808 _ = try appendToken(rp.c, .LParen, "(");
809809 const expr = try transCreateNodeStringLiteral(
810810 rp.c,
811 try std.fmt.allocPrint(rp.c.arena, "\"{}\"", .{str_ptr[0..str_len]}),
811 try std.fmt.allocPrint(rp.c.arena, "\"{s}\"", .{str_ptr[0..str_len]}),
812812 );
813813 _ = try appendToken(rp.c, .RParen, ")");
814814
......@@ -887,7 +887,7 @@ fn transTypeDef(c: *Context, typedef_decl: *const clang.TypedefNameDecl, top_lev
887887
888888 // TODO https://github.com/ziglang/zig/issues/3756
889889 // TODO https://github.com/ziglang/zig/issues/1802
890 const checked_name = if (isZigPrimitiveType(typedef_name)) try std.fmt.allocPrint(c.arena, "{}_{}", .{ typedef_name, c.getMangle() }) else typedef_name;
890 const checked_name = if (isZigPrimitiveType(typedef_name)) try std.fmt.allocPrint(c.arena, "{s}_{d}", .{ typedef_name, c.getMangle() }) else typedef_name;
891891 if (checkForBuiltinTypedef(checked_name)) |builtin| {
892892 return transTypeDefAsBuiltin(c, typedef_decl, builtin);
893893 }
......@@ -958,11 +958,11 @@ fn transRecordDecl(c: *Context, record_decl: *const clang.RecordDecl) Error!?*as
958958 container_kind_name = "struct";
959959 container_kind = .Keyword_struct;
960960 } else {
961 try emitWarning(c, record_loc, "record {} is not a struct or union", .{bare_name});
961 try emitWarning(c, record_loc, "record {s} is not a struct or union", .{bare_name});
962962 return null;
963963 }
964964
965 const name = try std.fmt.allocPrint(c.arena, "{}_{}", .{ container_kind_name, bare_name });
965 const name = try std.fmt.allocPrint(c.arena, "{s}_{s}", .{ container_kind_name, bare_name });
966966 _ = try c.decl_table.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), name);
967967
968968 const visib_tok = if (!is_unnamed) try appendToken(c, .Keyword_pub, "pub") else null;
......@@ -1003,7 +1003,7 @@ fn transRecordDecl(c: *Context, record_decl: *const clang.RecordDecl) Error!?*as
10031003 _ = try c.opaque_demotes.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), {});
10041004 const opaque_type = try transCreateNodeOpaqueType(c);
10051005 semicolon = try appendToken(c, .Semicolon, ";");
1006 try emitWarning(c, field_loc, "{} demoted to opaque type - has bitfield", .{container_kind_name});
1006 try emitWarning(c, field_loc, "{s} demoted to opaque type - has bitfield", .{container_kind_name});
10071007 break :blk opaque_type;
10081008 }
10091009
......@@ -1011,7 +1011,7 @@ fn transRecordDecl(c: *Context, record_decl: *const clang.RecordDecl) Error!?*as
10111011 _ = try c.opaque_demotes.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), {});
10121012 const opaque_type = try transCreateNodeOpaqueType(c);
10131013 semicolon = try appendToken(c, .Semicolon, ";");
1014 try emitWarning(c, field_loc, "{} demoted to opaque type - has variable length array", .{container_kind_name});
1014 try emitWarning(c, field_loc, "{s} demoted to opaque type - has variable length array", .{container_kind_name});
10151015 break :blk opaque_type;
10161016 }
10171017
......@@ -1030,7 +1030,7 @@ fn transRecordDecl(c: *Context, record_decl: *const clang.RecordDecl) Error!?*as
10301030 _ = try c.opaque_demotes.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), {});
10311031 const opaque_type = try transCreateNodeOpaqueType(c);
10321032 semicolon = try appendToken(c, .Semicolon, ";");
1033 try emitWarning(c, record_loc, "{} demoted to opaque type - unable to translate type of field {}", .{ container_kind_name, raw_name });
1033 try emitWarning(c, record_loc, "{s} demoted to opaque type - unable to translate type of field {s}", .{ container_kind_name, raw_name });
10341034 break :blk opaque_type;
10351035 },
10361036 else => |e| return e,
......@@ -1114,7 +1114,7 @@ fn transEnumDecl(c: *Context, enum_decl: *const clang.EnumDecl) Error!?*ast.Node
11141114 is_unnamed = true;
11151115 }
11161116
1117 const name = try std.fmt.allocPrint(c.arena, "enum_{}", .{bare_name});
1117 const name = try std.fmt.allocPrint(c.arena, "enum_{s}", .{bare_name});
11181118 _ = try c.decl_table.put(c.gpa, @ptrToInt(enum_decl.getCanonicalDecl()), name);
11191119
11201120 const visib_tok = if (!is_unnamed) try appendToken(c, .Keyword_pub, "pub") else null;
......@@ -1385,7 +1385,7 @@ fn transStmt(
13851385 rp,
13861386 error.UnsupportedTranslation,
13871387 stmt.getBeginLoc(),
1388 "TODO implement translation of stmt class {}",
1388 "TODO implement translation of stmt class {s}",
13891389 .{@tagName(sc)},
13901390 );
13911391 },
......@@ -1684,7 +1684,7 @@ fn transDeclStmtOne(
16841684 rp,
16851685 error.UnsupportedTranslation,
16861686 decl.getLocation(),
1687 "TODO implement translation of DeclStmt kind {}",
1687 "TODO implement translation of DeclStmt kind {s}",
16881688 .{@tagName(kind)},
16891689 ),
16901690 }
......@@ -1782,7 +1782,7 @@ fn transImplicitCastExpr(
17821782 rp,
17831783 error.UnsupportedTranslation,
17841784 @ptrCast(*const clang.Stmt, expr).getBeginLoc(),
1785 "TODO implement translation of CastKind {}",
1785 "TODO implement translation of CastKind {s}",
17861786 .{@tagName(kind)},
17871787 ),
17881788 }
......@@ -2043,7 +2043,7 @@ fn transStringLiteral(
20432043 rp,
20442044 error.UnsupportedTranslation,
20452045 @ptrCast(*const clang.Stmt, stmt).getBeginLoc(),
2046 "TODO: support string literal kind {}",
2046 "TODO: support string literal kind {s}",
20472047 .{kind},
20482048 ),
20492049 }
......@@ -2168,7 +2168,6 @@ fn transCCast(
21682168 // @boolToInt returns either a comptime_int or a u1
21692169 // TODO: if dst_type is 1 bit & signed (bitfield) we need @bitCast
21702170 // instead of @as
2171
21722171 const builtin_node = try rp.c.createBuiltinCall("@boolToInt", 1);
21732172 builtin_node.params()[0] = expr;
21742173 builtin_node.rparen_token = try appendToken(rp.c, .RParen, ")");
......@@ -2455,7 +2454,7 @@ fn transInitListExpr(
24552454 );
24562455 } else {
24572456 const type_name = rp.c.str(qual_type.getTypeClassName());
2458 return revertAndWarn(rp, error.UnsupportedType, source_loc, "unsupported initlist type: '{}'", .{type_name});
2457 return revertAndWarn(rp, error.UnsupportedType, source_loc, "unsupported initlist type: '{s}'", .{type_name});
24592458 }
24602459}
24612460
......@@ -4433,7 +4432,8 @@ fn transCreateNodeBoolLiteral(c: *Context, value: bool) !*ast.Node {
44334432}
44344433
44354434fn transCreateNodeInt(c: *Context, int: anytype) !*ast.Node {
4436 const token = try appendTokenFmt(c, .IntegerLiteral, "{}", .{int});
4435 const fmt_s = if (comptime std.meta.trait.isIntegerNumber(@TypeOf(int))) "{d}" else "{s}";
4436 const token = try appendTokenFmt(c, .IntegerLiteral, fmt_s, .{int});
44374437 const node = try c.arena.create(ast.Node.OneToken);
44384438 node.* = .{
44394439 .base = .{ .tag = .IntegerLiteral },
......@@ -4442,8 +4442,8 @@ fn transCreateNodeInt(c: *Context, int: anytype) !*ast.Node {
44424442 return &node.base;
44434443}
44444444
4445fn transCreateNodeFloat(c: *Context, int: anytype) !*ast.Node {
4446 const token = try appendTokenFmt(c, .FloatLiteral, "{}", .{int});
4445fn transCreateNodeFloat(c: *Context, str: []const u8) !*ast.Node {
4446 const token = try appendTokenFmt(c, .FloatLiteral, "{s}", .{str});
44474447 const node = try c.arena.create(ast.Node.OneToken);
44484448 node.* = .{
44494449 .base = .{ .tag = .FloatLiteral },
......@@ -4916,7 +4916,7 @@ fn transType(rp: RestorePoint, ty: *const clang.Type, source_loc: clang.SourceLo
49164916 },
49174917 else => {
49184918 const type_name = rp.c.str(ty.getTypeClassName());
4919 return revertAndWarn(rp, error.UnsupportedType, source_loc, "unsupported type: '{}'", .{type_name});
4919 return revertAndWarn(rp, error.UnsupportedType, source_loc, "unsupported type: '{s}'", .{type_name});
49204920 },
49214921 }
49224922}
......@@ -4999,7 +4999,7 @@ fn transCC(
49994999 rp,
50005000 error.UnsupportedType,
50015001 source_loc,
5002 "unsupported calling convention: {}",
5002 "unsupported calling convention: {s}",
50035003 .{@tagName(clang_cc)},
50045004 ),
50055005 }
......@@ -5117,7 +5117,7 @@ fn finishTransFnProto(
51175117 _ = try appendToken(rp.c, .LParen, "(");
51185118 const expr = try transCreateNodeStringLiteral(
51195119 rp.c,
5120 try std.fmt.allocPrint(rp.c.arena, "\"{}\"", .{str_ptr[0..str_len]}),
5120 try std.fmt.allocPrint(rp.c.arena, "\"{s}\"", .{str_ptr[0..str_len]}),
51215121 );
51225122 _ = try appendToken(rp.c, .RParen, ")");
51235123
......@@ -5214,7 +5214,7 @@ fn revertAndWarn(
52145214
52155215fn emitWarning(c: *Context, loc: clang.SourceLocation, comptime format: []const u8, args: anytype) !void {
52165216 const args_prefix = .{c.locStr(loc)};
5217 _ = try appendTokenFmt(c, .LineComment, "// {}: warning: " ++ format, args_prefix ++ args);
5217 _ = try appendTokenFmt(c, .LineComment, "// {s}: warning: " ++ format, args_prefix ++ args);
52185218}
52195219
52205220pub fn failDecl(c: *Context, loc: clang.SourceLocation, name: []const u8, comptime format: []const u8, args: anytype) !void {
......@@ -5228,7 +5228,7 @@ pub fn failDecl(c: *Context, loc: clang.SourceLocation, name: []const u8, compti
52285228 const msg_tok = try appendTokenFmt(c, .StringLiteral, "\"" ++ format ++ "\"", args);
52295229 const rparen_tok = try appendToken(c, .RParen, ")");
52305230 const semi_tok = try appendToken(c, .Semicolon, ";");
5231 _ = try appendTokenFmt(c, .LineComment, "// {}", .{c.locStr(loc)});
5231 _ = try appendTokenFmt(c, .LineComment, "// {s}", .{c.locStr(loc)});
52325232
52335233 const msg_node = try c.arena.create(ast.Node.OneToken);
52345234 msg_node.* = .{
......@@ -5258,7 +5258,7 @@ pub fn failDecl(c: *Context, loc: clang.SourceLocation, name: []const u8, compti
52585258
52595259fn appendToken(c: *Context, token_id: Token.Id, bytes: []const u8) !ast.TokenIndex {
52605260 std.debug.assert(token_id != .Identifier); // use appendIdentifier
5261 return appendTokenFmt(c, token_id, "{}", .{bytes});
5261 return appendTokenFmt(c, token_id, "{s}", .{bytes});
52625262}
52635263
52645264fn appendTokenFmt(c: *Context, token_id: Token.Id, comptime format: []const u8, args: anytype) !ast.TokenIndex {
......@@ -5329,7 +5329,7 @@ fn transCreateNodeIdentifier(c: *Context, name: []const u8) !*ast.Node {
53295329}
53305330
53315331fn transCreateNodeIdentifierUnchecked(c: *Context, name: []const u8) !*ast.Node {
5332 const token_index = try appendTokenFmt(c, .Identifier, "{}", .{name});
5332 const token_index = try appendTokenFmt(c, .Identifier, "{s}", .{name});
53335333 const identifier = try c.arena.create(ast.Node.OneToken);
53345334 identifier.* = .{
53355335 .base = .{ .tag = .Identifier },
......@@ -5390,7 +5390,7 @@ fn transPreprocessorEntities(c: *Context, unit: *clang.ASTUnit) Error!void {
53905390 const name = try c.str(raw_name);
53915391 // TODO https://github.com/ziglang/zig/issues/3756
53925392 // TODO https://github.com/ziglang/zig/issues/1802
5393 const mangled_name = if (isZigPrimitiveType(name)) try std.fmt.allocPrint(c.arena, "{}_{}", .{ name, c.getMangle() }) else name;
5393 const mangled_name = if (isZigPrimitiveType(name)) try std.fmt.allocPrint(c.arena, "{s}_{d}", .{ name, c.getMangle() }) else name;
53945394 if (scope.containsNow(mangled_name)) {
53955395 continue;
53965396 }
......@@ -5468,7 +5468,7 @@ fn transMacroDefine(c: *Context, m: *MacroCtx) ParseError!void {
54685468 const init_node = try parseCExpr(c, m, scope);
54695469 const last = m.next().?;
54705470 if (last != .Eof and last != .Nl)
5471 return m.fail(c, "unable to translate C expr: unexpected token .{}", .{@tagName(last)});
5471 return m.fail(c, "unable to translate C expr: unexpected token .{s}", .{@tagName(last)});
54725472
54735473 const semicolon_token = try appendToken(c, .Semicolon, ";");
54745474 const node = try ast.Node.VarDecl.create(c.arena, .{
......@@ -5540,7 +5540,7 @@ fn transMacroFnDefine(c: *Context, m: *MacroCtx) ParseError!void {
55405540 const expr = try parseCExpr(c, m, scope);
55415541 const last = m.next().?;
55425542 if (last != .Eof and last != .Nl)
5543 return m.fail(c, "unable to translate C expr: unexpected token .{}", .{@tagName(last)});
5543 return m.fail(c, "unable to translate C expr: unexpected token .{s}", .{@tagName(last)});
55445544 _ = try appendToken(c, .Semicolon, ";");
55455545 const type_of_arg = if (!expr.tag.isBlock()) expr else blk: {
55465546 const stmts = expr.blockStatements();
......@@ -5623,11 +5623,11 @@ fn parseCNumLit(c: *Context, m: *MacroCtx) ParseError!*ast.Node {
56235623 switch (lit_bytes[1]) {
56245624 '0'...'7' => {
56255625 // Octal
5626 lit_bytes = try std.fmt.allocPrint(c.arena, "0o{}", .{lit_bytes});
5626 lit_bytes = try std.fmt.allocPrint(c.arena, "0o{s}", .{lit_bytes});
56275627 },
56285628 'X' => {
56295629 // Hexadecimal with capital X, valid in C but not in Zig
5630 lit_bytes = try std.fmt.allocPrint(c.arena, "0x{}", .{lit_bytes[2..]});
5630 lit_bytes = try std.fmt.allocPrint(c.arena, "0x{s}", .{lit_bytes[2..]});
56315631 },
56325632 else => {},
56335633 }
......@@ -5659,7 +5659,7 @@ fn parseCNumLit(c: *Context, m: *MacroCtx) ParseError!*ast.Node {
56595659 },
56605660 .FloatLiteral => |suffix| {
56615661 if (lit_bytes[0] == '.')
5662 lit_bytes = try std.fmt.allocPrint(c.arena, "0{}", .{lit_bytes});
5662 lit_bytes = try std.fmt.allocPrint(c.arena, "0{s}", .{lit_bytes});
56635663 if (suffix == .none) {
56645664 return transCreateNodeFloat(c, lit_bytes);
56655665 }
......@@ -5937,7 +5937,7 @@ fn parseCPrimaryExprInner(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!*
59375937
59385938 const next_id = m.next().?;
59395939 if (next_id != .RParen) {
5940 try m.fail(c, "unable to translate C expr: expected ')' instead got: {}", .{@tagName(next_id)});
5940 try m.fail(c, "unable to translate C expr: expected ')' instead got: {s}", .{@tagName(next_id)});
59415941 return error.ParseError;
59425942 }
59435943 var saw_l_paren = false;
......@@ -5995,7 +5995,7 @@ fn parseCPrimaryExprInner(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!*
59955995 return &group_node.base;
59965996 },
59975997 else => {
5998 try m.fail(c, "unable to translate C expr: unexpected token .{}", .{@tagName(tok)});
5998 try m.fail(c, "unable to translate C expr: unexpected token .{s}", .{@tagName(tok)});
59995999 return error.ParseError;
60006000 },
60016001 }
src/value.zig+2-2
......@@ -464,7 +464,7 @@ pub const Value = extern union {
464464 .ty => return val.castTag(.ty).?.data.format("", options, out_stream),
465465 .int_type => {
466466 const int_type = val.castTag(.int_type).?.data;
467 return out_stream.print("{}{}", .{
467 return out_stream.print("{s}{d}", .{
468468 if (int_type.signed) "s" else "u",
469469 int_type.bits,
470470 });
......@@ -507,7 +507,7 @@ pub const Value = extern union {
507507 }
508508 return out_stream.writeAll("}");
509509 },
510 .@"error" => return out_stream.print("error.{}", .{val.castTag(.@"error").?.data.name}),
510 .@"error" => return out_stream.print("error.{s}", .{val.castTag(.@"error").?.data.name}),
511511 .inferred_alloc => return out_stream.writeAll("(inferred allocation value)"),
512512 };
513513 }
src/zir.zig+22-22
......@@ -1150,7 +1150,7 @@ pub const Module = struct {
11501150
11511151 for (self.decls) |decl, i| {
11521152 write.next_instr_index = 0;
1153 try stream.print("@{} ", .{decl.name});
1153 try stream.print("@{s} ", .{decl.name});
11541154 try write.writeInstToStream(stream, decl.inst);
11551155 try stream.writeByte('\n');
11561156 }
......@@ -1206,13 +1206,13 @@ const Writer = struct {
12061206 if (@typeInfo(arg_field.field_type) == .Optional) {
12071207 if (@field(inst.kw_args, arg_field.name)) |non_optional| {
12081208 if (need_comma) try stream.writeAll(", ");
1209 try stream.print("{}=", .{arg_field.name});
1209 try stream.print("{s}=", .{arg_field.name});
12101210 try self.writeParamToStream(stream, &non_optional);
12111211 need_comma = true;
12121212 }
12131213 } else {
12141214 if (need_comma) try stream.writeAll(", ");
1215 try stream.print("{}=", .{arg_field.name});
1215 try stream.print("{s}=", .{arg_field.name});
12161216 try self.writeParamToStream(stream, &@field(inst.kw_args, arg_field.name));
12171217 need_comma = true;
12181218 }
......@@ -1334,16 +1334,16 @@ const Writer = struct {
13341334 if (info.index) |i| {
13351335 try stream.print("%{}", .{info.index});
13361336 } else {
1337 try stream.print("@{}", .{info.name});
1337 try stream.print("@{s}", .{info.name});
13381338 }
13391339 } else if (inst.cast(Inst.DeclVal)) |decl_val| {
1340 try stream.print("@{}", .{decl_val.positionals.name});
1340 try stream.print("@{s}", .{decl_val.positionals.name});
13411341 } else if (inst.cast(Inst.DeclValInModule)) |decl_val| {
1342 try stream.print("@{}", .{decl_val.positionals.decl.name});
1342 try stream.print("@{s}", .{decl_val.positionals.decl.name});
13431343 } else {
13441344 // This should be unreachable in theory, but since ZIR is used for debugging the compiler
13451345 // we output some debug text instead.
1346 try stream.print("?{}?", .{@tagName(inst.tag)});
1346 try stream.print("?{s}?", .{@tagName(inst.tag)});
13471347 }
13481348 }
13491349};
......@@ -1424,7 +1424,7 @@ const Parser = struct {
14241424 const decl = try parseInstruction(self, &body_context, ident);
14251425 const ident_index = body_context.instructions.items.len;
14261426 if (try body_context.name_map.fetchPut(ident, decl.inst)) |_| {
1427 return self.fail("redefinition of identifier '{}'", .{ident});
1427 return self.fail("redefinition of identifier '{s}'", .{ident});
14281428 }
14291429 try body_context.instructions.append(decl.inst);
14301430 continue;
......@@ -1510,7 +1510,7 @@ const Parser = struct {
15101510 const decl = try parseInstruction(self, null, ident);
15111511 const ident_index = self.decls.items.len;
15121512 if (try self.global_name_map.fetchPut(ident, decl.inst)) |_| {
1513 return self.fail("redefinition of identifier '{}'", .{ident});
1513 return self.fail("redefinition of identifier '{s}'", .{ident});
15141514 }
15151515 try self.decls.append(self.allocator, decl);
15161516 },
......@@ -1538,7 +1538,7 @@ const Parser = struct {
15381538 for (bytes) |byte| {
15391539 if (self.source[self.i] != byte) {
15401540 self.i = start;
1541 return self.fail("expected '{}'", .{bytes});
1541 return self.fail("expected '{s}'", .{bytes});
15421542 }
15431543 self.i += 1;
15441544 }
......@@ -1585,7 +1585,7 @@ const Parser = struct {
15851585 return parseInstructionGeneric(self, field.name, tag.Type(), tag, body_ctx, name, contents_start);
15861586 }
15871587 }
1588 return self.fail("unknown instruction '{}'", .{fn_name});
1588 return self.fail("unknown instruction '{s}'", .{fn_name});
15891589 }
15901590
15911591 fn parseInstructionGeneric(
......@@ -1621,7 +1621,7 @@ const Parser = struct {
16211621 self.i += 1;
16221622 skipSpace(self);
16231623 } else if (self.source[self.i] == ')') {
1624 return self.fail("expected positional parameter '{}'", .{arg_field.name});
1624 return self.fail("expected positional parameter '{s}'", .{arg_field.name});
16251625 }
16261626 @field(inst_specific.positionals, arg_field.name) = try parseParameterGeneric(
16271627 self,
......@@ -1648,7 +1648,7 @@ const Parser = struct {
16481648 break;
16491649 }
16501650 } else {
1651 return self.fail("unrecognized keyword parameter: '{}'", .{name});
1651 return self.fail("unrecognized keyword parameter: '{s}'", .{name});
16521652 }
16531653 skipSpace(self);
16541654 }
......@@ -1672,7 +1672,7 @@ const Parser = struct {
16721672 ' ', '\n', ',', ')' => {
16731673 const enum_name = self.source[start..self.i];
16741674 return std.meta.stringToEnum(T, enum_name) orelse {
1675 return self.fail("tag '{}' not a member of enum '{}'", .{ enum_name, @typeName(T) });
1675 return self.fail("tag '{s}' not a member of enum '{s}'", .{ enum_name, @typeName(T) });
16761676 };
16771677 },
16781678 0 => return self.failByte(0),
......@@ -1710,7 +1710,7 @@ const Parser = struct {
17101710 BigIntConst => return self.parseIntegerLiteral(),
17111711 usize => {
17121712 const big_int = try self.parseIntegerLiteral();
1713 return big_int.to(usize) catch |err| return self.fail("integer literal: {}", .{@errorName(err)});
1713 return big_int.to(usize) catch |err| return self.fail("integer literal: {s}", .{@errorName(err)});
17141714 },
17151715 TypedValue => return self.fail("'const' is a special instruction; not legal in ZIR text", .{}),
17161716 *IrModule.Decl => return self.fail("'declval_in_module' is a special instruction; not legal in ZIR text", .{}),
......@@ -1759,7 +1759,7 @@ const Parser = struct {
17591759 },
17601760 else => @compileError("Unimplemented: ir parseParameterGeneric for type " ++ @typeName(T)),
17611761 }
1762 return self.fail("TODO parse parameter {}", .{@typeName(T)});
1762 return self.fail("TODO parse parameter {s}", .{@typeName(T)});
17631763 }
17641764
17651765 fn parseParameterInst(self: *Parser, body_ctx: ?*Body) !*Inst {
......@@ -1788,7 +1788,7 @@ const Parser = struct {
17881788 const src = name_start - 1;
17891789 if (local_ref) {
17901790 self.i = src;
1791 return self.fail("unrecognized identifier: {}", .{bad_name});
1791 return self.fail("unrecognized identifier: {s}", .{bad_name});
17921792 } else {
17931793 const declval = try self.arena.allocator.create(Inst.DeclVal);
17941794 declval.* = .{
......@@ -1873,7 +1873,7 @@ pub fn dumpFn(old_module: IrModule, module_fn: *IrModule.Fn) void {
18731873
18741874 const fn_ty = module_fn.owner_decl.typed_value.most_recent.typed_value.ty;
18751875 _ = ctx.emitFn(module_fn, 0, fn_ty) catch |err| {
1876 std.debug.print("unable to dump function: {}\n", .{err});
1876 std.debug.print("unable to dump function: {s}\n", .{@errorName(err)});
18771877 return;
18781878 };
18791879 var module = Module{
......@@ -2203,7 +2203,7 @@ const EmitZIR = struct {
22032203 };
22042204 return self.emitStringLiteral(src, bytes);
22052205 },
2206 else => |t| std.debug.panic("TODO implement emitTypedValue for pointer to {}", .{@tagName(t)}),
2206 else => |t| std.debug.panic("TODO implement emitTypedValue for pointer to {s}", .{@tagName(t)}),
22072207 }
22082208 },
22092209 .ComptimeInt => return self.emitComptimeIntVal(src, typed_value.val),
......@@ -2274,7 +2274,7 @@ const EmitZIR = struct {
22742274 };
22752275 return self.emitUnnamedDecl(&inst.base);
22762276 },
2277 else => |t| std.debug.panic("TODO implement emitTypedValue for {}", .{@tagName(t)}),
2277 else => |t| std.debug.panic("TODO implement emitTypedValue for {s}", .{@tagName(t)}),
22782278 }
22792279 }
22802280
......@@ -2947,7 +2947,7 @@ pub fn dumpZir(allocator: *Allocator, kind: []const u8, decl_name: [*:0]const u8
29472947 try write.inst_table.ensureCapacity(@intCast(u32, instructions.len));
29482948
29492949 const stderr = std.io.getStdErr().outStream();
2950 try stderr.print("{} {s} {{ // unanalyzed\n", .{ kind, decl_name });
2950 try stderr.print("{s} {s} {{ // unanalyzed\n", .{ kind, decl_name });
29512951
29522952 for (instructions) |inst| {
29532953 const my_i = write.next_instr_index;
......@@ -2967,5 +2967,5 @@ pub fn dumpZir(allocator: *Allocator, kind: []const u8, decl_name: [*:0]const u8
29672967 try stderr.writeByte('\n');
29682968 }
29692969
2970 try stderr.print("}} // {} {s}\n\n", .{ kind, decl_name });
2970 try stderr.print("}} // {s} {s}\n\n", .{ kind, decl_name });
29712971}
src/zir_sema.zig+17-17
......@@ -274,7 +274,7 @@ pub fn resolveInst(mod: *Module, scope: *Scope, old_inst: *zir.Inst) InnerError!
274274 const entry = if (old_inst.cast(zir.Inst.DeclVal)) |declval| blk: {
275275 const decl_name = declval.positionals.name;
276276 const entry = zir_module.contents.module.findDecl(decl_name) orelse
277 return mod.fail(scope, old_inst.src, "decl '{}' not found", .{decl_name});
277 return mod.fail(scope, old_inst.src, "decl '{s}' not found", .{decl_name});
278278 break :blk entry;
279279 } else blk: {
280280 // If this assert trips, the instruction that was referenced did not get
......@@ -564,14 +564,14 @@ fn analyzeInstStr(mod: *Module, scope: *Scope, str_inst: *zir.Inst.Str) InnerErr
564564fn analyzeInstExport(mod: *Module, scope: *Scope, export_inst: *zir.Inst.Export) InnerError!*Inst {
565565 const symbol_name = try resolveConstString(mod, scope, export_inst.positionals.symbol_name);
566566 const exported_decl = mod.lookupDeclName(scope, export_inst.positionals.decl_name) orelse
567 return mod.fail(scope, export_inst.base.src, "decl '{}' not found", .{export_inst.positionals.decl_name});
567 return mod.fail(scope, export_inst.base.src, "decl '{s}' not found", .{export_inst.positionals.decl_name});
568568 try mod.analyzeExport(scope, export_inst.base.src, symbol_name, exported_decl);
569569 return mod.constVoid(scope, export_inst.base.src);
570570}
571571
572572fn analyzeInstCompileError(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst {
573573 const msg = try resolveConstString(mod, scope, inst.positionals.operand);
574 return mod.fail(scope, inst.base.src, "{}", .{msg});
574 return mod.fail(scope, inst.base.src, "{s}", .{msg});
575575}
576576
577577fn analyzeInstArg(mod: *Module, scope: *Scope, inst: *zir.Inst.Arg) InnerError!*Inst {
......@@ -918,7 +918,7 @@ fn analyzeInstErrorSet(mod: *Module, scope: *Scope, inst: *zir.Inst.ErrorSet) In
918918 for (inst.positionals.fields) |field_name| {
919919 const entry = try mod.getErrorValue(field_name);
920920 if (payload.data.fields.fetchPutAssumeCapacity(entry.key, entry.value)) |prev| {
921 return mod.fail(scope, inst.base.src, "duplicate error: '{}'", .{field_name});
921 return mod.fail(scope, inst.base.src, "duplicate error: '{s}'", .{field_name});
922922 }
923923 }
924924 // TODO create name in format "error:line:column"
......@@ -1068,7 +1068,7 @@ fn analyzeInstFieldPtr(mod: *Module, scope: *Scope, fieldptr: *zir.Inst.FieldPtr
10681068 return mod.fail(
10691069 scope,
10701070 fieldptr.positionals.field_name.src,
1071 "no member named '{}' in '{}'",
1071 "no member named '{s}' in '{}'",
10721072 .{ field_name, elem_ty },
10731073 );
10741074 }
......@@ -1089,7 +1089,7 @@ fn analyzeInstFieldPtr(mod: *Module, scope: *Scope, fieldptr: *zir.Inst.FieldPtr
10891089 return mod.fail(
10901090 scope,
10911091 fieldptr.positionals.field_name.src,
1092 "no member named '{}' in '{}'",
1092 "no member named '{s}' in '{}'",
10931093 .{ field_name, elem_ty },
10941094 );
10951095 }
......@@ -1107,7 +1107,7 @@ fn analyzeInstFieldPtr(mod: *Module, scope: *Scope, fieldptr: *zir.Inst.FieldPtr
11071107 // TODO resolve inferred error sets
11081108 const entry = if (val.castTag(.error_set)) |payload|
11091109 (payload.data.fields.getEntry(field_name) orelse
1110 return mod.fail(scope, fieldptr.base.src, "no error named '{}' in '{}'", .{ field_name, child_type })).*
1110 return mod.fail(scope, fieldptr.base.src, "no error named '{s}' in '{}'", .{ field_name, child_type })).*
11111111 else
11121112 try mod.getErrorValue(field_name);
11131113
......@@ -1135,9 +1135,9 @@ fn analyzeInstFieldPtr(mod: *Module, scope: *Scope, fieldptr: *zir.Inst.FieldPtr
11351135 }
11361136
11371137 if (&container_scope.file_scope.base == mod.root_scope) {
1138 return mod.fail(scope, fieldptr.base.src, "root source file has no member called '{}'", .{field_name});
1138 return mod.fail(scope, fieldptr.base.src, "root source file has no member called '{s}'", .{field_name});
11391139 } else {
1140 return mod.fail(scope, fieldptr.base.src, "container '{}' has no member called '{}'", .{ child_type, field_name });
1140 return mod.fail(scope, fieldptr.base.src, "container '{}' has no member called '{s}'", .{ child_type, field_name });
11411141 }
11421142 },
11431143 else => return mod.fail(scope, fieldptr.base.src, "type '{}' does not support field access", .{child_type}),
......@@ -1503,14 +1503,14 @@ fn analyzeInstImport(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerErr
15031503
15041504 const file_scope = mod.analyzeImport(scope, inst.base.src, operand) catch |err| switch (err) {
15051505 error.ImportOutsidePkgPath => {
1506 return mod.fail(scope, inst.base.src, "import of file outside package path: '{}'", .{operand});
1506 return mod.fail(scope, inst.base.src, "import of file outside package path: '{s}'", .{operand});
15071507 },
15081508 error.FileNotFound => {
1509 return mod.fail(scope, inst.base.src, "unable to find '{}'", .{operand});
1509 return mod.fail(scope, inst.base.src, "unable to find '{s}'", .{operand});
15101510 },
15111511 else => {
15121512 // TODO user friendly error to string
1513 return mod.fail(scope, inst.base.src, "unable to open '{}': {}", .{ operand, @errorName(err) });
1513 return mod.fail(scope, inst.base.src, "unable to open '{s}': {s}", .{ operand, @errorName(err) });
15141514 },
15151515 };
15161516 return mod.constType(scope, inst.base.src, file_scope.root_container.ty);
......@@ -1637,7 +1637,7 @@ fn analyzeInstArithmetic(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) Inn
16371637 const is_float = scalar_tag == .Float or scalar_tag == .ComptimeFloat;
16381638
16391639 if (!is_int and !(is_float and floatOpAllowed(inst.base.tag))) {
1640 return mod.fail(scope, inst.base.src, "invalid operands to binary expression: '{}' and '{}'", .{ @tagName(lhs.ty.zigTypeTag()), @tagName(rhs.ty.zigTypeTag()) });
1640 return mod.fail(scope, inst.base.src, "invalid operands to binary expression: '{s}' and '{s}'", .{ @tagName(lhs.ty.zigTypeTag()), @tagName(rhs.ty.zigTypeTag()) });
16411641 }
16421642
16431643 if (casted_lhs.value()) |lhs_val| {
......@@ -1656,7 +1656,7 @@ fn analyzeInstArithmetic(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) Inn
16561656 const ir_tag = switch (inst.base.tag) {
16571657 .add => Inst.Tag.add,
16581658 .sub => Inst.Tag.sub,
1659 else => return mod.fail(scope, inst.base.src, "TODO implement arithmetic for operand '{}''", .{@tagName(inst.base.tag)}),
1659 else => return mod.fail(scope, inst.base.src, "TODO implement arithmetic for operand '{s}''", .{@tagName(inst.base.tag)}),
16601660 };
16611661
16621662 return mod.addBinOp(b, inst.base.src, scalar_type, ir_tag, casted_lhs, casted_rhs);
......@@ -1689,7 +1689,7 @@ fn analyzeInstComptimeOp(mod: *Module, scope: *Scope, res_type: Type, inst: *zir
16891689 mod.floatSub(scope, res_type, inst.base.src, lhs_val, rhs_val);
16901690 break :blk val;
16911691 },
1692 else => return mod.fail(scope, inst.base.src, "TODO Implement arithmetic operand '{}'", .{@tagName(inst.base.tag)}),
1692 else => return mod.fail(scope, inst.base.src, "TODO Implement arithmetic operand '{s}'", .{@tagName(inst.base.tag)}),
16931693 };
16941694
16951695 return mod.constInst(scope, inst.base.src, .{
......@@ -1781,7 +1781,7 @@ fn analyzeInstCmp(
17811781 return mod.fail(scope, inst.base.src, "TODO implement equality comparison between a union's tag value and an enum literal", .{});
17821782 } else if (lhs_ty_tag == .ErrorSet and rhs_ty_tag == .ErrorSet) {
17831783 if (!is_equality_cmp) {
1784 return mod.fail(scope, inst.base.src, "{} operator not allowed for errors", .{@tagName(op)});
1784 return mod.fail(scope, inst.base.src, "{s} operator not allowed for errors", .{@tagName(op)});
17851785 }
17861786 return mod.fail(scope, inst.base.src, "TODO implement equality comparison between errors", .{});
17871787 } else if (lhs.ty.isNumeric() and rhs.ty.isNumeric()) {
......@@ -1962,7 +1962,7 @@ fn analyzeDeclVal(mod: *Module, scope: *Scope, inst: *zir.Inst.DeclVal) InnerErr
19621962 const decl_name = inst.positionals.name;
19631963 const zir_module = scope.namespace().cast(Scope.ZIRModule).?;
19641964 const src_decl = zir_module.contents.module.findDecl(decl_name) orelse
1965 return mod.fail(scope, inst.base.src, "use of undeclared identifier '{}'", .{decl_name});
1965 return mod.fail(scope, inst.base.src, "use of undeclared identifier '{s}'", .{decl_name});
19661966
19671967 const decl = try resolveCompleteZirDecl(mod, scope, src_decl.decl);
19681968