authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-01-02 19:03:37-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-01-02 19:03:37-07:00
logfb37c1b0912c65d72b82f32df8bc7e780ab1ad80
treec12b14dceebe7f6055fe07cfed2780d2b5c7bf60
parentdb1e97d4b19d8399252e0fbc85fc3563b005a892
parent974c008a0ee0e0d7933e37d5ea930f712d494f6a

Merge branch 'LemonBoy-revive-6680'

closes #6870

76 files changed, 912 insertions(+), 847 deletions(-)

build.zig+8-8
......@@ -224,7 +224,7 @@ pub fn build(b: *Builder) !void {
224224
225225 const opt_version_string = b.option([]const u8, "version-string", "Override Zig version string. Default is to find out with git.");
226226 const version = if (opt_version_string) |version| version else v: {
227 const version_string = b.fmt("{}.{}.{}", .{ zig_version.major, zig_version.minor, zig_version.patch });
227 const version_string = b.fmt("{d}.{d}.{d}", .{ zig_version.major, zig_version.minor, zig_version.patch });
228228
229229 var code: u8 = undefined;
230230 const git_describe_untrimmed = b.execAllowFail(&[_][]const u8{
......@@ -238,7 +238,7 @@ pub fn build(b: *Builder) !void {
238238 0 => {
239239 // Tagged release version (e.g. 0.7.0).
240240 if (!mem.eql(u8, git_describe, version_string)) {
241 std.debug.print("Zig version '{}' does not match Git tag '{}'\n", .{ version_string, git_describe });
241 std.debug.print("Zig version '{s}' does not match Git tag '{s}'\n", .{ version_string, git_describe });
242242 std.process.exit(1);
243243 }
244244 break :v version_string;
......@@ -258,15 +258,15 @@ pub fn build(b: *Builder) !void {
258258
259259 // Check that the commit hash is prefixed with a 'g' (a Git convention).
260260 if (commit_id.len < 1 or commit_id[0] != 'g') {
261 std.debug.print("Unexpected `git describe` output: {}\n", .{git_describe});
261 std.debug.print("Unexpected `git describe` output: {s}\n", .{git_describe});
262262 break :v version_string;
263263 }
264264
265265 // The version is reformatted in accordance with the https://semver.org specification.
266 break :v b.fmt("{}-dev.{}+{}", .{ version_string, commit_height, commit_id[1..] });
266 break :v b.fmt("{s}-dev.{s}+{s}", .{ version_string, commit_height, commit_id[1..] });
267267 },
268268 else => {
269 std.debug.print("Unexpected `git describe` output: {}\n", .{git_describe});
269 std.debug.print("Unexpected `git describe` output: {s}\n", .{git_describe});
270270 break :v version_string;
271271 },
272272 }
......@@ -369,14 +369,14 @@ fn addCxxKnownPath(
369369) !void {
370370 const path_padded = try b.exec(&[_][]const u8{
371371 ctx.cxx_compiler,
372 b.fmt("-print-file-name={}", .{objname}),
372 b.fmt("-print-file-name={s}", .{objname}),
373373 });
374374 const path_unpadded = mem.tokenize(path_padded, "\r\n").next().?;
375375 if (mem.eql(u8, path_unpadded, objname)) {
376376 if (errtxt) |msg| {
377 warn("{}", .{msg});
377 warn("{s}", .{msg});
378378 } else {
379 warn("Unable to determine path to {}\n", .{objname});
379 warn("Unable to determine path to {s}\n", .{objname});
380380 }
381381 return error.RequiredLibraryNotFound;
382382 }
doc/docgen.zig+54-54
......@@ -215,9 +215,9 @@ const Tokenizer = struct {
215215fn parseError(tokenizer: *Tokenizer, token: Token, comptime fmt: []const u8, args: anytype) anyerror {
216216 const loc = tokenizer.getTokenLocation(token);
217217 const args_prefix = .{ tokenizer.source_file_name, loc.line + 1, loc.column + 1 };
218 print("{}:{}:{}: error: " ++ fmt ++ "\n", args_prefix ++ args);
218 print("{s}:{d}:{d}: error: " ++ fmt ++ "\n", args_prefix ++ args);
219219 if (loc.line_start <= loc.line_end) {
220 print("{}\n", .{tokenizer.buffer[loc.line_start..loc.line_end]});
220 print("{s}\n", .{tokenizer.buffer[loc.line_start..loc.line_end]});
221221 {
222222 var i: usize = 0;
223223 while (i < loc.column) : (i += 1) {
......@@ -238,7 +238,7 @@ fn parseError(tokenizer: *Tokenizer, token: Token, comptime fmt: []const u8, arg
238238
239239fn assertToken(tokenizer: *Tokenizer, token: Token, id: Token.Id) !void {
240240 if (token.id != id) {
241 return parseError(tokenizer, token, "expected {}, found {}", .{ @tagName(id), @tagName(token.id) });
241 return parseError(tokenizer, token, "expected {s}, found {s}", .{ @tagName(id), @tagName(token.id) });
242242 }
243243}
244244
......@@ -374,7 +374,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc {
374374 return parseError(
375375 tokenizer,
376376 bracket_tok,
377 "unrecognized header_open param: {}",
377 "unrecognized header_open param: {s}",
378378 .{param},
379379 );
380380 }
......@@ -394,7 +394,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc {
394394 },
395395 });
396396 if (try urls.fetchPut(urlized, tag_token)) |entry| {
397 parseError(tokenizer, tag_token, "duplicate header url: #{}", .{urlized}) catch {};
397 parseError(tokenizer, tag_token, "duplicate header url: #{s}", .{urlized}) catch {};
398398 parseError(tokenizer, entry.value, "other tag here", .{}) catch {};
399399 return error.ParseError;
400400 }
......@@ -411,7 +411,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc {
411411 }
412412 last_columns = columns;
413413 try toc.writeByteNTimes(' ', 4 + header_stack_size * 4);
414 try toc.print("<li><a id=\"toc-{}\" href=\"#{}\">{}</a>", .{ urlized, urlized, content });
414 try toc.print("<li><a id=\"toc-{s}\" href=\"#{s}\">{s}</a>", .{ urlized, urlized, content });
415415 } else if (mem.eql(u8, tag_name, "header_close")) {
416416 if (header_stack_size == 0) {
417417 return parseError(tokenizer, tag_token, "unbalanced close header", .{});
......@@ -515,7 +515,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc {
515515 code_kind_id = Code.Id{ .Obj = null };
516516 is_inline = true;
517517 } else {
518 return parseError(tokenizer, code_kind_tok, "unrecognized code kind: {}", .{code_kind_str});
518 return parseError(tokenizer, code_kind_tok, "unrecognized code kind: {s}", .{code_kind_str});
519519 }
520520
521521 var mode: builtin.Mode = .Debug;
......@@ -559,7 +559,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc {
559559 return parseError(
560560 tokenizer,
561561 end_code_tag,
562 "invalid token inside code_begin: {}",
562 "invalid token inside code_begin: {s}",
563563 .{end_tag_name},
564564 );
565565 }
......@@ -590,14 +590,14 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc {
590590 return parseError(
591591 tokenizer,
592592 end_syntax_tag,
593 "invalid token inside syntax: {}",
593 "invalid token inside syntax: {s}",
594594 .{end_tag_name},
595595 );
596596 }
597597 _ = try eatToken(tokenizer, Token.Id.BracketClose);
598598 try nodes.append(Node{ .Syntax = content_tok });
599599 } else {
600 return parseError(tokenizer, tag_token, "unrecognized tag name: {}", .{tag_name});
600 return parseError(tokenizer, tag_token, "unrecognized tag name: {s}", .{tag_name});
601601 }
602602 },
603603 else => return parseError(tokenizer, token, "invalid token", .{}),
......@@ -744,7 +744,7 @@ fn termColor(allocator: *mem.Allocator, input: []const u8) ![]u8 {
744744 try out.writeAll("</span>");
745745 }
746746 if (first_number != 0 or second_number != 0) {
747 try out.print("<span class=\"t{}_{}\">", .{ first_number, second_number });
747 try out.print("<span class=\"t{d}_{d}\">", .{ first_number, second_number });
748748 open_span_count += 1;
749749 }
750750 },
......@@ -1004,9 +1004,9 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
10041004 },
10051005 .Link => |info| {
10061006 if (!toc.urls.contains(info.url)) {
1007 return parseError(tokenizer, info.token, "url not found: {}", .{info.url});
1007 return parseError(tokenizer, info.token, "url not found: {s}", .{info.url});
10081008 }
1009 try out.print("<a href=\"#{}\">{}</a>", .{ info.url, info.name });
1009 try out.print("<a href=\"#{s}\">{s}</a>", .{ info.url, info.name });
10101010 },
10111011 .Nav => {
10121012 try out.writeAll(toc.toc);
......@@ -1018,7 +1018,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
10181018 },
10191019 .HeaderOpen => |info| {
10201020 try out.print(
1021 "<h{} id=\"{}\"><a href=\"#toc-{}\">{}</a> <a class=\"hdr\" href=\"#{}\">§</a></h{}>\n",
1021 "<h{d} id=\"{s}\"><a href=\"#toc-{s}\">{s}</a> <a class=\"hdr\" href=\"#{s}\">§</a></h{d}>\n",
10221022 .{ info.n, info.url, info.url, info.name, info.url, info.n },
10231023 );
10241024 },
......@@ -1027,9 +1027,9 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
10271027 for (items) |item| {
10281028 const url = try urlize(allocator, item.name);
10291029 if (!toc.urls.contains(url)) {
1030 return parseError(tokenizer, item.token, "url not found: {}", .{url});
1030 return parseError(tokenizer, item.token, "url not found: {s}", .{url});
10311031 }
1032 try out.print("<li><a href=\"#{}\">{}</a></li>\n", .{ url, item.name });
1032 try out.print("<li><a href=\"#{s}\">{s}</a></li>\n", .{ url, item.name });
10331033 }
10341034 try out.writeAll("</ul>\n");
10351035 },
......@@ -1043,12 +1043,12 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
10431043 const raw_source = tokenizer.buffer[code.source_token.start..code.source_token.end];
10441044 const trimmed_raw_source = mem.trim(u8, raw_source, " \n");
10451045 if (!code.is_inline) {
1046 try out.print("<p class=\"file\">{}.zig</p>", .{code.name});
1046 try out.print("<p class=\"file\">{s}.zig</p>", .{code.name});
10471047 }
10481048 try out.writeAll("<pre>");
10491049 try tokenizeAndPrint(tokenizer, out, code.source_token);
10501050 try out.writeAll("</pre>");
1051 const name_plus_ext = try std.fmt.allocPrint(allocator, "{}.zig", .{code.name});
1051 const name_plus_ext = try std.fmt.allocPrint(allocator, "{s}.zig", .{code.name});
10521052 const tmp_source_file_name = try fs.path.join(
10531053 allocator,
10541054 &[_][]const u8{ tmp_dir_name, name_plus_ext },
......@@ -1057,7 +1057,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
10571057
10581058 switch (code.id) {
10591059 Code.Id.Exe => |expected_outcome| code_block: {
1060 const name_plus_bin_ext = try std.fmt.allocPrint(allocator, "{}{}", .{ code.name, exe_ext });
1060 const name_plus_bin_ext = try std.fmt.allocPrint(allocator, "{s}{s}", .{ code.name, exe_ext });
10611061 var build_args = std.ArrayList([]const u8).init(allocator);
10621062 defer build_args.deinit();
10631063 try build_args.appendSlice(&[_][]const u8{
......@@ -1066,7 +1066,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
10661066 "--color", "on",
10671067 "--enable-cache", tmp_source_file_name,
10681068 });
1069 try out.print("<pre><code class=\"shell\">$ zig build-exe {}.zig", .{code.name});
1069 try out.print("<pre><code class=\"shell\">$ zig build-exe {s}.zig", .{code.name});
10701070 switch (code.mode) {
10711071 .Debug => {},
10721072 else => {
......@@ -1075,7 +1075,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
10751075 },
10761076 }
10771077 for (code.link_objects) |link_object| {
1078 const name_with_ext = try std.fmt.allocPrint(allocator, "{}{}", .{ link_object, obj_ext });
1078 const name_with_ext = try std.fmt.allocPrint(allocator, "{s}{s}", .{ link_object, obj_ext });
10791079 const full_path_object = try fs.path.join(
10801080 allocator,
10811081 &[_][]const u8{ tmp_dir_name, name_with_ext },
......@@ -1093,7 +1093,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
10931093 if (code.target_str) |triple| {
10941094 try build_args.appendSlice(&[_][]const u8{ "-target", triple });
10951095 if (!code.is_inline) {
1096 try out.print(" -target {}", .{triple});
1096 try out.print(" -target {s}", .{triple});
10971097 }
10981098 }
10991099 if (expected_outcome == .BuildFail) {
......@@ -1106,20 +1106,20 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
11061106 switch (result.term) {
11071107 .Exited => |exit_code| {
11081108 if (exit_code == 0) {
1109 print("{}\nThe following command incorrectly succeeded:\n", .{result.stderr});
1109 print("{s}\nThe following command incorrectly succeeded:\n", .{result.stderr});
11101110 dumpArgs(build_args.items);
11111111 return parseError(tokenizer, code.source_token, "example incorrectly compiled", .{});
11121112 }
11131113 },
11141114 else => {
1115 print("{}\nThe following command crashed:\n", .{result.stderr});
1115 print("{s}\nThe following command crashed:\n", .{result.stderr});
11161116 dumpArgs(build_args.items);
11171117 return parseError(tokenizer, code.source_token, "example compile crashed", .{});
11181118 },
11191119 }
11201120 const escaped_stderr = try escapeHtml(allocator, result.stderr);
11211121 const colored_stderr = try termColor(allocator, escaped_stderr);
1122 try out.print("\n{}</code></pre>\n", .{colored_stderr});
1122 try out.print("\n{s}</code></pre>\n", .{colored_stderr});
11231123 break :code_block;
11241124 }
11251125 const exec_result = exec(allocator, &env_map, build_args.items) catch
......@@ -1138,7 +1138,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
11381138 }
11391139
11401140 const path_to_exe_dir = mem.trim(u8, exec_result.stdout, " \r\n");
1141 const path_to_exe_basename = try std.fmt.allocPrint(allocator, "{}{}", .{
1141 const path_to_exe_basename = try std.fmt.allocPrint(allocator, "{s}{s}", .{
11421142 code.name,
11431143 target.exeFileExt(),
11441144 });
......@@ -1160,7 +1160,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
11601160 switch (result.term) {
11611161 .Exited => |exit_code| {
11621162 if (exit_code == 0) {
1163 print("{}\nThe following command incorrectly succeeded:\n", .{result.stderr});
1163 print("{s}\nThe following command incorrectly succeeded:\n", .{result.stderr});
11641164 dumpArgs(run_args);
11651165 return parseError(tokenizer, code.source_token, "example incorrectly compiled", .{});
11661166 }
......@@ -1179,7 +1179,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
11791179 const colored_stderr = try termColor(allocator, escaped_stderr);
11801180 const colored_stdout = try termColor(allocator, escaped_stdout);
11811181
1182 try out.print("\n$ ./{}\n{}{}", .{ code.name, colored_stdout, colored_stderr });
1182 try out.print("\n$ ./{s}\n{s}{s}", .{ code.name, colored_stdout, colored_stderr });
11831183 if (exited_with_signal) {
11841184 try out.print("(process terminated by signal)", .{});
11851185 }
......@@ -1190,7 +1190,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
11901190 defer test_args.deinit();
11911191
11921192 try test_args.appendSlice(&[_][]const u8{ zig_exe, "test", tmp_source_file_name });
1193 try out.print("<pre><code class=\"shell\">$ zig test {}.zig", .{code.name});
1193 try out.print("<pre><code class=\"shell\">$ zig test {s}.zig", .{code.name});
11941194 switch (code.mode) {
11951195 .Debug => {},
11961196 else => {
......@@ -1204,12 +1204,12 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
12041204 }
12051205 if (code.target_str) |triple| {
12061206 try test_args.appendSlice(&[_][]const u8{ "-target", triple });
1207 try out.print(" -target {}", .{triple});
1207 try out.print(" -target {s}", .{triple});
12081208 }
12091209 const result = exec(allocator, &env_map, test_args.items) catch return parseError(tokenizer, code.source_token, "test failed", .{});
12101210 const escaped_stderr = try escapeHtml(allocator, result.stderr);
12111211 const escaped_stdout = try escapeHtml(allocator, result.stdout);
1212 try out.print("\n{}{}</code></pre>\n", .{ escaped_stderr, escaped_stdout });
1212 try out.print("\n{s}{s}</code></pre>\n", .{ escaped_stderr, escaped_stdout });
12131213 },
12141214 Code.Id.TestError => |error_match| {
12151215 var test_args = std.ArrayList([]const u8).init(allocator);
......@@ -1222,7 +1222,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
12221222 "on",
12231223 tmp_source_file_name,
12241224 });
1225 try out.print("<pre><code class=\"shell\">$ zig test {}.zig", .{code.name});
1225 try out.print("<pre><code class=\"shell\">$ zig test {s}.zig", .{code.name});
12261226 switch (code.mode) {
12271227 .Debug => {},
12281228 else => {
......@@ -1239,24 +1239,24 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
12391239 switch (result.term) {
12401240 .Exited => |exit_code| {
12411241 if (exit_code == 0) {
1242 print("{}\nThe following command incorrectly succeeded:\n", .{result.stderr});
1242 print("{s}\nThe following command incorrectly succeeded:\n", .{result.stderr});
12431243 dumpArgs(test_args.items);
12441244 return parseError(tokenizer, code.source_token, "example incorrectly compiled", .{});
12451245 }
12461246 },
12471247 else => {
1248 print("{}\nThe following command crashed:\n", .{result.stderr});
1248 print("{s}\nThe following command crashed:\n", .{result.stderr});
12491249 dumpArgs(test_args.items);
12501250 return parseError(tokenizer, code.source_token, "example compile crashed", .{});
12511251 },
12521252 }
12531253 if (mem.indexOf(u8, result.stderr, error_match) == null) {
1254 print("{}\nExpected to find '{}' in stderr\n", .{ result.stderr, error_match });
1254 print("{s}\nExpected to find '{s}' in stderr\n", .{ result.stderr, error_match });
12551255 return parseError(tokenizer, code.source_token, "example did not have expected compile error", .{});
12561256 }
12571257 const escaped_stderr = try escapeHtml(allocator, result.stderr);
12581258 const colored_stderr = try termColor(allocator, escaped_stderr);
1259 try out.print("\n{}</code></pre>\n", .{colored_stderr});
1259 try out.print("\n{s}</code></pre>\n", .{colored_stderr});
12601260 },
12611261
12621262 Code.Id.TestSafety => |error_match| {
......@@ -1294,31 +1294,31 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
12941294 switch (result.term) {
12951295 .Exited => |exit_code| {
12961296 if (exit_code == 0) {
1297 print("{}\nThe following command incorrectly succeeded:\n", .{result.stderr});
1297 print("{s}\nThe following command incorrectly succeeded:\n", .{result.stderr});
12981298 dumpArgs(test_args.items);
12991299 return parseError(tokenizer, code.source_token, "example test incorrectly succeeded", .{});
13001300 }
13011301 },
13021302 else => {
1303 print("{}\nThe following command crashed:\n", .{result.stderr});
1303 print("{s}\nThe following command crashed:\n", .{result.stderr});
13041304 dumpArgs(test_args.items);
13051305 return parseError(tokenizer, code.source_token, "example compile crashed", .{});
13061306 },
13071307 }
13081308 if (mem.indexOf(u8, result.stderr, error_match) == null) {
1309 print("{}\nExpected to find '{}' in stderr\n", .{ result.stderr, error_match });
1309 print("{s}\nExpected to find '{s}' in stderr\n", .{ result.stderr, error_match });
13101310 return parseError(tokenizer, code.source_token, "example did not have expected runtime safety error message", .{});
13111311 }
13121312 const escaped_stderr = try escapeHtml(allocator, result.stderr);
13131313 const colored_stderr = try termColor(allocator, escaped_stderr);
1314 try out.print("<pre><code class=\"shell\">$ zig test {}.zig{}\n{}</code></pre>\n", .{
1314 try out.print("<pre><code class=\"shell\">$ zig test {s}.zig{s}\n{s}</code></pre>\n", .{
13151315 code.name,
13161316 mode_arg,
13171317 colored_stderr,
13181318 });
13191319 },
13201320 Code.Id.Obj => |maybe_error_match| {
1321 const name_plus_obj_ext = try std.fmt.allocPrint(allocator, "{}{}", .{ code.name, obj_ext });
1321 const name_plus_obj_ext = try std.fmt.allocPrint(allocator, "{s}{s}", .{ code.name, obj_ext });
13221322 const tmp_obj_file_name = try fs.path.join(
13231323 allocator,
13241324 &[_][]const u8{ tmp_dir_name, name_plus_obj_ext },
......@@ -1326,7 +1326,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
13261326 var build_args = std.ArrayList([]const u8).init(allocator);
13271327 defer build_args.deinit();
13281328
1329 const name_plus_h_ext = try std.fmt.allocPrint(allocator, "{}.h", .{code.name});
1329 const name_plus_h_ext = try std.fmt.allocPrint(allocator, "{s}.h", .{code.name});
13301330 const output_h_file_name = try fs.path.join(
13311331 allocator,
13321332 &[_][]const u8{ tmp_dir_name, name_plus_h_ext },
......@@ -1345,7 +1345,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
13451345 }),
13461346 });
13471347 if (!code.is_inline) {
1348 try out.print("<pre><code class=\"shell\">$ zig build-obj {}.zig", .{code.name});
1348 try out.print("<pre><code class=\"shell\">$ zig build-obj {s}.zig", .{code.name});
13491349 }
13501350
13511351 switch (code.mode) {
......@@ -1360,7 +1360,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
13601360
13611361 if (code.target_str) |triple| {
13621362 try build_args.appendSlice(&[_][]const u8{ "-target", triple });
1363 try out.print(" -target {}", .{triple});
1363 try out.print(" -target {s}", .{triple});
13641364 }
13651365
13661366 if (maybe_error_match) |error_match| {
......@@ -1373,24 +1373,24 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
13731373 switch (result.term) {
13741374 .Exited => |exit_code| {
13751375 if (exit_code == 0) {
1376 print("{}\nThe following command incorrectly succeeded:\n", .{result.stderr});
1376 print("{s}\nThe following command incorrectly succeeded:\n", .{result.stderr});
13771377 dumpArgs(build_args.items);
13781378 return parseError(tokenizer, code.source_token, "example build incorrectly succeeded", .{});
13791379 }
13801380 },
13811381 else => {
1382 print("{}\nThe following command crashed:\n", .{result.stderr});
1382 print("{s}\nThe following command crashed:\n", .{result.stderr});
13831383 dumpArgs(build_args.items);
13841384 return parseError(tokenizer, code.source_token, "example compile crashed", .{});
13851385 },
13861386 }
13871387 if (mem.indexOf(u8, result.stderr, error_match) == null) {
1388 print("{}\nExpected to find '{}' in stderr\n", .{ result.stderr, error_match });
1388 print("{s}\nExpected to find '{s}' in stderr\n", .{ result.stderr, error_match });
13891389 return parseError(tokenizer, code.source_token, "example did not have expected compile error message", .{});
13901390 }
13911391 const escaped_stderr = try escapeHtml(allocator, result.stderr);
13921392 const colored_stderr = try termColor(allocator, escaped_stderr);
1393 try out.print("\n{}", .{colored_stderr});
1393 try out.print("\n{s}", .{colored_stderr});
13941394 } else {
13951395 _ = exec(allocator, &env_map, build_args.items) catch return parseError(tokenizer, code.source_token, "example failed to compile", .{});
13961396 }
......@@ -1416,7 +1416,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
14161416 tmp_dir_name, fs.path.sep_str, bin_basename,
14171417 }),
14181418 });
1419 try out.print("<pre><code class=\"shell\">$ zig build-lib {}.zig", .{code.name});
1419 try out.print("<pre><code class=\"shell\">$ zig build-lib {s}.zig", .{code.name});
14201420 switch (code.mode) {
14211421 .Debug => {},
14221422 else => {
......@@ -1426,12 +1426,12 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
14261426 }
14271427 if (code.target_str) |triple| {
14281428 try test_args.appendSlice(&[_][]const u8{ "-target", triple });
1429 try out.print(" -target {}", .{triple});
1429 try out.print(" -target {s}", .{triple});
14301430 }
14311431 const result = exec(allocator, &env_map, test_args.items) catch return parseError(tokenizer, code.source_token, "test failed", .{});
14321432 const escaped_stderr = try escapeHtml(allocator, result.stderr);
14331433 const escaped_stdout = try escapeHtml(allocator, result.stdout);
1434 try out.print("\n{}{}</code></pre>\n", .{ escaped_stderr, escaped_stdout });
1434 try out.print("\n{s}{s}</code></pre>\n", .{ escaped_stderr, escaped_stdout });
14351435 },
14361436 }
14371437 print("OK\n", .{});
......@@ -1450,13 +1450,13 @@ fn exec(allocator: *mem.Allocator, env_map: *std.BufMap, args: []const []const u
14501450 switch (result.term) {
14511451 .Exited => |exit_code| {
14521452 if (exit_code != 0) {
1453 print("{}\nThe following command exited with code {}:\n", .{ result.stderr, exit_code });
1453 print("{s}\nThe following command exited with code {}:\n", .{ result.stderr, exit_code });
14541454 dumpArgs(args);
14551455 return error.ChildExitError;
14561456 }
14571457 },
14581458 else => {
1459 print("{}\nThe following command crashed:\n", .{result.stderr});
1459 print("{s}\nThe following command crashed:\n", .{result.stderr});
14601460 dumpArgs(args);
14611461 return error.ChildCrashed;
14621462 },
......@@ -1471,7 +1471,7 @@ fn getBuiltinCode(allocator: *mem.Allocator, env_map: *std.BufMap, zig_exe: []co
14711471
14721472fn dumpArgs(args: []const []const u8) void {
14731473 for (args) |arg|
1474 print("{} ", .{arg})
1474 print("{s} ", .{arg})
14751475 else
14761476 print("\n", .{});
14771477}
doc/langref.html.in+21-21
......@@ -236,7 +236,7 @@ const std = @import("std");
236236
237237pub fn main() !void {
238238 const stdout = std.io.getStdOut().writer();
239 try stdout.print("Hello, {}!\n", .{"world"});
239 try stdout.print("Hello, {s}!\n", .{"world"});
240240}
241241 {#code_end#}
242242 <p>
......@@ -308,7 +308,7 @@ pub fn main() !void {
308308 multiple arguments passed to a function, they are separated by commas <code>,</code>.
309309 </p>
310310 <p>
311 The two arguments passed to the <code>stdout.print()</code> function, <code>"Hello, {}!\n"</code>
311 The two arguments passed to the <code>stdout.print()</code> function, <code>"Hello, {s}!\n"</code>
312312 and <code>.{"world"}</code>, are evaluated at {#link|compile-time|comptime#}. The code sample is
313313 purposely written to show how to perform {#link|string|String Literals and Character Literals#}
314314 substitution in the <code>print</code> function. The curly-braces inside of the first argument
......@@ -435,7 +435,7 @@ pub fn main() void {
435435 var optional_value: ?[]const u8 = null;
436436 assert(optional_value == null);
437437
438 print("\noptional 1\ntype: {}\nvalue: {}\n", .{
438 print("\noptional 1\ntype: {s}\nvalue: {s}\n", .{
439439 @typeName(@TypeOf(optional_value)),
440440 optional_value,
441441 });
......@@ -443,7 +443,7 @@ pub fn main() void {
443443 optional_value = "hi";
444444 assert(optional_value != null);
445445
446 print("\noptional 2\ntype: {}\nvalue: {}\n", .{
446 print("\noptional 2\ntype: {s}\nvalue: {s}\n", .{
447447 @typeName(@TypeOf(optional_value)),
448448 optional_value,
449449 });
......@@ -451,14 +451,14 @@ pub fn main() void {
451451 // error union
452452 var number_or_error: anyerror!i32 = error.ArgNotFound;
453453
454 print("\nerror union 1\ntype: {}\nvalue: {}\n", .{
454 print("\nerror union 1\ntype: {s}\nvalue: {}\n", .{
455455 @typeName(@TypeOf(number_or_error)),
456456 number_or_error,
457457 });
458458
459459 number_or_error = 1234;
460460
461 print("\nerror union 2\ntype: {}\nvalue: {}\n", .{
461 print("\nerror union 2\ntype: {s}\nvalue: {}\n", .{
462462 @typeName(@TypeOf(number_or_error)),
463463 number_or_error,
464464 });
......@@ -2339,7 +2339,7 @@ test "using slices for strings" {
23392339 // You can use slice syntax on an array to convert an array into a slice.
23402340 const all_together_slice = all_together[0..];
23412341 // String concatenation example.
2342 const hello_world = try fmt.bufPrint(all_together_slice, "{} {}", .{ hello, world });
2342 const hello_world = try fmt.bufPrint(all_together_slice, "{s} {s}", .{ hello, world });
23432343
23442344 // Generally, you can use UTF-8 and not worry about whether something is a
23452345 // string. If you don't need to deal with individual characters, no need
......@@ -2772,9 +2772,9 @@ const std = @import("std");
27722772
27732773pub fn main() void {
27742774 const Foo = struct {};
2775 std.debug.print("variable: {}\n", .{@typeName(Foo)});
2776 std.debug.print("anonymous: {}\n", .{@typeName(struct {})});
2777 std.debug.print("function: {}\n", .{@typeName(List(i32))});
2775 std.debug.print("variable: {s}\n", .{@typeName(Foo)});
2776 std.debug.print("anonymous: {s}\n", .{@typeName(struct {})});
2777 std.debug.print("function: {s}\n", .{@typeName(List(i32))});
27782778}
27792779
27802780fn List(comptime T: type) type {
......@@ -6110,7 +6110,7 @@ const a_number: i32 = 1234;
61106110const a_string = "foobar";
61116111
61126112pub fn main() void {
6113 print("here is a string: '{}' here is a number: {}\n", .{a_string, a_number});
6113 print("here is a string: '{s}' here is a number: {}\n", .{a_string, a_number});
61146114}
61156115 {#code_end#}
61166116
......@@ -6230,7 +6230,7 @@ const a_number: i32 = 1234;
62306230const a_string = "foobar";
62316231
62326232test "printf too many arguments" {
6233 print("here is a string: '{}' here is a number: {}\n", .{
6233 print("here is a string: '{s}' here is a number: {}\n", .{
62346234 a_string,
62356235 a_number,
62366236 a_number,
......@@ -6249,7 +6249,7 @@ const print = @import("std").debug.print;
62496249
62506250const a_number: i32 = 1234;
62516251const a_string = "foobar";
6252const fmt = "here is a string: '{}' here is a number: {}\n";
6252const fmt = "here is a string: '{s}' here is a number: {}\n";
62536253
62546254pub fn main() void {
62556255 print(fmt, .{a_string, a_number});
......@@ -6720,8 +6720,8 @@ fn amain() !void {
67206720 const download_text = try await download_frame;
67216721 defer allocator.free(download_text);
67226722
6723 std.debug.print("download_text: {}\n", .{download_text});
6724 std.debug.print("file_text: {}\n", .{file_text});
6723 std.debug.print("download_text: {s}\n", .{download_text});
6724 std.debug.print("file_text: {s}\n", .{file_text});
67256725}
67266726
67276727var global_download_frame: anyframe = undefined;
......@@ -6790,8 +6790,8 @@ fn amain() !void {
67906790 const download_text = try await download_frame;
67916791 defer allocator.free(download_text);
67926792
6793 std.debug.print("download_text: {}\n", .{download_text});
6794 std.debug.print("file_text: {}\n", .{file_text});
6793 std.debug.print("download_text: {s}\n", .{download_text});
6794 std.debug.print("file_text: {s}\n", .{file_text});
67956795}
67966796
67976797fn fetchUrl(allocator: *Allocator, url: []const u8) ![]u8 {
......@@ -8848,7 +8848,7 @@ pub fn main() !void {
88488848 var byte: u8 = 255;
88498849
88508850 byte = if (math.add(u8, byte, 1)) |result| result else |err| {
8851 print("unable to add one: {}\n", .{@errorName(err)});
8851 print("unable to add one: {s}\n", .{@errorName(err)});
88528852 return err;
88538853 };
88548854
......@@ -9078,7 +9078,7 @@ pub fn main() void {
90789078 if (result) |number| {
90799079 print("got number: {}\n", .{number});
90809080 } else |err| {
9081 print("got error: {}\n", .{@errorName(err)});
9081 print("got error: {s}\n", .{@errorName(err)});
90829082 }
90839083}
90849084
......@@ -9135,7 +9135,7 @@ const Foo = enum {
91359135pub fn main() void {
91369136 var a: u2 = 3;
91379137 var b = @intToEnum(Foo, a);
9138 std.debug.print("value: {}\n", .{@tagName(b)});
9138 std.debug.print("value: {s}\n", .{@tagName(b)});
91399139}
91409140 {#code_end#}
91419141 {#header_close#}
......@@ -10025,7 +10025,7 @@ pub fn main() !void {
1002510025 defer std.process.argsFree(gpa, args);
1002610026
1002710027 for (args) |arg, i| {
10028 std.debug.print("{}: {}\n", .{ i, arg });
10028 std.debug.print("{}: {s}\n", .{ i, arg });
1002910029 }
1003010030}
1003110031 {#code_end#}
lib/std/SemanticVersion.zig+5-5
......@@ -163,9 +163,9 @@ pub fn format(
163163 out_stream: anytype,
164164) !void {
165165 if (fmt.len != 0) @compileError("Unknown format string: '" ++ fmt ++ "'");
166 try std.fmt.format(out_stream, "{}.{}.{}", .{ self.major, self.minor, self.patch });
167 if (self.pre) |pre| try std.fmt.format(out_stream, "-{}", .{pre});
168 if (self.build) |build| try std.fmt.format(out_stream, "+{}", .{build});
166 try std.fmt.format(out_stream, "{d}.{d}.{d}", .{ self.major, self.minor, self.patch });
167 if (self.pre) |pre| try std.fmt.format(out_stream, "-{s}", .{pre});
168 if (self.build) |build| try std.fmt.format(out_stream, "+{s}", .{build});
169169}
170170
171171const expect = std.testing.expect;
......@@ -287,9 +287,9 @@ fn testFmt(expected: []const u8, comptime template: []const u8, args: anytype) !
287287 if (std.mem.eql(u8, result, expected)) return;
288288
289289 std.debug.warn("\n====== expected this output: =========\n", .{});
290 std.debug.warn("{}", .{expected});
290 std.debug.warn("{s}", .{expected});
291291 std.debug.warn("\n======== instead found this: =========\n", .{});
292 std.debug.warn("{}", .{result});
292 std.debug.warn("{s}", .{result});
293293 std.debug.warn("\n======================================\n", .{});
294294 return error.TestFailed;
295295}
lib/std/build.zig+69-69
......@@ -294,7 +294,7 @@ pub const Builder = struct {
294294 /// To run an executable built with zig build, see `LibExeObjStep.run`.
295295 pub fn addSystemCommand(self: *Builder, argv: []const []const u8) *RunStep {
296296 assert(argv.len >= 1);
297 const run_step = RunStep.create(self, self.fmt("run {}", .{argv[0]}));
297 const run_step = RunStep.create(self, self.fmt("run {s}", .{argv[0]}));
298298 run_step.addArgs(argv);
299299 return run_step;
300300 }
......@@ -409,7 +409,7 @@ pub const Builder = struct {
409409 for (self.installed_files.items) |installed_file| {
410410 const full_path = self.getInstallPath(installed_file.dir, installed_file.path);
411411 if (self.verbose) {
412 warn("rm {}\n", .{full_path});
412 warn("rm {s}\n", .{full_path});
413413 }
414414 fs.cwd().deleteTree(full_path) catch {};
415415 }
......@@ -419,7 +419,7 @@ pub const Builder = struct {
419419
420420 fn makeOneStep(self: *Builder, s: *Step) anyerror!void {
421421 if (s.loop_flag) {
422 warn("Dependency loop detected:\n {}\n", .{s.name});
422 warn("Dependency loop detected:\n {s}\n", .{s.name});
423423 return error.DependencyLoopDetected;
424424 }
425425 s.loop_flag = true;
......@@ -427,7 +427,7 @@ pub const Builder = struct {
427427 for (s.dependencies.items) |dep| {
428428 self.makeOneStep(dep) catch |err| {
429429 if (err == error.DependencyLoopDetected) {
430 warn(" {}\n", .{s.name});
430 warn(" {s}\n", .{s.name});
431431 }
432432 return err;
433433 };
......@@ -444,7 +444,7 @@ pub const Builder = struct {
444444 return &top_level_step.step;
445445 }
446446 }
447 warn("Cannot run step '{}' because it does not exist\n", .{name});
447 warn("Cannot run step '{s}' because it does not exist\n", .{name});
448448 return error.InvalidStepName;
449449 }
450450
......@@ -456,7 +456,7 @@ pub const Builder = struct {
456456 .description = description,
457457 };
458458 if ((self.available_options_map.fetchPut(name, available_option) catch unreachable) != null) {
459 panic("Option '{}' declared twice", .{name});
459 panic("Option '{s}' declared twice", .{name});
460460 }
461461 self.available_options_list.append(available_option) catch unreachable;
462462
......@@ -471,32 +471,32 @@ pub const Builder = struct {
471471 } else if (mem.eql(u8, s, "false")) {
472472 return false;
473473 } else {
474 warn("Expected -D{} to be a boolean, but received '{}'\n\n", .{ name, s });
474 warn("Expected -D{s} to be a boolean, but received '{s}'\n\n", .{ name, s });
475475 self.markInvalidUserInput();
476476 return null;
477477 }
478478 },
479479 .List => {
480 warn("Expected -D{} to be a boolean, but received a list.\n\n", .{name});
480 warn("Expected -D{s} to be a boolean, but received a list.\n\n", .{name});
481481 self.markInvalidUserInput();
482482 return null;
483483 },
484484 },
485485 .Int => switch (entry.value.value) {
486486 .Flag => {
487 warn("Expected -D{} to be an integer, but received a boolean.\n\n", .{name});
487 warn("Expected -D{s} to be an integer, but received a boolean.\n\n", .{name});
488488 self.markInvalidUserInput();
489489 return null;
490490 },
491491 .Scalar => |s| {
492492 const n = std.fmt.parseInt(T, s, 10) catch |err| switch (err) {
493493 error.Overflow => {
494 warn("-D{} value {} cannot fit into type {}.\n\n", .{ name, s, @typeName(T) });
494 warn("-D{s} value {} cannot fit into type {s}.\n\n", .{ name, s, @typeName(T) });
495495 self.markInvalidUserInput();
496496 return null;
497497 },
498498 else => {
499 warn("Expected -D{} to be an integer of type {}.\n\n", .{ name, @typeName(T) });
499 warn("Expected -D{s} to be an integer of type {s}.\n\n", .{ name, @typeName(T) });
500500 self.markInvalidUserInput();
501501 return null;
502502 },
......@@ -504,34 +504,34 @@ pub const Builder = struct {
504504 return n;
505505 },
506506 .List => {
507 warn("Expected -D{} to be an integer, but received a list.\n\n", .{name});
507 warn("Expected -D{s} to be an integer, but received a list.\n\n", .{name});
508508 self.markInvalidUserInput();
509509 return null;
510510 },
511511 },
512512 .Float => switch (entry.value.value) {
513513 .Flag => {
514 warn("Expected -D{} to be a float, but received a boolean.\n\n", .{name});
514 warn("Expected -D{s} to be a float, but received a boolean.\n\n", .{name});
515515 self.markInvalidUserInput();
516516 return null;
517517 },
518518 .Scalar => |s| {
519519 const n = std.fmt.parseFloat(T, s) catch |err| {
520 warn("Expected -D{} to be a float of type {}.\n\n", .{ name, @typeName(T) });
520 warn("Expected -D{s} to be a float of type {s}.\n\n", .{ name, @typeName(T) });
521521 self.markInvalidUserInput();
522522 return null;
523523 };
524524 return n;
525525 },
526526 .List => {
527 warn("Expected -D{} to be a float, but received a list.\n\n", .{name});
527 warn("Expected -D{s} to be a float, but received a list.\n\n", .{name});
528528 self.markInvalidUserInput();
529529 return null;
530530 },
531531 },
532532 .Enum => switch (entry.value.value) {
533533 .Flag => {
534 warn("Expected -D{} to be a string, but received a boolean.\n\n", .{name});
534 warn("Expected -D{s} to be a string, but received a boolean.\n\n", .{name});
535535 self.markInvalidUserInput();
536536 return null;
537537 },
......@@ -539,25 +539,25 @@ pub const Builder = struct {
539539 if (std.meta.stringToEnum(T, s)) |enum_lit| {
540540 return enum_lit;
541541 } else {
542 warn("Expected -D{} to be of type {}.\n\n", .{ name, @typeName(T) });
542 warn("Expected -D{s} to be of type {s}.\n\n", .{ name, @typeName(T) });
543543 self.markInvalidUserInput();
544544 return null;
545545 }
546546 },
547547 .List => {
548 warn("Expected -D{} to be a string, but received a list.\n\n", .{name});
548 warn("Expected -D{s} to be a string, but received a list.\n\n", .{name});
549549 self.markInvalidUserInput();
550550 return null;
551551 },
552552 },
553553 .String => switch (entry.value.value) {
554554 .Flag => {
555 warn("Expected -D{} to be a string, but received a boolean.\n\n", .{name});
555 warn("Expected -D{s} to be a string, but received a boolean.\n\n", .{name});
556556 self.markInvalidUserInput();
557557 return null;
558558 },
559559 .List => {
560 warn("Expected -D{} to be a string, but received a list.\n\n", .{name});
560 warn("Expected -D{s} to be a string, but received a list.\n\n", .{name});
561561 self.markInvalidUserInput();
562562 return null;
563563 },
......@@ -565,7 +565,7 @@ pub const Builder = struct {
565565 },
566566 .List => switch (entry.value.value) {
567567 .Flag => {
568 warn("Expected -D{} to be a list, but received a boolean.\n\n", .{name});
568 warn("Expected -D{s} to be a list, but received a boolean.\n\n", .{name});
569569 self.markInvalidUserInput();
570570 return null;
571571 },
......@@ -592,7 +592,7 @@ pub const Builder = struct {
592592 if (self.release_mode != null) {
593593 @panic("setPreferredReleaseMode must be called before standardReleaseOptions and may not be called twice");
594594 }
595 const description = self.fmt("Create a release build ({})", .{@tagName(mode)});
595 const description = self.fmt("Create a release build ({s})", .{@tagName(mode)});
596596 self.is_release = self.option(bool, "release", description) orelse false;
597597 self.release_mode = if (self.is_release) mode else builtin.Mode.Debug;
598598 }
......@@ -646,12 +646,12 @@ pub const Builder = struct {
646646 .diagnostics = &diags,
647647 }) catch |err| switch (err) {
648648 error.UnknownCpuModel => {
649 warn("Unknown CPU: '{}'\nAvailable CPUs for architecture '{}':\n", .{
649 warn("Unknown CPU: '{s}'\nAvailable CPUs for architecture '{s}':\n", .{
650650 diags.cpu_name.?,
651651 @tagName(diags.arch.?),
652652 });
653653 for (diags.arch.?.allCpuModels()) |cpu| {
654 warn(" {}\n", .{cpu.name});
654 warn(" {s}\n", .{cpu.name});
655655 }
656656 warn("\n", .{});
657657 self.markInvalidUserInput();
......@@ -659,15 +659,15 @@ pub const Builder = struct {
659659 },
660660 error.UnknownCpuFeature => {
661661 warn(
662 \\Unknown CPU feature: '{}'
663 \\Available CPU features for architecture '{}':
662 \\Unknown CPU feature: '{s}'
663 \\Available CPU features for architecture '{s}':
664664 \\
665665 , .{
666666 diags.unknown_feature_name,
667667 @tagName(diags.arch.?),
668668 });
669669 for (diags.arch.?.allFeaturesList()) |feature| {
670 warn(" {}: {}\n", .{ feature.name, feature.description });
670 warn(" {s}: {s}\n", .{ feature.name, feature.description });
671671 }
672672 warn("\n", .{});
673673 self.markInvalidUserInput();
......@@ -675,19 +675,19 @@ pub const Builder = struct {
675675 },
676676 error.UnknownOperatingSystem => {
677677 warn(
678 \\Unknown OS: '{}'
678 \\Unknown OS: '{s}'
679679 \\Available operating systems:
680680 \\
681681 , .{diags.os_name});
682682 inline for (std.meta.fields(std.Target.Os.Tag)) |field| {
683 warn(" {}\n", .{field.name});
683 warn(" {s}\n", .{field.name});
684684 }
685685 warn("\n", .{});
686686 self.markInvalidUserInput();
687687 return args.default_target;
688688 },
689689 else => |e| {
690 warn("Unable to parse target '{}': {}\n\n", .{ triple, @errorName(e) });
690 warn("Unable to parse target '{}': {s}\n\n", .{ triple, @errorName(e) });
691691 self.markInvalidUserInput();
692692 return args.default_target;
693693 },
......@@ -703,12 +703,12 @@ pub const Builder = struct {
703703 break :whitelist_check;
704704 }
705705 }
706 warn("Chosen target '{}' does not match one of the supported targets:\n", .{
706 warn("Chosen target '{s}' does not match one of the supported targets:\n", .{
707707 selected_canonicalized_triple,
708708 });
709709 for (list) |t| {
710710 const t_triple = t.zigTriple(self.allocator) catch unreachable;
711 warn(" {}\n", .{t_triple});
711 warn(" {s}\n", .{t_triple});
712712 }
713713 warn("\n", .{});
714714 self.markInvalidUserInput();
......@@ -752,7 +752,7 @@ pub const Builder = struct {
752752 }) catch unreachable;
753753 },
754754 UserValue.Flag => {
755 warn("Option '-D{}={}' conflicts with flag '-D{}'.\n", .{ name, value, name });
755 warn("Option '-D{s}={s}' conflicts with flag '-D{s}'.\n", .{ name, value, name });
756756 return true;
757757 },
758758 }
......@@ -773,11 +773,11 @@ pub const Builder = struct {
773773 // option already exists
774774 switch (gop.entry.value.value) {
775775 UserValue.Scalar => |s| {
776 warn("Flag '-D{}' conflicts with option '-D{}={}'.\n", .{ name, name, s });
776 warn("Flag '-D{s}' conflicts with option '-D{s}={s}'.\n", .{ name, name, s });
777777 return true;
778778 },
779779 UserValue.List => {
780 warn("Flag '-D{}' conflicts with multiple options of the same name.\n", .{name});
780 warn("Flag '-D{s}' conflicts with multiple options of the same name.\n", .{name});
781781 return true;
782782 },
783783 UserValue.Flag => {},
......@@ -820,7 +820,7 @@ pub const Builder = struct {
820820 while (true) {
821821 const entry = it.next() orelse break;
822822 if (!entry.value.used) {
823 warn("Invalid option: -D{}\n\n", .{entry.key});
823 warn("Invalid option: -D{s}\n\n", .{entry.key});
824824 self.markInvalidUserInput();
825825 }
826826 }
......@@ -833,9 +833,9 @@ pub const Builder = struct {
833833 }
834834
835835 fn printCmd(cwd: ?[]const u8, argv: []const []const u8) void {
836 if (cwd) |yes_cwd| warn("cd {} && ", .{yes_cwd});
836 if (cwd) |yes_cwd| warn("cd {s} && ", .{yes_cwd});
837837 for (argv) |arg| {
838 warn("{} ", .{arg});
838 warn("{s} ", .{arg});
839839 }
840840 warn("\n", .{});
841841 }
......@@ -852,7 +852,7 @@ pub const Builder = struct {
852852 child.env_map = env_map;
853853
854854 const term = child.spawnAndWait() catch |err| {
855 warn("Unable to spawn {}: {}\n", .{ argv[0], @errorName(err) });
855 warn("Unable to spawn {s}: {s}\n", .{ argv[0], @errorName(err) });
856856 return err;
857857 };
858858
......@@ -875,7 +875,7 @@ pub const Builder = struct {
875875
876876 pub fn makePath(self: *Builder, path: []const u8) !void {
877877 fs.cwd().makePath(self.pathFromRoot(path)) catch |err| {
878 warn("Unable to create path {}: {}\n", .{ path, @errorName(err) });
878 warn("Unable to create path {s}: {s}\n", .{ path, @errorName(err) });
879879 return err;
880880 };
881881 }
......@@ -959,7 +959,7 @@ pub const Builder = struct {
959959
960960 pub fn updateFile(self: *Builder, source_path: []const u8, dest_path: []const u8) !void {
961961 if (self.verbose) {
962 warn("cp {} {} ", .{ source_path, dest_path });
962 warn("cp {s} {s} ", .{ source_path, dest_path });
963963 }
964964 const cwd = fs.cwd();
965965 const prev_status = try fs.Dir.updateFile(cwd, source_path, cwd, dest_path, .{});
......@@ -988,7 +988,7 @@ pub const Builder = struct {
988988 const full_path = try fs.path.join(self.allocator, &[_][]const u8{
989989 search_prefix,
990990 "bin",
991 self.fmt("{}{}", .{ name, exe_extension }),
991 self.fmt("{s}{s}", .{ name, exe_extension }),
992992 });
993993 return fs.realpathAlloc(self.allocator, full_path) catch continue;
994994 }
......@@ -1002,7 +1002,7 @@ pub const Builder = struct {
10021002 while (it.next()) |path| {
10031003 const full_path = try fs.path.join(self.allocator, &[_][]const u8{
10041004 path,
1005 self.fmt("{}{}", .{ name, exe_extension }),
1005 self.fmt("{s}{s}", .{ name, exe_extension }),
10061006 });
10071007 return fs.realpathAlloc(self.allocator, full_path) catch continue;
10081008 }
......@@ -1015,7 +1015,7 @@ pub const Builder = struct {
10151015 for (paths) |path| {
10161016 const full_path = try fs.path.join(self.allocator, &[_][]const u8{
10171017 path,
1018 self.fmt("{}{}", .{ name, exe_extension }),
1018 self.fmt("{s}{s}", .{ name, exe_extension }),
10191019 });
10201020 return fs.realpathAlloc(self.allocator, full_path) catch continue;
10211021 }
......@@ -1070,19 +1070,19 @@ pub const Builder = struct {
10701070 var code: u8 = undefined;
10711071 return self.execAllowFail(argv, &code, .Inherit) catch |err| switch (err) {
10721072 error.FileNotFound => {
1073 if (src_step) |s| warn("{}...", .{s.name});
1073 if (src_step) |s| warn("{s}...", .{s.name});
10741074 warn("Unable to spawn the following command: file not found\n", .{});
10751075 printCmd(null, argv);
10761076 std.os.exit(@truncate(u8, code));
10771077 },
10781078 error.ExitCodeFailure => {
1079 if (src_step) |s| warn("{}...", .{s.name});
1080 warn("The following command exited with error code {}:\n", .{code});
1079 if (src_step) |s| warn("{s}...", .{s.name});
1080 warn("The following command exited with error code {d}:\n", .{code});
10811081 printCmd(null, argv);
10821082 std.os.exit(@truncate(u8, code));
10831083 },
10841084 error.ProcessTerminated => {
1085 if (src_step) |s| warn("{}...", .{s.name});
1085 if (src_step) |s| warn("{s}...", .{s.name});
10861086 warn("The following command terminated unexpectedly:\n", .{});
10871087 printCmd(null, argv);
10881088 std.os.exit(@truncate(u8, code));
......@@ -1405,7 +1405,7 @@ pub const LibExeObjStep = struct {
14051405 ver: ?Version,
14061406 ) LibExeObjStep {
14071407 if (mem.indexOf(u8, name, "/") != null or mem.indexOf(u8, name, "\\") != null) {
1408 panic("invalid name: '{}'. It looks like a file path, but it is supposed to be the library or application name.", .{name});
1408 panic("invalid name: '{s}'. It looks like a file path, but it is supposed to be the library or application name.", .{name});
14091409 }
14101410 var self = LibExeObjStep{
14111411 .strip = false,
......@@ -1421,9 +1421,9 @@ pub const LibExeObjStep = struct {
14211421 .step = Step.init(.LibExeObj, name, builder.allocator, make),
14221422 .version = ver,
14231423 .out_filename = undefined,
1424 .out_h_filename = builder.fmt("{}.h", .{name}),
1424 .out_h_filename = builder.fmt("{s}.h", .{name}),
14251425 .out_lib_filename = undefined,
1426 .out_pdb_filename = builder.fmt("{}.pdb", .{name}),
1426 .out_pdb_filename = builder.fmt("{s}.pdb", .{name}),
14271427 .major_only_filename = undefined,
14281428 .name_only_filename = undefined,
14291429 .packages = ArrayList(Pkg).init(builder.allocator),
......@@ -1529,7 +1529,7 @@ pub const LibExeObjStep = struct {
15291529 // It doesn't have to be native. We catch that if you actually try to run it.
15301530 // Consider that this is declarative; the run step may not be run unless a user
15311531 // option is supplied.
1532 const run_step = RunStep.create(exe.builder, exe.builder.fmt("run {}", .{exe.step.name}));
1532 const run_step = RunStep.create(exe.builder, exe.builder.fmt("run {s}", .{exe.step.name}));
15331533 run_step.addArtifactArg(exe);
15341534
15351535 if (exe.vcpkg_bin_path) |path| {
......@@ -1680,7 +1680,7 @@ pub const LibExeObjStep = struct {
16801680 } else if (mem.eql(u8, tok, "-pthread")) {
16811681 self.linkLibC();
16821682 } else if (self.builder.verbose) {
1683 warn("Ignoring pkg-config flag '{}'\n", .{tok});
1683 warn("Ignoring pkg-config flag '{s}'\n", .{tok});
16841684 }
16851685 }
16861686 }
......@@ -1926,7 +1926,7 @@ pub const LibExeObjStep = struct {
19261926 },
19271927 else => {},
19281928 }
1929 out.print("pub const {z}: {} = {};\n", .{ name, @typeName(T), value }) catch unreachable;
1929 out.print("pub const {z}: {s} = {};\n", .{ name, @typeName(T), value }) catch unreachable;
19301930 }
19311931
19321932 /// The value is the path in the cache dir.
......@@ -2048,7 +2048,7 @@ pub const LibExeObjStep = struct {
20482048 const builder = self.builder;
20492049
20502050 if (self.root_src == null and self.link_objects.items.len == 0) {
2051 warn("{}: linker needs 1 or more objects to link\n", .{self.step.name});
2051 warn("{s}: linker needs 1 or more objects to link\n", .{self.step.name});
20522052 return error.NeedAnObject;
20532053 }
20542054
......@@ -2156,12 +2156,12 @@ pub const LibExeObjStep = struct {
21562156 // Render build artifact options at the last minute, now that the path is known.
21572157 for (self.build_options_artifact_args.items) |item| {
21582158 const out = self.build_options_contents.writer();
2159 out.print("pub const {}: []const u8 = \"{Z}\";\n", .{ item.name, item.artifact.getOutputPath() }) catch unreachable;
2159 out.print("pub const {s}: []const u8 = \"{Z}\";\n", .{ item.name, item.artifact.getOutputPath() }) catch unreachable;
21602160 }
21612161
21622162 const build_options_file = try fs.path.join(
21632163 builder.allocator,
2164 &[_][]const u8{ builder.cache_root, builder.fmt("{}_build_options.zig", .{self.name}) },
2164 &[_][]const u8{ builder.cache_root, builder.fmt("{s}_build_options.zig", .{self.name}) },
21652165 );
21662166 const path_from_root = builder.pathFromRoot(build_options_file);
21672167 try fs.cwd().writeFile(path_from_root, self.build_options_contents.items);
......@@ -2294,16 +2294,16 @@ pub const LibExeObjStep = struct {
22942294 } else {
22952295 var mcpu_buffer = std.ArrayList(u8).init(builder.allocator);
22962296
2297 try mcpu_buffer.outStream().print("-mcpu={}", .{cross.cpu.model.name});
2297 try mcpu_buffer.outStream().print("-mcpu={s}", .{cross.cpu.model.name});
22982298
22992299 for (all_features) |feature, i_usize| {
23002300 const i = @intCast(std.Target.Cpu.Feature.Set.Index, i_usize);
23012301 const in_cpu_set = populated_cpu_features.isEnabled(i);
23022302 const in_actual_set = cross.cpu.features.isEnabled(i);
23032303 if (in_cpu_set and !in_actual_set) {
2304 try mcpu_buffer.outStream().print("-{}", .{feature.name});
2304 try mcpu_buffer.outStream().print("-{s}", .{feature.name});
23052305 } else if (!in_cpu_set and in_actual_set) {
2306 try mcpu_buffer.outStream().print("+{}", .{feature.name});
2306 try mcpu_buffer.outStream().print("+{s}", .{feature.name});
23072307 }
23082308 }
23092309
......@@ -2536,7 +2536,7 @@ pub const InstallArtifactStep = struct {
25362536 const self = builder.allocator.create(Self) catch unreachable;
25372537 self.* = Self{
25382538 .builder = builder,
2539 .step = Step.init(.InstallArtifact, builder.fmt("install {}", .{artifact.step.name}), builder.allocator, make),
2539 .step = Step.init(.InstallArtifact, builder.fmt("install {s}", .{artifact.step.name}), builder.allocator, make),
25402540 .artifact = artifact,
25412541 .dest_dir = artifact.override_dest_dir orelse switch (artifact.kind) {
25422542 .Obj => unreachable,
......@@ -2612,7 +2612,7 @@ pub const InstallFileStep = struct {
26122612 builder.pushInstalledFile(dir, dest_rel_path);
26132613 return InstallFileStep{
26142614 .builder = builder,
2615 .step = Step.init(.InstallFile, builder.fmt("install {}", .{src_path}), builder.allocator, make),
2615 .step = Step.init(.InstallFile, builder.fmt("install {s}", .{src_path}), builder.allocator, make),
26162616 .src_path = src_path,
26172617 .dir = dir,
26182618 .dest_rel_path = dest_rel_path,
......@@ -2646,7 +2646,7 @@ pub const InstallDirStep = struct {
26462646 builder.pushInstalledFile(options.install_dir, options.install_subdir);
26472647 return InstallDirStep{
26482648 .builder = builder,
2649 .step = Step.init(.InstallDir, builder.fmt("install {}/", .{options.source_dir}), builder.allocator, make),
2649 .step = Step.init(.InstallDir, builder.fmt("install {s}/", .{options.source_dir}), builder.allocator, make),
26502650 .options = options,
26512651 };
26522652 }
......@@ -2682,14 +2682,14 @@ pub const LogStep = struct {
26822682 pub fn init(builder: *Builder, data: []const u8) LogStep {
26832683 return LogStep{
26842684 .builder = builder,
2685 .step = Step.init(.Log, builder.fmt("log {}", .{data}), builder.allocator, make),
2685 .step = Step.init(.Log, builder.fmt("log {s}", .{data}), builder.allocator, make),
26862686 .data = data,
26872687 };
26882688 }
26892689
26902690 fn make(step: *Step) anyerror!void {
26912691 const self = @fieldParentPtr(LogStep, "step", step);
2692 warn("{}", .{self.data});
2692 warn("{s}", .{self.data});
26932693 }
26942694};
26952695
......@@ -2701,7 +2701,7 @@ pub const RemoveDirStep = struct {
27012701 pub fn init(builder: *Builder, dir_path: []const u8) RemoveDirStep {
27022702 return RemoveDirStep{
27032703 .builder = builder,
2704 .step = Step.init(.RemoveDir, builder.fmt("RemoveDir {}", .{dir_path}), builder.allocator, make),
2704 .step = Step.init(.RemoveDir, builder.fmt("RemoveDir {s}", .{dir_path}), builder.allocator, make),
27052705 .dir_path = dir_path,
27062706 };
27072707 }
......@@ -2711,7 +2711,7 @@ pub const RemoveDirStep = struct {
27112711
27122712 const full_path = self.builder.pathFromRoot(self.dir_path);
27132713 fs.cwd().deleteTree(full_path) catch |err| {
2714 warn("Unable to remove {}: {}\n", .{ full_path, @errorName(err) });
2714 warn("Unable to remove {s}: {s}\n", .{ full_path, @errorName(err) });
27152715 return err;
27162716 };
27172717 }
......@@ -2799,7 +2799,7 @@ fn doAtomicSymLinks(allocator: *Allocator, output_path: []const u8, filename_maj
27992799 &[_][]const u8{ out_dir, filename_major_only },
28002800 ) catch unreachable;
28012801 fs.atomicSymLink(allocator, out_basename, major_only_path) catch |err| {
2802 warn("Unable to symlink {} -> {}\n", .{ major_only_path, out_basename });
2802 warn("Unable to symlink {s} -> {s}\n", .{ major_only_path, out_basename });
28032803 return err;
28042804 };
28052805 // sym link for libfoo.so to libfoo.so.1
......@@ -2808,7 +2808,7 @@ fn doAtomicSymLinks(allocator: *Allocator, output_path: []const u8, filename_maj
28082808 &[_][]const u8{ out_dir, filename_name_only },
28092809 ) catch unreachable;
28102810 fs.atomicSymLink(allocator, filename_major_only, name_only_path) catch |err| {
2811 warn("Unable to symlink {} -> {}\n", .{ name_only_path, filename_major_only });
2811 warn("Unable to symlink {s} -> {s}\n", .{ name_only_path, filename_major_only });
28122812 return err;
28132813 };
28142814}
lib/std/build/check_file.zig+2-2
......@@ -45,9 +45,9 @@ pub const CheckFileStep = struct {
4545 warn(
4646 \\
4747 \\========= Expected to find: ===================
48 \\{}
48 \\{s}
4949 \\========= But file does not contain it: =======
50 \\{}
50 \\{s}
5151 \\
5252 , .{ expected_match, contents });
5353 return error.TestFailed;
lib/std/build/emit_raw.zig+1-1
......@@ -189,7 +189,7 @@ pub const InstallRawStep = struct {
189189 pub fn create(builder: *Builder, artifact: *LibExeObjStep, dest_filename: []const u8) *Self {
190190 const self = builder.allocator.create(Self) catch unreachable;
191191 self.* = Self{
192 .step = Step.init(.InstallRaw, builder.fmt("install raw binary {}", .{artifact.step.name}), builder.allocator, make),
192 .step = Step.init(.InstallRaw, builder.fmt("install raw binary {s}", .{artifact.step.name}), builder.allocator, make),
193193 .builder = builder,
194194 .artifact = artifact,
195195 .dest_dir = switch (artifact.kind) {
lib/std/build/run.zig+13-13
......@@ -116,7 +116,7 @@ pub const RunStep = struct {
116116 }
117117
118118 if (prev_path) |pp| {
119 const new_path = self.builder.fmt("{}" ++ [1]u8{fs.path.delimiter} ++ "{}", .{ pp, search_path });
119 const new_path = self.builder.fmt("{s}" ++ [1]u8{fs.path.delimiter} ++ "{s}", .{ pp, search_path });
120120 env_map.set(key, new_path) catch unreachable;
121121 } else {
122122 env_map.set(key, search_path) catch unreachable;
......@@ -189,7 +189,7 @@ pub const RunStep = struct {
189189 child.stderr_behavior = stdIoActionToBehavior(self.stderr_action);
190190
191191 child.spawn() catch |err| {
192 warn("Unable to spawn {}: {}\n", .{ argv[0], @errorName(err) });
192 warn("Unable to spawn {s}: {s}\n", .{ argv[0], @errorName(err) });
193193 return err;
194194 };
195195
......@@ -216,7 +216,7 @@ pub const RunStep = struct {
216216 }
217217
218218 const term = child.wait() catch |err| {
219 warn("Unable to spawn {}: {}\n", .{ argv[0], @errorName(err) });
219 warn("Unable to spawn {s}: {s}\n", .{ argv[0], @errorName(err) });
220220 return err;
221221 };
222222
......@@ -245,9 +245,9 @@ pub const RunStep = struct {
245245 warn(
246246 \\
247247 \\========= Expected this stderr: =========
248 \\{}
248 \\{s}
249249 \\========= But found: ====================
250 \\{}
250 \\{s}
251251 \\
252252 , .{ expected_bytes, stderr.? });
253253 printCmd(cwd, argv);
......@@ -259,9 +259,9 @@ pub const RunStep = struct {
259259 warn(
260260 \\
261261 \\========= Expected to find in stderr: =========
262 \\{}
262 \\{s}
263263 \\========= But stderr does not contain it: =====
264 \\{}
264 \\{s}
265265 \\
266266 , .{ match, stderr.? });
267267 printCmd(cwd, argv);
......@@ -277,9 +277,9 @@ pub const RunStep = struct {
277277 warn(
278278 \\
279279 \\========= Expected this stdout: =========
280 \\{}
280 \\{s}
281281 \\========= But found: ====================
282 \\{}
282 \\{s}
283283 \\
284284 , .{ expected_bytes, stdout.? });
285285 printCmd(cwd, argv);
......@@ -291,9 +291,9 @@ pub const RunStep = struct {
291291 warn(
292292 \\
293293 \\========= Expected to find in stdout: =========
294 \\{}
294 \\{s}
295295 \\========= But stdout does not contain it: =====
296 \\{}
296 \\{s}
297297 \\
298298 , .{ match, stdout.? });
299299 printCmd(cwd, argv);
......@@ -304,9 +304,9 @@ pub const RunStep = struct {
304304 }
305305
306306 fn printCmd(cwd: ?[]const u8, argv: []const []const u8) void {
307 if (cwd) |yes_cwd| warn("cd {} && ", .{yes_cwd});
307 if (cwd) |yes_cwd| warn("cd {s} && ", .{yes_cwd});
308308 for (argv) |arg| {
309 warn("{} ", .{arg});
309 warn("{s} ", .{arg});
310310 }
311311 warn("\n", .{});
312312 }
lib/std/build/write_file.zig+2-2
......@@ -80,14 +80,14 @@ pub const WriteFileStep = struct {
8080 });
8181 // TODO replace with something like fs.makePathAndOpenDir
8282 fs.cwd().makePath(self.output_dir) catch |err| {
83 warn("unable to make path {}: {}\n", .{ self.output_dir, @errorName(err) });
83 warn("unable to make path {s}: {s}\n", .{ self.output_dir, @errorName(err) });
8484 return err;
8585 };
8686 var dir = try fs.cwd().openDir(self.output_dir, .{});
8787 defer dir.close();
8888 for (self.files.items) |file| {
8989 dir.writeFile(file.basename, file.bytes) catch |err| {
90 warn("unable to write {} into {}: {}\n", .{
90 warn("unable to write {s} into {s}: {s}\n", .{
9191 file.basename,
9292 self.output_dir,
9393 @errorName(err),
lib/std/builtin.zig+7-7
......@@ -67,12 +67,12 @@ pub const StackTrace = struct {
6767 var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
6868 defer arena.deinit();
6969 const debug_info = std.debug.getSelfDebugInfo() catch |err| {
70 return writer.print("\nUnable to print stack trace: Unable to open debug info: {}\n", .{@errorName(err)});
70 return writer.print("\nUnable to print stack trace: Unable to open debug info: {s}\n", .{@errorName(err)});
7171 };
7272 const tty_config = std.debug.detectTTYConfig();
7373 try writer.writeAll("\n");
7474 std.debug.writeStackTrace(self, writer, &arena.allocator, debug_info, tty_config) catch |err| {
75 try writer.print("Unable to print stack trace: {}\n", .{@errorName(err)});
75 try writer.print("Unable to print stack trace: {s}\n", .{@errorName(err)});
7676 };
7777 try writer.writeAll("\n");
7878 }
......@@ -529,12 +529,12 @@ pub const Version = struct {
529529 if (fmt.len == 0) {
530530 if (self.patch == 0) {
531531 if (self.minor == 0) {
532 return std.fmt.format(out_stream, "{}", .{self.major});
532 return std.fmt.format(out_stream, "{d}", .{self.major});
533533 } else {
534 return std.fmt.format(out_stream, "{}.{}", .{ self.major, self.minor });
534 return std.fmt.format(out_stream, "{d}.{d}", .{ self.major, self.minor });
535535 }
536536 } else {
537 return std.fmt.format(out_stream, "{}.{}.{}", .{ self.major, self.minor, self.patch });
537 return std.fmt.format(out_stream, "{d}.{d}.{d}", .{ self.major, self.minor, self.patch });
538538 }
539539 } else {
540540 @compileError("Unknown format string: '" ++ fmt ++ "'");
......@@ -683,7 +683,7 @@ pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace) noreturn
683683 }
684684 },
685685 .wasi => {
686 std.debug.warn("{}", .{msg});
686 std.debug.warn("{s}", .{msg});
687687 std.os.abort();
688688 },
689689 .uefi => {
......@@ -692,7 +692,7 @@ pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace) noreturn
692692 },
693693 else => {
694694 const first_trace_addr = @returnAddress();
695 std.debug.panicExtra(error_return_trace, first_trace_addr, "{}", .{msg});
695 std.debug.panicExtra(error_return_trace, first_trace_addr, "{s}", .{msg});
696696 },
697697 }
698698}
lib/std/c/ast.zig+4-4
......@@ -115,10 +115,10 @@ pub const Error = union(enum) {
115115 pub fn render(self: *const ExpectedToken, tree: *Tree, stream: anytype) !void {
116116 const found_token = tree.tokens.at(self.token);
117117 if (found_token.id == .Invalid) {
118 return stream.print("expected '{}', found invalid bytes", .{self.expected_id.symbol()});
118 return stream.print("expected '{s}', found invalid bytes", .{self.expected_id.symbol()});
119119 } else {
120120 const token_name = found_token.id.symbol();
121 return stream.print("expected '{}', found '{}'", .{ self.expected_id.symbol(), token_name });
121 return stream.print("expected '{s}', found '{s}'", .{ self.expected_id.symbol(), token_name });
122122 }
123123 }
124124 };
......@@ -131,7 +131,7 @@ pub const Error = union(enum) {
131131 try stream.write("invalid type specifier '");
132132 try type_spec.spec.print(tree, stream);
133133 const token_name = tree.tokens.at(self.token).id.symbol();
134 return stream.print("{}'", .{token_name});
134 return stream.print("{s}'", .{token_name});
135135 }
136136 };
137137
......@@ -140,7 +140,7 @@ pub const Error = union(enum) {
140140 name: TokenIndex,
141141
142142 pub fn render(self: *const ExpectedToken, tree: *Tree, stream: anytype) !void {
143 return stream.print("must use '{}' tag to refer to type '{}'", .{ tree.slice(kw), tree.slice(name) });
143 return stream.print("must use '{s}' tag to refer to type '{s}'", .{ tree.slice(kw), tree.slice(name) });
144144 }
145145 };
146146
lib/std/c/tokenizer.zig+1-1
......@@ -1552,7 +1552,7 @@ fn expectTokens(source: []const u8, expected_tokens: []const Token.Id) void {
15521552 for (expected_tokens) |expected_token_id| {
15531553 const token = tokenizer.next();
15541554 if (!std.meta.eql(token.id, expected_token_id)) {
1555 std.debug.panic("expected {}, found {}\n", .{ @tagName(expected_token_id), @tagName(token.id) });
1555 std.debug.panic("expected {s}, found {s}\n", .{ @tagName(expected_token_id), @tagName(token.id) });
15561556 }
15571557 }
15581558 const last_token = tokenizer.next();
lib/std/crypto/bcrypt.zig+1-1
......@@ -247,7 +247,7 @@ fn strHashInternal(password: []const u8, rounds_log: u6, salt: [salt_length]u8)
247247 Codec.encode(ct_str[0..], ct[0 .. ct.len - 1]);
248248
249249 var s_buf: [hash_length]u8 = undefined;
250 const s = fmt.bufPrint(s_buf[0..], "$2b${}{}${}{}", .{ rounds_log / 10, rounds_log % 10, salt_str, ct_str }) catch unreachable;
250 const s = fmt.bufPrint(s_buf[0..], "$2b${d}{d}${s}{s}", .{ rounds_log / 10, rounds_log % 10, salt_str, ct_str }) catch unreachable;
251251 debug.assert(s.len == s_buf.len);
252252 return s_buf;
253253}
lib/std/debug.zig+7-7
......@@ -108,11 +108,11 @@ pub fn dumpCurrentStackTrace(start_addr: ?usize) void {
108108 return;
109109 }
110110 const debug_info = getSelfDebugInfo() catch |err| {
111 stderr.print("Unable to dump stack trace: Unable to open debug info: {}\n", .{@errorName(err)}) catch return;
111 stderr.print("Unable to dump stack trace: Unable to open debug info: {s}\n", .{@errorName(err)}) catch return;
112112 return;
113113 };
114114 writeCurrentStackTrace(stderr, debug_info, detectTTYConfig(), start_addr) catch |err| {
115 stderr.print("Unable to dump stack trace: {}\n", .{@errorName(err)}) catch return;
115 stderr.print("Unable to dump stack trace: {s}\n", .{@errorName(err)}) catch return;
116116 return;
117117 };
118118 }
......@@ -129,7 +129,7 @@ pub fn dumpStackTraceFromBase(bp: usize, ip: usize) void {
129129 return;
130130 }
131131 const debug_info = getSelfDebugInfo() catch |err| {
132 stderr.print("Unable to dump stack trace: Unable to open debug info: {}\n", .{@errorName(err)}) catch return;
132 stderr.print("Unable to dump stack trace: Unable to open debug info: {s}\n", .{@errorName(err)}) catch return;
133133 return;
134134 };
135135 const tty_config = detectTTYConfig();
......@@ -199,11 +199,11 @@ pub fn dumpStackTrace(stack_trace: builtin.StackTrace) void {
199199 return;
200200 }
201201 const debug_info = getSelfDebugInfo() catch |err| {
202 stderr.print("Unable to dump stack trace: Unable to open debug info: {}\n", .{@errorName(err)}) catch return;
202 stderr.print("Unable to dump stack trace: Unable to open debug info: {s}\n", .{@errorName(err)}) catch return;
203203 return;
204204 };
205205 writeStackTrace(stack_trace, stderr, getDebugInfoAllocator(), debug_info, detectTTYConfig()) catch |err| {
206 stderr.print("Unable to dump stack trace: {}\n", .{@errorName(err)}) catch return;
206 stderr.print("Unable to dump stack trace: {s}\n", .{@errorName(err)}) catch return;
207207 return;
208208 };
209209 }
......@@ -611,7 +611,7 @@ fn printLineInfo(
611611 tty_config.setColor(out_stream, .White);
612612
613613 if (line_info) |*li| {
614 try out_stream.print("{}:{}:{}", .{ li.file_name, li.line, li.column });
614 try out_stream.print("{s}:{d}:{d}", .{ li.file_name, li.line, li.column });
615615 } else {
616616 try out_stream.writeAll("???:?:?");
617617 }
......@@ -619,7 +619,7 @@ fn printLineInfo(
619619 tty_config.setColor(out_stream, .Reset);
620620 try out_stream.writeAll(": ");
621621 tty_config.setColor(out_stream, .Dim);
622 try out_stream.print("0x{x} in {} ({})", .{ address, symbol_name, compile_unit_name });
622 try out_stream.print("0x{x} in {s} ({s})", .{ address, symbol_name, compile_unit_name });
623623 tty_config.setColor(out_stream, .Reset);
624624 try out_stream.writeAll("\n");
625625
lib/std/fifo.zig+1-1
......@@ -466,7 +466,7 @@ test "LinearFifo(u8, .Dynamic)" {
466466 fifo.shrink(0);
467467
468468 {
469 try fifo.writer().print("{}, {}!", .{ "Hello", "World" });
469 try fifo.writer().print("{s}, {s}!", .{ "Hello", "World" });
470470 var result: [30]u8 = undefined;
471471 testing.expectEqualSlices(u8, "Hello, World!", result[0..fifo.read(&result)]);
472472 testing.expectEqual(@as(usize, 0), fifo.readableLength());
lib/std/fmt.zig+106-56
......@@ -367,6 +367,36 @@ pub fn format(
367367 }
368368}
369369
370pub fn formatAddress(value: anytype, options: FormatOptions, writer: anytype) @TypeOf(writer).Error!void {
371 const T = @TypeOf(value);
372
373 switch (@typeInfo(T)) {
374 .Pointer => |info| {
375 try writer.writeAll(@typeName(info.child) ++ "@");
376 if (info.size == .Slice)
377 try formatInt(@ptrToInt(value.ptr), 16, false, FormatOptions{}, writer)
378 else
379 try formatInt(@ptrToInt(value), 16, false, FormatOptions{}, writer);
380 return;
381 },
382 .Optional => |info| {
383 if (@typeInfo(info.child) == .Pointer) {
384 try writer.writeAll(@typeName(info.child) ++ "@");
385 try formatInt(@ptrToInt(value), 16, false, FormatOptions{}, writer);
386 return;
387 }
388 },
389 .Array => |info| {
390 try writer.writeAll(@typeName(info.child) ++ "@");
391 try formatInt(@ptrToInt(value), 16, false, FormatOptions{}, writer);
392 return;
393 },
394 else => {},
395 }
396
397 @compileError("Cannot format non-pointer type " ++ @typeName(T) ++ " with * specifier");
398}
399
370400pub fn formatType(
371401 value: anytype,
372402 comptime fmt: []const u8,
......@@ -375,10 +405,7 @@ pub fn formatType(
375405 max_depth: usize,
376406) @TypeOf(writer).Error!void {
377407 if (comptime std.mem.eql(u8, fmt, "*")) {
378 try writer.writeAll(@typeName(std.meta.Child(@TypeOf(value))));
379 try writer.writeAll("@");
380 try formatInt(@ptrToInt(value), 16, false, FormatOptions{}, writer);
381 return;
408 return formatAddress(value, options, writer);
382409 }
383410
384411 const T = @TypeOf(value);
......@@ -436,12 +463,11 @@ pub fn formatType(
436463 try formatType(@enumToInt(value), fmt, options, writer, max_depth);
437464 try writer.writeAll(")");
438465 },
439 .Union => {
466 .Union => |info| {
440467 try writer.writeAll(@typeName(T));
441468 if (max_depth == 0) {
442469 return writer.writeAll("{ ... }");
443470 }
444 const info = @typeInfo(T).Union;
445471 if (info.tag_type) |UnionTagType| {
446472 try writer.writeAll("{ .");
447473 try writer.writeAll(@tagName(@as(UnionTagType, value)));
......@@ -456,13 +482,13 @@ pub fn formatType(
456482 try format(writer, "@{x}", .{@ptrToInt(&value)});
457483 }
458484 },
459 .Struct => |StructT| {
485 .Struct => |info| {
460486 try writer.writeAll(@typeName(T));
461487 if (max_depth == 0) {
462488 return writer.writeAll("{ ... }");
463489 }
464490 try writer.writeAll("{");
465 inline for (StructT.fields) |f, i| {
491 inline for (info.fields) |f, i| {
466492 if (i == 0) {
467493 try writer.writeAll(" .");
468494 } else {
......@@ -478,69 +504,83 @@ pub fn formatType(
478504 .One => switch (@typeInfo(ptr_info.child)) {
479505 .Array => |info| {
480506 if (info.child == u8) {
481 return formatText(value, fmt, options, writer);
507 if (fmt.len > 0 and comptime mem.indexOfScalar(u8, "sxXeEzZ", fmt[0]) != null) {
508 return formatText(value, fmt, options, writer);
509 }
482510 }
483 return format(writer, "{}@{x}", .{ @typeName(@typeInfo(T).Pointer.child), @ptrToInt(value) });
511 return format(writer, "{s}@{x}", .{ @typeName(ptr_info.child), @ptrToInt(value) });
484512 },
485513 .Enum, .Union, .Struct => {
486514 return formatType(value.*, fmt, options, writer, max_depth);
487515 },
488 else => return format(writer, "{}@{x}", .{ @typeName(@typeInfo(T).Pointer.child), @ptrToInt(value) }),
516 else => return format(writer, "{s}@{x}", .{ @typeName(ptr_info.child), @ptrToInt(value) }),
489517 },
490518 .Many, .C => {
491519 if (ptr_info.sentinel) |sentinel| {
492520 return formatType(mem.span(value), fmt, options, writer, max_depth);
493521 }
494522 if (ptr_info.child == u8) {
495 if (fmt.len > 0 and fmt[0] == 's') {
523 if (fmt.len > 0 and comptime mem.indexOfScalar(u8, "sxXeEzZ", fmt[0]) != null) {
496524 return formatText(mem.span(value), fmt, options, writer);
497525 }
498526 }
499 return format(writer, "{}@{x}", .{ @typeName(@typeInfo(T).Pointer.child), @ptrToInt(value) });
527 return format(writer, "{s}@{x}", .{ @typeName(ptr_info.child), @ptrToInt(value) });
500528 },
501529 .Slice => {
502 if (fmt.len > 0 and ((fmt[0] == 'x') or (fmt[0] == 'X'))) {
503 return formatText(value, fmt, options, writer);
530 if (max_depth == 0) {
531 return writer.writeAll("{ ... }");
504532 }
505533 if (ptr_info.child == u8) {
506 return formatText(value, fmt, options, writer);
534 if (fmt.len > 0 and comptime mem.indexOfScalar(u8, "sxXeEzZ", fmt[0]) != null) {
535 return formatText(value, fmt, options, writer);
536 }
507537 }
508 return format(writer, "{}@{x}", .{ @typeName(ptr_info.child), @ptrToInt(value.ptr) });
538 try writer.writeAll("{ ");
539 for (value) |elem, i| {
540 try formatType(elem, fmt, options, writer, max_depth - 1);
541 if (i != value.len - 1) {
542 try writer.writeAll(", ");
543 }
544 }
545 try writer.writeAll(" }");
509546 },
510547 },
511548 .Array => |info| {
512 const Slice = @Type(builtin.TypeInfo{
513 .Pointer = .{
514 .size = .Slice,
515 .is_const = true,
516 .is_volatile = false,
517 .is_allowzero = false,
518 .alignment = @alignOf(info.child),
519 .child = info.child,
520 .sentinel = null,
521 },
522 });
523 return formatType(@as(Slice, &value), fmt, options, writer, max_depth);
549 if (max_depth == 0) {
550 return writer.writeAll("{ ... }");
551 }
552 if (info.child == u8) {
553 if (fmt.len > 0 and comptime mem.indexOfScalar(u8, "sxXeEzZ", fmt[0]) != null) {
554 return formatText(&value, fmt, options, writer);
555 }
556 }
557 try writer.writeAll("{ ");
558 for (value) |elem, i| {
559 try formatType(elem, fmt, options, writer, max_depth - 1);
560 if (i < value.len - 1) {
561 try writer.writeAll(", ");
562 }
563 }
564 try writer.writeAll(" }");
524565 },
525 .Vector => {
526 const len = @typeInfo(T).Vector.len;
566 .Vector => |info| {
527567 try writer.writeAll("{ ");
528568 var i: usize = 0;
529 while (i < len) : (i += 1) {
569 while (i < info.len) : (i += 1) {
530570 try formatValue(value[i], fmt, options, writer);
531 if (i < len - 1) {
571 if (i < info.len - 1) {
532572 try writer.writeAll(", ");
533573 }
534574 }
535575 try writer.writeAll(" }");
536576 },
537577 .Fn => {
538 return format(writer, "{}@{x}", .{ @typeName(T), @ptrToInt(value) });
578 return format(writer, "{s}@{x}", .{ @typeName(T), @ptrToInt(value) });
539579 },
540580 .Type => return formatBuf(@typeName(value), options, writer),
541581 .EnumLiteral => {
542582 const buffer = [_]u8{'.'} ++ @tagName(value);
543 return formatType(buffer, fmt, options, writer, max_depth);
583 return formatBuf(buffer, options, writer);
544584 },
545585 .Null => return formatBuf("null", options, writer),
546586 else => @compileError("Unable to format type '" ++ @typeName(T) ++ "'"),
......@@ -657,7 +697,7 @@ pub fn formatText(
657697 options: FormatOptions,
658698 writer: anytype,
659699) !void {
660 if (comptime std.mem.eql(u8, fmt, "s") or (fmt.len == 0)) {
700 if (comptime std.mem.eql(u8, fmt, "s")) {
661701 return formatBuf(bytes, options, writer);
662702 } else if (comptime (std.mem.eql(u8, fmt, "x") or std.mem.eql(u8, fmt, "X"))) {
663703 for (bytes) |c| {
......@@ -1521,8 +1561,9 @@ test "buffer" {
15211561test "array" {
15221562 {
15231563 const value: [3]u8 = "abc".*;
1524 try testFmt("array: abc\n", "array: {}\n", .{value});
1525 try testFmt("array: abc\n", "array: {}\n", .{&value});
1564 try testFmt("array: abc\n", "array: {s}\n", .{value});
1565 try testFmt("array: abc\n", "array: {s}\n", .{&value});
1566 try testFmt("array: { 97, 98, 99 }\n", "array: {d}\n", .{value});
15261567
15271568 var buf: [100]u8 = undefined;
15281569 try testFmt(
......@@ -1536,12 +1577,12 @@ test "array" {
15361577test "slice" {
15371578 {
15381579 const value: []const u8 = "abc";
1539 try testFmt("slice: abc\n", "slice: {}\n", .{value});
1580 try testFmt("slice: abc\n", "slice: {s}\n", .{value});
15401581 }
15411582 {
15421583 var runtime_zero: usize = 0;
15431584 const value = @intToPtr([*]align(1) const []const u8, 0xdeadbeef)[runtime_zero..runtime_zero];
1544 try testFmt("slice: []const u8@deadbeef\n", "slice: {}\n", .{value});
1585 try testFmt("slice: []const u8@deadbeef\n", "slice: {*}\n", .{value});
15451586 }
15461587 {
15471588 const null_term_slice: [:0]const u8 = "\x00hello\x00";
......@@ -1550,6 +1591,15 @@ test "slice" {
15501591
15511592 try testFmt("buf: Test\n", "buf: {s:5}\n", .{"Test"});
15521593 try testFmt("buf: Test\n Other text", "buf: {s}\n Other text", .{"Test"});
1594
1595 {
1596 var int_slice = [_]u32{ 1, 4096, 391891, 1111111111 };
1597 var runtime_zero: usize = 0;
1598 try testFmt("int: { 1, 4096, 391891, 1111111111 }", "int: {}", .{int_slice[runtime_zero..]});
1599 try testFmt("int: { 1, 4096, 391891, 1111111111 }", "int: {d}", .{int_slice[runtime_zero..]});
1600 try testFmt("int: { 1, 1000, 5fad3, 423a35c7 }", "int: {x}", .{int_slice[runtime_zero..]});
1601 try testFmt("int: { 00001, 01000, 5fad3, 423a35c7 }", "int: {x:0>5}", .{int_slice[runtime_zero..]});
1602 }
15531603}
15541604
15551605test "escape non-printable" {
......@@ -1854,9 +1904,9 @@ fn testFmt(expected: []const u8, comptime template: []const u8, args: anytype) !
18541904 if (mem.eql(u8, result, expected)) return;
18551905
18561906 std.debug.warn("\n====== expected this output: =========\n", .{});
1857 std.debug.warn("{}", .{expected});
1907 std.debug.warn("{s}", .{expected});
18581908 std.debug.warn("\n======== instead found this: =========\n", .{});
1859 std.debug.warn("{}", .{result});
1909 std.debug.warn("{s}", .{result});
18601910 std.debug.warn("\n======================================\n", .{});
18611911 return error.TestFailed;
18621912}
......@@ -2013,24 +2063,24 @@ test "vector" {
20132063}
20142064
20152065test "enum-literal" {
2016 try testFmt(".hello_world", "{}", .{.hello_world});
2066 try testFmt(".hello_world", "{s}", .{.hello_world});
20172067}
20182068
20192069test "padding" {
2020 try testFmt("Simple", "{}", .{"Simple"});
2070 try testFmt("Simple", "{s}", .{"Simple"});
20212071 try testFmt(" true", "{:10}", .{true});
20222072 try testFmt(" true", "{:>10}", .{true});
20232073 try testFmt("======true", "{:=>10}", .{true});
20242074 try testFmt("true======", "{:=<10}", .{true});
20252075 try testFmt(" true ", "{:^10}", .{true});
20262076 try testFmt("===true===", "{:=^10}", .{true});
2027 try testFmt(" Minimum width", "{:18} width", .{"Minimum"});
2028 try testFmt("==================Filled", "{:=>24}", .{"Filled"});
2029 try testFmt(" Centered ", "{:^24}", .{"Centered"});
2030 try testFmt("-", "{:-^1}", .{""});
2031 try testFmt("==crêpe===", "{:=^10}", .{"crêpe"});
2032 try testFmt("=====crêpe", "{:=>10}", .{"crêpe"});
2033 try testFmt("crêpe=====", "{:=<10}", .{"crêpe"});
2077 try testFmt(" Minimum width", "{s:18} width", .{"Minimum"});
2078 try testFmt("==================Filled", "{s:=>24}", .{"Filled"});
2079 try testFmt(" Centered ", "{s:^24}", .{"Centered"});
2080 try testFmt("-", "{s:-^1}", .{""});
2081 try testFmt("==crêpe===", "{s:=^10}", .{"crêpe"});
2082 try testFmt("=====crêpe", "{s:=>10}", .{"crêpe"});
2083 try testFmt("crêpe=====", "{s:=<10}", .{"crêpe"});
20342084}
20352085
20362086test "decimal float padding" {
......@@ -2059,15 +2109,15 @@ test "type" {
20592109}
20602110
20612111test "named arguments" {
2062 try testFmt("hello world!", "{} world{c}", .{ "hello", '!' });
2063 try testFmt("hello world!", "{[greeting]} world{[punctuation]c}", .{ .punctuation = '!', .greeting = "hello" });
2064 try testFmt("hello world!", "{[1]} world{[0]c}", .{ '!', "hello" });
2112 try testFmt("hello world!", "{s} world{c}", .{ "hello", '!' });
2113 try testFmt("hello world!", "{[greeting]s} world{[punctuation]c}", .{ .punctuation = '!', .greeting = "hello" });
2114 try testFmt("hello world!", "{[1]s} world{[0]c}", .{ '!', "hello" });
20652115}
20662116
20672117test "runtime width specifier" {
20682118 var width: usize = 9;
2069 try testFmt("~~hello~~", "{:~^[1]}", .{ "hello", width });
2070 try testFmt("~~hello~~", "{:~^[width]}", .{ .string = "hello", .width = width });
2119 try testFmt("~~hello~~", "{s:~^[1]}", .{ "hello", width });
2120 try testFmt("~~hello~~", "{s:~^[width]}", .{ .string = "hello", .width = width });
20712121}
20722122
20732123test "runtime precision specifier" {
lib/std/fs/wasi.zig+1-1
......@@ -38,7 +38,7 @@ pub const PreopenType = union(PreopenTypeTag) {
3838 pub fn format(self: Self, comptime fmt: []const u8, options: std.fmt.FormatOptions, out_stream: anytype) !void {
3939 try out_stream.print("PreopenType{{ ", .{});
4040 switch (self) {
41 PreopenType.Dir => |path| try out_stream.print(".Dir = '{}'", .{path}),
41 PreopenType.Dir => |path| try out_stream.print(".Dir = '{z}'", .{path}),
4242 }
4343 return out_stream.print(" }}", .{});
4444 }
lib/std/heap/general_purpose_allocator.zig+4-4
......@@ -314,7 +314,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
314314 if (is_used) {
315315 const slot_index = @intCast(SlotIndex, used_bits_byte * 8 + bit_index);
316316 const stack_trace = bucketStackTrace(bucket, size_class, slot_index, .alloc);
317 log.err("Memory leak detected: {}", .{stack_trace});
317 log.err("Memory leak detected: {s}", .{stack_trace});
318318 leaks = true;
319319 }
320320 if (bit_index == math.maxInt(u3))
......@@ -342,7 +342,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
342342 }
343343 var it = self.large_allocations.iterator();
344344 while (it.next()) |large_alloc| {
345 log.err("Memory leak detected: {}", .{large_alloc.value.getStackTrace()});
345 log.err("Memory leak detected: {s}", .{large_alloc.value.getStackTrace()});
346346 leaks = true;
347347 }
348348 return leaks;
......@@ -443,7 +443,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
443443 .index = 0,
444444 };
445445 std.debug.captureStackTrace(ret_addr, &free_stack_trace);
446 log.err("Allocation size {} bytes does not match free size {}. Allocation: {} Free: {}", .{
446 log.err("Allocation size {d} bytes does not match free size {d}. Allocation: {s} Free: {s}", .{
447447 entry.value.bytes.len,
448448 old_mem.len,
449449 entry.value.getStackTrace(),
......@@ -526,7 +526,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
526526 .index = 0,
527527 };
528528 std.debug.captureStackTrace(ret_addr, &second_free_stack_trace);
529 log.err("Double free detected. Allocation: {} First free: {} Second free: {}", .{
529 log.err("Double free detected. Allocation: {s} First free: {s} Second free: {s}", .{
530530 alloc_stack_trace,
531531 free_stack_trace,
532532 second_free_stack_trace,
lib/std/io/fixed_buffer_stream.zig+1-1
......@@ -147,7 +147,7 @@ test "FixedBufferStream output" {
147147 var fbs = fixedBufferStream(&buf);
148148 const stream = fbs.writer();
149149
150 try stream.print("{}{}!", .{ "Hello", "World" });
150 try stream.print("{s}{s}!", .{ "Hello", "World" });
151151 testing.expectEqualSlices(u8, "HelloWorld!", fbs.getWritten());
152152}
153153
lib/std/json.zig+4-4
......@@ -2642,9 +2642,9 @@ fn teststringify(expected: []const u8, value: anytype, options: StringifyOptions
26422642 if (self.expected_remaining.len < bytes.len) {
26432643 std.debug.warn(
26442644 \\====== expected this output: =========
2645 \\{}
2645 \\{s}
26462646 \\======== instead found this: =========
2647 \\{}
2647 \\{s}
26482648 \\======================================
26492649 , .{
26502650 self.expected_remaining,
......@@ -2655,9 +2655,9 @@ fn teststringify(expected: []const u8, value: anytype, options: StringifyOptions
26552655 if (!mem.eql(u8, self.expected_remaining[0..bytes.len], bytes)) {
26562656 std.debug.warn(
26572657 \\====== expected this output: =========
2658 \\{}
2658 \\{s}
26592659 \\======== instead found this: =========
2660 \\{}
2660 \\{s}
26612661 \\======================================
26622662 , .{
26632663 self.expected_remaining[0..bytes.len],
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,
lib/std/net.zig+1-1
......@@ -154,7 +154,7 @@ pub const Address = extern union {
154154 unreachable;
155155 }
156156
157 try std.fmt.format(out_stream, "{}", .{&self.un.path});
157 try std.fmt.format(out_stream, "{s}", .{&self.un.path});
158158 },
159159 else => unreachable,
160160 }
lib/std/os.zig+2-2
......@@ -4256,7 +4256,7 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 {
42564256 },
42574257 .linux => {
42584258 var procfs_buf: ["/proc/self/fd/-2147483648".len:0]u8 = undefined;
4259 const proc_path = std.fmt.bufPrint(procfs_buf[0..], "/proc/self/fd/{}\x00", .{fd}) catch unreachable;
4259 const proc_path = std.fmt.bufPrint(procfs_buf[0..], "/proc/self/fd/{d}\x00", .{fd}) catch unreachable;
42604260
42614261 const target = readlinkZ(std.meta.assumeSentinel(proc_path.ptr, 0), out_buffer) catch |err| {
42624262 switch (err) {
......@@ -4487,7 +4487,7 @@ pub const UnexpectedError = error{
44874487/// and you get an unexpected error.
44884488pub fn unexpectedErrno(err: usize) UnexpectedError {
44894489 if (unexpected_error_tracing) {
4490 std.debug.warn("unexpected errno: {}\n", .{err});
4490 std.debug.warn("unexpected errno: {d}\n", .{err});
44914491 std.debug.dumpCurrentStackTrace(null);
44924492 }
44934493 return error.Unexpected;
lib/std/os/windows.zig+1-1
......@@ -1618,7 +1618,7 @@ pub fn unexpectedError(err: Win32Error) std.os.UnexpectedError {
16181618 null,
16191619 );
16201620 _ = std.unicode.utf16leToUtf8(&buf_u8, buf_u16[0..len]) catch unreachable;
1621 std.debug.warn("error.Unexpected: GetLastError({}): {}\n", .{ @enumToInt(err), buf_u8[0..len] });
1621 std.debug.warn("error.Unexpected: GetLastError({}): {s}\n", .{ @enumToInt(err), buf_u8[0..len] });
16221622 std.debug.dumpCurrentStackTrace(null);
16231623 }
16241624 return error.Unexpected;
lib/std/process.zig+1-1
......@@ -596,7 +596,7 @@ fn testWindowsCmdLine(input_cmd_line: [*]const u16, expected_args: []const []con
596596 for (expected_args) |expected_arg| {
597597 const arg = it.next(std.testing.allocator).? catch unreachable;
598598 defer std.testing.allocator.free(arg);
599 testing.expectEqualSlices(u8, expected_arg, arg);
599 testing.expectEqualStrings(expected_arg, arg);
600600 }
601601 testing.expect(it.next(std.testing.allocator) == null);
602602}
lib/std/special/build_runner.zig+7-7
......@@ -98,7 +98,7 @@ pub fn main() !void {
9898 return usageAndErr(builder, false, stderr_stream);
9999 };
100100 builder.color = std.meta.stringToEnum(@TypeOf(builder.color), next_arg) orelse {
101 warn("expected [auto|on|off] after --color, found '{}'", .{next_arg});
101 warn("expected [auto|on|off] after --color, found '{s}'", .{next_arg});
102102 return usageAndErr(builder, false, stderr_stream);
103103 };
104104 } else if (mem.eql(u8, arg, "--override-lib-dir")) {
......@@ -126,7 +126,7 @@ pub fn main() !void {
126126 builder.args = argsRest(args, arg_idx);
127127 break;
128128 } else {
129 warn("Unrecognized argument: {}\n\n", .{arg});
129 warn("Unrecognized argument: {s}\n\n", .{arg});
130130 return usageAndErr(builder, false, stderr_stream);
131131 }
132132 } else {
......@@ -168,7 +168,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void
168168 }
169169
170170 try out_stream.print(
171 \\Usage: {} build [steps] [options]
171 \\Usage: {s} build [steps] [options]
172172 \\
173173 \\Steps:
174174 \\
......@@ -177,10 +177,10 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void
177177 const allocator = builder.allocator;
178178 for (builder.top_level_steps.items) |top_level_step| {
179179 const name = if (&top_level_step.step == builder.default_step)
180 try fmt.allocPrint(allocator, "{} (default)", .{top_level_step.step.name})
180 try fmt.allocPrint(allocator, "{s} (default)", .{top_level_step.step.name})
181181 else
182182 top_level_step.step.name;
183 try out_stream.print(" {s:<27} {}\n", .{ name, top_level_step.description });
183 try out_stream.print(" {s:<27} {s}\n", .{ name, top_level_step.description });
184184 }
185185
186186 try out_stream.writeAll(
......@@ -200,12 +200,12 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void
200200 try out_stream.print(" (none)\n", .{});
201201 } else {
202202 for (builder.available_options_list.items) |option| {
203 const name = try fmt.allocPrint(allocator, " -D{}=[{}]", .{
203 const name = try fmt.allocPrint(allocator, " -D{s}=[{s}]", .{
204204 option.name,
205205 Builder.typeIdName(option.type_id),
206206 });
207207 defer allocator.free(name);
208 try out_stream.print("{s:<29} {}\n", .{ name, option.description });
208 try out_stream.print("{s:<29} {s}\n", .{ name, option.description });
209209 }
210210 }
211211
lib/std/special/c.zig+1-1
......@@ -172,7 +172,7 @@ test "strncmp" {
172172pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {
173173 if (builtin.is_test) {
174174 @setCold(true);
175 std.debug.panic("{}", .{msg});
175 std.debug.panic("{s}", .{msg});
176176 }
177177 if (builtin.os.tag != .freestanding and builtin.os.tag != .other) {
178178 std.os.abort();
lib/std/special/compiler_rt.zig+1-1
......@@ -324,7 +324,7 @@ pub usingnamespace @import("compiler_rt/atomics.zig");
324324pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {
325325 @setCold(true);
326326 if (is_test) {
327 std.debug.panic("{}", .{msg});
327 std.debug.panic("{s}", .{msg});
328328 } else {
329329 unreachable;
330330 }
lib/std/special/test_runner.zig+8-8
......@@ -48,7 +48,7 @@ pub fn main() anyerror!void {
4848 test_node.activate();
4949 progress.refresh();
5050 if (progress.terminal == null) {
51 std.debug.print("{}/{} {}... ", .{ i + 1, test_fn_list.len, test_fn.name });
51 std.debug.print("{d}/{d} {s}... ", .{ i + 1, test_fn_list.len, test_fn.name });
5252 }
5353 const result = if (test_fn.async_frame_size) |size| switch (io_mode) {
5454 .evented => blk: {
......@@ -62,7 +62,7 @@ pub fn main() anyerror!void {
6262 .blocking => {
6363 skip_count += 1;
6464 test_node.end();
65 progress.log("{}...SKIP (async test)\n", .{test_fn.name});
65 progress.log("{s}...SKIP (async test)\n", .{test_fn.name});
6666 if (progress.terminal == null) std.debug.print("SKIP (async test)\n", .{});
6767 continue;
6868 },
......@@ -75,7 +75,7 @@ pub fn main() anyerror!void {
7575 error.SkipZigTest => {
7676 skip_count += 1;
7777 test_node.end();
78 progress.log("{}...SKIP\n", .{test_fn.name});
78 progress.log("{s}...SKIP\n", .{test_fn.name});
7979 if (progress.terminal == null) std.debug.print("SKIP\n", .{});
8080 },
8181 else => {
......@@ -86,15 +86,15 @@ pub fn main() anyerror!void {
8686 }
8787 root_node.end();
8888 if (ok_count == test_fn_list.len) {
89 std.debug.print("All {} tests passed.\n", .{ok_count});
89 std.debug.print("All {d} tests passed.\n", .{ok_count});
9090 } else {
91 std.debug.print("{} passed; {} skipped.\n", .{ ok_count, skip_count });
91 std.debug.print("{d} passed; {d} skipped.\n", .{ ok_count, skip_count });
9292 }
9393 if (log_err_count != 0) {
94 std.debug.print("{} errors were logged.\n", .{log_err_count});
94 std.debug.print("{d} errors were logged.\n", .{log_err_count});
9595 }
9696 if (leaks != 0) {
97 std.debug.print("{} tests leaked memory.\n", .{leaks});
97 std.debug.print("{d} tests leaked memory.\n", .{leaks});
9898 }
9999 if (leaks != 0 or log_err_count != 0) {
100100 std.process.exit(1);
......@@ -111,6 +111,6 @@ pub fn log(
111111 log_err_count += 1;
112112 }
113113 if (@enumToInt(message_level) <= @enumToInt(std.testing.log_level)) {
114 std.debug.print("[{}] ({}): " ++ format ++ "\n", .{ @tagName(scope), @tagName(message_level) } ++ args);
114 std.debug.print("[{s}] ({s}): " ++ format ++ "\n", .{ @tagName(scope), @tagName(message_level) } ++ args);
115115 }
116116}
lib/std/start.zig+3-3
......@@ -266,7 +266,7 @@ inline fn initEventLoopAndCallMain() u8 {
266266 if (std.event.Loop.instance) |loop| {
267267 if (!@hasDecl(root, "event_loop")) {
268268 loop.init() catch |err| {
269 std.log.err("{}", .{@errorName(err)});
269 std.log.err("{s}", .{@errorName(err)});
270270 if (@errorReturnTrace()) |trace| {
271271 std.debug.dumpStackTrace(trace.*);
272272 }
......@@ -295,7 +295,7 @@ inline fn initEventLoopAndCallWinMain() std.os.windows.INT {
295295 if (std.event.Loop.instance) |loop| {
296296 if (!@hasDecl(root, "event_loop")) {
297297 loop.init() catch |err| {
298 std.log.err("{}", .{@errorName(err)});
298 std.log.err("{s}", .{@errorName(err)});
299299 if (@errorReturnTrace()) |trace| {
300300 std.debug.dumpStackTrace(trace.*);
301301 }
......@@ -343,7 +343,7 @@ pub fn callMain() u8 {
343343 },
344344 .ErrorUnion => {
345345 const result = root.main() catch |err| {
346 std.log.err("{}", .{@errorName(err)});
346 std.log.err("{s}", .{@errorName(err)});
347347 if (@errorReturnTrace()) |trace| {
348348 std.debug.dumpStackTrace(trace.*);
349349 }
lib/std/target.zig+6-6
......@@ -136,14 +136,14 @@ pub const Target = struct {
136136 ) !void {
137137 if (fmt.len > 0 and fmt[0] == 's') {
138138 if (@enumToInt(self) >= @enumToInt(WindowsVersion.nt4) and @enumToInt(self) <= @enumToInt(WindowsVersion.latest)) {
139 try std.fmt.format(out_stream, ".{}", .{@tagName(self)});
139 try std.fmt.format(out_stream, ".{s}", .{@tagName(self)});
140140 } else {
141141 // TODO this code path breaks zig triples, but it is used in `builtin`
142142 try std.fmt.format(out_stream, "@intToEnum(Target.Os.WindowsVersion, 0x{X:0>8})", .{@enumToInt(self)});
143143 }
144144 } else {
145145 if (@enumToInt(self) >= @enumToInt(WindowsVersion.nt4) and @enumToInt(self) <= @enumToInt(WindowsVersion.latest)) {
146 try std.fmt.format(out_stream, "WindowsVersion.{}", .{@tagName(self)});
146 try std.fmt.format(out_stream, "WindowsVersion.{s}", .{@tagName(self)});
147147 } else {
148148 try std.fmt.format(out_stream, "WindowsVersion(0x{X:0>8})", .{@enumToInt(self)});
149149 }
......@@ -1177,7 +1177,7 @@ pub const Target = struct {
11771177 }
11781178
11791179 pub fn linuxTripleSimple(allocator: *mem.Allocator, cpu_arch: Cpu.Arch, os_tag: Os.Tag, abi: Abi) ![]u8 {
1180 return std.fmt.allocPrint(allocator, "{}-{}-{}", .{ @tagName(cpu_arch), @tagName(os_tag), @tagName(abi) });
1180 return std.fmt.allocPrint(allocator, "{s}-{s}-{s}", .{ @tagName(cpu_arch), @tagName(os_tag), @tagName(abi) });
11811181 }
11821182
11831183 pub fn linuxTriple(self: Target, allocator: *mem.Allocator) ![]u8 {
......@@ -1381,7 +1381,7 @@ pub const Target = struct {
13811381
13821382 if (self.abi == .android) {
13831383 const suffix = if (self.cpu.arch.ptrBitWidth() == 64) "64" else "";
1384 return print(&result, "/system/bin/linker{}", .{suffix});
1384 return print(&result, "/system/bin/linker{s}", .{suffix});
13851385 }
13861386
13871387 if (self.abi.isMusl()) {
......@@ -1395,7 +1395,7 @@ pub const Target = struct {
13951395 else => |arch| @tagName(arch),
13961396 };
13971397 const arch_suffix = if (is_arm and self.abi.floatAbi() == .hard) "hf" else "";
1398 return print(&result, "/lib/ld-musl-{}{}.so.1", .{ arch_part, arch_suffix });
1398 return print(&result, "/lib/ld-musl-{s}{s}.so.1", .{ arch_part, arch_suffix });
13991399 }
14001400
14011401 switch (self.os.tag) {
......@@ -1434,7 +1434,7 @@ pub const Target = struct {
14341434 };
14351435 const is_nan_2008 = mips.featureSetHas(self.cpu.features, .nan2008);
14361436 const loader = if (is_nan_2008) "ld-linux-mipsn8.so.1" else "ld.so.1";
1437 return print(&result, "/lib{}/{}", .{ lib_suffix, loader });
1437 return print(&result, "/lib{s}/{s}", .{ lib_suffix, loader });
14381438 },
14391439
14401440 .powerpc => return copy(&result, "/lib/ld.so.1"),
lib/std/testing.zig+8-8
......@@ -29,10 +29,10 @@ pub var zig_exe_path: []const u8 = undefined;
2929/// and then aborts when actual_error_union is not expected_error.
3030pub fn expectError(expected_error: anyerror, actual_error_union: anytype) void {
3131 if (actual_error_union) |actual_payload| {
32 std.debug.panic("expected error.{}, found {}", .{ @errorName(expected_error), actual_payload });
32 std.debug.panic("expected error.{s}, found {}", .{ @errorName(expected_error), actual_payload });
3333 } else |actual_error| {
3434 if (expected_error != actual_error) {
35 std.debug.panic("expected error.{}, found error.{}", .{
35 std.debug.panic("expected error.{s}, found error.{s}", .{
3636 @errorName(expected_error),
3737 @errorName(actual_error),
3838 });
......@@ -60,7 +60,7 @@ pub fn expectEqual(expected: anytype, actual: @TypeOf(expected)) void {
6060
6161 .Type => {
6262 if (actual != expected) {
63 std.debug.panic("expected type {}, found type {}", .{ @typeName(expected), @typeName(actual) });
63 std.debug.panic("expected type {s}, found type {s}", .{ @typeName(expected), @typeName(actual) });
6464 }
6565 },
6666
......@@ -258,7 +258,7 @@ pub fn expectEqualSlices(comptime T: type, expected: []const T, actual: []const
258258 // If the child type is u8 and no weird bytes, we could print it as strings
259259 // Even for the length difference, it would be useful to see the values of the slices probably.
260260 if (expected.len != actual.len) {
261 std.debug.panic("slice lengths differ. expected {}, found {}", .{ expected.len, actual.len });
261 std.debug.panic("slice lengths differ. expected {d}, found {d}", .{ expected.len, actual.len });
262262 }
263263 var i: usize = 0;
264264 while (i < expected.len) : (i += 1) {
......@@ -360,7 +360,7 @@ pub fn expectEqualStrings(expected: []const u8, actual: []const u8) void {
360360 for (expected[0..diff_index]) |value| {
361361 if (value == '\n') diff_line_number += 1;
362362 }
363 print("First difference occurs on line {}:\n", .{diff_line_number});
363 print("First difference occurs on line {d}:\n", .{diff_line_number});
364364
365365 print("expected:\n", .{});
366366 printIndicatorLine(expected, diff_index);
......@@ -416,15 +416,15 @@ fn printWithVisibleNewlines(source: []const u8) void {
416416 while (std.mem.indexOf(u8, source[i..], "\n")) |nl| : (i += nl + 1) {
417417 printLine(source[i .. i + nl]);
418418 }
419 print("{}␃\n", .{source[i..]}); // End of Text symbol (ETX)
419 print("{s}␃\n", .{source[i..]}); // End of Text symbol (ETX)
420420}
421421
422422fn printLine(line: []const u8) void {
423423 if (line.len != 0) switch (line[line.len - 1]) {
424 ' ', '\t' => print("{}⏎\n", .{line}), // Carriage return symbol,
424 ' ', '\t' => print("{s}⏎\n", .{line}), // Carriage return symbol,
425425 else => {},
426426 };
427 print("{}\n", .{line});
427 print("{s}\n", .{line});
428428}
429429
430430test "" {
lib/std/thread.zig+3-3
......@@ -186,7 +186,7 @@ pub const Thread = struct {
186186 @compileError(bad_startfn_ret);
187187 }
188188 startFn(arg) catch |err| {
189 std.debug.warn("error: {}\n", .{@errorName(err)});
189 std.debug.warn("error: {s}\n", .{@errorName(err)});
190190 if (@errorReturnTrace()) |trace| {
191191 std.debug.dumpStackTrace(trace.*);
192192 }
......@@ -247,7 +247,7 @@ pub const Thread = struct {
247247 @compileError(bad_startfn_ret);
248248 }
249249 startFn(arg) catch |err| {
250 std.debug.warn("error: {}\n", .{@errorName(err)});
250 std.debug.warn("error: {s}\n", .{@errorName(err)});
251251 if (@errorReturnTrace()) |trace| {
252252 std.debug.dumpStackTrace(trace.*);
253253 }
......@@ -281,7 +281,7 @@ pub const Thread = struct {
281281 @compileError(bad_startfn_ret);
282282 }
283283 startFn(arg) catch |err| {
284 std.debug.warn("error: {}\n", .{@errorName(err)});
284 std.debug.warn("error: {s}\n", .{@errorName(err)});
285285 if (@errorReturnTrace()) |trace| {
286286 std.debug.dumpStackTrace(trace.*);
287287 }
lib/std/zig/ast.zig+42-42
......@@ -281,41 +281,41 @@ pub const Error = union(enum) {
281281 }
282282 }
283283
284 pub const InvalidToken = SingleTokenError("Invalid token '{}'");
285 pub const ExpectedContainerMembers = SingleTokenError("Expected test, comptime, var decl, or container field, found '{}'");
286 pub const ExpectedStringLiteral = SingleTokenError("Expected string literal, found '{}'");
287 pub const ExpectedIntegerLiteral = SingleTokenError("Expected integer literal, found '{}'");
288 pub const ExpectedIdentifier = SingleTokenError("Expected identifier, found '{}'");
289 pub const ExpectedStatement = SingleTokenError("Expected statement, found '{}'");
290 pub const ExpectedVarDeclOrFn = SingleTokenError("Expected variable declaration or function, found '{}'");
291 pub const ExpectedVarDecl = SingleTokenError("Expected variable declaration, found '{}'");
292 pub const ExpectedFn = SingleTokenError("Expected function, found '{}'");
293 pub const ExpectedReturnType = SingleTokenError("Expected 'var' or return type expression, found '{}'");
294 pub const ExpectedAggregateKw = SingleTokenError("Expected '" ++ Token.Id.Keyword_struct.symbol() ++ "', '" ++ Token.Id.Keyword_union.symbol() ++ "', '" ++ Token.Id.Keyword_enum.symbol() ++ "', or '" ++ Token.Id.Keyword_opaque.symbol() ++ "', found '{}'");
295 pub const ExpectedEqOrSemi = SingleTokenError("Expected '=' or ';', found '{}'");
296 pub const ExpectedSemiOrLBrace = SingleTokenError("Expected ';' or '{{', found '{}'");
297 pub const ExpectedSemiOrElse = SingleTokenError("Expected ';' or 'else', found '{}'");
298 pub const ExpectedLBrace = SingleTokenError("Expected '{{', found '{}'");
299 pub const ExpectedLabelOrLBrace = SingleTokenError("Expected label or '{{', found '{}'");
300 pub const ExpectedColonOrRParen = SingleTokenError("Expected ':' or ')', found '{}'");
301 pub const ExpectedLabelable = SingleTokenError("Expected 'while', 'for', 'inline', 'suspend', or '{{', found '{}'");
302 pub const ExpectedInlinable = SingleTokenError("Expected 'while' or 'for', found '{}'");
303 pub const ExpectedAsmOutputReturnOrType = SingleTokenError("Expected '->' or '" ++ Token.Id.Identifier.symbol() ++ "', found '{}'");
304 pub const ExpectedSliceOrRBracket = SingleTokenError("Expected ']' or '..', found '{}'");
305 pub const ExpectedTypeExpr = SingleTokenError("Expected type expression, found '{}'");
306 pub const ExpectedPrimaryTypeExpr = SingleTokenError("Expected primary type expression, found '{}'");
307 pub const ExpectedExpr = SingleTokenError("Expected expression, found '{}'");
308 pub const ExpectedPrimaryExpr = SingleTokenError("Expected primary expression, found '{}'");
309 pub const ExpectedParamList = SingleTokenError("Expected parameter list, found '{}'");
310 pub const ExpectedPayload = SingleTokenError("Expected loop payload, found '{}'");
311 pub const ExpectedBlockOrAssignment = SingleTokenError("Expected block or assignment, found '{}'");
312 pub const ExpectedBlockOrExpression = SingleTokenError("Expected block or expression, found '{}'");
313 pub const ExpectedExprOrAssignment = SingleTokenError("Expected expression or assignment, found '{}'");
314 pub const ExpectedPrefixExpr = SingleTokenError("Expected prefix expression, found '{}'");
315 pub const ExpectedLoopExpr = SingleTokenError("Expected loop expression, found '{}'");
316 pub const ExpectedDerefOrUnwrap = SingleTokenError("Expected pointer dereference or optional unwrap, found '{}'");
317 pub const ExpectedSuffixOp = SingleTokenError("Expected pointer dereference, optional unwrap, or field access, found '{}'");
318 pub const ExpectedBlockOrField = SingleTokenError("Expected block or field, found '{}'");
284 pub const InvalidToken = SingleTokenError("Invalid token '{s}'");
285 pub const ExpectedContainerMembers = SingleTokenError("Expected test, comptime, var decl, or container field, found '{s}'");
286 pub const ExpectedStringLiteral = SingleTokenError("Expected string literal, found '{s}'");
287 pub const ExpectedIntegerLiteral = SingleTokenError("Expected integer literal, found '{s}'");
288 pub const ExpectedIdentifier = SingleTokenError("Expected identifier, found '{s}'");
289 pub const ExpectedStatement = SingleTokenError("Expected statement, found '{s}'");
290 pub const ExpectedVarDeclOrFn = SingleTokenError("Expected variable declaration or function, found '{s}'");
291 pub const ExpectedVarDecl = SingleTokenError("Expected variable declaration, found '{s}'");
292 pub const ExpectedFn = SingleTokenError("Expected function, found '{s}'");
293 pub const ExpectedReturnType = SingleTokenError("Expected 'var' or return type expression, found '{s}'");
294 pub const ExpectedAggregateKw = SingleTokenError("Expected '" ++ Token.Id.Keyword_struct.symbol() ++ "', '" ++ Token.Id.Keyword_union.symbol() ++ "', '" ++ Token.Id.Keyword_enum.symbol() ++ "', or '" ++ Token.Id.Keyword_opaque.symbol() ++ "', found '{s}'");
295 pub const ExpectedEqOrSemi = SingleTokenError("Expected '=' or ';', found '{s}'");
296 pub const ExpectedSemiOrLBrace = SingleTokenError("Expected ';' or '{{', found '{s}'");
297 pub const ExpectedSemiOrElse = SingleTokenError("Expected ';' or 'else', found '{s}'");
298 pub const ExpectedLBrace = SingleTokenError("Expected '{{', found '{s}'");
299 pub const ExpectedLabelOrLBrace = SingleTokenError("Expected label or '{{', found '{s}'");
300 pub const ExpectedColonOrRParen = SingleTokenError("Expected ':' or ')', found '{s}'");
301 pub const ExpectedLabelable = SingleTokenError("Expected 'while', 'for', 'inline', 'suspend', or '{{', found '{s}'");
302 pub const ExpectedInlinable = SingleTokenError("Expected 'while' or 'for', found '{s}'");
303 pub const ExpectedAsmOutputReturnOrType = SingleTokenError("Expected '->' or '" ++ Token.Id.Identifier.symbol() ++ "', found '{s}'");
304 pub const ExpectedSliceOrRBracket = SingleTokenError("Expected ']' or '..', found '{s}'");
305 pub const ExpectedTypeExpr = SingleTokenError("Expected type expression, found '{s}'");
306 pub const ExpectedPrimaryTypeExpr = SingleTokenError("Expected primary type expression, found '{s}'");
307 pub const ExpectedExpr = SingleTokenError("Expected expression, found '{s}'");
308 pub const ExpectedPrimaryExpr = SingleTokenError("Expected primary expression, found '{s}'");
309 pub const ExpectedParamList = SingleTokenError("Expected parameter list, found '{s}'");
310 pub const ExpectedPayload = SingleTokenError("Expected loop payload, found '{s}'");
311 pub const ExpectedBlockOrAssignment = SingleTokenError("Expected block or assignment, found '{s}'");
312 pub const ExpectedBlockOrExpression = SingleTokenError("Expected block or expression, found '{s}'");
313 pub const ExpectedExprOrAssignment = SingleTokenError("Expected expression or assignment, found '{s}'");
314 pub const ExpectedPrefixExpr = SingleTokenError("Expected prefix expression, found '{s}'");
315 pub const ExpectedLoopExpr = SingleTokenError("Expected loop expression, found '{s}'");
316 pub const ExpectedDerefOrUnwrap = SingleTokenError("Expected pointer dereference or optional unwrap, found '{s}'");
317 pub const ExpectedSuffixOp = SingleTokenError("Expected pointer dereference, optional unwrap, or field access, found '{s}'");
318 pub const ExpectedBlockOrField = SingleTokenError("Expected block or field, found '{s}'");
319319
320320 pub const ExpectedParamType = SimpleError("Expected parameter type");
321321 pub const ExpectedPubItem = SimpleError("Expected function or variable declaration after pub");
......@@ -332,7 +332,7 @@ pub const Error = union(enum) {
332332 node: *Node,
333333
334334 pub fn render(self: *const ExpectedCall, tokens: []const Token.Id, stream: anytype) !void {
335 return stream.print("expected " ++ @tagName(Node.Tag.Call) ++ ", found {}", .{
335 return stream.print("expected " ++ @tagName(Node.Tag.Call) ++ ", found {s}", .{
336336 @tagName(self.node.tag),
337337 });
338338 }
......@@ -343,7 +343,7 @@ pub const Error = union(enum) {
343343
344344 pub fn render(self: *const ExpectedCallOrFnProto, tokens: []const Token.Id, stream: anytype) !void {
345345 return stream.print("expected " ++ @tagName(Node.Tag.Call) ++ " or " ++
346 @tagName(Node.Tag.FnProto) ++ ", found {}", .{@tagName(self.node.tag)});
346 @tagName(Node.Tag.FnProto) ++ ", found {s}", .{@tagName(self.node.tag)});
347347 }
348348 };
349349
......@@ -355,11 +355,11 @@ pub const Error = union(enum) {
355355 const found_token = tokens[self.token];
356356 switch (found_token) {
357357 .Invalid => {
358 return stream.print("expected '{}', found invalid bytes", .{self.expected_id.symbol()});
358 return stream.print("expected '{s}', found invalid bytes", .{self.expected_id.symbol()});
359359 },
360360 else => {
361361 const token_name = found_token.symbol();
362 return stream.print("expected '{}', found '{}'", .{ self.expected_id.symbol(), token_name });
362 return stream.print("expected '{s}', found '{s}'", .{ self.expected_id.symbol(), token_name });
363363 },
364364 }
365365 }
......@@ -371,7 +371,7 @@ pub const Error = union(enum) {
371371
372372 pub fn render(self: *const ExpectedCommaOrEnd, tokens: []const Token.Id, stream: anytype) !void {
373373 const actual_token = tokens[self.token];
374 return stream.print("expected ',' or '{}', found '{}'", .{
374 return stream.print("expected ',' or '{s}', found '{s}'", .{
375375 self.end_id.symbol(),
376376 actual_token.symbol(),
377377 });
......@@ -843,7 +843,7 @@ pub const Node = struct {
843843 std.debug.warn(" ", .{});
844844 }
845845 }
846 std.debug.warn("{}\n", .{@tagName(self.tag)});
846 std.debug.warn("{s}\n", .{@tagName(self.tag)});
847847
848848 var child_i: usize = 0;
849849 while (self.iterate(child_i)) |child| : (child_i += 1) {
......@@ -1418,7 +1418,7 @@ pub const Node = struct {
14181418 @alignOf(ParamDecl),
14191419 @ptrCast([*]const u8, self) + @sizeOf(FnProto) + @sizeOf(ParamDecl) * self.params_len,
14201420 );
1421 std.debug.print("{*} flags: {b} name_token: {} {*} params_len: {}\n", .{
1421 std.debug.print("{*} flags: {b} name_token: {s} {*} params_len: {d}\n", .{
14221422 self,
14231423 self.trailer_flags.bits,
14241424 self.getNameToken(),
lib/std/zig/cross_target.zig+5-5
......@@ -519,7 +519,7 @@ pub const CrossTarget = struct {
519519 var result = std.ArrayList(u8).init(allocator);
520520 defer result.deinit();
521521
522 try result.outStream().print("{}-{}", .{ arch_name, os_name });
522 try result.outStream().print("{s}-{s}", .{ arch_name, os_name });
523523
524524 // The zig target syntax does not allow specifying a max os version with no min, so
525525 // if either are present, we need the min.
......@@ -539,9 +539,9 @@ pub const CrossTarget = struct {
539539 }
540540
541541 if (self.glibc_version) |v| {
542 try result.outStream().print("-{}.{}", .{ @tagName(self.getAbi()), v });
542 try result.outStream().print("-{s}.{}", .{ @tagName(self.getAbi()), v });
543543 } else if (self.abi) |abi| {
544 try result.outStream().print("-{}", .{@tagName(abi)});
544 try result.outStream().print("-{s}", .{@tagName(abi)});
545545 }
546546
547547 return result.toOwnedSlice();
......@@ -595,7 +595,7 @@ pub const CrossTarget = struct {
595595 .Dynamic => "",
596596 };
597597
598 return std.fmt.allocPrint(allocator, "{}-{}{}", .{ arch, os, static_suffix });
598 return std.fmt.allocPrint(allocator, "{s}-{s}{s}", .{ arch, os, static_suffix });
599599 }
600600
601601 pub const Executor = union(enum) {
......@@ -790,7 +790,7 @@ test "CrossTarget.parse" {
790790 var buf: [256]u8 = undefined;
791791 const triple = std.fmt.bufPrint(
792792 buf[0..],
793 "native-native-{}.2.1.1",
793 "native-native-{s}.2.1.1",
794794 .{@tagName(std.Target.current.abi)},
795795 ) catch unreachable;
796796
lib/std/zig/parser_test.zig+3-3
......@@ -3742,9 +3742,9 @@ fn testParse(source: []const u8, allocator: *mem.Allocator, anything_changed: *b
37423742 for (tree.errors) |*parse_error| {
37433743 const token = tree.token_locs[parse_error.loc()];
37443744 const loc = tree.tokenLocation(0, parse_error.loc());
3745 try stderr.print("(memory buffer):{}:{}: error: ", .{ loc.line + 1, loc.column + 1 });
3745 try stderr.print("(memory buffer):{d}:{d}: error: ", .{ loc.line + 1, loc.column + 1 });
37463746 try tree.renderError(parse_error, stderr);
3747 try stderr.print("\n{}\n", .{source[loc.line_start..loc.line_end]});
3747 try stderr.print("\n{s}\n", .{source[loc.line_start..loc.line_end]});
37483748 {
37493749 var i: usize = 0;
37503750 while (i < loc.column) : (i += 1) {
......@@ -3800,7 +3800,7 @@ fn testTransform(source: []const u8, expected_source: []const u8) !void {
38003800 error.OutOfMemory => {
38013801 if (failing_allocator.allocated_bytes != failing_allocator.freed_bytes) {
38023802 warn(
3803 "\nfail_index: {}/{}\nallocated bytes: {}\nfreed bytes: {}\nallocations: {}\ndeallocations: {}\n",
3803 "\nfail_index: {d}/{d}\nallocated bytes: {d}\nfreed bytes: {d}\nallocations: {d}\ndeallocations: {d}\n",
38043804 .{
38053805 fail_index,
38063806 needed_alloc_count,
lib/std/zig/render.zig+1-1
......@@ -41,7 +41,7 @@ fn renderRoot(
4141 for (tree.token_ids) |token_id, i| {
4242 if (token_id != .LineComment) break;
4343 const token_loc = tree.token_locs[i];
44 try ais.writer().print("{}\n", .{mem.trimRight(u8, tree.tokenSliceLoc(token_loc), " ")});
44 try ais.writer().print("{s}\n", .{mem.trimRight(u8, tree.tokenSliceLoc(token_loc), " ")});
4545 const next_token = tree.token_locs[i + 1];
4646 const loc = tree.tokenLocationLoc(token_loc.end, next_token);
4747 if (loc.line >= 2) {
lib/std/zig/system.zig+8-8
......@@ -51,7 +51,7 @@ pub const NativePaths = struct {
5151 };
5252 try self.addIncludeDir(include_path);
5353 } else {
54 try self.addWarningFmt("Unrecognized C flag from NIX_CFLAGS_COMPILE: {}", .{word});
54 try self.addWarningFmt("Unrecognized C flag from NIX_CFLAGS_COMPILE: {s}", .{word});
5555 break;
5656 }
5757 }
......@@ -77,7 +77,7 @@ pub const NativePaths = struct {
7777 const lib_path = word[2..];
7878 try self.addLibDir(lib_path);
7979 } else {
80 try self.addWarningFmt("Unrecognized C flag from NIX_LDFLAGS: {}", .{word});
80 try self.addWarningFmt("Unrecognized C flag from NIX_LDFLAGS: {s}", .{word});
8181 break;
8282 }
8383 }
......@@ -113,22 +113,22 @@ pub const NativePaths = struct {
113113 // TODO: some of these are suspect and should only be added on some systems. audit needed.
114114
115115 try self.addIncludeDir("/usr/local/include");
116 try self.addLibDirFmt("/usr/local/lib{}", .{qual});
116 try self.addLibDirFmt("/usr/local/lib{d}", .{qual});
117117 try self.addLibDir("/usr/local/lib");
118118
119 try self.addIncludeDirFmt("/usr/include/{}", .{triple});
120 try self.addLibDirFmt("/usr/lib/{}", .{triple});
119 try self.addIncludeDirFmt("/usr/include/{s}", .{triple});
120 try self.addLibDirFmt("/usr/lib/{s}", .{triple});
121121
122122 try self.addIncludeDir("/usr/include");
123 try self.addLibDirFmt("/lib{}", .{qual});
123 try self.addLibDirFmt("/lib{d}", .{qual});
124124 try self.addLibDir("/lib");
125 try self.addLibDirFmt("/usr/lib{}", .{qual});
125 try self.addLibDirFmt("/usr/lib{d}", .{qual});
126126 try self.addLibDir("/usr/lib");
127127
128128 // example: on a 64-bit debian-based linux distro, with zlib installed from apt:
129129 // zlib.h is in /usr/include (added above)
130130 // libz.so.1 is in /lib/x86_64-linux-gnu (added here)
131 try self.addLibDirFmt("/lib/{}", .{triple});
131 try self.addLibDirFmt("/lib/{s}", .{triple});
132132 }
133133
134134 return self;
lib/std/zig/system/macos.zig+2-2
......@@ -450,7 +450,7 @@ test "version_from_build" {
450450 for (known) |pair| {
451451 var buf: [32]u8 = undefined;
452452 const ver = try version_from_build(pair[0]);
453 const sver = try std.fmt.bufPrint(buf[0..], "{}.{}.{}", .{ ver.major, ver.minor, ver.patch });
453 const sver = try std.fmt.bufPrint(buf[0..], "{d}.{d}.{d}", .{ ver.major, ver.minor, ver.patch });
454454 std.testing.expect(std.mem.eql(u8, sver, pair[1]));
455455 }
456456}
......@@ -468,7 +468,7 @@ pub fn getSDKPath(allocator: *mem.Allocator) ![]u8 {
468468 allocator.free(result.stdout);
469469 }
470470 if (result.stderr.len != 0) {
471 std.log.err("unexpected 'xcrun --show-sdk-path' stderr: {}", .{result.stderr});
471 std.log.err("unexpected 'xcrun --show-sdk-path' stderr: {s}", .{result.stderr});
472472 }
473473 if (result.term.Exited != 0) {
474474 return error.ProcessTerminated;
lib/std/zig/tokenizer.zig+2-2
......@@ -334,7 +334,7 @@ pub const Tokenizer = struct {
334334
335335 /// For debugging purposes
336336 pub fn dump(self: *Tokenizer, token: *const Token) void {
337 std.debug.warn("{} \"{}\"\n", .{ @tagName(token.id), self.buffer[token.start..token.end] });
337 std.debug.warn("{s} \"{s}\"\n", .{ @tagName(token.id), self.buffer[token.start..token.end] });
338338 }
339339
340340 pub fn init(buffer: []const u8) Tokenizer {
......@@ -2046,7 +2046,7 @@ fn testTokenize(source: []const u8, expected_tokens: []const Token.Id) void {
20462046 for (expected_tokens) |expected_token_id| {
20472047 const token = tokenizer.next();
20482048 if (token.id != expected_token_id) {
2049 std.debug.panic("expected {}, found {}\n", .{ @tagName(expected_token_id), @tagName(token.id) });
2049 std.debug.panic("expected {s}, found {s}\n", .{ @tagName(expected_token_id), @tagName(token.id) });
20502050 }
20512051 }
20522052 const last_token = tokenizer.next();
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+52-52
......@@ -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;
......@@ -1512,7 +1512,7 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor
15121512 module.failed_decls.putAssumeCapacityNoClobber(decl, try ErrorMsg.create(
15131513 module.gpa,
15141514 decl.src(),
1515 "unable to generate C header: {}",
1515 "unable to generate C header: {s}",
15161516 .{@errorName(err)},
15171517 ));
15181518 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,56 +1544,56 @@ 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 => {
15941594 libtsan.buildTsan(self) catch |err| {
15951595 // TODO Expose this as a normal compile error rather than crashing here.
1596 fatal("unable to build TSAN library: {}", .{@errorName(err)});
1596 fatal("unable to build TSAN library: {s}", .{@errorName(err)});
15971597 };
15981598 },
15991599 .compiler_rt_lib => {
......@@ -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});
1986 return comp.failCObj(c_object, "clang exited with code {}", .{code});
1985 log.err("clang failed with stderr: {s}", .{stderr});
1986 return comp.failCObj(c_object, "clang exited with code {d}", .{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.{z};
2657 \\pub const link_mode = LinkMode.{z};
26582658 \\pub const is_test = {};
26592659 \\pub const single_threaded = {};
2660 \\pub const abi = Abi.{};
2660 \\pub const abi = Abi.{z};
26612661 \\pub const cpu: Cpu = Cpu{{
2662 \\ .arch = .{},
2663 \\ .model = &Target.{}.cpu.{},
2664 \\ .features = Target.{}.featureSet(&[_]Target.{}.Feature{{
2662 \\ .arch = .{z},
2663 \\ .model = &Target.{z}.cpu.{z},
2664 \\ .features = Target.{z}.featureSet(&[_]Target.{z}.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 = .{z},
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.{z};
2782 \\pub const mode = Mode.{z};
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.{z};
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 {s} 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 };
......@@ -3021,7 +3021,7 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node
30213021 if (!mem.eql(u8, prev_digest[0..digest.len], &digest))
30223022 break :hit;
30233023
3024 log.debug("stage1 {} digest={} match - skipping invocation", .{ mod.root_pkg.root_src_path, digest });
3024 log.debug("stage1 {s} digest={} match - skipping invocation", .{ mod.root_pkg.root_src_path, digest });
30253025 var flags_bytes: [1]u8 = undefined;
30263026 _ = std.fmt.hexToBytes(&flags_bytes, prev_digest[digest.len..]) catch {
30273027 log.warn("bad cache stage1 digest: '{s}'", .{prev_digest});
......@@ -3044,7 +3044,7 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node
30443044 mod.stage1_flags = @bitCast(@TypeOf(mod.stage1_flags), flags_bytes[0]);
30453045 return;
30463046 }
3047 log.debug("stage1 {} prev_digest={} new_digest={}", .{ mod.root_pkg.root_src_path, prev_digest, digest });
3047 log.debug("stage1 {s} prev_digest={} new_digest={}", .{ mod.root_pkg.root_src_path, prev_digest, digest });
30483048 man.unhit(prev_hash_state, input_file_count);
30493049 }
30503050
......@@ -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+4-4
......@@ -366,14 +366,14 @@ 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);
373373 } else {
374374 try printCharValues(writer, index_and_bytes.bytes);
375375 }
376 try writer.print("' at position {}", .{index_and_bytes.index});
376 try writer.print("' at position {d}", .{index_and_bytes.index});
377377 },
378378 .invalid_target,
379379 .bad_target_escape,
......@@ -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 {d}: {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} {d} bytes ", .{ label, bytes.len });
947947 try out.writeAll(text);
948948 var i: usize = text.len;
949949 const end = 79;
src/Module.zig+25-25
......@@ -248,7 +248,7 @@ pub const Decl = struct {
248248
249249 pub fn dump(self: *Decl) void {
250250 const loc = std.zig.findLineColumn(self.scope.source.bytes, self.src);
251 std.debug.print("{}:{}:{} name={} status={}", .{
251 std.debug.print("{s}:{d}:{d} name={s} status={s}", .{
252252 self.scope.sub_file_path,
253253 loc.line + 1,
254254 loc.column + 1,
......@@ -308,7 +308,7 @@ pub const Fn = struct {
308308
309309 /// For debugging purposes.
310310 pub fn dump(self: *Fn, mod: Module) void {
311 std.debug.print("Module.Function(name={}) ", .{self.owner_decl.name});
311 std.debug.print("Module.Function(name={s}) ", .{self.owner_decl.name});
312312 switch (self.analysis) {
313313 .queued => {
314314 std.debug.print("queued\n", .{});
......@@ -632,7 +632,7 @@ pub const Scope = struct {
632632
633633 pub fn dumpSrc(self: *File, src: usize) void {
634634 const loc = std.zig.findLineColumn(self.source.bytes, src);
635 std.debug.print("{}:{}:{}\n", .{ self.sub_file_path, loc.line + 1, loc.column + 1 });
635 std.debug.print("{s}:{d}:{d}\n", .{ self.sub_file_path, loc.line + 1, loc.column + 1 });
636636 }
637637
638638 pub fn getSource(self: *File, module: *Module) ![:0]const u8 {
......@@ -730,7 +730,7 @@ pub const Scope = struct {
730730
731731 pub fn dumpSrc(self: *ZIRModule, src: usize) void {
732732 const loc = std.zig.findLineColumn(self.source.bytes, src);
733 std.debug.print("{}:{}:{}\n", .{ self.sub_file_path, loc.line + 1, loc.column + 1 });
733 std.debug.print("{s}:{d}:{d}\n", .{ self.sub_file_path, loc.line + 1, loc.column + 1 });
734734 }
735735
736736 pub fn getSource(self: *ZIRModule, module: *Module) ![:0]const u8 {
......@@ -918,7 +918,7 @@ pub fn ensureDeclAnalyzed(self: *Module, decl: *Decl) InnerError!void {
918918 .complete => return,
919919
920920 .outdated => blk: {
921 log.debug("re-analyzing {}\n", .{decl.name});
921 log.debug("re-analyzing {s}\n", .{decl.name});
922922
923923 // The exports this Decl performs will be re-discovered, so we remove them here
924924 // prior to re-analysis.
......@@ -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)) {
......@@ -1641,7 +1641,7 @@ pub fn analyzeContainer(self: *Module, container_scope: *Scope.Container) !void
16411641 }
16421642 } else if (src_decl.castTag(.Comptime)) |comptime_node| {
16431643 const name_index = self.getNextAnonNameIndex();
1644 const name = try std.fmt.allocPrint(self.gpa, "__comptime_{}", .{name_index});
1644 const name = try std.fmt.allocPrint(self.gpa, "__comptime_{d}", .{name_index});
16451645 defer self.gpa.free(name);
16461646
16471647 const name_hash = container_scope.fullyQualifiedNameHash(name);
......@@ -1663,7 +1663,7 @@ pub fn analyzeContainer(self: *Module, container_scope: *Scope.Container) !void
16631663 // Handle explicitly deleted decls from the source code. Not to be confused
16641664 // with when we delete decls because they are no longer referenced.
16651665 for (deleted_decls.items()) |entry| {
1666 log.debug("noticed '{}' deleted from source\n", .{entry.key.name});
1666 log.debug("noticed '{s}' deleted from source\n", .{entry.key.name});
16671667 try self.deleteDecl(entry.key);
16681668 }
16691669}
......@@ -1716,7 +1716,7 @@ pub fn analyzeRootZIRModule(self: *Module, root_scope: *Scope.ZIRModule) !void {
17161716 // Handle explicitly deleted decls from the source code. Not to be confused
17171717 // with when we delete decls because they are no longer referenced.
17181718 for (deleted_decls.items()) |entry| {
1719 log.debug("noticed '{}' deleted from source\n", .{entry.key.name});
1719 log.debug("noticed '{s}' deleted from source\n", .{entry.key.name});
17201720 try self.deleteDecl(entry.key);
17211721 }
17221722}
......@@ -1728,7 +1728,7 @@ pub fn deleteDecl(self: *Module, decl: *Decl) !void {
17281728 // not be present in the set, and this does nothing.
17291729 decl.scope.removeDecl(decl);
17301730
1731 log.debug("deleting decl '{}'\n", .{decl.name});
1731 log.debug("deleting decl '{s}'\n", .{decl.name});
17321732 const name_hash = decl.fullyQualifiedNameHash();
17331733 self.decl_table.removeAssertDiscard(name_hash);
17341734 // Remove itself from its dependencies, because we are about to destroy the decl pointer.
......@@ -1819,17 +1819,17 @@ pub fn analyzeFnBody(self: *Module, decl: *Decl, func: *Fn) !void {
18191819 const fn_zir = func.analysis.queued;
18201820 defer fn_zir.arena.promote(self.gpa).deinit();
18211821 func.analysis = .{ .in_progress = {} };
1822 log.debug("set {} to in_progress\n", .{decl.name});
1822 log.debug("set {s} to in_progress\n", .{decl.name});
18231823
18241824 try zir_sema.analyzeBody(self, &inner_block.base, fn_zir.body);
18251825
18261826 const instructions = try arena.allocator.dupe(*Inst, inner_block.instructions.items);
18271827 func.analysis = .{ .success = .{ .instructions = instructions } };
1828 log.debug("set {} to success\n", .{decl.name});
1828 log.debug("set {s} to success\n", .{decl.name});
18291829}
18301830
18311831fn markOutdatedDecl(self: *Module, decl: *Decl) !void {
1832 log.debug("mark {} outdated\n", .{decl.name});
1832 log.debug("mark {s} outdated\n", .{decl.name});
18331833 try self.comp.work_queue.writeItem(.{ .analyze_decl = decl });
18341834 if (self.failed_decls.remove(decl)) |entry| {
18351835 entry.value.destroy(self.gpa);
......@@ -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_{d}", .{ 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
......@@ -2555,7 +2555,7 @@ pub fn cmpNumeric(
25552555
25562556 if (lhs_ty_tag == .Vector and rhs_ty_tag == .Vector) {
25572557 if (lhs.ty.arrayLen() != rhs.ty.arrayLen()) {
2558 return self.fail(scope, src, "vector length mismatch: {} and {}", .{
2558 return self.fail(scope, src, "vector length mismatch: {d} and {d}", .{
25592559 lhs.ty.arrayLen(),
25602560 rhs.ty.arrayLen(),
25612561 });
......@@ -2700,7 +2700,7 @@ pub fn cmpNumeric(
27002700 const dest_type = if (dest_float_type) |ft| ft else blk: {
27012701 const max_bits = std.math.max(lhs_bits, rhs_bits);
27022702 const casted_bits = std.math.cast(u16, max_bits) catch |err| switch (err) {
2703 error.Overflow => return self.fail(scope, src, "{} exceeds maximum integer bit count", .{max_bits}),
2703 error.Overflow => return self.fail(scope, src, "{d} exceeds maximum integer bit count", .{max_bits}),
27042704 };
27052705 break :blk try self.makeIntType(scope, dest_int_is_signed, casted_bits);
27062706 };
......@@ -3319,7 +3319,7 @@ pub fn dumpInst(self: *Module, scope: *Scope, inst: *Inst) void {
33193319 const source = zir_module.getSource(self) catch @panic("dumpInst failed to get source");
33203320 const loc = std.zig.findLineColumn(source, inst.src);
33213321 if (inst.tag == .constant) {
3322 std.debug.print("constant ty={} val={} src={}:{}:{}\n", .{
3322 std.debug.print("constant ty={} val={} src={s}:{d}:{d}\n", .{
33233323 inst.ty,
33243324 inst.castTag(.constant).?.val,
33253325 zir_module.subFilePath(),
......@@ -3327,7 +3327,7 @@ pub fn dumpInst(self: *Module, scope: *Scope, inst: *Inst) void {
33273327 loc.column + 1,
33283328 });
33293329 } else if (inst.deaths == 0) {
3330 std.debug.print("{} ty={} src={}:{}:{}\n", .{
3330 std.debug.print("{s} ty={} src={s}:{d}:{d}\n", .{
33313331 @tagName(inst.tag),
33323332 inst.ty,
33333333 zir_module.subFilePath(),
......@@ -3335,7 +3335,7 @@ pub fn dumpInst(self: *Module, scope: *Scope, inst: *Inst) void {
33353335 loc.column + 1,
33363336 });
33373337 } else {
3338 std.debug.print("{} ty={} deaths={b} src={}:{}:{}\n", .{
3338 std.debug.print("{s} ty={} deaths={b} src={s}:{d}:{d}\n", .{
33393339 @tagName(inst.tag),
33403340 inst.ty,
33413341 inst.deaths,
src/astgen.zig+9-9
......@@ -385,7 +385,7 @@ fn breakExpr(mod: *Module, parent_scope: *Scope, node: *ast.Node.ControlFlowExpr
385385 .local_ptr => scope = scope.cast(Scope.LocalPtr).?.parent,
386386 else => if (node.getLabel()) |break_label| {
387387 const label_name = try identifierTokenString(mod, parent_scope, break_label);
388 return mod.failTok(parent_scope, break_label, "label not found: '{}'", .{label_name});
388 return mod.failTok(parent_scope, break_label, "label not found: '{s}'", .{label_name});
389389 } else {
390390 return mod.failTok(parent_scope, src, "break expression outside loop", .{});
391391 },
......@@ -427,7 +427,7 @@ fn continueExpr(mod: *Module, parent_scope: *Scope, node: *ast.Node.ControlFlowE
427427 .local_ptr => scope = scope.cast(Scope.LocalPtr).?.parent,
428428 else => if (node.getLabel()) |break_label| {
429429 const label_name = try identifierTokenString(mod, parent_scope, break_label);
430 return mod.failTok(parent_scope, break_label, "label not found: '{}'", .{label_name});
430 return mod.failTok(parent_scope, break_label, "label not found: '{s}'", .{label_name});
431431 } else {
432432 return mod.failTok(parent_scope, src, "continue expression outside loop", .{});
433433 },
......@@ -560,14 +560,14 @@ fn varDecl(
560560 .local_val => {
561561 const local_val = s.cast(Scope.LocalVal).?;
562562 if (mem.eql(u8, local_val.name, ident_name)) {
563 return mod.fail(scope, name_src, "redefinition of '{}'", .{ident_name});
563 return mod.fail(scope, name_src, "redefinition of '{s}'", .{ident_name});
564564 }
565565 s = local_val.parent;
566566 },
567567 .local_ptr => {
568568 const local_ptr = s.cast(Scope.LocalPtr).?;
569569 if (mem.eql(u8, local_ptr.name, ident_name)) {
570 return mod.fail(scope, name_src, "redefinition of '{}'", .{ident_name});
570 return mod.fail(scope, name_src, "redefinition of '{s}'", .{ident_name});
571571 }
572572 s = local_ptr.parent;
573573 },
......@@ -578,7 +578,7 @@ fn varDecl(
578578
579579 // Namespace vars shadowing detection
580580 if (mod.lookupDeclName(scope, ident_name)) |_| {
581 return mod.fail(scope, name_src, "redefinition of '{}'", .{ident_name});
581 return mod.fail(scope, name_src, "redefinition of '{s}'", .{ident_name});
582582 }
583583 const init_node = node.getInitNode() orelse
584584 return mod.fail(scope, name_src, "variables must be initialized", .{});
......@@ -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 {d} parameter{s}, found {d}", .{ 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-8
......@@ -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(')');
......@@ -383,7 +383,7 @@ const Context = struct {
383383 }
384384
385385 fn name(self: *Context) ![]u8 {
386 const val = try std.fmt.allocPrint(&self.arena.allocator, "__temp_{}", .{self.unnamed_index});
386 const val = try std.fmt.allocPrint(&self.arena.allocator, "__temp_{d}", .{self.unnamed_index});
387387 self.unnamed_index += 1;
388388 return val;
389389 }
......@@ -420,7 +420,7 @@ fn genAlloc(ctx: *Context, file: *C, alloc: *Inst.NoOp) !?[]u8 {
420420}
421421
422422fn genArg(ctx: *Context) !?[]u8 {
423 const name = try std.fmt.allocPrint(&ctx.arena.allocator, "arg{}", .{ctx.argdex});
423 const name = try std.fmt.allocPrint(&ctx.arena.allocator, "arg{d}", .{ctx.argdex});
424424 ctx.argdex += 1;
425425 return name;
426426}
......@@ -528,7 +528,7 @@ fn genCall(ctx: *Context, file: *C, inst: *Inst.Call) !?[]u8 {
528528 try renderValue(ctx, writer, arg.ty, val);
529529 } else {
530530 const val = try ctx.resolveInst(arg);
531 try writer.print("{}", .{val});
531 try writer.print("{s}", .{val});
532532 }
533533 }
534534 }
......@@ -587,7 +587,7 @@ fn genAsm(ctx: *Context, file: *C, as: *Inst.Assembly) !?[]u8 {
587587 const arg = as.args[index];
588588 try writer.writeAll("register ");
589589 try renderType(ctx, writer, arg.ty);
590 try writer.print(" {}_constant __asm__(\"{}\") = ", .{ reg, reg });
590 try writer.print(" {s}_constant __asm__(\"{s}\") = ", .{ reg, reg });
591591 // TODO merge constant handling into inst_map as well
592592 if (arg.castTag(.constant)) |c| {
593593 try renderValue(ctx, writer, arg.ty, c.val);
......@@ -597,13 +597,13 @@ fn genAsm(ctx: *Context, file: *C, as: *Inst.Assembly) !?[]u8 {
597597 if (!gop.found_existing) {
598598 return ctx.fail(ctx.decl.src(), "Internal error in C backend: asm argument not found in inst_map", .{});
599599 }
600 try writer.print("{};\n ", .{gop.entry.value});
600 try writer.print("{s};\n ", .{gop.entry.value});
601601 }
602602 } else {
603603 return ctx.fail(ctx.decl.src(), "TODO non-explicit inline asm regs", .{});
604604 }
605605 }
606 try writer.print("__asm {} (\"{}\"", .{ if (as.is_volatile) @as([]const u8, "volatile") else "", as.asm_source });
606 try writer.print("__asm {s} (\"{s}\"", .{ if (as.is_volatile) @as([]const u8, "volatile") else "", as.asm_source });
607607 if (as.output) |o| {
608608 return ctx.fail(ctx.decl.src(), "TODO inline asm output", .{});
609609 }
......@@ -619,7 +619,7 @@ fn genAsm(ctx: *Context, file: *C, as: *Inst.Assembly) !?[]u8 {
619619 if (index > 0) {
620620 try writer.writeAll(", ");
621621 }
622 try writer.print("\"\"({}_constant)", .{reg});
622 try writer.print("\"\"({s}_constant)", .{reg});
623623 } else {
624624 // This is blocked by the earlier test
625625 unreachable;
src/glibc.zig+21-21
......@@ -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 };
......@@ -111,12 +111,12 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError!
111111 while (it.next()) |line| : (line_i += 1) {
112112 const prefix = "GLIBC_";
113113 if (!mem.startsWith(u8, line, prefix)) {
114 std.log.err("vers.txt:{}: expected 'GLIBC_' prefix", .{line_i});
114 std.log.err("vers.txt:{d}: expected 'GLIBC_' prefix", .{line_i});
115115 return error.ZigInstallationCorrupt;
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:{d}: unable to parse glibc version '{s}': {s}", .{ line_i, line, @errorName(err) });
120120 return error.ZigInstallationCorrupt;
121121 };
122122 try all_versions.append(arena, ver);
......@@ -128,15 +128,15 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError!
128128 while (file_it.next()) |line| : (line_i += 1) {
129129 var line_it = mem.tokenize(line, " ");
130130 const fn_name = line_it.next() orelse {
131 std.log.err("fns.txt:{}: expected function name", .{line_i});
131 std.log.err("fns.txt:{d}: expected function name", .{line_i});
132132 return error.ZigInstallationCorrupt;
133133 };
134134 const lib_name = line_it.next() orelse {
135 std.log.err("fns.txt:{}: expected library name", .{line_i});
135 std.log.err("fns.txt:{d}: expected library name", .{line_i});
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:{d}: unknown library name: {s}", .{ line_i, lib_name });
140140 return error.ZigInstallationCorrupt;
141141 };
142142 try all_functions.append(arena, .{
......@@ -158,27 +158,27 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError!
158158 while (line_it.next()) |target_string| {
159159 var component_it = mem.tokenize(target_string, "-");
160160 const arch_name = component_it.next() orelse {
161 std.log.err("abi.txt:{}: expected arch name", .{line_i});
161 std.log.err("abi.txt:{d}: expected arch name", .{line_i});
162162 return error.ZigInstallationCorrupt;
163163 };
164164 const os_name = component_it.next() orelse {
165 std.log.err("abi.txt:{}: expected OS name", .{line_i});
165 std.log.err("abi.txt:{d}: expected OS name", .{line_i});
166166 return error.ZigInstallationCorrupt;
167167 };
168168 const abi_name = component_it.next() orelse {
169 std.log.err("abi.txt:{}: expected ABI name", .{line_i});
169 std.log.err("abi.txt:{d}: expected ABI name", .{line_i});
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:{d}: 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:{d}: 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:{d}: unrecognized ABI: '{s}'", .{ line_i, abi_name });
182182 return error.ZigInstallationCorrupt;
183183 };
184184
......@@ -193,7 +193,7 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError!
193193 };
194194 for (ver_list_base) |*ver_list| {
195195 const line = file_it.next() orelse {
196 std.log.err("abi.txt:{}: missing version number line", .{line_i});
196 std.log.err("abi.txt:{d}: missing version number line", .{line_i});
197197 return error.ZigInstallationCorrupt;
198198 };
199199 line_i += 1;
......@@ -206,12 +206,12 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError!
206206 while (line_it.next()) |version_index_string| {
207207 if (ver_list.len >= ver_list.versions.len) {
208208 // If this happens with legit data, increase the array len in the type.
209 std.log.err("abi.txt:{}: too many versions", .{line_i});
209 std.log.err("abi.txt:{d}: too many versions", .{line_i});
210210 return error.ZigInstallationCorrupt;
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:{d}: 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+5-5
......@@ -523,7 +523,7 @@ pub const File = struct {
523523 id_symlink_basename,
524524 &prev_digest_buf,
525525 ) catch |err| b: {
526 log.debug("archive new_digest={} readFile error: {}", .{ digest, @errorName(err) });
526 log.debug("archive new_digest={} readFile error: {s}", .{ digest, @errorName(err) });
527527 break :b prev_digest_buf[0..0];
528528 };
529529 if (mem.eql(u8, prev_digest, &digest)) {
......@@ -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+1-1
......@@ -112,7 +112,7 @@ pub fn flushModule(self: *C, comp: *Compilation) !void {
112112 try writer.writeByte('\n');
113113 }
114114 if (self.constants.items.len > 0) {
115 try writer.print("{}\n", .{self.constants.items});
115 try writer.print("{s}\n", .{self.constants.items});
116116 }
117117 if (self.main.items.len > 1) {
118118 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+12-12
......@@ -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 {d} 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 {d} 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 }
......@@ -2300,7 +2300,7 @@ pub fn updateDecl(self: *Elf, module: *Module, decl: *Module.Decl) !void {
23002300 !mem.isAlignedGeneric(u64, local_sym.st_value, required_alignment);
23012301 if (need_realloc) {
23022302 const vaddr = try self.growTextBlock(&decl.link.elf, code.len, required_alignment);
2303 log.debug("growing {} from 0x{x} to 0x{x}\n", .{ decl.name, local_sym.st_value, vaddr });
2303 log.debug("growing {s} from 0x{x} to 0x{x}\n", .{ decl.name, local_sym.st_value, vaddr });
23042304 if (vaddr != local_sym.st_value) {
23052305 local_sym.st_value = vaddr;
23062306
......@@ -2322,7 +2322,7 @@ pub fn updateDecl(self: *Elf, module: *Module, decl: *Module.Decl) !void {
23222322 const decl_name = mem.spanZ(decl.name);
23232323 const name_str_index = try self.makeString(decl_name);
23242324 const vaddr = try self.allocateTextBlock(&decl.link.elf, code.len, required_alignment);
2325 log.debug("allocated text block for {} at 0x{x}\n", .{ decl_name, vaddr });
2325 log.debug("allocated text block for {s} at 0x{x}\n", .{ decl_name, vaddr });
23262326 errdefer self.freeTextBlock(&decl.link.elf);
23272327
23282328 local_sym.* = .{
......@@ -2432,7 +2432,7 @@ pub fn updateDecl(self: *Elf, module: *Module, decl: *Module.Decl) !void {
24322432 if (needed_size > self.allocatedSize(debug_line_sect.sh_offset)) {
24332433 const new_offset = self.findFreeSpace(needed_size, 1);
24342434 const existing_size = last_src_fn.off;
2435 log.debug("moving .debug_line section: {} bytes from 0x{x} to 0x{x}\n", .{
2435 log.debug("moving .debug_line section: {d} bytes from 0x{x} to 0x{x}\n", .{
24362436 existing_size,
24372437 debug_line_sect.sh_offset,
24382438 new_offset,
src/link/MachO.zig+12-12
......@@ -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 };
......@@ -620,7 +620,7 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void {
620620 try argv.append(cur_vers);
621621 }
622622
623 const dylib_install_name = try std.fmt.allocPrint(arena, "@rpath/{}", .{self.base.options.emit.?.sub_path});
623 const dylib_install_name = try std.fmt.allocPrint(arena, "@rpath/{s}", .{self.base.options.emit.?.sub_path});
624624 try argv.append("-install_name");
625625 try argv.append(dylib_install_name);
626626 }
......@@ -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/liveness.zig+2-1
......@@ -1,6 +1,7 @@
11const std = @import("std");
22const ir = @import("ir.zig");
33const trace = @import("tracy.zig").trace;
4const log = std.log.scoped(.liveness);
45
56/// Perform Liveness Analysis over the `Body`. Each `Inst` will have its `deaths` field populated.
67pub fn analyze(
......@@ -248,5 +249,5 @@ fn analyzeInst(
248249 @panic("Handle liveness analysis for instructions with many parameters");
249250 }
250251
251 std.log.scoped(.liveness).debug("analyze {}: 0b{b}\n", .{ base.tag, base.deaths });
252 log.debug("analyze {}: 0b{b}\n", .{ base.tag, base.deaths });
252253}
src/llvm_backend.zig+1-1
......@@ -132,7 +132,7 @@ pub fn targetTriple(allocator: *Allocator, target: std.Target) ![:0]u8 {
132132 .macabi => "macabi",
133133 };
134134
135 return std.fmt.allocPrintZ(allocator, "{}-unknown-{}-{}", .{ llvm_arch, llvm_os, llvm_abi });
135 return std.fmt.allocPrintZ(allocator, "{s}-unknown-{s}-{s}", .{ llvm_arch, llvm_os, llvm_abi });
136136}
137137
138138pub const LLVMIRModule = struct {
src/main.zig+121-121
......@@ -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;
......@@ -626,7 +626,7 @@ fn buildOutputType(
626626 fs.path.dirname(pkg_path),
627627 fs.path.basename(pkg_path),
628628 ) catch |err| {
629 fatal("Failed to add package at path {}: {}", .{ pkg_path, @errorName(err) });
629 fatal("Failed to add package at path {s}: {s}", .{ pkg_path, @errorName(err) });
630630 };
631631 new_cur_pkg.parent = cur_pkg;
632632 try cur_pkg.add(gpa, pkg_name, new_cur_pkg);
......@@ -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| {
699 fatal("unable to parse '{}': {}", .{ arg, @errorName(err) });
699 fatal("unable to parse '{s}': {s}", .{ 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| {
705 fatal("unable to parse '{}': {}", .{ arg, @errorName(err) });
705 fatal("unable to parse '{s}': {s}", .{ 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 {d}:\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}:{d}:{d}: {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 {d}:\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}:{d}:{d}: 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/test.zig+1-1
......@@ -660,7 +660,7 @@ pub const TestContext = struct {
660660 }
661661 }
662662 if (comp.bin_file.cast(link.File.C)) |c_file| {
663 std.debug.print("Generated C: \n===============\n{}\n\n===========\n\n", .{
663 std.debug.print("Generated C: \n===============\n{s}\n\n===========\n\n", .{
664664 c_file.main.items,
665665 });
666666 }
src/translate_c.zig+46-46
......@@ -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}_{d}", .{ 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 {
......@@ -440,7 +440,7 @@ pub fn translate(
440440 mem.copy(*ast.Node, root_node.decls(), context.root_decls.items);
441441
442442 if (false) {
443 std.debug.warn("debug source:\n{}\n==EOF==\ntokens:\n", .{source_buffer.items});
443 std.debug.warn("debug source:\n{s}\n==EOF==\ntokens:\n", .{source_buffer.items});
444444 for (context.token_ids.items) |token| {
445445 std.debug.warn("{}\n", .{token});
446446 }
......@@ -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 }
......@@ -945,7 +945,7 @@ fn transRecordDecl(c: *Context, record_decl: *const clang.RecordDecl) Error!?*as
945945 // Record declarations such as `struct {...} x` have no name but they're not
946946 // anonymous hence here isAnonymousStructOrUnion is not needed
947947 if (bare_name.len == 0) {
948 bare_name = try std.fmt.allocPrint(c.arena, "unnamed_{}", .{c.getMangle()});
948 bare_name = try std.fmt.allocPrint(c.arena, "unnamed_{d}", .{c.getMangle()});
949949 is_unnamed = true;
950950 }
951951
......@@ -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
......@@ -1019,7 +1019,7 @@ fn transRecordDecl(c: *Context, record_decl: *const clang.RecordDecl) Error!?*as
10191019 var raw_name = try c.str(@ptrCast(*const clang.NamedDecl, field_decl).getName_bytes_begin());
10201020 if (field_decl.isAnonymousStructOrUnion() or raw_name.len == 0) {
10211021 // Context.getMangle() is not used here because doing so causes unpredictable field names for anonymous fields.
1022 raw_name = try std.fmt.allocPrint(c.arena, "unnamed_{}", .{unnamed_field_count});
1022 raw_name = try std.fmt.allocPrint(c.arena, "unnamed_{d}", .{unnamed_field_count});
10231023 unnamed_field_count += 1;
10241024 is_anon = true;
10251025 }
......@@ -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,
......@@ -1110,11 +1110,11 @@ fn transEnumDecl(c: *Context, enum_decl: *const clang.EnumDecl) Error!?*ast.Node
11101110 var bare_name = try c.str(@ptrCast(*const clang.NamedDecl, enum_decl).getName_bytes_begin());
11111111 var is_unnamed = false;
11121112 if (bare_name.len == 0) {
1113 bare_name = try std.fmt.allocPrint(c.arena, "unnamed_{}", .{c.getMangle()});
1113 bare_name = try std.fmt.allocPrint(c.arena, "unnamed_{d}", .{c.getMangle()});
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
......@@ -3957,7 +3956,7 @@ fn qualTypeToLog2IntRef(rp: RestorePoint, qt: clang.QualType, source_loc: clang.
39573956 const node = try rp.c.arena.create(ast.Node.OneToken);
39583957 node.* = .{
39593958 .base = .{ .tag = .IntegerLiteral },
3960 .token = try appendTokenFmt(rp.c, .Identifier, "u{}", .{cast_bit_width}),
3959 .token = try appendTokenFmt(rp.c, .Identifier, "u{d}", .{cast_bit_width}),
39613960 };
39623961 return &node.base;
39633962 }
......@@ -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 },
......@@ -4484,7 +4484,7 @@ fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: *ast.Node, proto_a
44844484 _ = try appendToken(c, .Comma, ",");
44854485 }
44864486 const param_name_tok = param.name_token orelse
4487 try appendTokenFmt(c, .Identifier, "arg_{}", .{c.getMangle()});
4487 try appendTokenFmt(c, .Identifier, "arg_{d}", .{c.getMangle()});
44884488
44894489 _ = try appendToken(c, .Colon, ":");
44904490
......@@ -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 }
......@@ -5916,11 +5916,11 @@ fn parseCPrimaryExprInner(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!*
59165916 // struct Foo will be declared as struct_Foo by transRecordDecl
59175917 const next_id = m.next().?;
59185918 if (next_id != .Identifier) {
5919 try m.fail(c, "unable to translate C expr: expected Identifier instead got: {}", .{@tagName(next_id)});
5919 try m.fail(c, "unable to translate C expr: expected Identifier instead got: {s}", .{@tagName(next_id)});
59205920 return error.ParseError;
59215921 }
59225922
5923 const ident_token = try appendTokenFmt(c, .Identifier, "{}_{}", .{ slice, m.slice() });
5923 const ident_token = try appendTokenFmt(c, .Identifier, "{s}_{s}", .{ slice, m.slice() });
59245924 const identifier = try c.arena.create(ast.Node.OneToken);
59255925 identifier.* = .{
59265926 .base = .{ .tag = .Identifier },
......@@ -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/type.zig+4-4
......@@ -558,21 +558,21 @@ pub const Type = extern union {
558558 },
559559 .array_u8 => {
560560 const len = ty.castTag(.array_u8).?.data;
561 return out_stream.print("[{}]u8", .{len});
561 return out_stream.print("[{d}]u8", .{len});
562562 },
563563 .array_u8_sentinel_0 => {
564564 const len = ty.castTag(.array_u8_sentinel_0).?.data;
565 return out_stream.print("[{}:0]u8", .{len});
565 return out_stream.print("[{d}:0]u8", .{len});
566566 },
567567 .array => {
568568 const payload = ty.castTag(.array).?.data;
569 try out_stream.print("[{}]", .{payload.len});
569 try out_stream.print("[{d}]", .{payload.len});
570570 ty = payload.elem_type;
571571 continue;
572572 },
573573 .array_sentinel => {
574574 const payload = ty.castTag(.array_sentinel).?.data;
575 try out_stream.print("[{}:{}]", .{ payload.len, payload.sentinel });
575 try out_stream.print("[{d}:{}]", .{ payload.len, payload.sentinel });
576576 ty = payload.elem_type;
577577 continue;
578578 },
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+31-32
......@@ -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 }
......@@ -1257,12 +1257,12 @@ const Writer = struct {
12571257 self.next_instr_index += 1;
12581258 try self.inst_table.putNoClobber(inst, .{ .inst = inst, .index = my_i, .name = undefined });
12591259 try stream.writeByteNTimes(' ', self.indent);
1260 try stream.print("%{} ", .{my_i});
1260 try stream.print("%{d} ", .{my_i});
12611261 if (inst.cast(Inst.Block)) |block| {
1262 const name = try std.fmt.allocPrint(&self.arena.allocator, "label_{}", .{my_i});
1262 const name = try std.fmt.allocPrint(&self.arena.allocator, "label_{d}", .{my_i});
12631263 try self.block_table.put(block, name);
12641264 } else if (inst.cast(Inst.Loop)) |loop| {
1265 const name = try std.fmt.allocPrint(&self.arena.allocator, "loop_{}", .{my_i});
1265 const name = try std.fmt.allocPrint(&self.arena.allocator, "loop_{d}", .{my_i});
12661266 try self.loop_table.put(loop, name);
12671267 }
12681268 self.indent += 2;
......@@ -1332,18 +1332,18 @@ const Writer = struct {
13321332 fn writeInstParamToStream(self: *Writer, stream: anytype, inst: *Inst) !void {
13331333 if (self.inst_table.get(inst)) |info| {
13341334 if (info.index) |i| {
1335 try stream.print("%{}", .{info.index});
1335 try stream.print("%{d}", .{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 }
......@@ -1660,7 +1660,6 @@ const Parser = struct {
16601660 .contents_hash = std.zig.hashSrc(self.source[contents_start..self.i]),
16611661 .inst = &inst_specific.base,
16621662 };
1663 //std.debug.warn("parsed {} = '{}'\n", .{ inst_specific.base.name, inst_specific.base.contents });
16641663
16651664 return decl;
16661665 }
......@@ -1672,7 +1671,7 @@ const Parser = struct {
16721671 ' ', '\n', ',', ')' => {
16731672 const enum_name = self.source[start..self.i];
16741673 return std.meta.stringToEnum(T, enum_name) orelse {
1675 return self.fail("tag '{}' not a member of enum '{}'", .{ enum_name, @typeName(T) });
1674 return self.fail("tag '{s}' not a member of enum '{s}'", .{ enum_name, @typeName(T) });
16761675 };
16771676 },
16781677 0 => return self.failByte(0),
......@@ -1710,7 +1709,7 @@ const Parser = struct {
17101709 BigIntConst => return self.parseIntegerLiteral(),
17111710 usize => {
17121711 const big_int = try self.parseIntegerLiteral();
1713 return big_int.to(usize) catch |err| return self.fail("integer literal: {}", .{@errorName(err)});
1712 return big_int.to(usize) catch |err| return self.fail("integer literal: {s}", .{@errorName(err)});
17141713 },
17151714 TypedValue => return self.fail("'const' is a special instruction; not legal in ZIR text", .{}),
17161715 *IrModule.Decl => return self.fail("'declval_in_module' is a special instruction; not legal in ZIR text", .{}),
......@@ -1759,7 +1758,7 @@ const Parser = struct {
17591758 },
17601759 else => @compileError("Unimplemented: ir parseParameterGeneric for type " ++ @typeName(T)),
17611760 }
1762 return self.fail("TODO parse parameter {}", .{@typeName(T)});
1761 return self.fail("TODO parse parameter {s}", .{@typeName(T)});
17631762 }
17641763
17651764 fn parseParameterInst(self: *Parser, body_ctx: ?*Body) !*Inst {
......@@ -1788,7 +1787,7 @@ const Parser = struct {
17881787 const src = name_start - 1;
17891788 if (local_ref) {
17901789 self.i = src;
1791 return self.fail("unrecognized identifier: {}", .{bad_name});
1790 return self.fail("unrecognized identifier: {s}", .{bad_name});
17921791 } else {
17931792 const declval = try self.arena.allocator.create(Inst.DeclVal);
17941793 declval.* = .{
......@@ -1805,7 +1804,7 @@ const Parser = struct {
18051804 }
18061805
18071806 fn generateName(self: *Parser) ![]u8 {
1808 const result = try std.fmt.allocPrint(&self.arena.allocator, "unnamed${}", .{self.unnamed_index});
1807 const result = try std.fmt.allocPrint(&self.arena.allocator, "unnamed${d}", .{self.unnamed_index});
18091808 self.unnamed_index += 1;
18101809 return result;
18111810 }
......@@ -1873,7 +1872,7 @@ pub fn dumpFn(old_module: IrModule, module_fn: *IrModule.Fn) void {
18731872
18741873 const fn_ty = module_fn.owner_decl.typed_value.most_recent.typed_value.ty;
18751874 _ = ctx.emitFn(module_fn, 0, fn_ty) catch |err| {
1876 std.debug.print("unable to dump function: {}\n", .{err});
1875 std.debug.print("unable to dump function: {s}\n", .{@errorName(err)});
18771876 return;
18781877 };
18791878 var module = Module{
......@@ -2203,7 +2202,7 @@ const EmitZIR = struct {
22032202 };
22042203 return self.emitStringLiteral(src, bytes);
22052204 },
2206 else => |t| std.debug.panic("TODO implement emitTypedValue for pointer to {}", .{@tagName(t)}),
2205 else => |t| std.debug.panic("TODO implement emitTypedValue for pointer to {s}", .{@tagName(t)}),
22072206 }
22082207 },
22092208 .ComptimeInt => return self.emitComptimeIntVal(src, typed_value.val),
......@@ -2274,7 +2273,7 @@ const EmitZIR = struct {
22742273 };
22752274 return self.emitUnnamedDecl(&inst.base);
22762275 },
2277 else => |t| std.debug.panic("TODO implement emitTypedValue for {}", .{@tagName(t)}),
2276 else => |t| std.debug.panic("TODO implement emitTypedValue for {s}", .{@tagName(t)}),
22782277 }
22792278 }
22802279
......@@ -2865,7 +2864,7 @@ const EmitZIR = struct {
28652864
28662865 fn autoName(self: *EmitZIR) ![]u8 {
28672866 while (true) {
2868 const proposed_name = try std.fmt.allocPrint(&self.arena.allocator, "unnamed${}", .{self.next_auto_name});
2867 const proposed_name = try std.fmt.allocPrint(&self.arena.allocator, "unnamed${d}", .{self.next_auto_name});
28692868 self.next_auto_name += 1;
28702869 const gop = try self.names.getOrPut(proposed_name);
28712870 if (!gop.found_existing) {
......@@ -2947,25 +2946,25 @@ pub fn dumpZir(allocator: *Allocator, kind: []const u8, decl_name: [*:0]const u8
29472946 try write.inst_table.ensureCapacity(@intCast(u32, instructions.len));
29482947
29492948 const stderr = std.io.getStdErr().outStream();
2950 try stderr.print("{} {s} {{ // unanalyzed\n", .{ kind, decl_name });
2949 try stderr.print("{s} {s} {{ // unanalyzed\n", .{ kind, decl_name });
29512950
29522951 for (instructions) |inst| {
29532952 const my_i = write.next_instr_index;
29542953 write.next_instr_index += 1;
29552954
29562955 if (inst.cast(Inst.Block)) |block| {
2957 const name = try std.fmt.allocPrint(&write.arena.allocator, "label_{}", .{my_i});
2956 const name = try std.fmt.allocPrint(&write.arena.allocator, "label_{d}", .{my_i});
29582957 try write.block_table.put(block, name);
29592958 } else if (inst.cast(Inst.Loop)) |loop| {
2960 const name = try std.fmt.allocPrint(&write.arena.allocator, "loop_{}", .{my_i});
2959 const name = try std.fmt.allocPrint(&write.arena.allocator, "loop_{d}", .{my_i});
29612960 try write.loop_table.put(loop, name);
29622961 }
29632962
29642963 try write.inst_table.putNoClobber(inst, .{ .inst = inst, .index = my_i, .name = "inst" });
2965 try stderr.print(" %{} ", .{my_i});
2964 try stderr.print(" %{d} ", .{my_i});
29662965 try write.writeInstToStream(stderr, inst);
29672966 try stderr.writeByte('\n');
29682967 }
29692968
2970 try stderr.print("}} // {} {s}\n\n", .{ kind, decl_name });
2969 try stderr.print("}} // {s} {s}\n\n", .{ kind, decl_name });
29712970}
src/zir_sema.zig+24-24
......@@ -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
......@@ -535,7 +535,7 @@ fn analyzeInstParamType(mod: *Module, scope: *Scope, inst: *zir.Inst.ParamType)
535535 // TODO support C-style var args
536536 const param_count = fn_ty.fnParamLen();
537537 if (arg_index >= param_count) {
538 return mod.fail(scope, inst.base.src, "arg index {} out of bounds; '{}' has {} argument(s)", .{
538 return mod.fail(scope, inst.base.src, "arg index {d} out of bounds; '{}' has {d} argument(s)", .{
539539 arg_index,
540540 fn_ty,
541541 param_count,
......@@ -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 {
......@@ -580,7 +580,7 @@ fn analyzeInstArg(mod: *Module, scope: *Scope, inst: *zir.Inst.Arg) InnerError!*
580580 const param_index = b.instructions.items.len;
581581 const param_count = fn_ty.fnParamLen();
582582 if (param_index >= param_count) {
583 return mod.fail(scope, inst.base.src, "parameter index {} outside list of length {}", .{
583 return mod.fail(scope, inst.base.src, "parameter index {d} outside list of length {d}", .{
584584 param_index,
585585 param_count,
586586 });
......@@ -790,7 +790,7 @@ fn analyzeInstCall(mod: *Module, scope: *Scope, inst: *zir.Inst.Call) InnerError
790790 return mod.fail(
791791 scope,
792792 inst.positionals.func.src,
793 "expected at least {} argument(s), found {}",
793 "expected at least {d} argument(s), found {d}",
794794 .{ fn_params_len, call_params_len },
795795 );
796796 }
......@@ -800,7 +800,7 @@ fn analyzeInstCall(mod: *Module, scope: *Scope, inst: *zir.Inst.Call) InnerError
800800 return mod.fail(
801801 scope,
802802 inst.positionals.func.src,
803 "expected {} argument(s), found {}",
803 "expected {d} argument(s), found {d}",
804804 .{ fn_params_len, call_params_len },
805805 );
806806 }
......@@ -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);
......@@ -1545,7 +1545,7 @@ fn analyzeInstBitwise(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerE
15451545
15461546 if (lhs.ty.zigTypeTag() == .Vector and rhs.ty.zigTypeTag() == .Vector) {
15471547 if (lhs.ty.arrayLen() != rhs.ty.arrayLen()) {
1548 return mod.fail(scope, inst.base.src, "vector length mismatch: {} and {}", .{
1548 return mod.fail(scope, inst.base.src, "vector length mismatch: {d} and {d}", .{
15491549 lhs.ty.arrayLen(),
15501550 rhs.ty.arrayLen(),
15511551 });
......@@ -1620,7 +1620,7 @@ fn analyzeInstArithmetic(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) Inn
16201620
16211621 if (lhs.ty.zigTypeTag() == .Vector and rhs.ty.zigTypeTag() == .Vector) {
16221622 if (lhs.ty.arrayLen() != rhs.ty.arrayLen()) {
1623 return mod.fail(scope, inst.base.src, "vector length mismatch: {} and {}", .{
1623 return mod.fail(scope, inst.base.src, "vector length mismatch: {d} and {d}", .{
16241624 lhs.ty.arrayLen(),
16251625 rhs.ty.arrayLen(),
16261626 });
......@@ -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()) {
......@@ -1791,7 +1791,7 @@ fn analyzeInstCmp(
17911791 return mod.cmpNumeric(scope, inst.base.src, lhs, rhs, op);
17921792 } else if (lhs_ty_tag == .Type and rhs_ty_tag == .Type) {
17931793 if (!is_equality_cmp) {
1794 return mod.fail(scope, inst.base.src, "{} operator not allowed for types", .{@tagName(op)});
1794 return mod.fail(scope, inst.base.src, "{s} operator not allowed for types", .{@tagName(op)});
17951795 }
17961796 return mod.constBool(scope, inst.base.src, lhs.value().?.eql(rhs.value().?) == (op == .eq));
17971797 }
......@@ -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
test/compare_output.zig+2-2
......@@ -453,7 +453,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
453453 \\ _ = args_it.skip();
454454 \\ while (args_it.next(allocator)) |arg_or_err| : (index += 1) {
455455 \\ const arg = try arg_or_err;
456 \\ try stdout.print("{}: {}\n", .{index, arg});
456 \\ try stdout.print("{}: {s}\n", .{index, arg});
457457 \\ }
458458 \\}
459459 ,
......@@ -492,7 +492,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
492492 \\ _ = args_it.skip();
493493 \\ while (args_it.next(allocator)) |arg_or_err| : (index += 1) {
494494 \\ const arg = try arg_or_err;
495 \\ try stdout.print("{}: {}\n", .{index, arg});
495 \\ try stdout.print("{}: {s}\n", .{index, arg});
496496 \\ }
497497 \\}
498498 ,
test/src/compare_output.zig+3-3
......@@ -97,7 +97,7 @@ pub const CompareOutputContext = struct {
9797
9898 switch (case.special) {
9999 Special.Asm => {
100 const annotated_case_name = fmt.allocPrint(self.b.allocator, "assemble-and-link {}", .{
100 const annotated_case_name = fmt.allocPrint(self.b.allocator, "assemble-and-link {s}", .{
101101 case.name,
102102 }) catch unreachable;
103103 if (self.test_filter) |filter| {
......@@ -116,7 +116,7 @@ pub const CompareOutputContext = struct {
116116 },
117117 Special.None => {
118118 for (self.modes) |mode| {
119 const annotated_case_name = fmt.allocPrint(self.b.allocator, "{} {} ({})", .{
119 const annotated_case_name = fmt.allocPrint(self.b.allocator, "{s} {s} ({s})", .{
120120 "compare-output",
121121 case.name,
122122 @tagName(mode),
......@@ -141,7 +141,7 @@ pub const CompareOutputContext = struct {
141141 }
142142 },
143143 Special.RuntimeSafety => {
144 const annotated_case_name = fmt.allocPrint(self.b.allocator, "safety {}", .{case.name}) catch unreachable;
144 const annotated_case_name = fmt.allocPrint(self.b.allocator, "safety {s}", .{case.name}) catch unreachable;
145145 if (self.test_filter) |filter| {
146146 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
147147 }
test/src/run_translated_c.zig+4-4
......@@ -77,7 +77,7 @@ pub const RunTranslatedCContext = struct {
7777 pub fn addCase(self: *RunTranslatedCContext, case: *const TestCase) void {
7878 const b = self.b;
7979
80 const annotated_case_name = fmt.allocPrint(self.b.allocator, "run-translated-c {}", .{case.name}) catch unreachable;
80 const annotated_case_name = fmt.allocPrint(self.b.allocator, "run-translated-c {s}", .{case.name}) catch unreachable;
8181 if (self.test_filter) |filter| {
8282 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
8383 }
......@@ -92,13 +92,13 @@ pub const RunTranslatedCContext = struct {
9292 .basename = case.sources.items[0].filename,
9393 },
9494 });
95 translate_c.step.name = b.fmt("{} translate-c", .{annotated_case_name});
95 translate_c.step.name = b.fmt("{s} translate-c", .{annotated_case_name});
9696 const exe = translate_c.addExecutable();
9797 exe.setTarget(self.target);
98 exe.step.name = b.fmt("{} build-exe", .{annotated_case_name});
98 exe.step.name = b.fmt("{s} build-exe", .{annotated_case_name});
9999 exe.linkLibC();
100100 const run = exe.run();
101 run.step.name = b.fmt("{} run", .{annotated_case_name});
101 run.step.name = b.fmt("{s} run", .{annotated_case_name});
102102 if (!case.allow_warnings) {
103103 run.expectStdErrEqual("");
104104 }
test/src/translate_c.zig+1-1
......@@ -99,7 +99,7 @@ pub const TranslateCContext = struct {
9999 const b = self.b;
100100
101101 const translate_c_cmd = "translate-c";
102 const annotated_case_name = fmt.allocPrint(self.b.allocator, "{} {}", .{ translate_c_cmd, case.name }) catch unreachable;
102 const annotated_case_name = fmt.allocPrint(self.b.allocator, "{s} {s}", .{ translate_c_cmd, case.name }) catch unreachable;
103103 if (self.test_filter) |filter| {
104104 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
105105 }
test/stage1/behavior.zig+1-1
......@@ -141,5 +141,5 @@ comptime {
141141 _ = @import("behavior/while.zig");
142142 _ = @import("behavior/widening.zig");
143143 _ = @import("behavior/src.zig");
144 _ = @import("behavior/translate_c_macros.zig");
144 // _ = @import("behavior/translate_c_macros.zig");
145145}
test/stage1/behavior/async_fn.zig+2-1
......@@ -2,6 +2,7 @@ const std = @import("std");
22const builtin = @import("builtin");
33const expect = std.testing.expect;
44const expectEqual = std.testing.expectEqual;
5const expectEqualStrings = std.testing.expectEqualStrings;
56const expectError = std.testing.expectError;
67
78var global_x: i32 = 1;
......@@ -541,7 +542,7 @@ test "pass string literal to async function" {
541542 fn hello(msg: []const u8) void {
542543 frame = @frame();
543544 suspend;
544 expectEqual(@as([]const u8, "hello"), msg);
545 expectEqualStrings("hello", msg);
545546 ok = true;
546547 }
547548 };
test/tests.zig+31-31
......@@ -482,7 +482,7 @@ pub fn addPkgTests(
482482 is_wasmtime_enabled: bool,
483483 glibc_dir: ?[]const u8,
484484) *build.Step {
485 const step = b.step(b.fmt("test-{}", .{name}), desc);
485 const step = b.step(b.fmt("test-{s}", .{name}), desc);
486486
487487 for (test_targets) |test_target| {
488488 if (skip_non_native and !test_target.target.isNative())
......@@ -523,7 +523,7 @@ pub fn addPkgTests(
523523
524524 const these_tests = b.addTest(root_src);
525525 const single_threaded_txt = if (test_target.single_threaded) "single" else "multi";
526 these_tests.setNamePrefix(b.fmt("{}-{}-{}-{}-{} ", .{
526 these_tests.setNamePrefix(b.fmt("{s}-{s}-{s}-{s}-{s} ", .{
527527 name,
528528 triple_prefix,
529529 @tagName(test_target.mode),
......@@ -570,7 +570,7 @@ pub const StackTracesContext = struct {
570570 const expect_for_mode = expect[@enumToInt(mode)];
571571 if (expect_for_mode.len == 0) continue;
572572
573 const annotated_case_name = fmt.allocPrint(self.b.allocator, "{} {} ({})", .{
573 const annotated_case_name = fmt.allocPrint(self.b.allocator, "{s} {s} ({s})", .{
574574 "stack-trace",
575575 name,
576576 @tagName(mode),
......@@ -637,7 +637,7 @@ pub const StackTracesContext = struct {
637637 defer args.deinit();
638638 args.append(full_exe_path) catch unreachable;
639639
640 warn("Test {}/{} {}...", .{ self.test_index + 1, self.context.test_index, self.name });
640 warn("Test {d}/{d} {s}...", .{ self.test_index + 1, self.context.test_index, self.name });
641641
642642 const child = std.ChildProcess.init(args.items, b.allocator) catch unreachable;
643643 defer child.deinit();
......@@ -650,7 +650,7 @@ pub const StackTracesContext = struct {
650650 if (b.verbose) {
651651 printInvocation(args.items);
652652 }
653 child.spawn() catch |err| debug.panic("Unable to spawn {}: {}\n", .{ full_exe_path, @errorName(err) });
653 child.spawn() catch |err| debug.panic("Unable to spawn {s}: {s}\n", .{ full_exe_path, @errorName(err) });
654654
655655 const stdout = child.stdout.?.inStream().readAllAlloc(b.allocator, max_stdout_size) catch unreachable;
656656 defer b.allocator.free(stdout);
......@@ -659,14 +659,14 @@ pub const StackTracesContext = struct {
659659 var stderr = stderrFull;
660660
661661 const term = child.wait() catch |err| {
662 debug.panic("Unable to spawn {}: {}\n", .{ full_exe_path, @errorName(err) });
662 debug.panic("Unable to spawn {s}: {s}\n", .{ full_exe_path, @errorName(err) });
663663 };
664664
665665 switch (term) {
666666 .Exited => |code| {
667667 const expect_code: u32 = 1;
668668 if (code != expect_code) {
669 warn("Process {} exited with error code {} but expected code {}\n", .{
669 warn("Process {s} exited with error code {d} but expected code {d}\n", .{
670670 full_exe_path,
671671 code,
672672 expect_code,
......@@ -676,17 +676,17 @@ pub const StackTracesContext = struct {
676676 }
677677 },
678678 .Signal => |signum| {
679 warn("Process {} terminated on signal {}\n", .{ full_exe_path, signum });
679 warn("Process {s} terminated on signal {d}\n", .{ full_exe_path, signum });
680680 printInvocation(args.items);
681681 return error.TestFailed;
682682 },
683683 .Stopped => |signum| {
684 warn("Process {} stopped on signal {}\n", .{ full_exe_path, signum });
684 warn("Process {s} stopped on signal {d}\n", .{ full_exe_path, signum });
685685 printInvocation(args.items);
686686 return error.TestFailed;
687687 },
688688 .Unknown => |code| {
689 warn("Process {} terminated unexpectedly with error code {}\n", .{ full_exe_path, code });
689 warn("Process {s} terminated unexpectedly with error code {d}\n", .{ full_exe_path, code });
690690 printInvocation(args.items);
691691 return error.TestFailed;
692692 },
......@@ -732,9 +732,9 @@ pub const StackTracesContext = struct {
732732 warn(
733733 \\
734734 \\========= Expected this output: =========
735 \\{}
735 \\{s}
736736 \\================================================
737 \\{}
737 \\{s}
738738 \\
739739 , .{ self.expect_output, got });
740740 return error.TestFailed;
......@@ -856,7 +856,7 @@ pub const CompileErrorContext = struct {
856856 zig_args.append("-O") catch unreachable;
857857 zig_args.append(@tagName(self.build_mode)) catch unreachable;
858858
859 warn("Test {}/{} {}...", .{ self.test_index + 1, self.context.test_index, self.name });
859 warn("Test {d}/{d} {s}...", .{ self.test_index + 1, self.context.test_index, self.name });
860860
861861 if (b.verbose) {
862862 printInvocation(zig_args.items);
......@@ -870,7 +870,7 @@ pub const CompileErrorContext = struct {
870870 child.stdout_behavior = .Pipe;
871871 child.stderr_behavior = .Pipe;
872872
873 child.spawn() catch |err| debug.panic("Unable to spawn {}: {}\n", .{ zig_args.items[0], @errorName(err) });
873 child.spawn() catch |err| debug.panic("Unable to spawn {s}: {s}\n", .{ zig_args.items[0], @errorName(err) });
874874
875875 var stdout_buf = ArrayList(u8).init(b.allocator);
876876 var stderr_buf = ArrayList(u8).init(b.allocator);
......@@ -879,7 +879,7 @@ pub const CompileErrorContext = struct {
879879 child.stderr.?.inStream().readAllArrayList(&stderr_buf, max_stdout_size) catch unreachable;
880880
881881 const term = child.wait() catch |err| {
882 debug.panic("Unable to spawn {}: {}\n", .{ zig_args.items[0], @errorName(err) });
882 debug.panic("Unable to spawn {s}: {s}\n", .{ zig_args.items[0], @errorName(err) });
883883 };
884884 switch (term) {
885885 .Exited => |code| {
......@@ -889,7 +889,7 @@ pub const CompileErrorContext = struct {
889889 }
890890 },
891891 else => {
892 warn("Process {} terminated unexpectedly\n", .{b.zig_exe});
892 warn("Process {s} terminated unexpectedly\n", .{b.zig_exe});
893893 printInvocation(zig_args.items);
894894 return error.TestFailed;
895895 },
......@@ -903,7 +903,7 @@ pub const CompileErrorContext = struct {
903903 \\
904904 \\Expected empty stdout, instead found:
905905 \\================================================
906 \\{}
906 \\{s}
907907 \\================================================
908908 \\
909909 , .{stdout});
......@@ -926,7 +926,7 @@ pub const CompileErrorContext = struct {
926926 if (!ok) {
927927 warn("\n======== Expected these compile errors: ========\n", .{});
928928 for (self.case.expected_errors.items) |expected| {
929 warn("{}\n", .{expected});
929 warn("{s}\n", .{expected});
930930 }
931931 }
932932 } else {
......@@ -935,7 +935,7 @@ pub const CompileErrorContext = struct {
935935 warn(
936936 \\
937937 \\=========== Expected compile error: ============
938 \\{}
938 \\{s}
939939 \\
940940 , .{expected});
941941 ok = false;
......@@ -947,7 +947,7 @@ pub const CompileErrorContext = struct {
947947 if (!ok) {
948948 warn(
949949 \\================= Full output: =================
950 \\{}
950 \\{s}
951951 \\
952952 , .{stderr});
953953 return error.TestFailed;
......@@ -1023,7 +1023,7 @@ pub const CompileErrorContext = struct {
10231023 pub fn addCase(self: *CompileErrorContext, case: *const TestCase) void {
10241024 const b = self.b;
10251025
1026 const annotated_case_name = fmt.allocPrint(self.b.allocator, "compile-error {}", .{
1026 const annotated_case_name = fmt.allocPrint(self.b.allocator, "compile-error {s}", .{
10271027 case.name,
10281028 }) catch unreachable;
10291029 if (self.test_filter) |filter| {
......@@ -1058,7 +1058,7 @@ pub const StandaloneContext = struct {
10581058 pub fn addBuildFile(self: *StandaloneContext, build_file: []const u8) void {
10591059 const b = self.b;
10601060
1061 const annotated_case_name = b.fmt("build {} (Debug)", .{build_file});
1061 const annotated_case_name = b.fmt("build {s} (Debug)", .{build_file});
10621062 if (self.test_filter) |filter| {
10631063 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
10641064 }
......@@ -1079,7 +1079,7 @@ pub const StandaloneContext = struct {
10791079
10801080 const run_cmd = b.addSystemCommand(zig_args.items);
10811081
1082 const log_step = b.addLog("PASS {}\n", .{annotated_case_name});
1082 const log_step = b.addLog("PASS {s}\n", .{annotated_case_name});
10831083 log_step.step.dependOn(&run_cmd.step);
10841084
10851085 self.step.dependOn(&log_step.step);
......@@ -1089,7 +1089,7 @@ pub const StandaloneContext = struct {
10891089 const b = self.b;
10901090
10911091 for (self.modes) |mode| {
1092 const annotated_case_name = fmt.allocPrint(self.b.allocator, "build {} ({})", .{
1092 const annotated_case_name = fmt.allocPrint(self.b.allocator, "build {s} ({s})", .{
10931093 root_src,
10941094 @tagName(mode),
10951095 }) catch unreachable;
......@@ -1103,7 +1103,7 @@ pub const StandaloneContext = struct {
11031103 exe.linkSystemLibrary("c");
11041104 }
11051105
1106 const log_step = b.addLog("PASS {}\n", .{annotated_case_name});
1106 const log_step = b.addLog("PASS {s}\n", .{annotated_case_name});
11071107 log_step.step.dependOn(&exe.step);
11081108
11091109 self.step.dependOn(&log_step.step);
......@@ -1172,7 +1172,7 @@ pub const GenHContext = struct {
11721172 const self = @fieldParentPtr(GenHCmpOutputStep, "step", step);
11731173 const b = self.context.b;
11741174
1175 warn("Test {}/{} {}...", .{ self.test_index + 1, self.context.test_index, self.name });
1175 warn("Test {d}/{d} {s}...", .{ self.test_index + 1, self.context.test_index, self.name });
11761176
11771177 const full_h_path = self.obj.getOutputHPath();
11781178 const actual_h = try io.readFileAlloc(b.allocator, full_h_path);
......@@ -1182,9 +1182,9 @@ pub const GenHContext = struct {
11821182 warn(
11831183 \\
11841184 \\========= Expected this output: ================
1185 \\{}
1185 \\{s}
11861186 \\========= But found: ===========================
1187 \\{}
1187 \\{s}
11881188 \\
11891189 , .{ expected_line, actual_h });
11901190 return error.TestFailed;
......@@ -1196,7 +1196,7 @@ pub const GenHContext = struct {
11961196
11971197 fn printInvocation(args: []const []const u8) void {
11981198 for (args) |arg| {
1199 warn("{} ", .{arg});
1199 warn("{s} ", .{arg});
12001200 }
12011201 warn("\n", .{});
12021202 }
......@@ -1232,7 +1232,7 @@ pub const GenHContext = struct {
12321232 const b = self.b;
12331233
12341234 const mode = builtin.Mode.Debug;
1235 const annotated_case_name = fmt.allocPrint(self.b.allocator, "gen-h {} ({})", .{ case.name, @tagName(mode) }) catch unreachable;
1235 const annotated_case_name = fmt.allocPrint(self.b.allocator, "gen-h {s} ({s})", .{ case.name, @tagName(mode) }) catch unreachable;
12361236 if (self.test_filter) |filter| {
12371237 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
12381238 }
......@@ -1253,7 +1253,7 @@ pub const GenHContext = struct {
12531253
12541254fn printInvocation(args: []const []const u8) void {
12551255 for (args) |arg| {
1256 warn("{} ", .{arg});
1256 warn("{s} ", .{arg});
12571257 }
12581258 warn("\n", .{});
12591259}