| author | |
| committer | |
| log | fb37c1b0912c65d72b82f32df8bc7e780ab1ad80 |
| tree | c12b14dceebe7f6055fe07cfed2780d2b5c7bf60 |
| parent | db1e97d4b19d8399252e0fbc85fc3563b005a892 |
| parent | 974c008a0ee0e0d7933e37d5ea930f712d494f6a |
closes #687076 files changed, 912 insertions(+), 847 deletions(-)
build.zig+8-8| ... | @@ -224,7 +224,7 @@ pub fn build(b: *Builder) !void { | ... | @@ -224,7 +224,7 @@ pub fn build(b: *Builder) !void { |
| 224 | 224 | ||
| 225 | const opt_version_string = b.option([]const u8, "version-string", "Override Zig version string. Default is to find out with git."); | 225 | const opt_version_string = b.option([]const u8, "version-string", "Override Zig version string. Default is to find out with git."); |
| 226 | const version = if (opt_version_string) |version| version else v: { | 226 | 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 }); |
| 228 | 228 | ||
| 229 | var code: u8 = undefined; | 229 | var code: u8 = undefined; |
| 230 | const git_describe_untrimmed = b.execAllowFail(&[_][]const u8{ | 230 | const git_describe_untrimmed = b.execAllowFail(&[_][]const u8{ |
| ... | @@ -238,7 +238,7 @@ pub fn build(b: *Builder) !void { | ... | @@ -238,7 +238,7 @@ pub fn build(b: *Builder) !void { |
| 238 | 0 => { | 238 | 0 => { |
| 239 | // Tagged release version (e.g. 0.7.0). | 239 | // Tagged release version (e.g. 0.7.0). |
| 240 | if (!mem.eql(u8, git_describe, version_string)) { | 240 | 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 }); |
| 242 | std.process.exit(1); | 242 | std.process.exit(1); |
| 243 | } | 243 | } |
| 244 | break :v version_string; | 244 | break :v version_string; |
| ... | @@ -258,15 +258,15 @@ pub fn build(b: *Builder) !void { | ... | @@ -258,15 +258,15 @@ pub fn build(b: *Builder) !void { |
| 258 | 258 | ||
| 259 | // Check that the commit hash is prefixed with a 'g' (a Git convention). | 259 | // Check that the commit hash is prefixed with a 'g' (a Git convention). |
| 260 | if (commit_id.len < 1 or commit_id[0] != 'g') { | 260 | 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}); |
| 262 | break :v version_string; | 262 | break :v version_string; |
| 263 | } | 263 | } |
| 264 | 264 | ||
| 265 | // The version is reformatted in accordance with the https://semver.org specification. | 265 | // 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..] }); |
| 267 | }, | 267 | }, |
| 268 | else => { | 268 | else => { |
| 269 | std.debug.print("Unexpected `git describe` output: {}\n", .{git_describe}); | 269 | std.debug.print("Unexpected `git describe` output: {s}\n", .{git_describe}); |
| 270 | break :v version_string; | 270 | break :v version_string; |
| 271 | }, | 271 | }, |
| 272 | } | 272 | } |
| ... | @@ -369,14 +369,14 @@ fn addCxxKnownPath( | ... | @@ -369,14 +369,14 @@ fn addCxxKnownPath( |
| 369 | ) !void { | 369 | ) !void { |
| 370 | const path_padded = try b.exec(&[_][]const u8{ | 370 | const path_padded = try b.exec(&[_][]const u8{ |
| 371 | ctx.cxx_compiler, | 371 | ctx.cxx_compiler, |
| 372 | b.fmt("-print-file-name={}", .{objname}), | 372 | b.fmt("-print-file-name={s}", .{objname}), |
| 373 | }); | 373 | }); |
| 374 | const path_unpadded = mem.tokenize(path_padded, "\r\n").next().?; | 374 | const path_unpadded = mem.tokenize(path_padded, "\r\n").next().?; |
| 375 | if (mem.eql(u8, path_unpadded, objname)) { | 375 | if (mem.eql(u8, path_unpadded, objname)) { |
| 376 | if (errtxt) |msg| { | 376 | if (errtxt) |msg| { |
| 377 | warn("{}", .{msg}); | 377 | warn("{s}", .{msg}); |
| 378 | } else { | 378 | } else { |
| 379 | warn("Unable to determine path to {}\n", .{objname}); | 379 | warn("Unable to determine path to {s}\n", .{objname}); |
| 380 | } | 380 | } |
| 381 | return error.RequiredLibraryNotFound; | 381 | return error.RequiredLibraryNotFound; |
| 382 | } | 382 | } |
doc/docgen.zig+54-54| ... | @@ -215,9 +215,9 @@ const Tokenizer = struct { | ... | @@ -215,9 +215,9 @@ const Tokenizer = struct { |
| 215 | fn parseError(tokenizer: *Tokenizer, token: Token, comptime fmt: []const u8, args: anytype) anyerror { | 215 | fn parseError(tokenizer: *Tokenizer, token: Token, comptime fmt: []const u8, args: anytype) anyerror { |
| 216 | const loc = tokenizer.getTokenLocation(token); | 216 | const loc = tokenizer.getTokenLocation(token); |
| 217 | const args_prefix = .{ tokenizer.source_file_name, loc.line + 1, loc.column + 1 }; | 217 | 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); |
| 219 | if (loc.line_start <= loc.line_end) { | 219 | 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]}); |
| 221 | { | 221 | { |
| 222 | var i: usize = 0; | 222 | var i: usize = 0; |
| 223 | while (i < loc.column) : (i += 1) { | 223 | while (i < loc.column) : (i += 1) { |
| ... | @@ -238,7 +238,7 @@ fn parseError(tokenizer: *Tokenizer, token: Token, comptime fmt: []const u8, arg | ... | @@ -238,7 +238,7 @@ fn parseError(tokenizer: *Tokenizer, token: Token, comptime fmt: []const u8, arg |
| 238 | 238 | ||
| 239 | fn assertToken(tokenizer: *Tokenizer, token: Token, id: Token.Id) !void { | 239 | fn assertToken(tokenizer: *Tokenizer, token: Token, id: Token.Id) !void { |
| 240 | if (token.id != id) { | 240 | 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) }); |
| 242 | } | 242 | } |
| 243 | } | 243 | } |
| 244 | 244 | ||
| ... | @@ -374,7 +374,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { | ... | @@ -374,7 +374,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { |
| 374 | return parseError( | 374 | return parseError( |
| 375 | tokenizer, | 375 | tokenizer, |
| 376 | bracket_tok, | 376 | bracket_tok, |
| 377 | "unrecognized header_open param: {}", | 377 | "unrecognized header_open param: {s}", |
| 378 | .{param}, | 378 | .{param}, |
| 379 | ); | 379 | ); |
| 380 | } | 380 | } |
| ... | @@ -394,7 +394,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { | ... | @@ -394,7 +394,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { |
| 394 | }, | 394 | }, |
| 395 | }); | 395 | }); |
| 396 | if (try urls.fetchPut(urlized, tag_token)) |entry| { | 396 | 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 {}; |
| 398 | parseError(tokenizer, entry.value, "other tag here", .{}) catch {}; | 398 | parseError(tokenizer, entry.value, "other tag here", .{}) catch {}; |
| 399 | return error.ParseError; | 399 | return error.ParseError; |
| 400 | } | 400 | } |
| ... | @@ -411,7 +411,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { | ... | @@ -411,7 +411,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { |
| 411 | } | 411 | } |
| 412 | last_columns = columns; | 412 | last_columns = columns; |
| 413 | try toc.writeByteNTimes(' ', 4 + header_stack_size * 4); | 413 | 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 }); |
| 415 | } else if (mem.eql(u8, tag_name, "header_close")) { | 415 | } else if (mem.eql(u8, tag_name, "header_close")) { |
| 416 | if (header_stack_size == 0) { | 416 | if (header_stack_size == 0) { |
| 417 | return parseError(tokenizer, tag_token, "unbalanced close header", .{}); | 417 | return parseError(tokenizer, tag_token, "unbalanced close header", .{}); |
| ... | @@ -515,7 +515,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { | ... | @@ -515,7 +515,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { |
| 515 | code_kind_id = Code.Id{ .Obj = null }; | 515 | code_kind_id = Code.Id{ .Obj = null }; |
| 516 | is_inline = true; | 516 | is_inline = true; |
| 517 | } else { | 517 | } 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}); |
| 519 | } | 519 | } |
| 520 | 520 | ||
| 521 | var mode: builtin.Mode = .Debug; | 521 | var mode: builtin.Mode = .Debug; |
| ... | @@ -559,7 +559,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { | ... | @@ -559,7 +559,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { |
| 559 | return parseError( | 559 | return parseError( |
| 560 | tokenizer, | 560 | tokenizer, |
| 561 | end_code_tag, | 561 | end_code_tag, |
| 562 | "invalid token inside code_begin: {}", | 562 | "invalid token inside code_begin: {s}", |
| 563 | .{end_tag_name}, | 563 | .{end_tag_name}, |
| 564 | ); | 564 | ); |
| 565 | } | 565 | } |
| ... | @@ -590,14 +590,14 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { | ... | @@ -590,14 +590,14 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { |
| 590 | return parseError( | 590 | return parseError( |
| 591 | tokenizer, | 591 | tokenizer, |
| 592 | end_syntax_tag, | 592 | end_syntax_tag, |
| 593 | "invalid token inside syntax: {}", | 593 | "invalid token inside syntax: {s}", |
| 594 | .{end_tag_name}, | 594 | .{end_tag_name}, |
| 595 | ); | 595 | ); |
| 596 | } | 596 | } |
| 597 | _ = try eatToken(tokenizer, Token.Id.BracketClose); | 597 | _ = try eatToken(tokenizer, Token.Id.BracketClose); |
| 598 | try nodes.append(Node{ .Syntax = content_tok }); | 598 | try nodes.append(Node{ .Syntax = content_tok }); |
| 599 | } else { | 599 | } else { |
| 600 | return parseError(tokenizer, tag_token, "unrecognized tag name: {}", .{tag_name}); | 600 | return parseError(tokenizer, tag_token, "unrecognized tag name: {s}", .{tag_name}); |
| 601 | } | 601 | } |
| 602 | }, | 602 | }, |
| 603 | else => return parseError(tokenizer, token, "invalid token", .{}), | 603 | else => return parseError(tokenizer, token, "invalid token", .{}), |
| ... | @@ -744,7 +744,7 @@ fn termColor(allocator: *mem.Allocator, input: []const u8) ![]u8 { | ... | @@ -744,7 +744,7 @@ fn termColor(allocator: *mem.Allocator, input: []const u8) ![]u8 { |
| 744 | try out.writeAll("</span>"); | 744 | try out.writeAll("</span>"); |
| 745 | } | 745 | } |
| 746 | if (first_number != 0 or second_number != 0) { | 746 | 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 }); |
| 748 | open_span_count += 1; | 748 | open_span_count += 1; |
| 749 | } | 749 | } |
| 750 | }, | 750 | }, |
| ... | @@ -1004,9 +1004,9 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any | ... | @@ -1004,9 +1004,9 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any |
| 1004 | }, | 1004 | }, |
| 1005 | .Link => |info| { | 1005 | .Link => |info| { |
| 1006 | if (!toc.urls.contains(info.url)) { | 1006 | 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}); |
| 1008 | } | 1008 | } |
| 1009 | try out.print("<a href=\"#{}\">{}</a>", .{ info.url, info.name }); | 1009 | try out.print("<a href=\"#{s}\">{s}</a>", .{ info.url, info.name }); |
| 1010 | }, | 1010 | }, |
| 1011 | .Nav => { | 1011 | .Nav => { |
| 1012 | try out.writeAll(toc.toc); | 1012 | try out.writeAll(toc.toc); |
| ... | @@ -1018,7 +1018,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any | ... | @@ -1018,7 +1018,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any |
| 1018 | }, | 1018 | }, |
| 1019 | .HeaderOpen => |info| { | 1019 | .HeaderOpen => |info| { |
| 1020 | try out.print( | 1020 | 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", |
| 1022 | .{ info.n, info.url, info.url, info.name, info.url, info.n }, | 1022 | .{ info.n, info.url, info.url, info.name, info.url, info.n }, |
| 1023 | ); | 1023 | ); |
| 1024 | }, | 1024 | }, |
| ... | @@ -1027,9 +1027,9 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any | ... | @@ -1027,9 +1027,9 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any |
| 1027 | for (items) |item| { | 1027 | for (items) |item| { |
| 1028 | const url = try urlize(allocator, item.name); | 1028 | const url = try urlize(allocator, item.name); |
| 1029 | if (!toc.urls.contains(url)) { | 1029 | 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}); |
| 1031 | } | 1031 | } |
| 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 }); |
| 1033 | } | 1033 | } |
| 1034 | try out.writeAll("</ul>\n"); | 1034 | try out.writeAll("</ul>\n"); |
| 1035 | }, | 1035 | }, |
| ... | @@ -1043,12 +1043,12 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any | ... | @@ -1043,12 +1043,12 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any |
| 1043 | const raw_source = tokenizer.buffer[code.source_token.start..code.source_token.end]; | 1043 | const raw_source = tokenizer.buffer[code.source_token.start..code.source_token.end]; |
| 1044 | const trimmed_raw_source = mem.trim(u8, raw_source, " \n"); | 1044 | const trimmed_raw_source = mem.trim(u8, raw_source, " \n"); |
| 1045 | if (!code.is_inline) { | 1045 | 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}); |
| 1047 | } | 1047 | } |
| 1048 | try out.writeAll("<pre>"); | 1048 | try out.writeAll("<pre>"); |
| 1049 | try tokenizeAndPrint(tokenizer, out, code.source_token); | 1049 | try tokenizeAndPrint(tokenizer, out, code.source_token); |
| 1050 | try out.writeAll("</pre>"); | 1050 | 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}); |
| 1052 | const tmp_source_file_name = try fs.path.join( | 1052 | const tmp_source_file_name = try fs.path.join( |
| 1053 | allocator, | 1053 | allocator, |
| 1054 | &[_][]const u8{ tmp_dir_name, name_plus_ext }, | 1054 | &[_][]const u8{ tmp_dir_name, name_plus_ext }, |
| ... | @@ -1057,7 +1057,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any | ... | @@ -1057,7 +1057,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any |
| 1057 | 1057 | ||
| 1058 | switch (code.id) { | 1058 | switch (code.id) { |
| 1059 | Code.Id.Exe => |expected_outcome| code_block: { | 1059 | 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 }); |
| 1061 | var build_args = std.ArrayList([]const u8).init(allocator); | 1061 | var build_args = std.ArrayList([]const u8).init(allocator); |
| 1062 | defer build_args.deinit(); | 1062 | defer build_args.deinit(); |
| 1063 | try build_args.appendSlice(&[_][]const u8{ | 1063 | try build_args.appendSlice(&[_][]const u8{ |
| ... | @@ -1066,7 +1066,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any | ... | @@ -1066,7 +1066,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any |
| 1066 | "--color", "on", | 1066 | "--color", "on", |
| 1067 | "--enable-cache", tmp_source_file_name, | 1067 | "--enable-cache", tmp_source_file_name, |
| 1068 | }); | 1068 | }); |
| 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}); |
| 1070 | switch (code.mode) { | 1070 | switch (code.mode) { |
| 1071 | .Debug => {}, | 1071 | .Debug => {}, |
| 1072 | else => { | 1072 | else => { |
| ... | @@ -1075,7 +1075,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any | ... | @@ -1075,7 +1075,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any |
| 1075 | }, | 1075 | }, |
| 1076 | } | 1076 | } |
| 1077 | for (code.link_objects) |link_object| { | 1077 | 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 }); |
| 1079 | const full_path_object = try fs.path.join( | 1079 | const full_path_object = try fs.path.join( |
| 1080 | allocator, | 1080 | allocator, |
| 1081 | &[_][]const u8{ tmp_dir_name, name_with_ext }, | 1081 | &[_][]const u8{ tmp_dir_name, name_with_ext }, |
| ... | @@ -1093,7 +1093,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any | ... | @@ -1093,7 +1093,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any |
| 1093 | if (code.target_str) |triple| { | 1093 | if (code.target_str) |triple| { |
| 1094 | try build_args.appendSlice(&[_][]const u8{ "-target", triple }); | 1094 | try build_args.appendSlice(&[_][]const u8{ "-target", triple }); |
| 1095 | if (!code.is_inline) { | 1095 | if (!code.is_inline) { |
| 1096 | try out.print(" -target {}", .{triple}); | 1096 | try out.print(" -target {s}", .{triple}); |
| 1097 | } | 1097 | } |
| 1098 | } | 1098 | } |
| 1099 | if (expected_outcome == .BuildFail) { | 1099 | if (expected_outcome == .BuildFail) { |
| ... | @@ -1106,20 +1106,20 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any | ... | @@ -1106,20 +1106,20 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any |
| 1106 | switch (result.term) { | 1106 | switch (result.term) { |
| 1107 | .Exited => |exit_code| { | 1107 | .Exited => |exit_code| { |
| 1108 | if (exit_code == 0) { | 1108 | 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}); |
| 1110 | dumpArgs(build_args.items); | 1110 | dumpArgs(build_args.items); |
| 1111 | return parseError(tokenizer, code.source_token, "example incorrectly compiled", .{}); | 1111 | return parseError(tokenizer, code.source_token, "example incorrectly compiled", .{}); |
| 1112 | } | 1112 | } |
| 1113 | }, | 1113 | }, |
| 1114 | else => { | 1114 | else => { |
| 1115 | print("{}\nThe following command crashed:\n", .{result.stderr}); | 1115 | print("{s}\nThe following command crashed:\n", .{result.stderr}); |
| 1116 | dumpArgs(build_args.items); | 1116 | dumpArgs(build_args.items); |
| 1117 | return parseError(tokenizer, code.source_token, "example compile crashed", .{}); | 1117 | return parseError(tokenizer, code.source_token, "example compile crashed", .{}); |
| 1118 | }, | 1118 | }, |
| 1119 | } | 1119 | } |
| 1120 | const escaped_stderr = try escapeHtml(allocator, result.stderr); | 1120 | const escaped_stderr = try escapeHtml(allocator, result.stderr); |
| 1121 | const colored_stderr = try termColor(allocator, escaped_stderr); | 1121 | 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}); |
| 1123 | break :code_block; | 1123 | break :code_block; |
| 1124 | } | 1124 | } |
| 1125 | const exec_result = exec(allocator, &env_map, build_args.items) catch | 1125 | 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 | ... | @@ -1138,7 +1138,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any |
| 1138 | } | 1138 | } |
| 1139 | 1139 | ||
| 1140 | const path_to_exe_dir = mem.trim(u8, exec_result.stdout, " \r\n"); | 1140 | 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}", .{ |
| 1142 | code.name, | 1142 | code.name, |
| 1143 | target.exeFileExt(), | 1143 | target.exeFileExt(), |
| 1144 | }); | 1144 | }); |
| ... | @@ -1160,7 +1160,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any | ... | @@ -1160,7 +1160,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any |
| 1160 | switch (result.term) { | 1160 | switch (result.term) { |
| 1161 | .Exited => |exit_code| { | 1161 | .Exited => |exit_code| { |
| 1162 | if (exit_code == 0) { | 1162 | 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}); |
| 1164 | dumpArgs(run_args); | 1164 | dumpArgs(run_args); |
| 1165 | return parseError(tokenizer, code.source_token, "example incorrectly compiled", .{}); | 1165 | return parseError(tokenizer, code.source_token, "example incorrectly compiled", .{}); |
| 1166 | } | 1166 | } |
| ... | @@ -1179,7 +1179,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any | ... | @@ -1179,7 +1179,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any |
| 1179 | const colored_stderr = try termColor(allocator, escaped_stderr); | 1179 | const colored_stderr = try termColor(allocator, escaped_stderr); |
| 1180 | const colored_stdout = try termColor(allocator, escaped_stdout); | 1180 | const colored_stdout = try termColor(allocator, escaped_stdout); |
| 1181 | 1181 | ||
| 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 }); |
| 1183 | if (exited_with_signal) { | 1183 | if (exited_with_signal) { |
| 1184 | try out.print("(process terminated by signal)", .{}); | 1184 | try out.print("(process terminated by signal)", .{}); |
| 1185 | } | 1185 | } |
| ... | @@ -1190,7 +1190,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any | ... | @@ -1190,7 +1190,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any |
| 1190 | defer test_args.deinit(); | 1190 | defer test_args.deinit(); |
| 1191 | 1191 | ||
| 1192 | try test_args.appendSlice(&[_][]const u8{ zig_exe, "test", tmp_source_file_name }); | 1192 | 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}); |
| 1194 | switch (code.mode) { | 1194 | switch (code.mode) { |
| 1195 | .Debug => {}, | 1195 | .Debug => {}, |
| 1196 | else => { | 1196 | else => { |
| ... | @@ -1204,12 +1204,12 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any | ... | @@ -1204,12 +1204,12 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any |
| 1204 | } | 1204 | } |
| 1205 | if (code.target_str) |triple| { | 1205 | if (code.target_str) |triple| { |
| 1206 | try test_args.appendSlice(&[_][]const u8{ "-target", triple }); | 1206 | try test_args.appendSlice(&[_][]const u8{ "-target", triple }); |
| 1207 | try out.print(" -target {}", .{triple}); | 1207 | try out.print(" -target {s}", .{triple}); |
| 1208 | } | 1208 | } |
| 1209 | const result = exec(allocator, &env_map, test_args.items) catch return parseError(tokenizer, code.source_token, "test failed", .{}); | 1209 | const result = exec(allocator, &env_map, test_args.items) catch return parseError(tokenizer, code.source_token, "test failed", .{}); |
| 1210 | const escaped_stderr = try escapeHtml(allocator, result.stderr); | 1210 | const escaped_stderr = try escapeHtml(allocator, result.stderr); |
| 1211 | const escaped_stdout = try escapeHtml(allocator, result.stdout); | 1211 | 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 }); |
| 1213 | }, | 1213 | }, |
| 1214 | Code.Id.TestError => |error_match| { | 1214 | Code.Id.TestError => |error_match| { |
| 1215 | var test_args = std.ArrayList([]const u8).init(allocator); | 1215 | var test_args = std.ArrayList([]const u8).init(allocator); |
| ... | @@ -1222,7 +1222,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any | ... | @@ -1222,7 +1222,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any |
| 1222 | "on", | 1222 | "on", |
| 1223 | tmp_source_file_name, | 1223 | tmp_source_file_name, |
| 1224 | }); | 1224 | }); |
| 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}); |
| 1226 | switch (code.mode) { | 1226 | switch (code.mode) { |
| 1227 | .Debug => {}, | 1227 | .Debug => {}, |
| 1228 | else => { | 1228 | else => { |
| ... | @@ -1239,24 +1239,24 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any | ... | @@ -1239,24 +1239,24 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any |
| 1239 | switch (result.term) { | 1239 | switch (result.term) { |
| 1240 | .Exited => |exit_code| { | 1240 | .Exited => |exit_code| { |
| 1241 | if (exit_code == 0) { | 1241 | 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}); |
| 1243 | dumpArgs(test_args.items); | 1243 | dumpArgs(test_args.items); |
| 1244 | return parseError(tokenizer, code.source_token, "example incorrectly compiled", .{}); | 1244 | return parseError(tokenizer, code.source_token, "example incorrectly compiled", .{}); |
| 1245 | } | 1245 | } |
| 1246 | }, | 1246 | }, |
| 1247 | else => { | 1247 | else => { |
| 1248 | print("{}\nThe following command crashed:\n", .{result.stderr}); | 1248 | print("{s}\nThe following command crashed:\n", .{result.stderr}); |
| 1249 | dumpArgs(test_args.items); | 1249 | dumpArgs(test_args.items); |
| 1250 | return parseError(tokenizer, code.source_token, "example compile crashed", .{}); | 1250 | return parseError(tokenizer, code.source_token, "example compile crashed", .{}); |
| 1251 | }, | 1251 | }, |
| 1252 | } | 1252 | } |
| 1253 | if (mem.indexOf(u8, result.stderr, error_match) == null) { | 1253 | 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 }); |
| 1255 | return parseError(tokenizer, code.source_token, "example did not have expected compile error", .{}); | 1255 | return parseError(tokenizer, code.source_token, "example did not have expected compile error", .{}); |
| 1256 | } | 1256 | } |
| 1257 | const escaped_stderr = try escapeHtml(allocator, result.stderr); | 1257 | const escaped_stderr = try escapeHtml(allocator, result.stderr); |
| 1258 | const colored_stderr = try termColor(allocator, escaped_stderr); | 1258 | 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}); |
| 1260 | }, | 1260 | }, |
| 1261 | 1261 | ||
| 1262 | Code.Id.TestSafety => |error_match| { | 1262 | Code.Id.TestSafety => |error_match| { |
| ... | @@ -1294,31 +1294,31 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any | ... | @@ -1294,31 +1294,31 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any |
| 1294 | switch (result.term) { | 1294 | switch (result.term) { |
| 1295 | .Exited => |exit_code| { | 1295 | .Exited => |exit_code| { |
| 1296 | if (exit_code == 0) { | 1296 | 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}); |
| 1298 | dumpArgs(test_args.items); | 1298 | dumpArgs(test_args.items); |
| 1299 | return parseError(tokenizer, code.source_token, "example test incorrectly succeeded", .{}); | 1299 | return parseError(tokenizer, code.source_token, "example test incorrectly succeeded", .{}); |
| 1300 | } | 1300 | } |
| 1301 | }, | 1301 | }, |
| 1302 | else => { | 1302 | else => { |
| 1303 | print("{}\nThe following command crashed:\n", .{result.stderr}); | 1303 | print("{s}\nThe following command crashed:\n", .{result.stderr}); |
| 1304 | dumpArgs(test_args.items); | 1304 | dumpArgs(test_args.items); |
| 1305 | return parseError(tokenizer, code.source_token, "example compile crashed", .{}); | 1305 | return parseError(tokenizer, code.source_token, "example compile crashed", .{}); |
| 1306 | }, | 1306 | }, |
| 1307 | } | 1307 | } |
| 1308 | if (mem.indexOf(u8, result.stderr, error_match) == null) { | 1308 | 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 }); |
| 1310 | return parseError(tokenizer, code.source_token, "example did not have expected runtime safety error message", .{}); | 1310 | return parseError(tokenizer, code.source_token, "example did not have expected runtime safety error message", .{}); |
| 1311 | } | 1311 | } |
| 1312 | const escaped_stderr = try escapeHtml(allocator, result.stderr); | 1312 | const escaped_stderr = try escapeHtml(allocator, result.stderr); |
| 1313 | const colored_stderr = try termColor(allocator, escaped_stderr); | 1313 | 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", .{ |
| 1315 | code.name, | 1315 | code.name, |
| 1316 | mode_arg, | 1316 | mode_arg, |
| 1317 | colored_stderr, | 1317 | colored_stderr, |
| 1318 | }); | 1318 | }); |
| 1319 | }, | 1319 | }, |
| 1320 | Code.Id.Obj => |maybe_error_match| { | 1320 | 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 }); |
| 1322 | const tmp_obj_file_name = try fs.path.join( | 1322 | const tmp_obj_file_name = try fs.path.join( |
| 1323 | allocator, | 1323 | allocator, |
| 1324 | &[_][]const u8{ tmp_dir_name, name_plus_obj_ext }, | 1324 | &[_][]const u8{ tmp_dir_name, name_plus_obj_ext }, |
| ... | @@ -1326,7 +1326,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any | ... | @@ -1326,7 +1326,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any |
| 1326 | var build_args = std.ArrayList([]const u8).init(allocator); | 1326 | var build_args = std.ArrayList([]const u8).init(allocator); |
| 1327 | defer build_args.deinit(); | 1327 | defer build_args.deinit(); |
| 1328 | 1328 | ||
| 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}); |
| 1330 | const output_h_file_name = try fs.path.join( | 1330 | const output_h_file_name = try fs.path.join( |
| 1331 | allocator, | 1331 | allocator, |
| 1332 | &[_][]const u8{ tmp_dir_name, name_plus_h_ext }, | 1332 | &[_][]const u8{ tmp_dir_name, name_plus_h_ext }, |
| ... | @@ -1345,7 +1345,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any | ... | @@ -1345,7 +1345,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any |
| 1345 | }), | 1345 | }), |
| 1346 | }); | 1346 | }); |
| 1347 | if (!code.is_inline) { | 1347 | 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}); |
| 1349 | } | 1349 | } |
| 1350 | 1350 | ||
| 1351 | switch (code.mode) { | 1351 | switch (code.mode) { |
| ... | @@ -1360,7 +1360,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any | ... | @@ -1360,7 +1360,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any |
| 1360 | 1360 | ||
| 1361 | if (code.target_str) |triple| { | 1361 | if (code.target_str) |triple| { |
| 1362 | try build_args.appendSlice(&[_][]const u8{ "-target", triple }); | 1362 | try build_args.appendSlice(&[_][]const u8{ "-target", triple }); |
| 1363 | try out.print(" -target {}", .{triple}); | 1363 | try out.print(" -target {s}", .{triple}); |
| 1364 | } | 1364 | } |
| 1365 | 1365 | ||
| 1366 | if (maybe_error_match) |error_match| { | 1366 | if (maybe_error_match) |error_match| { |
| ... | @@ -1373,24 +1373,24 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any | ... | @@ -1373,24 +1373,24 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any |
| 1373 | switch (result.term) { | 1373 | switch (result.term) { |
| 1374 | .Exited => |exit_code| { | 1374 | .Exited => |exit_code| { |
| 1375 | if (exit_code == 0) { | 1375 | 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}); |
| 1377 | dumpArgs(build_args.items); | 1377 | dumpArgs(build_args.items); |
| 1378 | return parseError(tokenizer, code.source_token, "example build incorrectly succeeded", .{}); | 1378 | return parseError(tokenizer, code.source_token, "example build incorrectly succeeded", .{}); |
| 1379 | } | 1379 | } |
| 1380 | }, | 1380 | }, |
| 1381 | else => { | 1381 | else => { |
| 1382 | print("{}\nThe following command crashed:\n", .{result.stderr}); | 1382 | print("{s}\nThe following command crashed:\n", .{result.stderr}); |
| 1383 | dumpArgs(build_args.items); | 1383 | dumpArgs(build_args.items); |
| 1384 | return parseError(tokenizer, code.source_token, "example compile crashed", .{}); | 1384 | return parseError(tokenizer, code.source_token, "example compile crashed", .{}); |
| 1385 | }, | 1385 | }, |
| 1386 | } | 1386 | } |
| 1387 | if (mem.indexOf(u8, result.stderr, error_match) == null) { | 1387 | 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 }); |
| 1389 | return parseError(tokenizer, code.source_token, "example did not have expected compile error message", .{}); | 1389 | return parseError(tokenizer, code.source_token, "example did not have expected compile error message", .{}); |
| 1390 | } | 1390 | } |
| 1391 | const escaped_stderr = try escapeHtml(allocator, result.stderr); | 1391 | const escaped_stderr = try escapeHtml(allocator, result.stderr); |
| 1392 | const colored_stderr = try termColor(allocator, escaped_stderr); | 1392 | const colored_stderr = try termColor(allocator, escaped_stderr); |
| 1393 | try out.print("\n{}", .{colored_stderr}); | 1393 | try out.print("\n{s}", .{colored_stderr}); |
| 1394 | } else { | 1394 | } else { |
| 1395 | _ = exec(allocator, &env_map, build_args.items) catch return parseError(tokenizer, code.source_token, "example failed to compile", .{}); | 1395 | _ = exec(allocator, &env_map, build_args.items) catch return parseError(tokenizer, code.source_token, "example failed to compile", .{}); |
| 1396 | } | 1396 | } |
| ... | @@ -1416,7 +1416,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any | ... | @@ -1416,7 +1416,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any |
| 1416 | tmp_dir_name, fs.path.sep_str, bin_basename, | 1416 | tmp_dir_name, fs.path.sep_str, bin_basename, |
| 1417 | }), | 1417 | }), |
| 1418 | }); | 1418 | }); |
| 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}); |
| 1420 | switch (code.mode) { | 1420 | switch (code.mode) { |
| 1421 | .Debug => {}, | 1421 | .Debug => {}, |
| 1422 | else => { | 1422 | else => { |
| ... | @@ -1426,12 +1426,12 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any | ... | @@ -1426,12 +1426,12 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any |
| 1426 | } | 1426 | } |
| 1427 | if (code.target_str) |triple| { | 1427 | if (code.target_str) |triple| { |
| 1428 | try test_args.appendSlice(&[_][]const u8{ "-target", triple }); | 1428 | try test_args.appendSlice(&[_][]const u8{ "-target", triple }); |
| 1429 | try out.print(" -target {}", .{triple}); | 1429 | try out.print(" -target {s}", .{triple}); |
| 1430 | } | 1430 | } |
| 1431 | const result = exec(allocator, &env_map, test_args.items) catch return parseError(tokenizer, code.source_token, "test failed", .{}); | 1431 | const result = exec(allocator, &env_map, test_args.items) catch return parseError(tokenizer, code.source_token, "test failed", .{}); |
| 1432 | const escaped_stderr = try escapeHtml(allocator, result.stderr); | 1432 | const escaped_stderr = try escapeHtml(allocator, result.stderr); |
| 1433 | const escaped_stdout = try escapeHtml(allocator, result.stdout); | 1433 | 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 }); |
| 1435 | }, | 1435 | }, |
| 1436 | } | 1436 | } |
| 1437 | print("OK\n", .{}); | 1437 | print("OK\n", .{}); |
| ... | @@ -1450,13 +1450,13 @@ fn exec(allocator: *mem.Allocator, env_map: *std.BufMap, args: []const []const u | ... | @@ -1450,13 +1450,13 @@ fn exec(allocator: *mem.Allocator, env_map: *std.BufMap, args: []const []const u |
| 1450 | switch (result.term) { | 1450 | switch (result.term) { |
| 1451 | .Exited => |exit_code| { | 1451 | .Exited => |exit_code| { |
| 1452 | if (exit_code != 0) { | 1452 | 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 }); |
| 1454 | dumpArgs(args); | 1454 | dumpArgs(args); |
| 1455 | return error.ChildExitError; | 1455 | return error.ChildExitError; |
| 1456 | } | 1456 | } |
| 1457 | }, | 1457 | }, |
| 1458 | else => { | 1458 | else => { |
| 1459 | print("{}\nThe following command crashed:\n", .{result.stderr}); | 1459 | print("{s}\nThe following command crashed:\n", .{result.stderr}); |
| 1460 | dumpArgs(args); | 1460 | dumpArgs(args); |
| 1461 | return error.ChildCrashed; | 1461 | return error.ChildCrashed; |
| 1462 | }, | 1462 | }, |
| ... | @@ -1471,7 +1471,7 @@ fn getBuiltinCode(allocator: *mem.Allocator, env_map: *std.BufMap, zig_exe: []co | ... | @@ -1471,7 +1471,7 @@ fn getBuiltinCode(allocator: *mem.Allocator, env_map: *std.BufMap, zig_exe: []co |
| 1471 | 1471 | ||
| 1472 | fn dumpArgs(args: []const []const u8) void { | 1472 | fn dumpArgs(args: []const []const u8) void { |
| 1473 | for (args) |arg| | 1473 | for (args) |arg| |
| 1474 | print("{} ", .{arg}) | 1474 | print("{s} ", .{arg}) |
| 1475 | else | 1475 | else |
| 1476 | print("\n", .{}); | 1476 | print("\n", .{}); |
| 1477 | } | 1477 | } |
doc/langref.html.in+21-21| ... | @@ -236,7 +236,7 @@ const std = @import("std"); | ... | @@ -236,7 +236,7 @@ const std = @import("std"); |
| 236 | 236 | ||
| 237 | pub fn main() !void { | 237 | pub fn main() !void { |
| 238 | const stdout = std.io.getStdOut().writer(); | 238 | const stdout = std.io.getStdOut().writer(); |
| 239 | try stdout.print("Hello, {}!\n", .{"world"}); | 239 | try stdout.print("Hello, {s}!\n", .{"world"}); |
| 240 | } | 240 | } |
| 241 | {#code_end#} | 241 | {#code_end#} |
| 242 | <p> | 242 | <p> |
| ... | @@ -308,7 +308,7 @@ pub fn main() !void { | ... | @@ -308,7 +308,7 @@ pub fn main() !void { |
| 308 | multiple arguments passed to a function, they are separated by commas <code>,</code>. | 308 | multiple arguments passed to a function, they are separated by commas <code>,</code>. |
| 309 | </p> | 309 | </p> |
| 310 | <p> | 310 | <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> |
| 312 | and <code>.{"world"}</code>, are evaluated at {#link|compile-time|comptime#}. The code sample is | 312 | and <code>.{"world"}</code>, are evaluated at {#link|compile-time|comptime#}. The code sample is |
| 313 | purposely written to show how to perform {#link|string|String Literals and Character Literals#} | 313 | purposely written to show how to perform {#link|string|String Literals and Character Literals#} |
| 314 | substitution in the <code>print</code> function. The curly-braces inside of the first argument | 314 | substitution in the <code>print</code> function. The curly-braces inside of the first argument |
| ... | @@ -435,7 +435,7 @@ pub fn main() void { | ... | @@ -435,7 +435,7 @@ pub fn main() void { |
| 435 | var optional_value: ?[]const u8 = null; | 435 | var optional_value: ?[]const u8 = null; |
| 436 | assert(optional_value == null); | 436 | assert(optional_value == null); |
| 437 | 437 | ||
| 438 | print("\noptional 1\ntype: {}\nvalue: {}\n", .{ | 438 | print("\noptional 1\ntype: {s}\nvalue: {s}\n", .{ |
| 439 | @typeName(@TypeOf(optional_value)), | 439 | @typeName(@TypeOf(optional_value)), |
| 440 | optional_value, | 440 | optional_value, |
| 441 | }); | 441 | }); |
| ... | @@ -443,7 +443,7 @@ pub fn main() void { | ... | @@ -443,7 +443,7 @@ pub fn main() void { |
| 443 | optional_value = "hi"; | 443 | optional_value = "hi"; |
| 444 | assert(optional_value != null); | 444 | assert(optional_value != null); |
| 445 | 445 | ||
| 446 | print("\noptional 2\ntype: {}\nvalue: {}\n", .{ | 446 | print("\noptional 2\ntype: {s}\nvalue: {s}\n", .{ |
| 447 | @typeName(@TypeOf(optional_value)), | 447 | @typeName(@TypeOf(optional_value)), |
| 448 | optional_value, | 448 | optional_value, |
| 449 | }); | 449 | }); |
| ... | @@ -451,14 +451,14 @@ pub fn main() void { | ... | @@ -451,14 +451,14 @@ pub fn main() void { |
| 451 | // error union | 451 | // error union |
| 452 | var number_or_error: anyerror!i32 = error.ArgNotFound; | 452 | var number_or_error: anyerror!i32 = error.ArgNotFound; |
| 453 | 453 | ||
| 454 | print("\nerror union 1\ntype: {}\nvalue: {}\n", .{ | 454 | print("\nerror union 1\ntype: {s}\nvalue: {}\n", .{ |
| 455 | @typeName(@TypeOf(number_or_error)), | 455 | @typeName(@TypeOf(number_or_error)), |
| 456 | number_or_error, | 456 | number_or_error, |
| 457 | }); | 457 | }); |
| 458 | 458 | ||
| 459 | number_or_error = 1234; | 459 | number_or_error = 1234; |
| 460 | 460 | ||
| 461 | print("\nerror union 2\ntype: {}\nvalue: {}\n", .{ | 461 | print("\nerror union 2\ntype: {s}\nvalue: {}\n", .{ |
| 462 | @typeName(@TypeOf(number_or_error)), | 462 | @typeName(@TypeOf(number_or_error)), |
| 463 | number_or_error, | 463 | number_or_error, |
| 464 | }); | 464 | }); |
| ... | @@ -2339,7 +2339,7 @@ test "using slices for strings" { | ... | @@ -2339,7 +2339,7 @@ test "using slices for strings" { |
| 2339 | // You can use slice syntax on an array to convert an array into a slice. | 2339 | // You can use slice syntax on an array to convert an array into a slice. |
| 2340 | const all_together_slice = all_together[0..]; | 2340 | const all_together_slice = all_together[0..]; |
| 2341 | // String concatenation example. | 2341 | // 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 }); |
| 2343 | 2343 | ||
| 2344 | // Generally, you can use UTF-8 and not worry about whether something is a | 2344 | // Generally, you can use UTF-8 and not worry about whether something is a |
| 2345 | // string. If you don't need to deal with individual characters, no need | 2345 | // string. If you don't need to deal with individual characters, no need |
| ... | @@ -2772,9 +2772,9 @@ const std = @import("std"); | ... | @@ -2772,9 +2772,9 @@ const std = @import("std"); |
| 2772 | 2772 | ||
| 2773 | pub fn main() void { | 2773 | pub fn main() void { |
| 2774 | const Foo = struct {}; | 2774 | const Foo = struct {}; |
| 2775 | std.debug.print("variable: {}\n", .{@typeName(Foo)}); | 2775 | std.debug.print("variable: {s}\n", .{@typeName(Foo)}); |
| 2776 | std.debug.print("anonymous: {}\n", .{@typeName(struct {})}); | 2776 | std.debug.print("anonymous: {s}\n", .{@typeName(struct {})}); |
| 2777 | std.debug.print("function: {}\n", .{@typeName(List(i32))}); | 2777 | std.debug.print("function: {s}\n", .{@typeName(List(i32))}); |
| 2778 | } | 2778 | } |
| 2779 | 2779 | ||
| 2780 | fn List(comptime T: type) type { | 2780 | fn List(comptime T: type) type { |
| ... | @@ -6110,7 +6110,7 @@ const a_number: i32 = 1234; | ... | @@ -6110,7 +6110,7 @@ const a_number: i32 = 1234; |
| 6110 | const a_string = "foobar"; | 6110 | const a_string = "foobar"; |
| 6111 | 6111 | ||
| 6112 | pub fn main() void { | 6112 | pub 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}); |
| 6114 | } | 6114 | } |
| 6115 | {#code_end#} | 6115 | {#code_end#} |
| 6116 | 6116 | ||
| ... | @@ -6230,7 +6230,7 @@ const a_number: i32 = 1234; | ... | @@ -6230,7 +6230,7 @@ const a_number: i32 = 1234; |
| 6230 | const a_string = "foobar"; | 6230 | const a_string = "foobar"; |
| 6231 | 6231 | ||
| 6232 | test "printf too many arguments" { | 6232 | test "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", .{ |
| 6234 | a_string, | 6234 | a_string, |
| 6235 | a_number, | 6235 | a_number, |
| 6236 | a_number, | 6236 | a_number, |
| ... | @@ -6249,7 +6249,7 @@ const print = @import("std").debug.print; | ... | @@ -6249,7 +6249,7 @@ const print = @import("std").debug.print; |
| 6249 | 6249 | ||
| 6250 | const a_number: i32 = 1234; | 6250 | const a_number: i32 = 1234; |
| 6251 | const a_string = "foobar"; | 6251 | const a_string = "foobar"; |
| 6252 | const fmt = "here is a string: '{}' here is a number: {}\n"; | 6252 | const fmt = "here is a string: '{s}' here is a number: {}\n"; |
| 6253 | 6253 | ||
| 6254 | pub fn main() void { | 6254 | pub fn main() void { |
| 6255 | print(fmt, .{a_string, a_number}); | 6255 | print(fmt, .{a_string, a_number}); |
| ... | @@ -6720,8 +6720,8 @@ fn amain() !void { | ... | @@ -6720,8 +6720,8 @@ fn amain() !void { |
| 6720 | const download_text = try await download_frame; | 6720 | const download_text = try await download_frame; |
| 6721 | defer allocator.free(download_text); | 6721 | defer allocator.free(download_text); |
| 6722 | 6722 | ||
| 6723 | std.debug.print("download_text: {}\n", .{download_text}); | 6723 | std.debug.print("download_text: {s}\n", .{download_text}); |
| 6724 | std.debug.print("file_text: {}\n", .{file_text}); | 6724 | std.debug.print("file_text: {s}\n", .{file_text}); |
| 6725 | } | 6725 | } |
| 6726 | 6726 | ||
| 6727 | var global_download_frame: anyframe = undefined; | 6727 | var global_download_frame: anyframe = undefined; |
| ... | @@ -6790,8 +6790,8 @@ fn amain() !void { | ... | @@ -6790,8 +6790,8 @@ fn amain() !void { |
| 6790 | const download_text = try await download_frame; | 6790 | const download_text = try await download_frame; |
| 6791 | defer allocator.free(download_text); | 6791 | defer allocator.free(download_text); |
| 6792 | 6792 | ||
| 6793 | std.debug.print("download_text: {}\n", .{download_text}); | 6793 | std.debug.print("download_text: {s}\n", .{download_text}); |
| 6794 | std.debug.print("file_text: {}\n", .{file_text}); | 6794 | std.debug.print("file_text: {s}\n", .{file_text}); |
| 6795 | } | 6795 | } |
| 6796 | 6796 | ||
| 6797 | fn fetchUrl(allocator: *Allocator, url: []const u8) ![]u8 { | 6797 | fn fetchUrl(allocator: *Allocator, url: []const u8) ![]u8 { |
| ... | @@ -8848,7 +8848,7 @@ pub fn main() !void { | ... | @@ -8848,7 +8848,7 @@ pub fn main() !void { |
| 8848 | var byte: u8 = 255; | 8848 | var byte: u8 = 255; |
| 8849 | 8849 | ||
| 8850 | byte = if (math.add(u8, byte, 1)) |result| result else |err| { | 8850 | 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)}); |
| 8852 | return err; | 8852 | return err; |
| 8853 | }; | 8853 | }; |
| 8854 | 8854 | ||
| ... | @@ -9078,7 +9078,7 @@ pub fn main() void { | ... | @@ -9078,7 +9078,7 @@ pub fn main() void { |
| 9078 | if (result) |number| { | 9078 | if (result) |number| { |
| 9079 | print("got number: {}\n", .{number}); | 9079 | print("got number: {}\n", .{number}); |
| 9080 | } else |err| { | 9080 | } else |err| { |
| 9081 | print("got error: {}\n", .{@errorName(err)}); | 9081 | print("got error: {s}\n", .{@errorName(err)}); |
| 9082 | } | 9082 | } |
| 9083 | } | 9083 | } |
| 9084 | 9084 | ||
| ... | @@ -9135,7 +9135,7 @@ const Foo = enum { | ... | @@ -9135,7 +9135,7 @@ const Foo = enum { |
| 9135 | pub fn main() void { | 9135 | pub fn main() void { |
| 9136 | var a: u2 = 3; | 9136 | var a: u2 = 3; |
| 9137 | var b = @intToEnum(Foo, a); | 9137 | var b = @intToEnum(Foo, a); |
| 9138 | std.debug.print("value: {}\n", .{@tagName(b)}); | 9138 | std.debug.print("value: {s}\n", .{@tagName(b)}); |
| 9139 | } | 9139 | } |
| 9140 | {#code_end#} | 9140 | {#code_end#} |
| 9141 | {#header_close#} | 9141 | {#header_close#} |
| ... | @@ -10025,7 +10025,7 @@ pub fn main() !void { | ... | @@ -10025,7 +10025,7 @@ pub fn main() !void { |
| 10025 | defer std.process.argsFree(gpa, args); | 10025 | defer std.process.argsFree(gpa, args); |
| 10026 | 10026 | ||
| 10027 | for (args) |arg, i| { | 10027 | for (args) |arg, i| { |
| 10028 | std.debug.print("{}: {}\n", .{ i, arg }); | 10028 | std.debug.print("{}: {s}\n", .{ i, arg }); |
| 10029 | } | 10029 | } |
| 10030 | } | 10030 | } |
| 10031 | {#code_end#} | 10031 | {#code_end#} |
lib/std/SemanticVersion.zig+5-5| ... | @@ -163,9 +163,9 @@ pub fn format( | ... | @@ -163,9 +163,9 @@ pub fn format( |
| 163 | out_stream: anytype, | 163 | out_stream: anytype, |
| 164 | ) !void { | 164 | ) !void { |
| 165 | if (fmt.len != 0) @compileError("Unknown format string: '" ++ fmt ++ "'"); | 165 | if (fmt.len != 0) @compileError("Unknown format string: '" ++ fmt ++ "'"); |
| 166 | try std.fmt.format(out_stream, "{}.{}.{}", .{ self.major, self.minor, self.patch }); | 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, "-{}", .{pre}); | 167 | if (self.pre) |pre| try std.fmt.format(out_stream, "-{s}", .{pre}); |
| 168 | if (self.build) |build| try std.fmt.format(out_stream, "+{}", .{build}); | 168 | if (self.build) |build| try std.fmt.format(out_stream, "+{s}", .{build}); |
| 169 | } | 169 | } |
| 170 | 170 | ||
| 171 | const expect = std.testing.expect; | 171 | const expect = std.testing.expect; |
| ... | @@ -287,9 +287,9 @@ fn testFmt(expected: []const u8, comptime template: []const u8, args: anytype) ! | ... | @@ -287,9 +287,9 @@ fn testFmt(expected: []const u8, comptime template: []const u8, args: anytype) ! |
| 287 | if (std.mem.eql(u8, result, expected)) return; | 287 | if (std.mem.eql(u8, result, expected)) return; |
| 288 | 288 | ||
| 289 | std.debug.warn("\n====== expected this output: =========\n", .{}); | 289 | std.debug.warn("\n====== expected this output: =========\n", .{}); |
| 290 | std.debug.warn("{}", .{expected}); | 290 | std.debug.warn("{s}", .{expected}); |
| 291 | std.debug.warn("\n======== instead found this: =========\n", .{}); | 291 | std.debug.warn("\n======== instead found this: =========\n", .{}); |
| 292 | std.debug.warn("{}", .{result}); | 292 | std.debug.warn("{s}", .{result}); |
| 293 | std.debug.warn("\n======================================\n", .{}); | 293 | std.debug.warn("\n======================================\n", .{}); |
| 294 | return error.TestFailed; | 294 | return error.TestFailed; |
| 295 | } | 295 | } |
lib/std/build.zig+69-69| ... | @@ -294,7 +294,7 @@ pub const Builder = struct { | ... | @@ -294,7 +294,7 @@ pub const Builder = struct { |
| 294 | /// To run an executable built with zig build, see `LibExeObjStep.run`. | 294 | /// To run an executable built with zig build, see `LibExeObjStep.run`. |
| 295 | pub fn addSystemCommand(self: *Builder, argv: []const []const u8) *RunStep { | 295 | pub fn addSystemCommand(self: *Builder, argv: []const []const u8) *RunStep { |
| 296 | assert(argv.len >= 1); | 296 | 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]})); |
| 298 | run_step.addArgs(argv); | 298 | run_step.addArgs(argv); |
| 299 | return run_step; | 299 | return run_step; |
| 300 | } | 300 | } |
| ... | @@ -409,7 +409,7 @@ pub const Builder = struct { | ... | @@ -409,7 +409,7 @@ pub const Builder = struct { |
| 409 | for (self.installed_files.items) |installed_file| { | 409 | for (self.installed_files.items) |installed_file| { |
| 410 | const full_path = self.getInstallPath(installed_file.dir, installed_file.path); | 410 | const full_path = self.getInstallPath(installed_file.dir, installed_file.path); |
| 411 | if (self.verbose) { | 411 | if (self.verbose) { |
| 412 | warn("rm {}\n", .{full_path}); | 412 | warn("rm {s}\n", .{full_path}); |
| 413 | } | 413 | } |
| 414 | fs.cwd().deleteTree(full_path) catch {}; | 414 | fs.cwd().deleteTree(full_path) catch {}; |
| 415 | } | 415 | } |
| ... | @@ -419,7 +419,7 @@ pub const Builder = struct { | ... | @@ -419,7 +419,7 @@ pub const Builder = struct { |
| 419 | 419 | ||
| 420 | fn makeOneStep(self: *Builder, s: *Step) anyerror!void { | 420 | fn makeOneStep(self: *Builder, s: *Step) anyerror!void { |
| 421 | if (s.loop_flag) { | 421 | if (s.loop_flag) { |
| 422 | warn("Dependency loop detected:\n {}\n", .{s.name}); | 422 | warn("Dependency loop detected:\n {s}\n", .{s.name}); |
| 423 | return error.DependencyLoopDetected; | 423 | return error.DependencyLoopDetected; |
| 424 | } | 424 | } |
| 425 | s.loop_flag = true; | 425 | s.loop_flag = true; |
| ... | @@ -427,7 +427,7 @@ pub const Builder = struct { | ... | @@ -427,7 +427,7 @@ pub const Builder = struct { |
| 427 | for (s.dependencies.items) |dep| { | 427 | for (s.dependencies.items) |dep| { |
| 428 | self.makeOneStep(dep) catch |err| { | 428 | self.makeOneStep(dep) catch |err| { |
| 429 | if (err == error.DependencyLoopDetected) { | 429 | if (err == error.DependencyLoopDetected) { |
| 430 | warn(" {}\n", .{s.name}); | 430 | warn(" {s}\n", .{s.name}); |
| 431 | } | 431 | } |
| 432 | return err; | 432 | return err; |
| 433 | }; | 433 | }; |
| ... | @@ -444,7 +444,7 @@ pub const Builder = struct { | ... | @@ -444,7 +444,7 @@ pub const Builder = struct { |
| 444 | return &top_level_step.step; | 444 | return &top_level_step.step; |
| 445 | } | 445 | } |
| 446 | } | 446 | } |
| 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}); |
| 448 | return error.InvalidStepName; | 448 | return error.InvalidStepName; |
| 449 | } | 449 | } |
| 450 | 450 | ||
| ... | @@ -456,7 +456,7 @@ pub const Builder = struct { | ... | @@ -456,7 +456,7 @@ pub const Builder = struct { |
| 456 | .description = description, | 456 | .description = description, |
| 457 | }; | 457 | }; |
| 458 | if ((self.available_options_map.fetchPut(name, available_option) catch unreachable) != null) { | 458 | 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}); |
| 460 | } | 460 | } |
| 461 | self.available_options_list.append(available_option) catch unreachable; | 461 | self.available_options_list.append(available_option) catch unreachable; |
| 462 | 462 | ||
| ... | @@ -471,32 +471,32 @@ pub const Builder = struct { | ... | @@ -471,32 +471,32 @@ pub const Builder = struct { |
| 471 | } else if (mem.eql(u8, s, "false")) { | 471 | } else if (mem.eql(u8, s, "false")) { |
| 472 | return false; | 472 | return false; |
| 473 | } else { | 473 | } 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 }); |
| 475 | self.markInvalidUserInput(); | 475 | self.markInvalidUserInput(); |
| 476 | return null; | 476 | return null; |
| 477 | } | 477 | } |
| 478 | }, | 478 | }, |
| 479 | .List => { | 479 | .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}); |
| 481 | self.markInvalidUserInput(); | 481 | self.markInvalidUserInput(); |
| 482 | return null; | 482 | return null; |
| 483 | }, | 483 | }, |
| 484 | }, | 484 | }, |
| 485 | .Int => switch (entry.value.value) { | 485 | .Int => switch (entry.value.value) { |
| 486 | .Flag => { | 486 | .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}); |
| 488 | self.markInvalidUserInput(); | 488 | self.markInvalidUserInput(); |
| 489 | return null; | 489 | return null; |
| 490 | }, | 490 | }, |
| 491 | .Scalar => |s| { | 491 | .Scalar => |s| { |
| 492 | const n = std.fmt.parseInt(T, s, 10) catch |err| switch (err) { | 492 | const n = std.fmt.parseInt(T, s, 10) catch |err| switch (err) { |
| 493 | error.Overflow => { | 493 | 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) }); |
| 495 | self.markInvalidUserInput(); | 495 | self.markInvalidUserInput(); |
| 496 | return null; | 496 | return null; |
| 497 | }, | 497 | }, |
| 498 | else => { | 498 | 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) }); |
| 500 | self.markInvalidUserInput(); | 500 | self.markInvalidUserInput(); |
| 501 | return null; | 501 | return null; |
| 502 | }, | 502 | }, |
| ... | @@ -504,34 +504,34 @@ pub const Builder = struct { | ... | @@ -504,34 +504,34 @@ pub const Builder = struct { |
| 504 | return n; | 504 | return n; |
| 505 | }, | 505 | }, |
| 506 | .List => { | 506 | .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}); |
| 508 | self.markInvalidUserInput(); | 508 | self.markInvalidUserInput(); |
| 509 | return null; | 509 | return null; |
| 510 | }, | 510 | }, |
| 511 | }, | 511 | }, |
| 512 | .Float => switch (entry.value.value) { | 512 | .Float => switch (entry.value.value) { |
| 513 | .Flag => { | 513 | .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}); |
| 515 | self.markInvalidUserInput(); | 515 | self.markInvalidUserInput(); |
| 516 | return null; | 516 | return null; |
| 517 | }, | 517 | }, |
| 518 | .Scalar => |s| { | 518 | .Scalar => |s| { |
| 519 | const n = std.fmt.parseFloat(T, s) catch |err| { | 519 | 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) }); |
| 521 | self.markInvalidUserInput(); | 521 | self.markInvalidUserInput(); |
| 522 | return null; | 522 | return null; |
| 523 | }; | 523 | }; |
| 524 | return n; | 524 | return n; |
| 525 | }, | 525 | }, |
| 526 | .List => { | 526 | .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}); |
| 528 | self.markInvalidUserInput(); | 528 | self.markInvalidUserInput(); |
| 529 | return null; | 529 | return null; |
| 530 | }, | 530 | }, |
| 531 | }, | 531 | }, |
| 532 | .Enum => switch (entry.value.value) { | 532 | .Enum => switch (entry.value.value) { |
| 533 | .Flag => { | 533 | .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}); |
| 535 | self.markInvalidUserInput(); | 535 | self.markInvalidUserInput(); |
| 536 | return null; | 536 | return null; |
| 537 | }, | 537 | }, |
| ... | @@ -539,25 +539,25 @@ pub const Builder = struct { | ... | @@ -539,25 +539,25 @@ pub const Builder = struct { |
| 539 | if (std.meta.stringToEnum(T, s)) |enum_lit| { | 539 | if (std.meta.stringToEnum(T, s)) |enum_lit| { |
| 540 | return enum_lit; | 540 | return enum_lit; |
| 541 | } else { | 541 | } 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) }); |
| 543 | self.markInvalidUserInput(); | 543 | self.markInvalidUserInput(); |
| 544 | return null; | 544 | return null; |
| 545 | } | 545 | } |
| 546 | }, | 546 | }, |
| 547 | .List => { | 547 | .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}); |
| 549 | self.markInvalidUserInput(); | 549 | self.markInvalidUserInput(); |
| 550 | return null; | 550 | return null; |
| 551 | }, | 551 | }, |
| 552 | }, | 552 | }, |
| 553 | .String => switch (entry.value.value) { | 553 | .String => switch (entry.value.value) { |
| 554 | .Flag => { | 554 | .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}); |
| 556 | self.markInvalidUserInput(); | 556 | self.markInvalidUserInput(); |
| 557 | return null; | 557 | return null; |
| 558 | }, | 558 | }, |
| 559 | .List => { | 559 | .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}); |
| 561 | self.markInvalidUserInput(); | 561 | self.markInvalidUserInput(); |
| 562 | return null; | 562 | return null; |
| 563 | }, | 563 | }, |
| ... | @@ -565,7 +565,7 @@ pub const Builder = struct { | ... | @@ -565,7 +565,7 @@ pub const Builder = struct { |
| 565 | }, | 565 | }, |
| 566 | .List => switch (entry.value.value) { | 566 | .List => switch (entry.value.value) { |
| 567 | .Flag => { | 567 | .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}); |
| 569 | self.markInvalidUserInput(); | 569 | self.markInvalidUserInput(); |
| 570 | return null; | 570 | return null; |
| 571 | }, | 571 | }, |
| ... | @@ -592,7 +592,7 @@ pub const Builder = struct { | ... | @@ -592,7 +592,7 @@ pub const Builder = struct { |
| 592 | if (self.release_mode != null) { | 592 | if (self.release_mode != null) { |
| 593 | @panic("setPreferredReleaseMode must be called before standardReleaseOptions and may not be called twice"); | 593 | @panic("setPreferredReleaseMode must be called before standardReleaseOptions and may not be called twice"); |
| 594 | } | 594 | } |
| 595 | const description = self.fmt("Create a release build ({})", .{@tagName(mode)}); | 595 | const description = self.fmt("Create a release build ({s})", .{@tagName(mode)}); |
| 596 | self.is_release = self.option(bool, "release", description) orelse false; | 596 | self.is_release = self.option(bool, "release", description) orelse false; |
| 597 | self.release_mode = if (self.is_release) mode else builtin.Mode.Debug; | 597 | self.release_mode = if (self.is_release) mode else builtin.Mode.Debug; |
| 598 | } | 598 | } |
| ... | @@ -646,12 +646,12 @@ pub const Builder = struct { | ... | @@ -646,12 +646,12 @@ pub const Builder = struct { |
| 646 | .diagnostics = &diags, | 646 | .diagnostics = &diags, |
| 647 | }) catch |err| switch (err) { | 647 | }) catch |err| switch (err) { |
| 648 | error.UnknownCpuModel => { | 648 | error.UnknownCpuModel => { |
| 649 | warn("Unknown CPU: '{}'\nAvailable CPUs for architecture '{}':\n", .{ | 649 | warn("Unknown CPU: '{s}'\nAvailable CPUs for architecture '{s}':\n", .{ |
| 650 | diags.cpu_name.?, | 650 | diags.cpu_name.?, |
| 651 | @tagName(diags.arch.?), | 651 | @tagName(diags.arch.?), |
| 652 | }); | 652 | }); |
| 653 | for (diags.arch.?.allCpuModels()) |cpu| { | 653 | for (diags.arch.?.allCpuModels()) |cpu| { |
| 654 | warn(" {}\n", .{cpu.name}); | 654 | warn(" {s}\n", .{cpu.name}); |
| 655 | } | 655 | } |
| 656 | warn("\n", .{}); | 656 | warn("\n", .{}); |
| 657 | self.markInvalidUserInput(); | 657 | self.markInvalidUserInput(); |
| ... | @@ -659,15 +659,15 @@ pub const Builder = struct { | ... | @@ -659,15 +659,15 @@ pub const Builder = struct { |
| 659 | }, | 659 | }, |
| 660 | error.UnknownCpuFeature => { | 660 | error.UnknownCpuFeature => { |
| 661 | warn( | 661 | warn( |
| 662 | \\Unknown CPU feature: '{}' | 662 | \\Unknown CPU feature: '{s}' |
| 663 | \\Available CPU features for architecture '{}': | 663 | \\Available CPU features for architecture '{s}': |
| 664 | \\ | 664 | \\ |
| 665 | , .{ | 665 | , .{ |
| 666 | diags.unknown_feature_name, | 666 | diags.unknown_feature_name, |
| 667 | @tagName(diags.arch.?), | 667 | @tagName(diags.arch.?), |
| 668 | }); | 668 | }); |
| 669 | for (diags.arch.?.allFeaturesList()) |feature| { | 669 | for (diags.arch.?.allFeaturesList()) |feature| { |
| 670 | warn(" {}: {}\n", .{ feature.name, feature.description }); | 670 | warn(" {s}: {s}\n", .{ feature.name, feature.description }); |
| 671 | } | 671 | } |
| 672 | warn("\n", .{}); | 672 | warn("\n", .{}); |
| 673 | self.markInvalidUserInput(); | 673 | self.markInvalidUserInput(); |
| ... | @@ -675,19 +675,19 @@ pub const Builder = struct { | ... | @@ -675,19 +675,19 @@ pub const Builder = struct { |
| 675 | }, | 675 | }, |
| 676 | error.UnknownOperatingSystem => { | 676 | error.UnknownOperatingSystem => { |
| 677 | warn( | 677 | warn( |
| 678 | \\Unknown OS: '{}' | 678 | \\Unknown OS: '{s}' |
| 679 | \\Available operating systems: | 679 | \\Available operating systems: |
| 680 | \\ | 680 | \\ |
| 681 | , .{diags.os_name}); | 681 | , .{diags.os_name}); |
| 682 | inline for (std.meta.fields(std.Target.Os.Tag)) |field| { | 682 | inline for (std.meta.fields(std.Target.Os.Tag)) |field| { |
| 683 | warn(" {}\n", .{field.name}); | 683 | warn(" {s}\n", .{field.name}); |
| 684 | } | 684 | } |
| 685 | warn("\n", .{}); | 685 | warn("\n", .{}); |
| 686 | self.markInvalidUserInput(); | 686 | self.markInvalidUserInput(); |
| 687 | return args.default_target; | 687 | return args.default_target; |
| 688 | }, | 688 | }, |
| 689 | else => |e| { | 689 | 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) }); |
| 691 | self.markInvalidUserInput(); | 691 | self.markInvalidUserInput(); |
| 692 | return args.default_target; | 692 | return args.default_target; |
| 693 | }, | 693 | }, |
| ... | @@ -703,12 +703,12 @@ pub const Builder = struct { | ... | @@ -703,12 +703,12 @@ pub const Builder = struct { |
| 703 | break :whitelist_check; | 703 | break :whitelist_check; |
| 704 | } | 704 | } |
| 705 | } | 705 | } |
| 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", .{ |
| 707 | selected_canonicalized_triple, | 707 | selected_canonicalized_triple, |
| 708 | }); | 708 | }); |
| 709 | for (list) |t| { | 709 | for (list) |t| { |
| 710 | const t_triple = t.zigTriple(self.allocator) catch unreachable; | 710 | const t_triple = t.zigTriple(self.allocator) catch unreachable; |
| 711 | warn(" {}\n", .{t_triple}); | 711 | warn(" {s}\n", .{t_triple}); |
| 712 | } | 712 | } |
| 713 | warn("\n", .{}); | 713 | warn("\n", .{}); |
| 714 | self.markInvalidUserInput(); | 714 | self.markInvalidUserInput(); |
| ... | @@ -752,7 +752,7 @@ pub const Builder = struct { | ... | @@ -752,7 +752,7 @@ pub const Builder = struct { |
| 752 | }) catch unreachable; | 752 | }) catch unreachable; |
| 753 | }, | 753 | }, |
| 754 | UserValue.Flag => { | 754 | 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 }); |
| 756 | return true; | 756 | return true; |
| 757 | }, | 757 | }, |
| 758 | } | 758 | } |
| ... | @@ -773,11 +773,11 @@ pub const Builder = struct { | ... | @@ -773,11 +773,11 @@ pub const Builder = struct { |
| 773 | // option already exists | 773 | // option already exists |
| 774 | switch (gop.entry.value.value) { | 774 | switch (gop.entry.value.value) { |
| 775 | UserValue.Scalar => |s| { | 775 | 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 }); |
| 777 | return true; | 777 | return true; |
| 778 | }, | 778 | }, |
| 779 | UserValue.List => { | 779 | 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}); |
| 781 | return true; | 781 | return true; |
| 782 | }, | 782 | }, |
| 783 | UserValue.Flag => {}, | 783 | UserValue.Flag => {}, |
| ... | @@ -820,7 +820,7 @@ pub const Builder = struct { | ... | @@ -820,7 +820,7 @@ pub const Builder = struct { |
| 820 | while (true) { | 820 | while (true) { |
| 821 | const entry = it.next() orelse break; | 821 | const entry = it.next() orelse break; |
| 822 | if (!entry.value.used) { | 822 | if (!entry.value.used) { |
| 823 | warn("Invalid option: -D{}\n\n", .{entry.key}); | 823 | warn("Invalid option: -D{s}\n\n", .{entry.key}); |
| 824 | self.markInvalidUserInput(); | 824 | self.markInvalidUserInput(); |
| 825 | } | 825 | } |
| 826 | } | 826 | } |
| ... | @@ -833,9 +833,9 @@ pub const Builder = struct { | ... | @@ -833,9 +833,9 @@ pub const Builder = struct { |
| 833 | } | 833 | } |
| 834 | 834 | ||
| 835 | fn printCmd(cwd: ?[]const u8, argv: []const []const u8) void { | 835 | 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}); |
| 837 | for (argv) |arg| { | 837 | for (argv) |arg| { |
| 838 | warn("{} ", .{arg}); | 838 | warn("{s} ", .{arg}); |
| 839 | } | 839 | } |
| 840 | warn("\n", .{}); | 840 | warn("\n", .{}); |
| 841 | } | 841 | } |
| ... | @@ -852,7 +852,7 @@ pub const Builder = struct { | ... | @@ -852,7 +852,7 @@ pub const Builder = struct { |
| 852 | child.env_map = env_map; | 852 | child.env_map = env_map; |
| 853 | 853 | ||
| 854 | const term = child.spawnAndWait() catch |err| { | 854 | 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) }); |
| 856 | return err; | 856 | return err; |
| 857 | }; | 857 | }; |
| 858 | 858 | ||
| ... | @@ -875,7 +875,7 @@ pub const Builder = struct { | ... | @@ -875,7 +875,7 @@ pub const Builder = struct { |
| 875 | 875 | ||
| 876 | pub fn makePath(self: *Builder, path: []const u8) !void { | 876 | pub fn makePath(self: *Builder, path: []const u8) !void { |
| 877 | fs.cwd().makePath(self.pathFromRoot(path)) catch |err| { | 877 | 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) }); |
| 879 | return err; | 879 | return err; |
| 880 | }; | 880 | }; |
| 881 | } | 881 | } |
| ... | @@ -959,7 +959,7 @@ pub const Builder = struct { | ... | @@ -959,7 +959,7 @@ pub const Builder = struct { |
| 959 | 959 | ||
| 960 | pub fn updateFile(self: *Builder, source_path: []const u8, dest_path: []const u8) !void { | 960 | pub fn updateFile(self: *Builder, source_path: []const u8, dest_path: []const u8) !void { |
| 961 | if (self.verbose) { | 961 | if (self.verbose) { |
| 962 | warn("cp {} {} ", .{ source_path, dest_path }); | 962 | warn("cp {s} {s} ", .{ source_path, dest_path }); |
| 963 | } | 963 | } |
| 964 | const cwd = fs.cwd(); | 964 | const cwd = fs.cwd(); |
| 965 | const prev_status = try fs.Dir.updateFile(cwd, source_path, cwd, dest_path, .{}); | 965 | const prev_status = try fs.Dir.updateFile(cwd, source_path, cwd, dest_path, .{}); |
| ... | @@ -988,7 +988,7 @@ pub const Builder = struct { | ... | @@ -988,7 +988,7 @@ pub const Builder = struct { |
| 988 | const full_path = try fs.path.join(self.allocator, &[_][]const u8{ | 988 | const full_path = try fs.path.join(self.allocator, &[_][]const u8{ |
| 989 | search_prefix, | 989 | search_prefix, |
| 990 | "bin", | 990 | "bin", |
| 991 | self.fmt("{}{}", .{ name, exe_extension }), | 991 | self.fmt("{s}{s}", .{ name, exe_extension }), |
| 992 | }); | 992 | }); |
| 993 | return fs.realpathAlloc(self.allocator, full_path) catch continue; | 993 | return fs.realpathAlloc(self.allocator, full_path) catch continue; |
| 994 | } | 994 | } |
| ... | @@ -1002,7 +1002,7 @@ pub const Builder = struct { | ... | @@ -1002,7 +1002,7 @@ pub const Builder = struct { |
| 1002 | while (it.next()) |path| { | 1002 | while (it.next()) |path| { |
| 1003 | const full_path = try fs.path.join(self.allocator, &[_][]const u8{ | 1003 | const full_path = try fs.path.join(self.allocator, &[_][]const u8{ |
| 1004 | path, | 1004 | path, |
| 1005 | self.fmt("{}{}", .{ name, exe_extension }), | 1005 | self.fmt("{s}{s}", .{ name, exe_extension }), |
| 1006 | }); | 1006 | }); |
| 1007 | return fs.realpathAlloc(self.allocator, full_path) catch continue; | 1007 | return fs.realpathAlloc(self.allocator, full_path) catch continue; |
| 1008 | } | 1008 | } |
| ... | @@ -1015,7 +1015,7 @@ pub const Builder = struct { | ... | @@ -1015,7 +1015,7 @@ pub const Builder = struct { |
| 1015 | for (paths) |path| { | 1015 | for (paths) |path| { |
| 1016 | const full_path = try fs.path.join(self.allocator, &[_][]const u8{ | 1016 | const full_path = try fs.path.join(self.allocator, &[_][]const u8{ |
| 1017 | path, | 1017 | path, |
| 1018 | self.fmt("{}{}", .{ name, exe_extension }), | 1018 | self.fmt("{s}{s}", .{ name, exe_extension }), |
| 1019 | }); | 1019 | }); |
| 1020 | return fs.realpathAlloc(self.allocator, full_path) catch continue; | 1020 | return fs.realpathAlloc(self.allocator, full_path) catch continue; |
| 1021 | } | 1021 | } |
| ... | @@ -1070,19 +1070,19 @@ pub const Builder = struct { | ... | @@ -1070,19 +1070,19 @@ pub const Builder = struct { |
| 1070 | var code: u8 = undefined; | 1070 | var code: u8 = undefined; |
| 1071 | return self.execAllowFail(argv, &code, .Inherit) catch |err| switch (err) { | 1071 | return self.execAllowFail(argv, &code, .Inherit) catch |err| switch (err) { |
| 1072 | error.FileNotFound => { | 1072 | error.FileNotFound => { |
| 1073 | if (src_step) |s| warn("{}...", .{s.name}); | 1073 | if (src_step) |s| warn("{s}...", .{s.name}); |
| 1074 | warn("Unable to spawn the following command: file not found\n", .{}); | 1074 | warn("Unable to spawn the following command: file not found\n", .{}); |
| 1075 | printCmd(null, argv); | 1075 | printCmd(null, argv); |
| 1076 | std.os.exit(@truncate(u8, code)); | 1076 | std.os.exit(@truncate(u8, code)); |
| 1077 | }, | 1077 | }, |
| 1078 | error.ExitCodeFailure => { | 1078 | error.ExitCodeFailure => { |
| 1079 | if (src_step) |s| warn("{}...", .{s.name}); | 1079 | if (src_step) |s| warn("{s}...", .{s.name}); |
| 1080 | warn("The following command exited with error code {}:\n", .{code}); | 1080 | warn("The following command exited with error code {d}:\n", .{code}); |
| 1081 | printCmd(null, argv); | 1081 | printCmd(null, argv); |
| 1082 | std.os.exit(@truncate(u8, code)); | 1082 | std.os.exit(@truncate(u8, code)); |
| 1083 | }, | 1083 | }, |
| 1084 | error.ProcessTerminated => { | 1084 | error.ProcessTerminated => { |
| 1085 | if (src_step) |s| warn("{}...", .{s.name}); | 1085 | if (src_step) |s| warn("{s}...", .{s.name}); |
| 1086 | warn("The following command terminated unexpectedly:\n", .{}); | 1086 | warn("The following command terminated unexpectedly:\n", .{}); |
| 1087 | printCmd(null, argv); | 1087 | printCmd(null, argv); |
| 1088 | std.os.exit(@truncate(u8, code)); | 1088 | std.os.exit(@truncate(u8, code)); |
| ... | @@ -1405,7 +1405,7 @@ pub const LibExeObjStep = struct { | ... | @@ -1405,7 +1405,7 @@ pub const LibExeObjStep = struct { |
| 1405 | ver: ?Version, | 1405 | ver: ?Version, |
| 1406 | ) LibExeObjStep { | 1406 | ) LibExeObjStep { |
| 1407 | if (mem.indexOf(u8, name, "/") != null or mem.indexOf(u8, name, "\\") != null) { | 1407 | 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}); |
| 1409 | } | 1409 | } |
| 1410 | var self = LibExeObjStep{ | 1410 | var self = LibExeObjStep{ |
| 1411 | .strip = false, | 1411 | .strip = false, |
| ... | @@ -1421,9 +1421,9 @@ pub const LibExeObjStep = struct { | ... | @@ -1421,9 +1421,9 @@ pub const LibExeObjStep = struct { |
| 1421 | .step = Step.init(.LibExeObj, name, builder.allocator, make), | 1421 | .step = Step.init(.LibExeObj, name, builder.allocator, make), |
| 1422 | .version = ver, | 1422 | .version = ver, |
| 1423 | .out_filename = undefined, | 1423 | .out_filename = undefined, |
| 1424 | .out_h_filename = builder.fmt("{}.h", .{name}), | 1424 | .out_h_filename = builder.fmt("{s}.h", .{name}), |
| 1425 | .out_lib_filename = undefined, | 1425 | .out_lib_filename = undefined, |
| 1426 | .out_pdb_filename = builder.fmt("{}.pdb", .{name}), | 1426 | .out_pdb_filename = builder.fmt("{s}.pdb", .{name}), |
| 1427 | .major_only_filename = undefined, | 1427 | .major_only_filename = undefined, |
| 1428 | .name_only_filename = undefined, | 1428 | .name_only_filename = undefined, |
| 1429 | .packages = ArrayList(Pkg).init(builder.allocator), | 1429 | .packages = ArrayList(Pkg).init(builder.allocator), |
| ... | @@ -1529,7 +1529,7 @@ pub const LibExeObjStep = struct { | ... | @@ -1529,7 +1529,7 @@ pub const LibExeObjStep = struct { |
| 1529 | // It doesn't have to be native. We catch that if you actually try to run it. | 1529 | // It doesn't have to be native. We catch that if you actually try to run it. |
| 1530 | // Consider that this is declarative; the run step may not be run unless a user | 1530 | // Consider that this is declarative; the run step may not be run unless a user |
| 1531 | // option is supplied. | 1531 | // 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})); |
| 1533 | run_step.addArtifactArg(exe); | 1533 | run_step.addArtifactArg(exe); |
| 1534 | 1534 | ||
| 1535 | if (exe.vcpkg_bin_path) |path| { | 1535 | if (exe.vcpkg_bin_path) |path| { |
| ... | @@ -1680,7 +1680,7 @@ pub const LibExeObjStep = struct { | ... | @@ -1680,7 +1680,7 @@ pub const LibExeObjStep = struct { |
| 1680 | } else if (mem.eql(u8, tok, "-pthread")) { | 1680 | } else if (mem.eql(u8, tok, "-pthread")) { |
| 1681 | self.linkLibC(); | 1681 | self.linkLibC(); |
| 1682 | } else if (self.builder.verbose) { | 1682 | } else if (self.builder.verbose) { |
| 1683 | warn("Ignoring pkg-config flag '{}'\n", .{tok}); | 1683 | warn("Ignoring pkg-config flag '{s}'\n", .{tok}); |
| 1684 | } | 1684 | } |
| 1685 | } | 1685 | } |
| 1686 | } | 1686 | } |
| ... | @@ -1926,7 +1926,7 @@ pub const LibExeObjStep = struct { | ... | @@ -1926,7 +1926,7 @@ pub const LibExeObjStep = struct { |
| 1926 | }, | 1926 | }, |
| 1927 | else => {}, | 1927 | else => {}, |
| 1928 | } | 1928 | } |
| 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; |
| 1930 | } | 1930 | } |
| 1931 | 1931 | ||
| 1932 | /// The value is the path in the cache dir. | 1932 | /// The value is the path in the cache dir. |
| ... | @@ -2048,7 +2048,7 @@ pub const LibExeObjStep = struct { | ... | @@ -2048,7 +2048,7 @@ pub const LibExeObjStep = struct { |
| 2048 | const builder = self.builder; | 2048 | const builder = self.builder; |
| 2049 | 2049 | ||
| 2050 | if (self.root_src == null and self.link_objects.items.len == 0) { | 2050 | 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}); |
| 2052 | return error.NeedAnObject; | 2052 | return error.NeedAnObject; |
| 2053 | } | 2053 | } |
| 2054 | 2054 | ||
| ... | @@ -2156,12 +2156,12 @@ pub const LibExeObjStep = struct { | ... | @@ -2156,12 +2156,12 @@ pub const LibExeObjStep = struct { |
| 2156 | // Render build artifact options at the last minute, now that the path is known. | 2156 | // Render build artifact options at the last minute, now that the path is known. |
| 2157 | for (self.build_options_artifact_args.items) |item| { | 2157 | for (self.build_options_artifact_args.items) |item| { |
| 2158 | const out = self.build_options_contents.writer(); | 2158 | 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; |
| 2160 | } | 2160 | } |
| 2161 | 2161 | ||
| 2162 | const build_options_file = try fs.path.join( | 2162 | const build_options_file = try fs.path.join( |
| 2163 | builder.allocator, | 2163 | 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}) }, |
| 2165 | ); | 2165 | ); |
| 2166 | const path_from_root = builder.pathFromRoot(build_options_file); | 2166 | const path_from_root = builder.pathFromRoot(build_options_file); |
| 2167 | try fs.cwd().writeFile(path_from_root, self.build_options_contents.items); | 2167 | try fs.cwd().writeFile(path_from_root, self.build_options_contents.items); |
| ... | @@ -2294,16 +2294,16 @@ pub const LibExeObjStep = struct { | ... | @@ -2294,16 +2294,16 @@ pub const LibExeObjStep = struct { |
| 2294 | } else { | 2294 | } else { |
| 2295 | var mcpu_buffer = std.ArrayList(u8).init(builder.allocator); | 2295 | var mcpu_buffer = std.ArrayList(u8).init(builder.allocator); |
| 2296 | 2296 | ||
| 2297 | try mcpu_buffer.outStream().print("-mcpu={}", .{cross.cpu.model.name}); | 2297 | try mcpu_buffer.outStream().print("-mcpu={s}", .{cross.cpu.model.name}); |
| 2298 | 2298 | ||
| 2299 | for (all_features) |feature, i_usize| { | 2299 | for (all_features) |feature, i_usize| { |
| 2300 | const i = @intCast(std.Target.Cpu.Feature.Set.Index, i_usize); | 2300 | const i = @intCast(std.Target.Cpu.Feature.Set.Index, i_usize); |
| 2301 | const in_cpu_set = populated_cpu_features.isEnabled(i); | 2301 | const in_cpu_set = populated_cpu_features.isEnabled(i); |
| 2302 | const in_actual_set = cross.cpu.features.isEnabled(i); | 2302 | const in_actual_set = cross.cpu.features.isEnabled(i); |
| 2303 | if (in_cpu_set and !in_actual_set) { | 2303 | 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}); |
| 2305 | } else if (!in_cpu_set and in_actual_set) { | 2305 | } 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}); |
| 2307 | } | 2307 | } |
| 2308 | } | 2308 | } |
| 2309 | 2309 | ||
| ... | @@ -2536,7 +2536,7 @@ pub const InstallArtifactStep = struct { | ... | @@ -2536,7 +2536,7 @@ pub const InstallArtifactStep = struct { |
| 2536 | const self = builder.allocator.create(Self) catch unreachable; | 2536 | const self = builder.allocator.create(Self) catch unreachable; |
| 2537 | self.* = Self{ | 2537 | self.* = Self{ |
| 2538 | .builder = builder, | 2538 | .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), |
| 2540 | .artifact = artifact, | 2540 | .artifact = artifact, |
| 2541 | .dest_dir = artifact.override_dest_dir orelse switch (artifact.kind) { | 2541 | .dest_dir = artifact.override_dest_dir orelse switch (artifact.kind) { |
| 2542 | .Obj => unreachable, | 2542 | .Obj => unreachable, |
| ... | @@ -2612,7 +2612,7 @@ pub const InstallFileStep = struct { | ... | @@ -2612,7 +2612,7 @@ pub const InstallFileStep = struct { |
| 2612 | builder.pushInstalledFile(dir, dest_rel_path); | 2612 | builder.pushInstalledFile(dir, dest_rel_path); |
| 2613 | return InstallFileStep{ | 2613 | return InstallFileStep{ |
| 2614 | .builder = builder, | 2614 | .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), |
| 2616 | .src_path = src_path, | 2616 | .src_path = src_path, |
| 2617 | .dir = dir, | 2617 | .dir = dir, |
| 2618 | .dest_rel_path = dest_rel_path, | 2618 | .dest_rel_path = dest_rel_path, |
| ... | @@ -2646,7 +2646,7 @@ pub const InstallDirStep = struct { | ... | @@ -2646,7 +2646,7 @@ pub const InstallDirStep = struct { |
| 2646 | builder.pushInstalledFile(options.install_dir, options.install_subdir); | 2646 | builder.pushInstalledFile(options.install_dir, options.install_subdir); |
| 2647 | return InstallDirStep{ | 2647 | return InstallDirStep{ |
| 2648 | .builder = builder, | 2648 | .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), |
| 2650 | .options = options, | 2650 | .options = options, |
| 2651 | }; | 2651 | }; |
| 2652 | } | 2652 | } |
| ... | @@ -2682,14 +2682,14 @@ pub const LogStep = struct { | ... | @@ -2682,14 +2682,14 @@ pub const LogStep = struct { |
| 2682 | pub fn init(builder: *Builder, data: []const u8) LogStep { | 2682 | pub fn init(builder: *Builder, data: []const u8) LogStep { |
| 2683 | return LogStep{ | 2683 | return LogStep{ |
| 2684 | .builder = builder, | 2684 | .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), |
| 2686 | .data = data, | 2686 | .data = data, |
| 2687 | }; | 2687 | }; |
| 2688 | } | 2688 | } |
| 2689 | 2689 | ||
| 2690 | fn make(step: *Step) anyerror!void { | 2690 | fn make(step: *Step) anyerror!void { |
| 2691 | const self = @fieldParentPtr(LogStep, "step", step); | 2691 | const self = @fieldParentPtr(LogStep, "step", step); |
| 2692 | warn("{}", .{self.data}); | 2692 | warn("{s}", .{self.data}); |
| 2693 | } | 2693 | } |
| 2694 | }; | 2694 | }; |
| 2695 | 2695 | ||
| ... | @@ -2701,7 +2701,7 @@ pub const RemoveDirStep = struct { | ... | @@ -2701,7 +2701,7 @@ pub const RemoveDirStep = struct { |
| 2701 | pub fn init(builder: *Builder, dir_path: []const u8) RemoveDirStep { | 2701 | pub fn init(builder: *Builder, dir_path: []const u8) RemoveDirStep { |
| 2702 | return RemoveDirStep{ | 2702 | return RemoveDirStep{ |
| 2703 | .builder = builder, | 2703 | .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), |
| 2705 | .dir_path = dir_path, | 2705 | .dir_path = dir_path, |
| 2706 | }; | 2706 | }; |
| 2707 | } | 2707 | } |
| ... | @@ -2711,7 +2711,7 @@ pub const RemoveDirStep = struct { | ... | @@ -2711,7 +2711,7 @@ pub const RemoveDirStep = struct { |
| 2711 | 2711 | ||
| 2712 | const full_path = self.builder.pathFromRoot(self.dir_path); | 2712 | const full_path = self.builder.pathFromRoot(self.dir_path); |
| 2713 | fs.cwd().deleteTree(full_path) catch |err| { | 2713 | 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) }); |
| 2715 | return err; | 2715 | return err; |
| 2716 | }; | 2716 | }; |
| 2717 | } | 2717 | } |
| ... | @@ -2799,7 +2799,7 @@ fn doAtomicSymLinks(allocator: *Allocator, output_path: []const u8, filename_maj | ... | @@ -2799,7 +2799,7 @@ fn doAtomicSymLinks(allocator: *Allocator, output_path: []const u8, filename_maj |
| 2799 | &[_][]const u8{ out_dir, filename_major_only }, | 2799 | &[_][]const u8{ out_dir, filename_major_only }, |
| 2800 | ) catch unreachable; | 2800 | ) catch unreachable; |
| 2801 | fs.atomicSymLink(allocator, out_basename, major_only_path) catch |err| { | 2801 | 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 }); |
| 2803 | return err; | 2803 | return err; |
| 2804 | }; | 2804 | }; |
| 2805 | // sym link for libfoo.so to libfoo.so.1 | 2805 | // sym link for libfoo.so to libfoo.so.1 |
| ... | @@ -2808,7 +2808,7 @@ fn doAtomicSymLinks(allocator: *Allocator, output_path: []const u8, filename_maj | ... | @@ -2808,7 +2808,7 @@ fn doAtomicSymLinks(allocator: *Allocator, output_path: []const u8, filename_maj |
| 2808 | &[_][]const u8{ out_dir, filename_name_only }, | 2808 | &[_][]const u8{ out_dir, filename_name_only }, |
| 2809 | ) catch unreachable; | 2809 | ) catch unreachable; |
| 2810 | fs.atomicSymLink(allocator, filename_major_only, name_only_path) catch |err| { | 2810 | 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 }); |
| 2812 | return err; | 2812 | return err; |
| 2813 | }; | 2813 | }; |
| 2814 | } | 2814 | } |
lib/std/build/check_file.zig+2-2| ... | @@ -45,9 +45,9 @@ pub const CheckFileStep = struct { | ... | @@ -45,9 +45,9 @@ pub const CheckFileStep = struct { |
| 45 | warn( | 45 | warn( |
| 46 | \\ | 46 | \\ |
| 47 | \\========= Expected to find: =================== | 47 | \\========= Expected to find: =================== |
| 48 | \\{} | 48 | \\{s} |
| 49 | \\========= But file does not contain it: ======= | 49 | \\========= But file does not contain it: ======= |
| 50 | \\{} | 50 | \\{s} |
| 51 | \\ | 51 | \\ |
| 52 | , .{ expected_match, contents }); | 52 | , .{ expected_match, contents }); |
| 53 | return error.TestFailed; | 53 | return error.TestFailed; |
lib/std/build/emit_raw.zig+1-1| ... | @@ -189,7 +189,7 @@ pub const InstallRawStep = struct { | ... | @@ -189,7 +189,7 @@ pub const InstallRawStep = struct { |
| 189 | pub fn create(builder: *Builder, artifact: *LibExeObjStep, dest_filename: []const u8) *Self { | 189 | pub fn create(builder: *Builder, artifact: *LibExeObjStep, dest_filename: []const u8) *Self { |
| 190 | const self = builder.allocator.create(Self) catch unreachable; | 190 | const self = builder.allocator.create(Self) catch unreachable; |
| 191 | self.* = Self{ | 191 | 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), |
| 193 | .builder = builder, | 193 | .builder = builder, |
| 194 | .artifact = artifact, | 194 | .artifact = artifact, |
| 195 | .dest_dir = switch (artifact.kind) { | 195 | .dest_dir = switch (artifact.kind) { |
lib/std/build/run.zig+13-13| ... | @@ -116,7 +116,7 @@ pub const RunStep = struct { | ... | @@ -116,7 +116,7 @@ pub const RunStep = struct { |
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | if (prev_path) |pp| { | 118 | 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 }); |
| 120 | env_map.set(key, new_path) catch unreachable; | 120 | env_map.set(key, new_path) catch unreachable; |
| 121 | } else { | 121 | } else { |
| 122 | env_map.set(key, search_path) catch unreachable; | 122 | env_map.set(key, search_path) catch unreachable; |
| ... | @@ -189,7 +189,7 @@ pub const RunStep = struct { | ... | @@ -189,7 +189,7 @@ pub const RunStep = struct { |
| 189 | child.stderr_behavior = stdIoActionToBehavior(self.stderr_action); | 189 | child.stderr_behavior = stdIoActionToBehavior(self.stderr_action); |
| 190 | 190 | ||
| 191 | child.spawn() catch |err| { | 191 | 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) }); |
| 193 | return err; | 193 | return err; |
| 194 | }; | 194 | }; |
| 195 | 195 | ||
| ... | @@ -216,7 +216,7 @@ pub const RunStep = struct { | ... | @@ -216,7 +216,7 @@ pub const RunStep = struct { |
| 216 | } | 216 | } |
| 217 | 217 | ||
| 218 | const term = child.wait() catch |err| { | 218 | 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) }); |
| 220 | return err; | 220 | return err; |
| 221 | }; | 221 | }; |
| 222 | 222 | ||
| ... | @@ -245,9 +245,9 @@ pub const RunStep = struct { | ... | @@ -245,9 +245,9 @@ pub const RunStep = struct { |
| 245 | warn( | 245 | warn( |
| 246 | \\ | 246 | \\ |
| 247 | \\========= Expected this stderr: ========= | 247 | \\========= Expected this stderr: ========= |
| 248 | \\{} | 248 | \\{s} |
| 249 | \\========= But found: ==================== | 249 | \\========= But found: ==================== |
| 250 | \\{} | 250 | \\{s} |
| 251 | \\ | 251 | \\ |
| 252 | , .{ expected_bytes, stderr.? }); | 252 | , .{ expected_bytes, stderr.? }); |
| 253 | printCmd(cwd, argv); | 253 | printCmd(cwd, argv); |
| ... | @@ -259,9 +259,9 @@ pub const RunStep = struct { | ... | @@ -259,9 +259,9 @@ pub const RunStep = struct { |
| 259 | warn( | 259 | warn( |
| 260 | \\ | 260 | \\ |
| 261 | \\========= Expected to find in stderr: ========= | 261 | \\========= Expected to find in stderr: ========= |
| 262 | \\{} | 262 | \\{s} |
| 263 | \\========= But stderr does not contain it: ===== | 263 | \\========= But stderr does not contain it: ===== |
| 264 | \\{} | 264 | \\{s} |
| 265 | \\ | 265 | \\ |
| 266 | , .{ match, stderr.? }); | 266 | , .{ match, stderr.? }); |
| 267 | printCmd(cwd, argv); | 267 | printCmd(cwd, argv); |
| ... | @@ -277,9 +277,9 @@ pub const RunStep = struct { | ... | @@ -277,9 +277,9 @@ pub const RunStep = struct { |
| 277 | warn( | 277 | warn( |
| 278 | \\ | 278 | \\ |
| 279 | \\========= Expected this stdout: ========= | 279 | \\========= Expected this stdout: ========= |
| 280 | \\{} | 280 | \\{s} |
| 281 | \\========= But found: ==================== | 281 | \\========= But found: ==================== |
| 282 | \\{} | 282 | \\{s} |
| 283 | \\ | 283 | \\ |
| 284 | , .{ expected_bytes, stdout.? }); | 284 | , .{ expected_bytes, stdout.? }); |
| 285 | printCmd(cwd, argv); | 285 | printCmd(cwd, argv); |
| ... | @@ -291,9 +291,9 @@ pub const RunStep = struct { | ... | @@ -291,9 +291,9 @@ pub const RunStep = struct { |
| 291 | warn( | 291 | warn( |
| 292 | \\ | 292 | \\ |
| 293 | \\========= Expected to find in stdout: ========= | 293 | \\========= Expected to find in stdout: ========= |
| 294 | \\{} | 294 | \\{s} |
| 295 | \\========= But stdout does not contain it: ===== | 295 | \\========= But stdout does not contain it: ===== |
| 296 | \\{} | 296 | \\{s} |
| 297 | \\ | 297 | \\ |
| 298 | , .{ match, stdout.? }); | 298 | , .{ match, stdout.? }); |
| 299 | printCmd(cwd, argv); | 299 | printCmd(cwd, argv); |
| ... | @@ -304,9 +304,9 @@ pub const RunStep = struct { | ... | @@ -304,9 +304,9 @@ pub const RunStep = struct { |
| 304 | } | 304 | } |
| 305 | 305 | ||
| 306 | fn printCmd(cwd: ?[]const u8, argv: []const []const u8) void { | 306 | 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}); |
| 308 | for (argv) |arg| { | 308 | for (argv) |arg| { |
| 309 | warn("{} ", .{arg}); | 309 | warn("{s} ", .{arg}); |
| 310 | } | 310 | } |
| 311 | warn("\n", .{}); | 311 | warn("\n", .{}); |
| 312 | } | 312 | } |
lib/std/build/write_file.zig+2-2| ... | @@ -80,14 +80,14 @@ pub const WriteFileStep = struct { | ... | @@ -80,14 +80,14 @@ pub const WriteFileStep = struct { |
| 80 | }); | 80 | }); |
| 81 | // TODO replace with something like fs.makePathAndOpenDir | 81 | // TODO replace with something like fs.makePathAndOpenDir |
| 82 | fs.cwd().makePath(self.output_dir) catch |err| { | 82 | 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) }); |
| 84 | return err; | 84 | return err; |
| 85 | }; | 85 | }; |
| 86 | var dir = try fs.cwd().openDir(self.output_dir, .{}); | 86 | var dir = try fs.cwd().openDir(self.output_dir, .{}); |
| 87 | defer dir.close(); | 87 | defer dir.close(); |
| 88 | for (self.files.items) |file| { | 88 | for (self.files.items) |file| { |
| 89 | dir.writeFile(file.basename, file.bytes) catch |err| { | 89 | 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", .{ |
| 91 | file.basename, | 91 | file.basename, |
| 92 | self.output_dir, | 92 | self.output_dir, |
| 93 | @errorName(err), | 93 | @errorName(err), |
lib/std/builtin.zig+7-7| ... | @@ -67,12 +67,12 @@ pub const StackTrace = struct { | ... | @@ -67,12 +67,12 @@ pub const StackTrace = struct { |
| 67 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); | 67 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); |
| 68 | defer arena.deinit(); | 68 | defer arena.deinit(); |
| 69 | const debug_info = std.debug.getSelfDebugInfo() catch |err| { | 69 | 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)}); |
| 71 | }; | 71 | }; |
| 72 | const tty_config = std.debug.detectTTYConfig(); | 72 | const tty_config = std.debug.detectTTYConfig(); |
| 73 | try writer.writeAll("\n"); | 73 | try writer.writeAll("\n"); |
| 74 | std.debug.writeStackTrace(self, writer, &arena.allocator, debug_info, tty_config) catch |err| { | 74 | 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)}); |
| 76 | }; | 76 | }; |
| 77 | try writer.writeAll("\n"); | 77 | try writer.writeAll("\n"); |
| 78 | } | 78 | } |
| ... | @@ -529,12 +529,12 @@ pub const Version = struct { | ... | @@ -529,12 +529,12 @@ pub const Version = struct { |
| 529 | if (fmt.len == 0) { | 529 | if (fmt.len == 0) { |
| 530 | if (self.patch == 0) { | 530 | if (self.patch == 0) { |
| 531 | if (self.minor == 0) { | 531 | if (self.minor == 0) { |
| 532 | return std.fmt.format(out_stream, "{}", .{self.major}); | 532 | return std.fmt.format(out_stream, "{d}", .{self.major}); |
| 533 | } else { | 533 | } 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 }); |
| 535 | } | 535 | } |
| 536 | } else { | 536 | } 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 }); |
| 538 | } | 538 | } |
| 539 | } else { | 539 | } else { |
| 540 | @compileError("Unknown format string: '" ++ fmt ++ "'"); | 540 | @compileError("Unknown format string: '" ++ fmt ++ "'"); |
| ... | @@ -683,7 +683,7 @@ pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace) noreturn | ... | @@ -683,7 +683,7 @@ pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace) noreturn |
| 683 | } | 683 | } |
| 684 | }, | 684 | }, |
| 685 | .wasi => { | 685 | .wasi => { |
| 686 | std.debug.warn("{}", .{msg}); | 686 | std.debug.warn("{s}", .{msg}); |
| 687 | std.os.abort(); | 687 | std.os.abort(); |
| 688 | }, | 688 | }, |
| 689 | .uefi => { | 689 | .uefi => { |
| ... | @@ -692,7 +692,7 @@ pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace) noreturn | ... | @@ -692,7 +692,7 @@ pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace) noreturn |
| 692 | }, | 692 | }, |
| 693 | else => { | 693 | else => { |
| 694 | const first_trace_addr = @returnAddress(); | 694 | 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}); |
| 696 | }, | 696 | }, |
| 697 | } | 697 | } |
| 698 | } | 698 | } |
lib/std/c/ast.zig+4-4| ... | @@ -115,10 +115,10 @@ pub const Error = union(enum) { | ... | @@ -115,10 +115,10 @@ pub const Error = union(enum) { |
| 115 | pub fn render(self: *const ExpectedToken, tree: *Tree, stream: anytype) !void { | 115 | pub fn render(self: *const ExpectedToken, tree: *Tree, stream: anytype) !void { |
| 116 | const found_token = tree.tokens.at(self.token); | 116 | const found_token = tree.tokens.at(self.token); |
| 117 | if (found_token.id == .Invalid) { | 117 | 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()}); |
| 119 | } else { | 119 | } else { |
| 120 | const token_name = found_token.id.symbol(); | 120 | 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 }); |
| 122 | } | 122 | } |
| 123 | } | 123 | } |
| 124 | }; | 124 | }; |
| ... | @@ -131,7 +131,7 @@ pub const Error = union(enum) { | ... | @@ -131,7 +131,7 @@ pub const Error = union(enum) { |
| 131 | try stream.write("invalid type specifier '"); | 131 | try stream.write("invalid type specifier '"); |
| 132 | try type_spec.spec.print(tree, stream); | 132 | try type_spec.spec.print(tree, stream); |
| 133 | const token_name = tree.tokens.at(self.token).id.symbol(); | 133 | const token_name = tree.tokens.at(self.token).id.symbol(); |
| 134 | return stream.print("{}'", .{token_name}); | 134 | return stream.print("{s}'", .{token_name}); |
| 135 | } | 135 | } |
| 136 | }; | 136 | }; |
| 137 | 137 | ||
| ... | @@ -140,7 +140,7 @@ pub const Error = union(enum) { | ... | @@ -140,7 +140,7 @@ pub const Error = union(enum) { |
| 140 | name: TokenIndex, | 140 | name: TokenIndex, |
| 141 | 141 | ||
| 142 | pub fn render(self: *const ExpectedToken, tree: *Tree, stream: anytype) !void { | 142 | 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) }); |
| 144 | } | 144 | } |
| 145 | }; | 145 | }; |
| 146 | 146 |
lib/std/c/tokenizer.zig+1-1| ... | @@ -1552,7 +1552,7 @@ fn expectTokens(source: []const u8, expected_tokens: []const Token.Id) void { | ... | @@ -1552,7 +1552,7 @@ fn expectTokens(source: []const u8, expected_tokens: []const Token.Id) void { |
| 1552 | for (expected_tokens) |expected_token_id| { | 1552 | for (expected_tokens) |expected_token_id| { |
| 1553 | const token = tokenizer.next(); | 1553 | const token = tokenizer.next(); |
| 1554 | if (!std.meta.eql(token.id, expected_token_id)) { | 1554 | 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) }); |
| 1556 | } | 1556 | } |
| 1557 | } | 1557 | } |
| 1558 | const last_token = tokenizer.next(); | 1558 | 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) | ... | @@ -247,7 +247,7 @@ fn strHashInternal(password: []const u8, rounds_log: u6, salt: [salt_length]u8) |
| 247 | Codec.encode(ct_str[0..], ct[0 .. ct.len - 1]); | 247 | Codec.encode(ct_str[0..], ct[0 .. ct.len - 1]); |
| 248 | 248 | ||
| 249 | var s_buf: [hash_length]u8 = undefined; | 249 | 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; |
| 251 | debug.assert(s.len == s_buf.len); | 251 | debug.assert(s.len == s_buf.len); |
| 252 | return s_buf; | 252 | return s_buf; |
| 253 | } | 253 | } |
lib/std/debug.zig+7-7| ... | @@ -108,11 +108,11 @@ pub fn dumpCurrentStackTrace(start_addr: ?usize) void { | ... | @@ -108,11 +108,11 @@ pub fn dumpCurrentStackTrace(start_addr: ?usize) void { |
| 108 | return; | 108 | return; |
| 109 | } | 109 | } |
| 110 | const debug_info = getSelfDebugInfo() catch |err| { | 110 | 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; |
| 112 | return; | 112 | return; |
| 113 | }; | 113 | }; |
| 114 | writeCurrentStackTrace(stderr, debug_info, detectTTYConfig(), start_addr) catch |err| { | 114 | 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; |
| 116 | return; | 116 | return; |
| 117 | }; | 117 | }; |
| 118 | } | 118 | } |
| ... | @@ -129,7 +129,7 @@ pub fn dumpStackTraceFromBase(bp: usize, ip: usize) void { | ... | @@ -129,7 +129,7 @@ pub fn dumpStackTraceFromBase(bp: usize, ip: usize) void { |
| 129 | return; | 129 | return; |
| 130 | } | 130 | } |
| 131 | const debug_info = getSelfDebugInfo() catch |err| { | 131 | 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; |
| 133 | return; | 133 | return; |
| 134 | }; | 134 | }; |
| 135 | const tty_config = detectTTYConfig(); | 135 | const tty_config = detectTTYConfig(); |
| ... | @@ -199,11 +199,11 @@ pub fn dumpStackTrace(stack_trace: builtin.StackTrace) void { | ... | @@ -199,11 +199,11 @@ pub fn dumpStackTrace(stack_trace: builtin.StackTrace) void { |
| 199 | return; | 199 | return; |
| 200 | } | 200 | } |
| 201 | const debug_info = getSelfDebugInfo() catch |err| { | 201 | 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; |
| 203 | return; | 203 | return; |
| 204 | }; | 204 | }; |
| 205 | writeStackTrace(stack_trace, stderr, getDebugInfoAllocator(), debug_info, detectTTYConfig()) catch |err| { | 205 | 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; |
| 207 | return; | 207 | return; |
| 208 | }; | 208 | }; |
| 209 | } | 209 | } |
| ... | @@ -611,7 +611,7 @@ fn printLineInfo( | ... | @@ -611,7 +611,7 @@ fn printLineInfo( |
| 611 | tty_config.setColor(out_stream, .White); | 611 | tty_config.setColor(out_stream, .White); |
| 612 | 612 | ||
| 613 | if (line_info) |*li| { | 613 | 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 }); |
| 615 | } else { | 615 | } else { |
| 616 | try out_stream.writeAll("???:?:?"); | 616 | try out_stream.writeAll("???:?:?"); |
| 617 | } | 617 | } |
| ... | @@ -619,7 +619,7 @@ fn printLineInfo( | ... | @@ -619,7 +619,7 @@ fn printLineInfo( |
| 619 | tty_config.setColor(out_stream, .Reset); | 619 | tty_config.setColor(out_stream, .Reset); |
| 620 | try out_stream.writeAll(": "); | 620 | try out_stream.writeAll(": "); |
| 621 | tty_config.setColor(out_stream, .Dim); | 621 | 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 }); |
| 623 | tty_config.setColor(out_stream, .Reset); | 623 | tty_config.setColor(out_stream, .Reset); |
| 624 | try out_stream.writeAll("\n"); | 624 | try out_stream.writeAll("\n"); |
| 625 | 625 |
lib/std/fifo.zig+1-1| ... | @@ -466,7 +466,7 @@ test "LinearFifo(u8, .Dynamic)" { | ... | @@ -466,7 +466,7 @@ test "LinearFifo(u8, .Dynamic)" { |
| 466 | fifo.shrink(0); | 466 | fifo.shrink(0); |
| 467 | 467 | ||
| 468 | { | 468 | { |
| 469 | try fifo.writer().print("{}, {}!", .{ "Hello", "World" }); | 469 | try fifo.writer().print("{s}, {s}!", .{ "Hello", "World" }); |
| 470 | var result: [30]u8 = undefined; | 470 | var result: [30]u8 = undefined; |
| 471 | testing.expectEqualSlices(u8, "Hello, World!", result[0..fifo.read(&result)]); | 471 | testing.expectEqualSlices(u8, "Hello, World!", result[0..fifo.read(&result)]); |
| 472 | testing.expectEqual(@as(usize, 0), fifo.readableLength()); | 472 | testing.expectEqual(@as(usize, 0), fifo.readableLength()); |
lib/std/fmt.zig+106-56| ... | @@ -367,6 +367,36 @@ pub fn format( | ... | @@ -367,6 +367,36 @@ pub fn format( |
| 367 | } | 367 | } |
| 368 | } | 368 | } |
| 369 | 369 | ||
| 370 | pub 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 | |||
| 370 | pub fn formatType( | 400 | pub fn formatType( |
| 371 | value: anytype, | 401 | value: anytype, |
| 372 | comptime fmt: []const u8, | 402 | comptime fmt: []const u8, |
| ... | @@ -375,10 +405,7 @@ pub fn formatType( | ... | @@ -375,10 +405,7 @@ pub fn formatType( |
| 375 | max_depth: usize, | 405 | max_depth: usize, |
| 376 | ) @TypeOf(writer).Error!void { | 406 | ) @TypeOf(writer).Error!void { |
| 377 | if (comptime std.mem.eql(u8, fmt, "*")) { | 407 | if (comptime std.mem.eql(u8, fmt, "*")) { |
| 378 | try writer.writeAll(@typeName(std.meta.Child(@TypeOf(value)))); | 408 | return formatAddress(value, options, writer); |
| 379 | try writer.writeAll("@"); | ||
| 380 | try formatInt(@ptrToInt(value), 16, false, FormatOptions{}, writer); | ||
| 381 | return; | ||
| 382 | } | 409 | } |
| 383 | 410 | ||
| 384 | const T = @TypeOf(value); | 411 | const T = @TypeOf(value); |
| ... | @@ -436,12 +463,11 @@ pub fn formatType( | ... | @@ -436,12 +463,11 @@ pub fn formatType( |
| 436 | try formatType(@enumToInt(value), fmt, options, writer, max_depth); | 463 | try formatType(@enumToInt(value), fmt, options, writer, max_depth); |
| 437 | try writer.writeAll(")"); | 464 | try writer.writeAll(")"); |
| 438 | }, | 465 | }, |
| 439 | .Union => { | 466 | .Union => |info| { |
| 440 | try writer.writeAll(@typeName(T)); | 467 | try writer.writeAll(@typeName(T)); |
| 441 | if (max_depth == 0) { | 468 | if (max_depth == 0) { |
| 442 | return writer.writeAll("{ ... }"); | 469 | return writer.writeAll("{ ... }"); |
| 443 | } | 470 | } |
| 444 | const info = @typeInfo(T).Union; | ||
| 445 | if (info.tag_type) |UnionTagType| { | 471 | if (info.tag_type) |UnionTagType| { |
| 446 | try writer.writeAll("{ ."); | 472 | try writer.writeAll("{ ."); |
| 447 | try writer.writeAll(@tagName(@as(UnionTagType, value))); | 473 | try writer.writeAll(@tagName(@as(UnionTagType, value))); |
| ... | @@ -456,13 +482,13 @@ pub fn formatType( | ... | @@ -456,13 +482,13 @@ pub fn formatType( |
| 456 | try format(writer, "@{x}", .{@ptrToInt(&value)}); | 482 | try format(writer, "@{x}", .{@ptrToInt(&value)}); |
| 457 | } | 483 | } |
| 458 | }, | 484 | }, |
| 459 | .Struct => |StructT| { | 485 | .Struct => |info| { |
| 460 | try writer.writeAll(@typeName(T)); | 486 | try writer.writeAll(@typeName(T)); |
| 461 | if (max_depth == 0) { | 487 | if (max_depth == 0) { |
| 462 | return writer.writeAll("{ ... }"); | 488 | return writer.writeAll("{ ... }"); |
| 463 | } | 489 | } |
| 464 | try writer.writeAll("{"); | 490 | try writer.writeAll("{"); |
| 465 | inline for (StructT.fields) |f, i| { | 491 | inline for (info.fields) |f, i| { |
| 466 | if (i == 0) { | 492 | if (i == 0) { |
| 467 | try writer.writeAll(" ."); | 493 | try writer.writeAll(" ."); |
| 468 | } else { | 494 | } else { |
| ... | @@ -478,69 +504,83 @@ pub fn formatType( | ... | @@ -478,69 +504,83 @@ pub fn formatType( |
| 478 | .One => switch (@typeInfo(ptr_info.child)) { | 504 | .One => switch (@typeInfo(ptr_info.child)) { |
| 479 | .Array => |info| { | 505 | .Array => |info| { |
| 480 | if (info.child == u8) { | 506 | 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 | } | ||
| 482 | } | 510 | } |
| 483 | return format(writer, "{}@{x}", .{ @typeName(@typeInfo(T).Pointer.child), @ptrToInt(value) }); | 511 | return format(writer, "{s}@{x}", .{ @typeName(ptr_info.child), @ptrToInt(value) }); |
| 484 | }, | 512 | }, |
| 485 | .Enum, .Union, .Struct => { | 513 | .Enum, .Union, .Struct => { |
| 486 | return formatType(value.*, fmt, options, writer, max_depth); | 514 | return formatType(value.*, fmt, options, writer, max_depth); |
| 487 | }, | 515 | }, |
| 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) }), |
| 489 | }, | 517 | }, |
| 490 | .Many, .C => { | 518 | .Many, .C => { |
| 491 | if (ptr_info.sentinel) |sentinel| { | 519 | if (ptr_info.sentinel) |sentinel| { |
| 492 | return formatType(mem.span(value), fmt, options, writer, max_depth); | 520 | return formatType(mem.span(value), fmt, options, writer, max_depth); |
| 493 | } | 521 | } |
| 494 | if (ptr_info.child == u8) { | 522 | 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) { |
| 496 | return formatText(mem.span(value), fmt, options, writer); | 524 | return formatText(mem.span(value), fmt, options, writer); |
| 497 | } | 525 | } |
| 498 | } | 526 | } |
| 499 | return format(writer, "{}@{x}", .{ @typeName(@typeInfo(T).Pointer.child), @ptrToInt(value) }); | 527 | return format(writer, "{s}@{x}", .{ @typeName(ptr_info.child), @ptrToInt(value) }); |
| 500 | }, | 528 | }, |
| 501 | .Slice => { | 529 | .Slice => { |
| 502 | if (fmt.len > 0 and ((fmt[0] == 'x') or (fmt[0] == 'X'))) { | 530 | if (max_depth == 0) { |
| 503 | return formatText(value, fmt, options, writer); | 531 | return writer.writeAll("{ ... }"); |
| 504 | } | 532 | } |
| 505 | if (ptr_info.child == u8) { | 533 | 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 | } | ||
| 507 | } | 537 | } |
| 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(" }"); | ||
| 509 | }, | 546 | }, |
| 510 | }, | 547 | }, |
| 511 | .Array => |info| { | 548 | .Array => |info| { |
| 512 | const Slice = @Type(builtin.TypeInfo{ | 549 | if (max_depth == 0) { |
| 513 | .Pointer = .{ | 550 | return writer.writeAll("{ ... }"); |
| 514 | .size = .Slice, | 551 | } |
| 515 | .is_const = true, | 552 | if (info.child == u8) { |
| 516 | .is_volatile = false, | 553 | if (fmt.len > 0 and comptime mem.indexOfScalar(u8, "sxXeEzZ", fmt[0]) != null) { |
| 517 | .is_allowzero = false, | 554 | return formatText(&value, fmt, options, writer); |
| 518 | .alignment = @alignOf(info.child), | 555 | } |
| 519 | .child = info.child, | 556 | } |
| 520 | .sentinel = null, | 557 | try writer.writeAll("{ "); |
| 521 | }, | 558 | for (value) |elem, i| { |
| 522 | }); | 559 | try formatType(elem, fmt, options, writer, max_depth - 1); |
| 523 | return formatType(@as(Slice, &value), fmt, options, writer, max_depth); | 560 | if (i < value.len - 1) { |
| 561 | try writer.writeAll(", "); | ||
| 562 | } | ||
| 563 | } | ||
| 564 | try writer.writeAll(" }"); | ||
| 524 | }, | 565 | }, |
| 525 | .Vector => { | 566 | .Vector => |info| { |
| 526 | const len = @typeInfo(T).Vector.len; | ||
| 527 | try writer.writeAll("{ "); | 567 | try writer.writeAll("{ "); |
| 528 | var i: usize = 0; | 568 | var i: usize = 0; |
| 529 | while (i < len) : (i += 1) { | 569 | while (i < info.len) : (i += 1) { |
| 530 | try formatValue(value[i], fmt, options, writer); | 570 | try formatValue(value[i], fmt, options, writer); |
| 531 | if (i < len - 1) { | 571 | if (i < info.len - 1) { |
| 532 | try writer.writeAll(", "); | 572 | try writer.writeAll(", "); |
| 533 | } | 573 | } |
| 534 | } | 574 | } |
| 535 | try writer.writeAll(" }"); | 575 | try writer.writeAll(" }"); |
| 536 | }, | 576 | }, |
| 537 | .Fn => { | 577 | .Fn => { |
| 538 | return format(writer, "{}@{x}", .{ @typeName(T), @ptrToInt(value) }); | 578 | return format(writer, "{s}@{x}", .{ @typeName(T), @ptrToInt(value) }); |
| 539 | }, | 579 | }, |
| 540 | .Type => return formatBuf(@typeName(value), options, writer), | 580 | .Type => return formatBuf(@typeName(value), options, writer), |
| 541 | .EnumLiteral => { | 581 | .EnumLiteral => { |
| 542 | const buffer = [_]u8{'.'} ++ @tagName(value); | 582 | const buffer = [_]u8{'.'} ++ @tagName(value); |
| 543 | return formatType(buffer, fmt, options, writer, max_depth); | 583 | return formatBuf(buffer, options, writer); |
| 544 | }, | 584 | }, |
| 545 | .Null => return formatBuf("null", options, writer), | 585 | .Null => return formatBuf("null", options, writer), |
| 546 | else => @compileError("Unable to format type '" ++ @typeName(T) ++ "'"), | 586 | else => @compileError("Unable to format type '" ++ @typeName(T) ++ "'"), |
| ... | @@ -657,7 +697,7 @@ pub fn formatText( | ... | @@ -657,7 +697,7 @@ pub fn formatText( |
| 657 | options: FormatOptions, | 697 | options: FormatOptions, |
| 658 | writer: anytype, | 698 | writer: anytype, |
| 659 | ) !void { | 699 | ) !void { |
| 660 | if (comptime std.mem.eql(u8, fmt, "s") or (fmt.len == 0)) { | 700 | if (comptime std.mem.eql(u8, fmt, "s")) { |
| 661 | return formatBuf(bytes, options, writer); | 701 | return formatBuf(bytes, options, writer); |
| 662 | } else if (comptime (std.mem.eql(u8, fmt, "x") or std.mem.eql(u8, fmt, "X"))) { | 702 | } else if (comptime (std.mem.eql(u8, fmt, "x") or std.mem.eql(u8, fmt, "X"))) { |
| 663 | for (bytes) |c| { | 703 | for (bytes) |c| { |
| ... | @@ -1521,8 +1561,9 @@ test "buffer" { | ... | @@ -1521,8 +1561,9 @@ test "buffer" { |
| 1521 | test "array" { | 1561 | test "array" { |
| 1522 | { | 1562 | { |
| 1523 | const value: [3]u8 = "abc".*; | 1563 | const value: [3]u8 = "abc".*; |
| 1524 | try testFmt("array: abc\n", "array: {}\n", .{value}); | 1564 | try testFmt("array: abc\n", "array: {s}\n", .{value}); |
| 1525 | try testFmt("array: abc\n", "array: {}\n", .{&value}); | 1565 | try testFmt("array: abc\n", "array: {s}\n", .{&value}); |
| 1566 | try testFmt("array: { 97, 98, 99 }\n", "array: {d}\n", .{value}); | ||
| 1526 | 1567 | ||
| 1527 | var buf: [100]u8 = undefined; | 1568 | var buf: [100]u8 = undefined; |
| 1528 | try testFmt( | 1569 | try testFmt( |
| ... | @@ -1536,12 +1577,12 @@ test "array" { | ... | @@ -1536,12 +1577,12 @@ test "array" { |
| 1536 | test "slice" { | 1577 | test "slice" { |
| 1537 | { | 1578 | { |
| 1538 | const value: []const u8 = "abc"; | 1579 | const value: []const u8 = "abc"; |
| 1539 | try testFmt("slice: abc\n", "slice: {}\n", .{value}); | 1580 | try testFmt("slice: abc\n", "slice: {s}\n", .{value}); |
| 1540 | } | 1581 | } |
| 1541 | { | 1582 | { |
| 1542 | var runtime_zero: usize = 0; | 1583 | var runtime_zero: usize = 0; |
| 1543 | const value = @intToPtr([*]align(1) const []const u8, 0xdeadbeef)[runtime_zero..runtime_zero]; | 1584 | 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}); |
| 1545 | } | 1586 | } |
| 1546 | { | 1587 | { |
| 1547 | const null_term_slice: [:0]const u8 = "\x00hello\x00"; | 1588 | const null_term_slice: [:0]const u8 = "\x00hello\x00"; |
| ... | @@ -1550,6 +1591,15 @@ test "slice" { | ... | @@ -1550,6 +1591,15 @@ test "slice" { |
| 1550 | 1591 | ||
| 1551 | try testFmt("buf: Test\n", "buf: {s:5}\n", .{"Test"}); | 1592 | try testFmt("buf: Test\n", "buf: {s:5}\n", .{"Test"}); |
| 1552 | try testFmt("buf: Test\n Other text", "buf: {s}\n Other text", .{"Test"}); | 1593 | 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 | } | ||
| 1553 | } | 1603 | } |
| 1554 | 1604 | ||
| 1555 | test "escape non-printable" { | 1605 | test "escape non-printable" { |
| ... | @@ -1854,9 +1904,9 @@ fn testFmt(expected: []const u8, comptime template: []const u8, args: anytype) ! | ... | @@ -1854,9 +1904,9 @@ fn testFmt(expected: []const u8, comptime template: []const u8, args: anytype) ! |
| 1854 | if (mem.eql(u8, result, expected)) return; | 1904 | if (mem.eql(u8, result, expected)) return; |
| 1855 | 1905 | ||
| 1856 | std.debug.warn("\n====== expected this output: =========\n", .{}); | 1906 | std.debug.warn("\n====== expected this output: =========\n", .{}); |
| 1857 | std.debug.warn("{}", .{expected}); | 1907 | std.debug.warn("{s}", .{expected}); |
| 1858 | std.debug.warn("\n======== instead found this: =========\n", .{}); | 1908 | std.debug.warn("\n======== instead found this: =========\n", .{}); |
| 1859 | std.debug.warn("{}", .{result}); | 1909 | std.debug.warn("{s}", .{result}); |
| 1860 | std.debug.warn("\n======================================\n", .{}); | 1910 | std.debug.warn("\n======================================\n", .{}); |
| 1861 | return error.TestFailed; | 1911 | return error.TestFailed; |
| 1862 | } | 1912 | } |
| ... | @@ -2013,24 +2063,24 @@ test "vector" { | ... | @@ -2013,24 +2063,24 @@ test "vector" { |
| 2013 | } | 2063 | } |
| 2014 | 2064 | ||
| 2015 | test "enum-literal" { | 2065 | test "enum-literal" { |
| 2016 | try testFmt(".hello_world", "{}", .{.hello_world}); | 2066 | try testFmt(".hello_world", "{s}", .{.hello_world}); |
| 2017 | } | 2067 | } |
| 2018 | 2068 | ||
| 2019 | test "padding" { | 2069 | test "padding" { |
| 2020 | try testFmt("Simple", "{}", .{"Simple"}); | 2070 | try testFmt("Simple", "{s}", .{"Simple"}); |
| 2021 | try testFmt(" true", "{:10}", .{true}); | 2071 | try testFmt(" true", "{:10}", .{true}); |
| 2022 | try testFmt(" true", "{:>10}", .{true}); | 2072 | try testFmt(" true", "{:>10}", .{true}); |
| 2023 | try testFmt("======true", "{:=>10}", .{true}); | 2073 | try testFmt("======true", "{:=>10}", .{true}); |
| 2024 | try testFmt("true======", "{:=<10}", .{true}); | 2074 | try testFmt("true======", "{:=<10}", .{true}); |
| 2025 | try testFmt(" true ", "{:^10}", .{true}); | 2075 | try testFmt(" true ", "{:^10}", .{true}); |
| 2026 | try testFmt("===true===", "{:=^10}", .{true}); | 2076 | try testFmt("===true===", "{:=^10}", .{true}); |
| 2027 | try testFmt(" Minimum width", "{:18} width", .{"Minimum"}); | 2077 | try testFmt(" Minimum width", "{s:18} width", .{"Minimum"}); |
| 2028 | try testFmt("==================Filled", "{:=>24}", .{"Filled"}); | 2078 | try testFmt("==================Filled", "{s:=>24}", .{"Filled"}); |
| 2029 | try testFmt(" Centered ", "{:^24}", .{"Centered"}); | 2079 | try testFmt(" Centered ", "{s:^24}", .{"Centered"}); |
| 2030 | try testFmt("-", "{:-^1}", .{""}); | 2080 | try testFmt("-", "{s:-^1}", .{""}); |
| 2031 | try testFmt("==crêpe===", "{:=^10}", .{"crêpe"}); | 2081 | try testFmt("==crêpe===", "{s:=^10}", .{"crêpe"}); |
| 2032 | try testFmt("=====crêpe", "{:=>10}", .{"crêpe"}); | 2082 | try testFmt("=====crêpe", "{s:=>10}", .{"crêpe"}); |
| 2033 | try testFmt("crêpe=====", "{:=<10}", .{"crêpe"}); | 2083 | try testFmt("crêpe=====", "{s:=<10}", .{"crêpe"}); |
| 2034 | } | 2084 | } |
| 2035 | 2085 | ||
| 2036 | test "decimal float padding" { | 2086 | test "decimal float padding" { |
| ... | @@ -2059,15 +2109,15 @@ test "type" { | ... | @@ -2059,15 +2109,15 @@ test "type" { |
| 2059 | } | 2109 | } |
| 2060 | 2110 | ||
| 2061 | test "named arguments" { | 2111 | test "named arguments" { |
| 2062 | try testFmt("hello world!", "{} world{c}", .{ "hello", '!' }); | 2112 | try testFmt("hello world!", "{s} world{c}", .{ "hello", '!' }); |
| 2063 | try testFmt("hello world!", "{[greeting]} world{[punctuation]c}", .{ .punctuation = '!', .greeting = "hello" }); | 2113 | try testFmt("hello world!", "{[greeting]s} world{[punctuation]c}", .{ .punctuation = '!', .greeting = "hello" }); |
| 2064 | try testFmt("hello world!", "{[1]} world{[0]c}", .{ '!', "hello" }); | 2114 | try testFmt("hello world!", "{[1]s} world{[0]c}", .{ '!', "hello" }); |
| 2065 | } | 2115 | } |
| 2066 | 2116 | ||
| 2067 | test "runtime width specifier" { | 2117 | test "runtime width specifier" { |
| 2068 | var width: usize = 9; | 2118 | var width: usize = 9; |
| 2069 | try testFmt("~~hello~~", "{:~^[1]}", .{ "hello", width }); | 2119 | try testFmt("~~hello~~", "{s:~^[1]}", .{ "hello", width }); |
| 2070 | try testFmt("~~hello~~", "{:~^[width]}", .{ .string = "hello", .width = width }); | 2120 | try testFmt("~~hello~~", "{s:~^[width]}", .{ .string = "hello", .width = width }); |
| 2071 | } | 2121 | } |
| 2072 | 2122 | ||
| 2073 | test "runtime precision specifier" { | 2123 | test "runtime precision specifier" { |
lib/std/fs/wasi.zig+1-1| ... | @@ -38,7 +38,7 @@ pub const PreopenType = union(PreopenTypeTag) { | ... | @@ -38,7 +38,7 @@ pub const PreopenType = union(PreopenTypeTag) { |
| 38 | pub fn format(self: Self, comptime fmt: []const u8, options: std.fmt.FormatOptions, out_stream: anytype) !void { | 38 | pub fn format(self: Self, comptime fmt: []const u8, options: std.fmt.FormatOptions, out_stream: anytype) !void { |
| 39 | try out_stream.print("PreopenType{{ ", .{}); | 39 | try out_stream.print("PreopenType{{ ", .{}); |
| 40 | switch (self) { | 40 | switch (self) { |
| 41 | PreopenType.Dir => |path| try out_stream.print(".Dir = '{}'", .{path}), | 41 | PreopenType.Dir => |path| try out_stream.print(".Dir = '{z}'", .{path}), |
| 42 | } | 42 | } |
| 43 | return out_stream.print(" }}", .{}); | 43 | return out_stream.print(" }}", .{}); |
| 44 | } | 44 | } |
lib/std/heap/general_purpose_allocator.zig+4-4| ... | @@ -314,7 +314,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { | ... | @@ -314,7 +314,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { |
| 314 | if (is_used) { | 314 | if (is_used) { |
| 315 | const slot_index = @intCast(SlotIndex, used_bits_byte * 8 + bit_index); | 315 | const slot_index = @intCast(SlotIndex, used_bits_byte * 8 + bit_index); |
| 316 | const stack_trace = bucketStackTrace(bucket, size_class, slot_index, .alloc); | 316 | 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}); |
| 318 | leaks = true; | 318 | leaks = true; |
| 319 | } | 319 | } |
| 320 | if (bit_index == math.maxInt(u3)) | 320 | if (bit_index == math.maxInt(u3)) |
| ... | @@ -342,7 +342,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { | ... | @@ -342,7 +342,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { |
| 342 | } | 342 | } |
| 343 | var it = self.large_allocations.iterator(); | 343 | var it = self.large_allocations.iterator(); |
| 344 | while (it.next()) |large_alloc| { | 344 | 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()}); |
| 346 | leaks = true; | 346 | leaks = true; |
| 347 | } | 347 | } |
| 348 | return leaks; | 348 | return leaks; |
| ... | @@ -443,7 +443,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { | ... | @@ -443,7 +443,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { |
| 443 | .index = 0, | 443 | .index = 0, |
| 444 | }; | 444 | }; |
| 445 | std.debug.captureStackTrace(ret_addr, &free_stack_trace); | 445 | 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}", .{ |
| 447 | entry.value.bytes.len, | 447 | entry.value.bytes.len, |
| 448 | old_mem.len, | 448 | old_mem.len, |
| 449 | entry.value.getStackTrace(), | 449 | entry.value.getStackTrace(), |
| ... | @@ -526,7 +526,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { | ... | @@ -526,7 +526,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { |
| 526 | .index = 0, | 526 | .index = 0, |
| 527 | }; | 527 | }; |
| 528 | std.debug.captureStackTrace(ret_addr, &second_free_stack_trace); | 528 | 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}", .{ |
| 530 | alloc_stack_trace, | 530 | alloc_stack_trace, |
| 531 | free_stack_trace, | 531 | free_stack_trace, |
| 532 | second_free_stack_trace, | 532 | second_free_stack_trace, |
lib/std/io/fixed_buffer_stream.zig+1-1| ... | @@ -147,7 +147,7 @@ test "FixedBufferStream output" { | ... | @@ -147,7 +147,7 @@ test "FixedBufferStream output" { |
| 147 | var fbs = fixedBufferStream(&buf); | 147 | var fbs = fixedBufferStream(&buf); |
| 148 | const stream = fbs.writer(); | 148 | const stream = fbs.writer(); |
| 149 | 149 | ||
| 150 | try stream.print("{}{}!", .{ "Hello", "World" }); | 150 | try stream.print("{s}{s}!", .{ "Hello", "World" }); |
| 151 | testing.expectEqualSlices(u8, "HelloWorld!", fbs.getWritten()); | 151 | testing.expectEqualSlices(u8, "HelloWorld!", fbs.getWritten()); |
| 152 | } | 152 | } |
| 153 | 153 |
lib/std/json.zig+4-4| ... | @@ -2642,9 +2642,9 @@ fn teststringify(expected: []const u8, value: anytype, options: StringifyOptions | ... | @@ -2642,9 +2642,9 @@ fn teststringify(expected: []const u8, value: anytype, options: StringifyOptions |
| 2642 | if (self.expected_remaining.len < bytes.len) { | 2642 | if (self.expected_remaining.len < bytes.len) { |
| 2643 | std.debug.warn( | 2643 | std.debug.warn( |
| 2644 | \\====== expected this output: ========= | 2644 | \\====== expected this output: ========= |
| 2645 | \\{} | 2645 | \\{s} |
| 2646 | \\======== instead found this: ========= | 2646 | \\======== instead found this: ========= |
| 2647 | \\{} | 2647 | \\{s} |
| 2648 | \\====================================== | 2648 | \\====================================== |
| 2649 | , .{ | 2649 | , .{ |
| 2650 | self.expected_remaining, | 2650 | self.expected_remaining, |
| ... | @@ -2655,9 +2655,9 @@ fn teststringify(expected: []const u8, value: anytype, options: StringifyOptions | ... | @@ -2655,9 +2655,9 @@ fn teststringify(expected: []const u8, value: anytype, options: StringifyOptions |
| 2655 | if (!mem.eql(u8, self.expected_remaining[0..bytes.len], bytes)) { | 2655 | if (!mem.eql(u8, self.expected_remaining[0..bytes.len], bytes)) { |
| 2656 | std.debug.warn( | 2656 | std.debug.warn( |
| 2657 | \\====== expected this output: ========= | 2657 | \\====== expected this output: ========= |
| 2658 | \\{} | 2658 | \\{s} |
| 2659 | \\======== instead found this: ========= | 2659 | \\======== instead found this: ========= |
| 2660 | \\{} | 2660 | \\{s} |
| 2661 | \\====================================== | 2661 | \\====================================== |
| 2662 | , .{ | 2662 | , .{ |
| 2663 | self.expected_remaining[0..bytes.len], | 2663 | self.expected_remaining[0..bytes.len], |
lib/std/meta/trait.zig+14| ... | @@ -298,6 +298,20 @@ pub fn isNumber(comptime T: type) bool { | ... | @@ -298,6 +298,20 @@ pub fn isNumber(comptime T: type) bool { |
| 298 | }; | 298 | }; |
| 299 | } | 299 | } |
| 300 | 300 | ||
| 301 | pub fn isIntegerNumber(comptime T: type) bool { | ||
| 302 | return switch (@typeInfo(T)) { | ||
| 303 | .Int, .ComptimeInt => true, | ||
| 304 | else => false, | ||
| 305 | }; | ||
| 306 | } | ||
| 307 | |||
| 308 | pub fn isFloatingNumber(comptime T: type) bool { | ||
| 309 | return switch (@typeInfo(T)) { | ||
| 310 | .Float, .ComptimeFloat => true, | ||
| 311 | else => false, | ||
| 312 | }; | ||
| 313 | } | ||
| 314 | |||
| 301 | test "std.meta.trait.isNumber" { | 315 | test "std.meta.trait.isNumber" { |
| 302 | const NotANumber = struct { | 316 | const NotANumber = struct { |
| 303 | number: u8, | 317 | number: u8, |
lib/std/net.zig+1-1| ... | @@ -154,7 +154,7 @@ pub const Address = extern union { | ... | @@ -154,7 +154,7 @@ pub const Address = extern union { |
| 154 | unreachable; | 154 | unreachable; |
| 155 | } | 155 | } |
| 156 | 156 | ||
| 157 | try std.fmt.format(out_stream, "{}", .{&self.un.path}); | 157 | try std.fmt.format(out_stream, "{s}", .{&self.un.path}); |
| 158 | }, | 158 | }, |
| 159 | else => unreachable, | 159 | else => unreachable, |
| 160 | } | 160 | } |
lib/std/os.zig+2-2| ... | @@ -4256,7 +4256,7 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 { | ... | @@ -4256,7 +4256,7 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 { |
| 4256 | }, | 4256 | }, |
| 4257 | .linux => { | 4257 | .linux => { |
| 4258 | var procfs_buf: ["/proc/self/fd/-2147483648".len:0]u8 = undefined; | 4258 | 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; |
| 4260 | 4260 | ||
| 4261 | const target = readlinkZ(std.meta.assumeSentinel(proc_path.ptr, 0), out_buffer) catch |err| { | 4261 | const target = readlinkZ(std.meta.assumeSentinel(proc_path.ptr, 0), out_buffer) catch |err| { |
| 4262 | switch (err) { | 4262 | switch (err) { |
| ... | @@ -4487,7 +4487,7 @@ pub const UnexpectedError = error{ | ... | @@ -4487,7 +4487,7 @@ pub const UnexpectedError = error{ |
| 4487 | /// and you get an unexpected error. | 4487 | /// and you get an unexpected error. |
| 4488 | pub fn unexpectedErrno(err: usize) UnexpectedError { | 4488 | pub fn unexpectedErrno(err: usize) UnexpectedError { |
| 4489 | if (unexpected_error_tracing) { | 4489 | if (unexpected_error_tracing) { |
| 4490 | std.debug.warn("unexpected errno: {}\n", .{err}); | 4490 | std.debug.warn("unexpected errno: {d}\n", .{err}); |
| 4491 | std.debug.dumpCurrentStackTrace(null); | 4491 | std.debug.dumpCurrentStackTrace(null); |
| 4492 | } | 4492 | } |
| 4493 | return error.Unexpected; | 4493 | return error.Unexpected; |
lib/std/os/windows.zig+1-1| ... | @@ -1618,7 +1618,7 @@ pub fn unexpectedError(err: Win32Error) std.os.UnexpectedError { | ... | @@ -1618,7 +1618,7 @@ pub fn unexpectedError(err: Win32Error) std.os.UnexpectedError { |
| 1618 | null, | 1618 | null, |
| 1619 | ); | 1619 | ); |
| 1620 | _ = std.unicode.utf16leToUtf8(&buf_u8, buf_u16[0..len]) catch unreachable; | 1620 | _ = 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] }); |
| 1622 | std.debug.dumpCurrentStackTrace(null); | 1622 | std.debug.dumpCurrentStackTrace(null); |
| 1623 | } | 1623 | } |
| 1624 | return error.Unexpected; | 1624 | return error.Unexpected; |
lib/std/process.zig+1-1| ... | @@ -596,7 +596,7 @@ fn testWindowsCmdLine(input_cmd_line: [*]const u16, expected_args: []const []con | ... | @@ -596,7 +596,7 @@ fn testWindowsCmdLine(input_cmd_line: [*]const u16, expected_args: []const []con |
| 596 | for (expected_args) |expected_arg| { | 596 | for (expected_args) |expected_arg| { |
| 597 | const arg = it.next(std.testing.allocator).? catch unreachable; | 597 | const arg = it.next(std.testing.allocator).? catch unreachable; |
| 598 | defer std.testing.allocator.free(arg); | 598 | defer std.testing.allocator.free(arg); |
| 599 | testing.expectEqualSlices(u8, expected_arg, arg); | 599 | testing.expectEqualStrings(expected_arg, arg); |
| 600 | } | 600 | } |
| 601 | testing.expect(it.next(std.testing.allocator) == null); | 601 | testing.expect(it.next(std.testing.allocator) == null); |
| 602 | } | 602 | } |
lib/std/special/build_runner.zig+7-7| ... | @@ -98,7 +98,7 @@ pub fn main() !void { | ... | @@ -98,7 +98,7 @@ pub fn main() !void { |
| 98 | return usageAndErr(builder, false, stderr_stream); | 98 | return usageAndErr(builder, false, stderr_stream); |
| 99 | }; | 99 | }; |
| 100 | builder.color = std.meta.stringToEnum(@TypeOf(builder.color), next_arg) orelse { | 100 | 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}); |
| 102 | return usageAndErr(builder, false, stderr_stream); | 102 | return usageAndErr(builder, false, stderr_stream); |
| 103 | }; | 103 | }; |
| 104 | } else if (mem.eql(u8, arg, "--override-lib-dir")) { | 104 | } else if (mem.eql(u8, arg, "--override-lib-dir")) { |
| ... | @@ -126,7 +126,7 @@ pub fn main() !void { | ... | @@ -126,7 +126,7 @@ pub fn main() !void { |
| 126 | builder.args = argsRest(args, arg_idx); | 126 | builder.args = argsRest(args, arg_idx); |
| 127 | break; | 127 | break; |
| 128 | } else { | 128 | } else { |
| 129 | warn("Unrecognized argument: {}\n\n", .{arg}); | 129 | warn("Unrecognized argument: {s}\n\n", .{arg}); |
| 130 | return usageAndErr(builder, false, stderr_stream); | 130 | return usageAndErr(builder, false, stderr_stream); |
| 131 | } | 131 | } |
| 132 | } else { | 132 | } else { |
| ... | @@ -168,7 +168,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void | ... | @@ -168,7 +168,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void |
| 168 | } | 168 | } |
| 169 | 169 | ||
| 170 | try out_stream.print( | 170 | try out_stream.print( |
| 171 | \\Usage: {} build [steps] [options] | 171 | \\Usage: {s} build [steps] [options] |
| 172 | \\ | 172 | \\ |
| 173 | \\Steps: | 173 | \\Steps: |
| 174 | \\ | 174 | \\ |
| ... | @@ -177,10 +177,10 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void | ... | @@ -177,10 +177,10 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void |
| 177 | const allocator = builder.allocator; | 177 | const allocator = builder.allocator; |
| 178 | for (builder.top_level_steps.items) |top_level_step| { | 178 | for (builder.top_level_steps.items) |top_level_step| { |
| 179 | const name = if (&top_level_step.step == builder.default_step) | 179 | 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}) |
| 181 | else | 181 | else |
| 182 | top_level_step.step.name; | 182 | 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 }); |
| 184 | } | 184 | } |
| 185 | 185 | ||
| 186 | try out_stream.writeAll( | 186 | try out_stream.writeAll( |
| ... | @@ -200,12 +200,12 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void | ... | @@ -200,12 +200,12 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void |
| 200 | try out_stream.print(" (none)\n", .{}); | 200 | try out_stream.print(" (none)\n", .{}); |
| 201 | } else { | 201 | } else { |
| 202 | for (builder.available_options_list.items) |option| { | 202 | 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}]", .{ |
| 204 | option.name, | 204 | option.name, |
| 205 | Builder.typeIdName(option.type_id), | 205 | Builder.typeIdName(option.type_id), |
| 206 | }); | 206 | }); |
| 207 | defer allocator.free(name); | 207 | 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 }); |
| 209 | } | 209 | } |
| 210 | } | 210 | } |
| 211 | 211 |
lib/std/special/c.zig+1-1| ... | @@ -172,7 +172,7 @@ test "strncmp" { | ... | @@ -172,7 +172,7 @@ test "strncmp" { |
| 172 | pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn { | 172 | pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn { |
| 173 | if (builtin.is_test) { | 173 | if (builtin.is_test) { |
| 174 | @setCold(true); | 174 | @setCold(true); |
| 175 | std.debug.panic("{}", .{msg}); | 175 | std.debug.panic("{s}", .{msg}); |
| 176 | } | 176 | } |
| 177 | if (builtin.os.tag != .freestanding and builtin.os.tag != .other) { | 177 | if (builtin.os.tag != .freestanding and builtin.os.tag != .other) { |
| 178 | std.os.abort(); | 178 | std.os.abort(); |
lib/std/special/compiler_rt.zig+1-1| ... | @@ -324,7 +324,7 @@ pub usingnamespace @import("compiler_rt/atomics.zig"); | ... | @@ -324,7 +324,7 @@ pub usingnamespace @import("compiler_rt/atomics.zig"); |
| 324 | pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn { | 324 | pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn { |
| 325 | @setCold(true); | 325 | @setCold(true); |
| 326 | if (is_test) { | 326 | if (is_test) { |
| 327 | std.debug.panic("{}", .{msg}); | 327 | std.debug.panic("{s}", .{msg}); |
| 328 | } else { | 328 | } else { |
| 329 | unreachable; | 329 | unreachable; |
| 330 | } | 330 | } |
lib/std/special/test_runner.zig+8-8| ... | @@ -48,7 +48,7 @@ pub fn main() anyerror!void { | ... | @@ -48,7 +48,7 @@ pub fn main() anyerror!void { |
| 48 | test_node.activate(); | 48 | test_node.activate(); |
| 49 | progress.refresh(); | 49 | progress.refresh(); |
| 50 | if (progress.terminal == null) { | 50 | 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 }); |
| 52 | } | 52 | } |
| 53 | const result = if (test_fn.async_frame_size) |size| switch (io_mode) { | 53 | const result = if (test_fn.async_frame_size) |size| switch (io_mode) { |
| 54 | .evented => blk: { | 54 | .evented => blk: { |
| ... | @@ -62,7 +62,7 @@ pub fn main() anyerror!void { | ... | @@ -62,7 +62,7 @@ pub fn main() anyerror!void { |
| 62 | .blocking => { | 62 | .blocking => { |
| 63 | skip_count += 1; | 63 | skip_count += 1; |
| 64 | test_node.end(); | 64 | test_node.end(); |
| 65 | progress.log("{}...SKIP (async test)\n", .{test_fn.name}); | 65 | progress.log("{s}...SKIP (async test)\n", .{test_fn.name}); |
| 66 | if (progress.terminal == null) std.debug.print("SKIP (async test)\n", .{}); | 66 | if (progress.terminal == null) std.debug.print("SKIP (async test)\n", .{}); |
| 67 | continue; | 67 | continue; |
| 68 | }, | 68 | }, |
| ... | @@ -75,7 +75,7 @@ pub fn main() anyerror!void { | ... | @@ -75,7 +75,7 @@ pub fn main() anyerror!void { |
| 75 | error.SkipZigTest => { | 75 | error.SkipZigTest => { |
| 76 | skip_count += 1; | 76 | skip_count += 1; |
| 77 | test_node.end(); | 77 | test_node.end(); |
| 78 | progress.log("{}...SKIP\n", .{test_fn.name}); | 78 | progress.log("{s}...SKIP\n", .{test_fn.name}); |
| 79 | if (progress.terminal == null) std.debug.print("SKIP\n", .{}); | 79 | if (progress.terminal == null) std.debug.print("SKIP\n", .{}); |
| 80 | }, | 80 | }, |
| 81 | else => { | 81 | else => { |
| ... | @@ -86,15 +86,15 @@ pub fn main() anyerror!void { | ... | @@ -86,15 +86,15 @@ pub fn main() anyerror!void { |
| 86 | } | 86 | } |
| 87 | root_node.end(); | 87 | root_node.end(); |
| 88 | if (ok_count == test_fn_list.len) { | 88 | 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}); |
| 90 | } else { | 90 | } 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 }); |
| 92 | } | 92 | } |
| 93 | if (log_err_count != 0) { | 93 | 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}); |
| 95 | } | 95 | } |
| 96 | if (leaks != 0) { | 96 | if (leaks != 0) { |
| 97 | std.debug.print("{} tests leaked memory.\n", .{leaks}); | 97 | std.debug.print("{d} tests leaked memory.\n", .{leaks}); |
| 98 | } | 98 | } |
| 99 | if (leaks != 0 or log_err_count != 0) { | 99 | if (leaks != 0 or log_err_count != 0) { |
| 100 | std.process.exit(1); | 100 | std.process.exit(1); |
| ... | @@ -111,6 +111,6 @@ pub fn log( | ... | @@ -111,6 +111,6 @@ pub fn log( |
| 111 | log_err_count += 1; | 111 | log_err_count += 1; |
| 112 | } | 112 | } |
| 113 | if (@enumToInt(message_level) <= @enumToInt(std.testing.log_level)) { | 113 | 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); |
| 115 | } | 115 | } |
| 116 | } | 116 | } |
lib/std/start.zig+3-3| ... | @@ -266,7 +266,7 @@ inline fn initEventLoopAndCallMain() u8 { | ... | @@ -266,7 +266,7 @@ inline fn initEventLoopAndCallMain() u8 { |
| 266 | if (std.event.Loop.instance) |loop| { | 266 | if (std.event.Loop.instance) |loop| { |
| 267 | if (!@hasDecl(root, "event_loop")) { | 267 | if (!@hasDecl(root, "event_loop")) { |
| 268 | loop.init() catch |err| { | 268 | loop.init() catch |err| { |
| 269 | std.log.err("{}", .{@errorName(err)}); | 269 | std.log.err("{s}", .{@errorName(err)}); |
| 270 | if (@errorReturnTrace()) |trace| { | 270 | if (@errorReturnTrace()) |trace| { |
| 271 | std.debug.dumpStackTrace(trace.*); | 271 | std.debug.dumpStackTrace(trace.*); |
| 272 | } | 272 | } |
| ... | @@ -295,7 +295,7 @@ inline fn initEventLoopAndCallWinMain() std.os.windows.INT { | ... | @@ -295,7 +295,7 @@ inline fn initEventLoopAndCallWinMain() std.os.windows.INT { |
| 295 | if (std.event.Loop.instance) |loop| { | 295 | if (std.event.Loop.instance) |loop| { |
| 296 | if (!@hasDecl(root, "event_loop")) { | 296 | if (!@hasDecl(root, "event_loop")) { |
| 297 | loop.init() catch |err| { | 297 | loop.init() catch |err| { |
| 298 | std.log.err("{}", .{@errorName(err)}); | 298 | std.log.err("{s}", .{@errorName(err)}); |
| 299 | if (@errorReturnTrace()) |trace| { | 299 | if (@errorReturnTrace()) |trace| { |
| 300 | std.debug.dumpStackTrace(trace.*); | 300 | std.debug.dumpStackTrace(trace.*); |
| 301 | } | 301 | } |
| ... | @@ -343,7 +343,7 @@ pub fn callMain() u8 { | ... | @@ -343,7 +343,7 @@ pub fn callMain() u8 { |
| 343 | }, | 343 | }, |
| 344 | .ErrorUnion => { | 344 | .ErrorUnion => { |
| 345 | const result = root.main() catch |err| { | 345 | const result = root.main() catch |err| { |
| 346 | std.log.err("{}", .{@errorName(err)}); | 346 | std.log.err("{s}", .{@errorName(err)}); |
| 347 | if (@errorReturnTrace()) |trace| { | 347 | if (@errorReturnTrace()) |trace| { |
| 348 | std.debug.dumpStackTrace(trace.*); | 348 | std.debug.dumpStackTrace(trace.*); |
| 349 | } | 349 | } |
lib/std/target.zig+6-6| ... | @@ -136,14 +136,14 @@ pub const Target = struct { | ... | @@ -136,14 +136,14 @@ pub const Target = struct { |
| 136 | ) !void { | 136 | ) !void { |
| 137 | if (fmt.len > 0 and fmt[0] == 's') { | 137 | if (fmt.len > 0 and fmt[0] == 's') { |
| 138 | if (@enumToInt(self) >= @enumToInt(WindowsVersion.nt4) and @enumToInt(self) <= @enumToInt(WindowsVersion.latest)) { | 138 | 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)}); |
| 140 | } else { | 140 | } else { |
| 141 | // TODO this code path breaks zig triples, but it is used in `builtin` | 141 | // TODO this code path breaks zig triples, but it is used in `builtin` |
| 142 | try std.fmt.format(out_stream, "@intToEnum(Target.Os.WindowsVersion, 0x{X:0>8})", .{@enumToInt(self)}); | 142 | try std.fmt.format(out_stream, "@intToEnum(Target.Os.WindowsVersion, 0x{X:0>8})", .{@enumToInt(self)}); |
| 143 | } | 143 | } |
| 144 | } else { | 144 | } else { |
| 145 | if (@enumToInt(self) >= @enumToInt(WindowsVersion.nt4) and @enumToInt(self) <= @enumToInt(WindowsVersion.latest)) { | 145 | 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)}); |
| 147 | } else { | 147 | } else { |
| 148 | try std.fmt.format(out_stream, "WindowsVersion(0x{X:0>8})", .{@enumToInt(self)}); | 148 | try std.fmt.format(out_stream, "WindowsVersion(0x{X:0>8})", .{@enumToInt(self)}); |
| 149 | } | 149 | } |
| ... | @@ -1177,7 +1177,7 @@ pub const Target = struct { | ... | @@ -1177,7 +1177,7 @@ pub const Target = struct { |
| 1177 | } | 1177 | } |
| 1178 | 1178 | ||
| 1179 | pub fn linuxTripleSimple(allocator: *mem.Allocator, cpu_arch: Cpu.Arch, os_tag: Os.Tag, abi: Abi) ![]u8 { | 1179 | 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) }); |
| 1181 | } | 1181 | } |
| 1182 | 1182 | ||
| 1183 | pub fn linuxTriple(self: Target, allocator: *mem.Allocator) ![]u8 { | 1183 | pub fn linuxTriple(self: Target, allocator: *mem.Allocator) ![]u8 { |
| ... | @@ -1381,7 +1381,7 @@ pub const Target = struct { | ... | @@ -1381,7 +1381,7 @@ pub const Target = struct { |
| 1381 | 1381 | ||
| 1382 | if (self.abi == .android) { | 1382 | if (self.abi == .android) { |
| 1383 | const suffix = if (self.cpu.arch.ptrBitWidth() == 64) "64" else ""; | 1383 | 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}); |
| 1385 | } | 1385 | } |
| 1386 | 1386 | ||
| 1387 | if (self.abi.isMusl()) { | 1387 | if (self.abi.isMusl()) { |
| ... | @@ -1395,7 +1395,7 @@ pub const Target = struct { | ... | @@ -1395,7 +1395,7 @@ pub const Target = struct { |
| 1395 | else => |arch| @tagName(arch), | 1395 | else => |arch| @tagName(arch), |
| 1396 | }; | 1396 | }; |
| 1397 | const arch_suffix = if (is_arm and self.abi.floatAbi() == .hard) "hf" else ""; | 1397 | 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 }); |
| 1399 | } | 1399 | } |
| 1400 | 1400 | ||
| 1401 | switch (self.os.tag) { | 1401 | switch (self.os.tag) { |
| ... | @@ -1434,7 +1434,7 @@ pub const Target = struct { | ... | @@ -1434,7 +1434,7 @@ pub const Target = struct { |
| 1434 | }; | 1434 | }; |
| 1435 | const is_nan_2008 = mips.featureSetHas(self.cpu.features, .nan2008); | 1435 | const is_nan_2008 = mips.featureSetHas(self.cpu.features, .nan2008); |
| 1436 | const loader = if (is_nan_2008) "ld-linux-mipsn8.so.1" else "ld.so.1"; | 1436 | 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 }); |
| 1438 | }, | 1438 | }, |
| 1439 | 1439 | ||
| 1440 | .powerpc => return copy(&result, "/lib/ld.so.1"), | 1440 | .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; | ... | @@ -29,10 +29,10 @@ pub var zig_exe_path: []const u8 = undefined; |
| 29 | /// and then aborts when actual_error_union is not expected_error. | 29 | /// and then aborts when actual_error_union is not expected_error. |
| 30 | pub fn expectError(expected_error: anyerror, actual_error_union: anytype) void { | 30 | pub fn expectError(expected_error: anyerror, actual_error_union: anytype) void { |
| 31 | if (actual_error_union) |actual_payload| { | 31 | 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 }); |
| 33 | } else |actual_error| { | 33 | } else |actual_error| { |
| 34 | if (expected_error != actual_error) { | 34 | if (expected_error != actual_error) { |
| 35 | std.debug.panic("expected error.{}, found error.{}", .{ | 35 | std.debug.panic("expected error.{s}, found error.{s}", .{ |
| 36 | @errorName(expected_error), | 36 | @errorName(expected_error), |
| 37 | @errorName(actual_error), | 37 | @errorName(actual_error), |
| 38 | }); | 38 | }); |
| ... | @@ -60,7 +60,7 @@ pub fn expectEqual(expected: anytype, actual: @TypeOf(expected)) void { | ... | @@ -60,7 +60,7 @@ pub fn expectEqual(expected: anytype, actual: @TypeOf(expected)) void { |
| 60 | 60 | ||
| 61 | .Type => { | 61 | .Type => { |
| 62 | if (actual != expected) { | 62 | 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) }); |
| 64 | } | 64 | } |
| 65 | }, | 65 | }, |
| 66 | 66 | ||
| ... | @@ -258,7 +258,7 @@ pub fn expectEqualSlices(comptime T: type, expected: []const T, actual: []const | ... | @@ -258,7 +258,7 @@ pub fn expectEqualSlices(comptime T: type, expected: []const T, actual: []const |
| 258 | // If the child type is u8 and no weird bytes, we could print it as strings | 258 | // If the child type is u8 and no weird bytes, we could print it as strings |
| 259 | // Even for the length difference, it would be useful to see the values of the slices probably. | 259 | // Even for the length difference, it would be useful to see the values of the slices probably. |
| 260 | if (expected.len != actual.len) { | 260 | 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 }); |
| 262 | } | 262 | } |
| 263 | var i: usize = 0; | 263 | var i: usize = 0; |
| 264 | while (i < expected.len) : (i += 1) { | 264 | while (i < expected.len) : (i += 1) { |
| ... | @@ -360,7 +360,7 @@ pub fn expectEqualStrings(expected: []const u8, actual: []const u8) void { | ... | @@ -360,7 +360,7 @@ pub fn expectEqualStrings(expected: []const u8, actual: []const u8) void { |
| 360 | for (expected[0..diff_index]) |value| { | 360 | for (expected[0..diff_index]) |value| { |
| 361 | if (value == '\n') diff_line_number += 1; | 361 | if (value == '\n') diff_line_number += 1; |
| 362 | } | 362 | } |
| 363 | print("First difference occurs on line {}:\n", .{diff_line_number}); | 363 | print("First difference occurs on line {d}:\n", .{diff_line_number}); |
| 364 | 364 | ||
| 365 | print("expected:\n", .{}); | 365 | print("expected:\n", .{}); |
| 366 | printIndicatorLine(expected, diff_index); | 366 | printIndicatorLine(expected, diff_index); |
| ... | @@ -416,15 +416,15 @@ fn printWithVisibleNewlines(source: []const u8) void { | ... | @@ -416,15 +416,15 @@ fn printWithVisibleNewlines(source: []const u8) void { |
| 416 | while (std.mem.indexOf(u8, source[i..], "\n")) |nl| : (i += nl + 1) { | 416 | while (std.mem.indexOf(u8, source[i..], "\n")) |nl| : (i += nl + 1) { |
| 417 | printLine(source[i .. i + nl]); | 417 | printLine(source[i .. i + nl]); |
| 418 | } | 418 | } |
| 419 | print("{}␃\n", .{source[i..]}); // End of Text symbol (ETX) | 419 | print("{s}␃\n", .{source[i..]}); // End of Text symbol (ETX) |
| 420 | } | 420 | } |
| 421 | 421 | ||
| 422 | fn printLine(line: []const u8) void { | 422 | fn printLine(line: []const u8) void { |
| 423 | if (line.len != 0) switch (line[line.len - 1]) { | 423 | 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, |
| 425 | else => {}, | 425 | else => {}, |
| 426 | }; | 426 | }; |
| 427 | print("{}\n", .{line}); | 427 | print("{s}\n", .{line}); |
| 428 | } | 428 | } |
| 429 | 429 | ||
| 430 | test "" { | 430 | test "" { |
lib/std/thread.zig+3-3| ... | @@ -186,7 +186,7 @@ pub const Thread = struct { | ... | @@ -186,7 +186,7 @@ pub const Thread = struct { |
| 186 | @compileError(bad_startfn_ret); | 186 | @compileError(bad_startfn_ret); |
| 187 | } | 187 | } |
| 188 | startFn(arg) catch |err| { | 188 | startFn(arg) catch |err| { |
| 189 | std.debug.warn("error: {}\n", .{@errorName(err)}); | 189 | std.debug.warn("error: {s}\n", .{@errorName(err)}); |
| 190 | if (@errorReturnTrace()) |trace| { | 190 | if (@errorReturnTrace()) |trace| { |
| 191 | std.debug.dumpStackTrace(trace.*); | 191 | std.debug.dumpStackTrace(trace.*); |
| 192 | } | 192 | } |
| ... | @@ -247,7 +247,7 @@ pub const Thread = struct { | ... | @@ -247,7 +247,7 @@ pub const Thread = struct { |
| 247 | @compileError(bad_startfn_ret); | 247 | @compileError(bad_startfn_ret); |
| 248 | } | 248 | } |
| 249 | startFn(arg) catch |err| { | 249 | startFn(arg) catch |err| { |
| 250 | std.debug.warn("error: {}\n", .{@errorName(err)}); | 250 | std.debug.warn("error: {s}\n", .{@errorName(err)}); |
| 251 | if (@errorReturnTrace()) |trace| { | 251 | if (@errorReturnTrace()) |trace| { |
| 252 | std.debug.dumpStackTrace(trace.*); | 252 | std.debug.dumpStackTrace(trace.*); |
| 253 | } | 253 | } |
| ... | @@ -281,7 +281,7 @@ pub const Thread = struct { | ... | @@ -281,7 +281,7 @@ pub const Thread = struct { |
| 281 | @compileError(bad_startfn_ret); | 281 | @compileError(bad_startfn_ret); |
| 282 | } | 282 | } |
| 283 | startFn(arg) catch |err| { | 283 | startFn(arg) catch |err| { |
| 284 | std.debug.warn("error: {}\n", .{@errorName(err)}); | 284 | std.debug.warn("error: {s}\n", .{@errorName(err)}); |
| 285 | if (@errorReturnTrace()) |trace| { | 285 | if (@errorReturnTrace()) |trace| { |
| 286 | std.debug.dumpStackTrace(trace.*); | 286 | std.debug.dumpStackTrace(trace.*); |
| 287 | } | 287 | } |
lib/std/zig/ast.zig+42-42| ... | @@ -281,41 +281,41 @@ pub const Error = union(enum) { | ... | @@ -281,41 +281,41 @@ pub const Error = union(enum) { |
| 281 | } | 281 | } |
| 282 | } | 282 | } |
| 283 | 283 | ||
| 284 | pub const InvalidToken = SingleTokenError("Invalid token '{}'"); | 284 | pub const InvalidToken = SingleTokenError("Invalid token '{s}'"); |
| 285 | pub const ExpectedContainerMembers = SingleTokenError("Expected test, comptime, var decl, or container field, found '{}'"); | 285 | pub const ExpectedContainerMembers = SingleTokenError("Expected test, comptime, var decl, or container field, found '{s}'"); |
| 286 | pub const ExpectedStringLiteral = SingleTokenError("Expected string literal, found '{}'"); | 286 | pub const ExpectedStringLiteral = SingleTokenError("Expected string literal, found '{s}'"); |
| 287 | pub const ExpectedIntegerLiteral = SingleTokenError("Expected integer literal, found '{}'"); | 287 | pub const ExpectedIntegerLiteral = SingleTokenError("Expected integer literal, found '{s}'"); |
| 288 | pub const ExpectedIdentifier = SingleTokenError("Expected identifier, found '{}'"); | 288 | pub const ExpectedIdentifier = SingleTokenError("Expected identifier, found '{s}'"); |
| 289 | pub const ExpectedStatement = SingleTokenError("Expected statement, found '{}'"); | 289 | pub const ExpectedStatement = SingleTokenError("Expected statement, found '{s}'"); |
| 290 | pub const ExpectedVarDeclOrFn = SingleTokenError("Expected variable declaration or function, found '{}'"); | 290 | pub const ExpectedVarDeclOrFn = SingleTokenError("Expected variable declaration or function, found '{s}'"); |
| 291 | pub const ExpectedVarDecl = SingleTokenError("Expected variable declaration, found '{}'"); | 291 | pub const ExpectedVarDecl = SingleTokenError("Expected variable declaration, found '{s}'"); |
| 292 | pub const ExpectedFn = SingleTokenError("Expected function, found '{}'"); | 292 | pub const ExpectedFn = SingleTokenError("Expected function, found '{s}'"); |
| 293 | pub const ExpectedReturnType = SingleTokenError("Expected 'var' or return type expression, found '{}'"); | 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 '{}'"); | 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 '{}'"); | 295 | pub const ExpectedEqOrSemi = SingleTokenError("Expected '=' or ';', found '{s}'"); |
| 296 | pub const ExpectedSemiOrLBrace = SingleTokenError("Expected ';' or '{{', found '{}'"); | 296 | pub const ExpectedSemiOrLBrace = SingleTokenError("Expected ';' or '{{', found '{s}'"); |
| 297 | pub const ExpectedSemiOrElse = SingleTokenError("Expected ';' or 'else', found '{}'"); | 297 | pub const ExpectedSemiOrElse = SingleTokenError("Expected ';' or 'else', found '{s}'"); |
| 298 | pub const ExpectedLBrace = SingleTokenError("Expected '{{', found '{}'"); | 298 | pub const ExpectedLBrace = SingleTokenError("Expected '{{', found '{s}'"); |
| 299 | pub const ExpectedLabelOrLBrace = SingleTokenError("Expected label or '{{', found '{}'"); | 299 | pub const ExpectedLabelOrLBrace = SingleTokenError("Expected label or '{{', found '{s}'"); |
| 300 | pub const ExpectedColonOrRParen = SingleTokenError("Expected ':' or ')', found '{}'"); | 300 | pub const ExpectedColonOrRParen = SingleTokenError("Expected ':' or ')', found '{s}'"); |
| 301 | pub const ExpectedLabelable = SingleTokenError("Expected 'while', 'for', 'inline', 'suspend', or '{{', found '{}'"); | 301 | pub const ExpectedLabelable = SingleTokenError("Expected 'while', 'for', 'inline', 'suspend', or '{{', found '{s}'"); |
| 302 | pub const ExpectedInlinable = SingleTokenError("Expected 'while' or 'for', found '{}'"); | 302 | pub const ExpectedInlinable = SingleTokenError("Expected 'while' or 'for', found '{s}'"); |
| 303 | pub const ExpectedAsmOutputReturnOrType = SingleTokenError("Expected '->' or '" ++ Token.Id.Identifier.symbol() ++ "', found '{}'"); | 303 | pub const ExpectedAsmOutputReturnOrType = SingleTokenError("Expected '->' or '" ++ Token.Id.Identifier.symbol() ++ "', found '{s}'"); |
| 304 | pub const ExpectedSliceOrRBracket = SingleTokenError("Expected ']' or '..', found '{}'"); | 304 | pub const ExpectedSliceOrRBracket = SingleTokenError("Expected ']' or '..', found '{s}'"); |
| 305 | pub const ExpectedTypeExpr = SingleTokenError("Expected type expression, found '{}'"); | 305 | pub const ExpectedTypeExpr = SingleTokenError("Expected type expression, found '{s}'"); |
| 306 | pub const ExpectedPrimaryTypeExpr = SingleTokenError("Expected primary type expression, found '{}'"); | 306 | pub const ExpectedPrimaryTypeExpr = SingleTokenError("Expected primary type expression, found '{s}'"); |
| 307 | pub const ExpectedExpr = SingleTokenError("Expected expression, found '{}'"); | 307 | pub const ExpectedExpr = SingleTokenError("Expected expression, found '{s}'"); |
| 308 | pub const ExpectedPrimaryExpr = SingleTokenError("Expected primary expression, found '{}'"); | 308 | pub const ExpectedPrimaryExpr = SingleTokenError("Expected primary expression, found '{s}'"); |
| 309 | pub const ExpectedParamList = SingleTokenError("Expected parameter list, found '{}'"); | 309 | pub const ExpectedParamList = SingleTokenError("Expected parameter list, found '{s}'"); |
| 310 | pub const ExpectedPayload = SingleTokenError("Expected loop payload, found '{}'"); | 310 | pub const ExpectedPayload = SingleTokenError("Expected loop payload, found '{s}'"); |
| 311 | pub const ExpectedBlockOrAssignment = SingleTokenError("Expected block or assignment, found '{}'"); | 311 | pub const ExpectedBlockOrAssignment = SingleTokenError("Expected block or assignment, found '{s}'"); |
| 312 | pub const ExpectedBlockOrExpression = SingleTokenError("Expected block or expression, found '{}'"); | 312 | pub const ExpectedBlockOrExpression = SingleTokenError("Expected block or expression, found '{s}'"); |
| 313 | pub const ExpectedExprOrAssignment = SingleTokenError("Expected expression or assignment, found '{}'"); | 313 | pub const ExpectedExprOrAssignment = SingleTokenError("Expected expression or assignment, found '{s}'"); |
| 314 | pub const ExpectedPrefixExpr = SingleTokenError("Expected prefix expression, found '{}'"); | 314 | pub const ExpectedPrefixExpr = SingleTokenError("Expected prefix expression, found '{s}'"); |
| 315 | pub const ExpectedLoopExpr = SingleTokenError("Expected loop expression, found '{}'"); | 315 | pub const ExpectedLoopExpr = SingleTokenError("Expected loop expression, found '{s}'"); |
| 316 | pub const ExpectedDerefOrUnwrap = SingleTokenError("Expected pointer dereference or optional unwrap, found '{}'"); | 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 '{}'"); | 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 '{}'"); | 318 | pub const ExpectedBlockOrField = SingleTokenError("Expected block or field, found '{s}'"); |
| 319 | 319 | ||
| 320 | pub const ExpectedParamType = SimpleError("Expected parameter type"); | 320 | pub const ExpectedParamType = SimpleError("Expected parameter type"); |
| 321 | pub const ExpectedPubItem = SimpleError("Expected function or variable declaration after pub"); | 321 | pub const ExpectedPubItem = SimpleError("Expected function or variable declaration after pub"); |
| ... | @@ -332,7 +332,7 @@ pub const Error = union(enum) { | ... | @@ -332,7 +332,7 @@ pub const Error = union(enum) { |
| 332 | node: *Node, | 332 | node: *Node, |
| 333 | 333 | ||
| 334 | pub fn render(self: *const ExpectedCall, tokens: []const Token.Id, stream: anytype) !void { | 334 | 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}", .{ |
| 336 | @tagName(self.node.tag), | 336 | @tagName(self.node.tag), |
| 337 | }); | 337 | }); |
| 338 | } | 338 | } |
| ... | @@ -343,7 +343,7 @@ pub const Error = union(enum) { | ... | @@ -343,7 +343,7 @@ pub const Error = union(enum) { |
| 343 | 343 | ||
| 344 | pub fn render(self: *const ExpectedCallOrFnProto, tokens: []const Token.Id, stream: anytype) !void { | 344 | pub fn render(self: *const ExpectedCallOrFnProto, tokens: []const Token.Id, stream: anytype) !void { |
| 345 | return stream.print("expected " ++ @tagName(Node.Tag.Call) ++ " or " ++ | 345 | 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)}); |
| 347 | } | 347 | } |
| 348 | }; | 348 | }; |
| 349 | 349 | ||
| ... | @@ -355,11 +355,11 @@ pub const Error = union(enum) { | ... | @@ -355,11 +355,11 @@ pub const Error = union(enum) { |
| 355 | const found_token = tokens[self.token]; | 355 | const found_token = tokens[self.token]; |
| 356 | switch (found_token) { | 356 | switch (found_token) { |
| 357 | .Invalid => { | 357 | .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()}); |
| 359 | }, | 359 | }, |
| 360 | else => { | 360 | else => { |
| 361 | const token_name = found_token.symbol(); | 361 | 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 }); |
| 363 | }, | 363 | }, |
| 364 | } | 364 | } |
| 365 | } | 365 | } |
| ... | @@ -371,7 +371,7 @@ pub const Error = union(enum) { | ... | @@ -371,7 +371,7 @@ pub const Error = union(enum) { |
| 371 | 371 | ||
| 372 | pub fn render(self: *const ExpectedCommaOrEnd, tokens: []const Token.Id, stream: anytype) !void { | 372 | pub fn render(self: *const ExpectedCommaOrEnd, tokens: []const Token.Id, stream: anytype) !void { |
| 373 | const actual_token = tokens[self.token]; | 373 | const actual_token = tokens[self.token]; |
| 374 | return stream.print("expected ',' or '{}', found '{}'", .{ | 374 | return stream.print("expected ',' or '{s}', found '{s}'", .{ |
| 375 | self.end_id.symbol(), | 375 | self.end_id.symbol(), |
| 376 | actual_token.symbol(), | 376 | actual_token.symbol(), |
| 377 | }); | 377 | }); |
| ... | @@ -843,7 +843,7 @@ pub const Node = struct { | ... | @@ -843,7 +843,7 @@ pub const Node = struct { |
| 843 | std.debug.warn(" ", .{}); | 843 | std.debug.warn(" ", .{}); |
| 844 | } | 844 | } |
| 845 | } | 845 | } |
| 846 | std.debug.warn("{}\n", .{@tagName(self.tag)}); | 846 | std.debug.warn("{s}\n", .{@tagName(self.tag)}); |
| 847 | 847 | ||
| 848 | var child_i: usize = 0; | 848 | var child_i: usize = 0; |
| 849 | while (self.iterate(child_i)) |child| : (child_i += 1) { | 849 | while (self.iterate(child_i)) |child| : (child_i += 1) { |
| ... | @@ -1418,7 +1418,7 @@ pub const Node = struct { | ... | @@ -1418,7 +1418,7 @@ pub const Node = struct { |
| 1418 | @alignOf(ParamDecl), | 1418 | @alignOf(ParamDecl), |
| 1419 | @ptrCast([*]const u8, self) + @sizeOf(FnProto) + @sizeOf(ParamDecl) * self.params_len, | 1419 | @ptrCast([*]const u8, self) + @sizeOf(FnProto) + @sizeOf(ParamDecl) * self.params_len, |
| 1420 | ); | 1420 | ); |
| 1421 | std.debug.print("{*} flags: {b} name_token: {} {*} params_len: {}\n", .{ | 1421 | std.debug.print("{*} flags: {b} name_token: {s} {*} params_len: {d}\n", .{ |
| 1422 | self, | 1422 | self, |
| 1423 | self.trailer_flags.bits, | 1423 | self.trailer_flags.bits, |
| 1424 | self.getNameToken(), | 1424 | self.getNameToken(), |
lib/std/zig/cross_target.zig+5-5| ... | @@ -519,7 +519,7 @@ pub const CrossTarget = struct { | ... | @@ -519,7 +519,7 @@ pub const CrossTarget = struct { |
| 519 | var result = std.ArrayList(u8).init(allocator); | 519 | var result = std.ArrayList(u8).init(allocator); |
| 520 | defer result.deinit(); | 520 | defer result.deinit(); |
| 521 | 521 | ||
| 522 | try result.outStream().print("{}-{}", .{ arch_name, os_name }); | 522 | try result.outStream().print("{s}-{s}", .{ arch_name, os_name }); |
| 523 | 523 | ||
| 524 | // The zig target syntax does not allow specifying a max os version with no min, so | 524 | // The zig target syntax does not allow specifying a max os version with no min, so |
| 525 | // if either are present, we need the min. | 525 | // if either are present, we need the min. |
| ... | @@ -539,9 +539,9 @@ pub const CrossTarget = struct { | ... | @@ -539,9 +539,9 @@ pub const CrossTarget = struct { |
| 539 | } | 539 | } |
| 540 | 540 | ||
| 541 | if (self.glibc_version) |v| { | 541 | if (self.glibc_version) |v| { |
| 542 | try result.outStream().print("-{}.{}", .{ @tagName(self.getAbi()), v }); | 542 | try result.outStream().print("-{s}.{}", .{ @tagName(self.getAbi()), v }); |
| 543 | } else if (self.abi) |abi| { | 543 | } else if (self.abi) |abi| { |
| 544 | try result.outStream().print("-{}", .{@tagName(abi)}); | 544 | try result.outStream().print("-{s}", .{@tagName(abi)}); |
| 545 | } | 545 | } |
| 546 | 546 | ||
| 547 | return result.toOwnedSlice(); | 547 | return result.toOwnedSlice(); |
| ... | @@ -595,7 +595,7 @@ pub const CrossTarget = struct { | ... | @@ -595,7 +595,7 @@ pub const CrossTarget = struct { |
| 595 | .Dynamic => "", | 595 | .Dynamic => "", |
| 596 | }; | 596 | }; |
| 597 | 597 | ||
| 598 | return std.fmt.allocPrint(allocator, "{}-{}{}", .{ arch, os, static_suffix }); | 598 | return std.fmt.allocPrint(allocator, "{s}-{s}{s}", .{ arch, os, static_suffix }); |
| 599 | } | 599 | } |
| 600 | 600 | ||
| 601 | pub const Executor = union(enum) { | 601 | pub const Executor = union(enum) { |
| ... | @@ -790,7 +790,7 @@ test "CrossTarget.parse" { | ... | @@ -790,7 +790,7 @@ test "CrossTarget.parse" { |
| 790 | var buf: [256]u8 = undefined; | 790 | var buf: [256]u8 = undefined; |
| 791 | const triple = std.fmt.bufPrint( | 791 | const triple = std.fmt.bufPrint( |
| 792 | buf[0..], | 792 | buf[0..], |
| 793 | "native-native-{}.2.1.1", | 793 | "native-native-{s}.2.1.1", |
| 794 | .{@tagName(std.Target.current.abi)}, | 794 | .{@tagName(std.Target.current.abi)}, |
| 795 | ) catch unreachable; | 795 | ) catch unreachable; |
| 796 | 796 |
lib/std/zig/parser_test.zig+3-3| ... | @@ -3742,9 +3742,9 @@ fn testParse(source: []const u8, allocator: *mem.Allocator, anything_changed: *b | ... | @@ -3742,9 +3742,9 @@ fn testParse(source: []const u8, allocator: *mem.Allocator, anything_changed: *b |
| 3742 | for (tree.errors) |*parse_error| { | 3742 | for (tree.errors) |*parse_error| { |
| 3743 | const token = tree.token_locs[parse_error.loc()]; | 3743 | const token = tree.token_locs[parse_error.loc()]; |
| 3744 | const loc = tree.tokenLocation(0, parse_error.loc()); | 3744 | 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 }); |
| 3746 | try tree.renderError(parse_error, stderr); | 3746 | 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]}); |
| 3748 | { | 3748 | { |
| 3749 | var i: usize = 0; | 3749 | var i: usize = 0; |
| 3750 | while (i < loc.column) : (i += 1) { | 3750 | while (i < loc.column) : (i += 1) { |
| ... | @@ -3800,7 +3800,7 @@ fn testTransform(source: []const u8, expected_source: []const u8) !void { | ... | @@ -3800,7 +3800,7 @@ fn testTransform(source: []const u8, expected_source: []const u8) !void { |
| 3800 | error.OutOfMemory => { | 3800 | error.OutOfMemory => { |
| 3801 | if (failing_allocator.allocated_bytes != failing_allocator.freed_bytes) { | 3801 | if (failing_allocator.allocated_bytes != failing_allocator.freed_bytes) { |
| 3802 | warn( | 3802 | 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", |
| 3804 | .{ | 3804 | .{ |
| 3805 | fail_index, | 3805 | fail_index, |
| 3806 | needed_alloc_count, | 3806 | needed_alloc_count, |
lib/std/zig/render.zig+1-1| ... | @@ -41,7 +41,7 @@ fn renderRoot( | ... | @@ -41,7 +41,7 @@ fn renderRoot( |
| 41 | for (tree.token_ids) |token_id, i| { | 41 | for (tree.token_ids) |token_id, i| { |
| 42 | if (token_id != .LineComment) break; | 42 | if (token_id != .LineComment) break; |
| 43 | const token_loc = tree.token_locs[i]; | 43 | 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), " ")}); |
| 45 | const next_token = tree.token_locs[i + 1]; | 45 | const next_token = tree.token_locs[i + 1]; |
| 46 | const loc = tree.tokenLocationLoc(token_loc.end, next_token); | 46 | const loc = tree.tokenLocationLoc(token_loc.end, next_token); |
| 47 | if (loc.line >= 2) { | 47 | if (loc.line >= 2) { |
lib/std/zig/system.zig+8-8| ... | @@ -51,7 +51,7 @@ pub const NativePaths = struct { | ... | @@ -51,7 +51,7 @@ pub const NativePaths = struct { |
| 51 | }; | 51 | }; |
| 52 | try self.addIncludeDir(include_path); | 52 | try self.addIncludeDir(include_path); |
| 53 | } else { | 53 | } 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}); |
| 55 | break; | 55 | break; |
| 56 | } | 56 | } |
| 57 | } | 57 | } |
| ... | @@ -77,7 +77,7 @@ pub const NativePaths = struct { | ... | @@ -77,7 +77,7 @@ pub const NativePaths = struct { |
| 77 | const lib_path = word[2..]; | 77 | const lib_path = word[2..]; |
| 78 | try self.addLibDir(lib_path); | 78 | try self.addLibDir(lib_path); |
| 79 | } else { | 79 | } else { |
| 80 | try self.addWarningFmt("Unrecognized C flag from NIX_LDFLAGS: {}", .{word}); | 80 | try self.addWarningFmt("Unrecognized C flag from NIX_LDFLAGS: {s}", .{word}); |
| 81 | break; | 81 | break; |
| 82 | } | 82 | } |
| 83 | } | 83 | } |
| ... | @@ -113,22 +113,22 @@ pub const NativePaths = struct { | ... | @@ -113,22 +113,22 @@ pub const NativePaths = struct { |
| 113 | // TODO: some of these are suspect and should only be added on some systems. audit needed. | 113 | // TODO: some of these are suspect and should only be added on some systems. audit needed. |
| 114 | 114 | ||
| 115 | try self.addIncludeDir("/usr/local/include"); | 115 | try self.addIncludeDir("/usr/local/include"); |
| 116 | try self.addLibDirFmt("/usr/local/lib{}", .{qual}); | 116 | try self.addLibDirFmt("/usr/local/lib{d}", .{qual}); |
| 117 | try self.addLibDir("/usr/local/lib"); | 117 | try self.addLibDir("/usr/local/lib"); |
| 118 | 118 | ||
| 119 | try self.addIncludeDirFmt("/usr/include/{}", .{triple}); | 119 | try self.addIncludeDirFmt("/usr/include/{s}", .{triple}); |
| 120 | try self.addLibDirFmt("/usr/lib/{}", .{triple}); | 120 | try self.addLibDirFmt("/usr/lib/{s}", .{triple}); |
| 121 | 121 | ||
| 122 | try self.addIncludeDir("/usr/include"); | 122 | try self.addIncludeDir("/usr/include"); |
| 123 | try self.addLibDirFmt("/lib{}", .{qual}); | 123 | try self.addLibDirFmt("/lib{d}", .{qual}); |
| 124 | try self.addLibDir("/lib"); | 124 | try self.addLibDir("/lib"); |
| 125 | try self.addLibDirFmt("/usr/lib{}", .{qual}); | 125 | try self.addLibDirFmt("/usr/lib{d}", .{qual}); |
| 126 | try self.addLibDir("/usr/lib"); | 126 | try self.addLibDir("/usr/lib"); |
| 127 | 127 | ||
| 128 | // example: on a 64-bit debian-based linux distro, with zlib installed from apt: | 128 | // example: on a 64-bit debian-based linux distro, with zlib installed from apt: |
| 129 | // zlib.h is in /usr/include (added above) | 129 | // zlib.h is in /usr/include (added above) |
| 130 | // libz.so.1 is in /lib/x86_64-linux-gnu (added here) | 130 | // 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}); |
| 132 | } | 132 | } |
| 133 | 133 | ||
| 134 | return self; | 134 | return self; |
lib/std/zig/system/macos.zig+2-2| ... | @@ -450,7 +450,7 @@ test "version_from_build" { | ... | @@ -450,7 +450,7 @@ test "version_from_build" { |
| 450 | for (known) |pair| { | 450 | for (known) |pair| { |
| 451 | var buf: [32]u8 = undefined; | 451 | var buf: [32]u8 = undefined; |
| 452 | const ver = try version_from_build(pair[0]); | 452 | 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 }); |
| 454 | std.testing.expect(std.mem.eql(u8, sver, pair[1])); | 454 | std.testing.expect(std.mem.eql(u8, sver, pair[1])); |
| 455 | } | 455 | } |
| 456 | } | 456 | } |
| ... | @@ -468,7 +468,7 @@ pub fn getSDKPath(allocator: *mem.Allocator) ![]u8 { | ... | @@ -468,7 +468,7 @@ pub fn getSDKPath(allocator: *mem.Allocator) ![]u8 { |
| 468 | allocator.free(result.stdout); | 468 | allocator.free(result.stdout); |
| 469 | } | 469 | } |
| 470 | if (result.stderr.len != 0) { | 470 | 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}); |
| 472 | } | 472 | } |
| 473 | if (result.term.Exited != 0) { | 473 | if (result.term.Exited != 0) { |
| 474 | return error.ProcessTerminated; | 474 | return error.ProcessTerminated; |
lib/std/zig/tokenizer.zig+2-2| ... | @@ -334,7 +334,7 @@ pub const Tokenizer = struct { | ... | @@ -334,7 +334,7 @@ pub const Tokenizer = struct { |
| 334 | 334 | ||
| 335 | /// For debugging purposes | 335 | /// For debugging purposes |
| 336 | pub fn dump(self: *Tokenizer, token: *const Token) void { | 336 | 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] }); |
| 338 | } | 338 | } |
| 339 | 339 | ||
| 340 | pub fn init(buffer: []const u8) Tokenizer { | 340 | pub fn init(buffer: []const u8) Tokenizer { |
| ... | @@ -2046,7 +2046,7 @@ fn testTokenize(source: []const u8, expected_tokens: []const Token.Id) void { | ... | @@ -2046,7 +2046,7 @@ fn testTokenize(source: []const u8, expected_tokens: []const Token.Id) void { |
| 2046 | for (expected_tokens) |expected_token_id| { | 2046 | for (expected_tokens) |expected_token_id| { |
| 2047 | const token = tokenizer.next(); | 2047 | const token = tokenizer.next(); |
| 2048 | if (token.id != expected_token_id) { | 2048 | 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) }); |
| 2050 | } | 2050 | } |
| 2051 | } | 2051 | } |
| 2052 | const last_token = tokenizer.next(); | 2052 | const last_token = tokenizer.next(); |
src/Cache.zig+2-2| ... | @@ -549,7 +549,7 @@ pub const Manifest = struct { | ... | @@ -549,7 +549,7 @@ pub const Manifest = struct { |
| 549 | .target, .target_must_resolve, .prereq => {}, | 549 | .target, .target_must_resolve, .prereq => {}, |
| 550 | else => |err| { | 550 | else => |err| { |
| 551 | try err.printError(error_buf.writer()); | 551 | 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 }); |
| 553 | return error.InvalidDepFile; | 553 | return error.InvalidDepFile; |
| 554 | }, | 554 | }, |
| 555 | } | 555 | } |
| ... | @@ -561,7 +561,7 @@ pub const Manifest = struct { | ... | @@ -561,7 +561,7 @@ pub const Manifest = struct { |
| 561 | .prereq => |bytes| try self.addFilePost(bytes), | 561 | .prereq => |bytes| try self.addFilePost(bytes), |
| 562 | else => |err| { | 562 | else => |err| { |
| 563 | try err.printError(error_buf.writer()); | 563 | 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 }); |
| 565 | return error.InvalidDepFile; | 565 | return error.InvalidDepFile; |
| 566 | }, | 566 | }, |
| 567 | } | 567 | } |
src/Compilation.zig+52-52| ... | @@ -1475,7 +1475,7 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor | ... | @@ -1475,7 +1475,7 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor |
| 1475 | // lifetime annotations in the ZIR. | 1475 | // lifetime annotations in the ZIR. |
| 1476 | var decl_arena = decl.typed_value.most_recent.arena.?.promote(module.gpa); | 1476 | var decl_arena = decl.typed_value.most_recent.arena.?.promote(module.gpa); |
| 1477 | defer decl.typed_value.most_recent.arena.?.* = decl_arena.state; | 1477 | 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}); |
| 1479 | try liveness.analyze(module.gpa, &decl_arena.allocator, func.analysis.success); | 1479 | try liveness.analyze(module.gpa, &decl_arena.allocator, func.analysis.success); |
| 1480 | } | 1480 | } |
| 1481 | 1481 | ||
| ... | @@ -1492,7 +1492,7 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor | ... | @@ -1492,7 +1492,7 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor |
| 1492 | module.failed_decls.putAssumeCapacityNoClobber(decl, try ErrorMsg.create( | 1492 | module.failed_decls.putAssumeCapacityNoClobber(decl, try ErrorMsg.create( |
| 1493 | module.gpa, | 1493 | module.gpa, |
| 1494 | decl.src(), | 1494 | decl.src(), |
| 1495 | "unable to codegen: {}", | 1495 | "unable to codegen: {s}", |
| 1496 | .{@errorName(err)}, | 1496 | .{@errorName(err)}, |
| 1497 | )); | 1497 | )); |
| 1498 | decl.analysis = .codegen_failure_retryable; | 1498 | decl.analysis = .codegen_failure_retryable; |
| ... | @@ -1512,7 +1512,7 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor | ... | @@ -1512,7 +1512,7 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor |
| 1512 | module.failed_decls.putAssumeCapacityNoClobber(decl, try ErrorMsg.create( | 1512 | module.failed_decls.putAssumeCapacityNoClobber(decl, try ErrorMsg.create( |
| 1513 | module.gpa, | 1513 | module.gpa, |
| 1514 | decl.src(), | 1514 | decl.src(), |
| 1515 | "unable to generate C header: {}", | 1515 | "unable to generate C header: {s}", |
| 1516 | .{@errorName(err)}, | 1516 | .{@errorName(err)}, |
| 1517 | )); | 1517 | )); |
| 1518 | decl.analysis = .codegen_failure_retryable; | 1518 | decl.analysis = .codegen_failure_retryable; |
| ... | @@ -1535,7 +1535,7 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor | ... | @@ -1535,7 +1535,7 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor |
| 1535 | module.failed_decls.putAssumeCapacityNoClobber(decl, try ErrorMsg.create( | 1535 | module.failed_decls.putAssumeCapacityNoClobber(decl, try ErrorMsg.create( |
| 1536 | module.gpa, | 1536 | module.gpa, |
| 1537 | decl.src(), | 1537 | decl.src(), |
| 1538 | "unable to update line number: {}", | 1538 | "unable to update line number: {s}", |
| 1539 | .{@errorName(err)}, | 1539 | .{@errorName(err)}, |
| 1540 | )); | 1540 | )); |
| 1541 | decl.analysis = .codegen_failure_retryable; | 1541 | decl.analysis = .codegen_failure_retryable; |
| ... | @@ -1544,56 +1544,56 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor | ... | @@ -1544,56 +1544,56 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor |
| 1544 | .glibc_crt_file => |crt_file| { | 1544 | .glibc_crt_file => |crt_file| { |
| 1545 | glibc.buildCRTFile(self, crt_file) catch |err| { | 1545 | glibc.buildCRTFile(self, crt_file) catch |err| { |
| 1546 | // TODO Expose this as a normal compile error rather than crashing here. | 1546 | // 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)}); |
| 1548 | }; | 1548 | }; |
| 1549 | }, | 1549 | }, |
| 1550 | .glibc_shared_objects => { | 1550 | .glibc_shared_objects => { |
| 1551 | glibc.buildSharedObjects(self) catch |err| { | 1551 | glibc.buildSharedObjects(self) catch |err| { |
| 1552 | // TODO Expose this as a normal compile error rather than crashing here. | 1552 | // 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)}); |
| 1554 | }; | 1554 | }; |
| 1555 | }, | 1555 | }, |
| 1556 | .musl_crt_file => |crt_file| { | 1556 | .musl_crt_file => |crt_file| { |
| 1557 | musl.buildCRTFile(self, crt_file) catch |err| { | 1557 | musl.buildCRTFile(self, crt_file) catch |err| { |
| 1558 | // TODO Expose this as a normal compile error rather than crashing here. | 1558 | // 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)}); |
| 1560 | }; | 1560 | }; |
| 1561 | }, | 1561 | }, |
| 1562 | .mingw_crt_file => |crt_file| { | 1562 | .mingw_crt_file => |crt_file| { |
| 1563 | mingw.buildCRTFile(self, crt_file) catch |err| { | 1563 | mingw.buildCRTFile(self, crt_file) catch |err| { |
| 1564 | // TODO Expose this as a normal compile error rather than crashing here. | 1564 | // 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)}); |
| 1566 | }; | 1566 | }; |
| 1567 | }, | 1567 | }, |
| 1568 | .windows_import_lib => |index| { | 1568 | .windows_import_lib => |index| { |
| 1569 | const link_lib = self.bin_file.options.system_libs.items()[index].key; | 1569 | const link_lib = self.bin_file.options.system_libs.items()[index].key; |
| 1570 | mingw.buildImportLib(self, link_lib) catch |err| { | 1570 | mingw.buildImportLib(self, link_lib) catch |err| { |
| 1571 | // TODO Expose this as a normal compile error rather than crashing here. | 1571 | // 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)}); |
| 1573 | }; | 1573 | }; |
| 1574 | }, | 1574 | }, |
| 1575 | .libunwind => { | 1575 | .libunwind => { |
| 1576 | libunwind.buildStaticLib(self) catch |err| { | 1576 | libunwind.buildStaticLib(self) catch |err| { |
| 1577 | // TODO Expose this as a normal compile error rather than crashing here. | 1577 | // 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)}); |
| 1579 | }; | 1579 | }; |
| 1580 | }, | 1580 | }, |
| 1581 | .libcxx => { | 1581 | .libcxx => { |
| 1582 | libcxx.buildLibCXX(self) catch |err| { | 1582 | libcxx.buildLibCXX(self) catch |err| { |
| 1583 | // TODO Expose this as a normal compile error rather than crashing here. | 1583 | // 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)}); |
| 1585 | }; | 1585 | }; |
| 1586 | }, | 1586 | }, |
| 1587 | .libcxxabi => { | 1587 | .libcxxabi => { |
| 1588 | libcxx.buildLibCXXABI(self) catch |err| { | 1588 | libcxx.buildLibCXXABI(self) catch |err| { |
| 1589 | // TODO Expose this as a normal compile error rather than crashing here. | 1589 | // 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)}); |
| 1591 | }; | 1591 | }; |
| 1592 | }, | 1592 | }, |
| 1593 | .libtsan => { | 1593 | .libtsan => { |
| 1594 | libtsan.buildTsan(self) catch |err| { | 1594 | libtsan.buildTsan(self) catch |err| { |
| 1595 | // TODO Expose this as a normal compile error rather than crashing here. | 1595 | // 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)}); |
| 1597 | }; | 1597 | }; |
| 1598 | }, | 1598 | }, |
| 1599 | .compiler_rt_lib => { | 1599 | .compiler_rt_lib => { |
| ... | @@ -1611,20 +1611,20 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor | ... | @@ -1611,20 +1611,20 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor |
| 1611 | .libssp => { | 1611 | .libssp => { |
| 1612 | self.buildOutputFromZig("ssp.zig", .Lib, &self.libssp_static_lib) catch |err| { | 1612 | self.buildOutputFromZig("ssp.zig", .Lib, &self.libssp_static_lib) catch |err| { |
| 1613 | // TODO Expose this as a normal compile error rather than crashing here. | 1613 | // 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)}); |
| 1615 | }; | 1615 | }; |
| 1616 | }, | 1616 | }, |
| 1617 | .zig_libc => { | 1617 | .zig_libc => { |
| 1618 | self.buildOutputFromZig("c.zig", .Lib, &self.libc_static_lib) catch |err| { | 1618 | self.buildOutputFromZig("c.zig", .Lib, &self.libc_static_lib) catch |err| { |
| 1619 | // TODO Expose this as a normal compile error rather than crashing here. | 1619 | // 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)}); |
| 1621 | }; | 1621 | }; |
| 1622 | }, | 1622 | }, |
| 1623 | .generate_builtin_zig => { | 1623 | .generate_builtin_zig => { |
| 1624 | // This Job is only queued up if there is a zig module. | 1624 | // This Job is only queued up if there is a zig module. |
| 1625 | self.updateBuiltinZigFile(self.bin_file.options.module.?) catch |err| { | 1625 | self.updateBuiltinZigFile(self.bin_file.options.module.?) catch |err| { |
| 1626 | // TODO Expose this as a normal compile error rather than crashing here. | 1626 | // 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)}); |
| 1628 | }; | 1628 | }; |
| 1629 | }, | 1629 | }, |
| 1630 | .stage1_module => { | 1630 | .stage1_module => { |
| ... | @@ -1704,11 +1704,11 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult { | ... | @@ -1704,11 +1704,11 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult { |
| 1704 | const out_h_path = try comp.local_cache_directory.join(arena, &[_][]const u8{ | 1704 | const out_h_path = try comp.local_cache_directory.join(arena, &[_][]const u8{ |
| 1705 | tmp_dir_sub_path, cimport_basename, | 1705 | tmp_dir_sub_path, cimport_basename, |
| 1706 | }); | 1706 | }); |
| 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}); |
| 1708 | 1708 | ||
| 1709 | try zig_cache_tmp_dir.writeFile(cimport_basename, c_src); | 1709 | try zig_cache_tmp_dir.writeFile(cimport_basename, c_src); |
| 1710 | if (comp.verbose_cimport) { | 1710 | if (comp.verbose_cimport) { |
| 1711 | log.info("C import source: {}", .{out_h_path}); | 1711 | log.info("C import source: {s}", .{out_h_path}); |
| 1712 | } | 1712 | } |
| 1713 | 1713 | ||
| 1714 | var argv = std.ArrayList([]const u8).init(comp.gpa); | 1714 | var argv = std.ArrayList([]const u8).init(comp.gpa); |
| ... | @@ -1755,7 +1755,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult { | ... | @@ -1755,7 +1755,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult { |
| 1755 | defer tree.deinit(); | 1755 | defer tree.deinit(); |
| 1756 | 1756 | ||
| 1757 | if (comp.verbose_cimport) { | 1757 | 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}); |
| 1759 | } | 1759 | } |
| 1760 | 1760 | ||
| 1761 | const dep_basename = std.fs.path.basename(out_dep_path); | 1761 | const dep_basename = std.fs.path.basename(out_dep_path); |
| ... | @@ -1775,7 +1775,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult { | ... | @@ -1775,7 +1775,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult { |
| 1775 | try bos.flush(); | 1775 | try bos.flush(); |
| 1776 | 1776 | ||
| 1777 | man.writeManifest() catch |err| { | 1777 | 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)}); |
| 1779 | }; | 1779 | }; |
| 1780 | 1780 | ||
| 1781 | break :digest digest; | 1781 | break :digest digest; |
| ... | @@ -1785,7 +1785,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult { | ... | @@ -1785,7 +1785,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult { |
| 1785 | "o", &digest, cimport_zig_basename, | 1785 | "o", &digest, cimport_zig_basename, |
| 1786 | }); | 1786 | }); |
| 1787 | if (comp.verbose_cimport) { | 1787 | 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}); |
| 1789 | } | 1789 | } |
| 1790 | return CImportResult{ | 1790 | return CImportResult{ |
| 1791 | .out_zig_path = out_zig_path, | 1791 | .out_zig_path = out_zig_path, |
| ... | @@ -1946,7 +1946,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_comp_progress_node: * | ... | @@ -1946,7 +1946,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_comp_progress_node: * |
| 1946 | child.stderr_behavior = .Inherit; | 1946 | child.stderr_behavior = .Inherit; |
| 1947 | 1947 | ||
| 1948 | const term = child.spawnAndWait() catch |err| { | 1948 | 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) }); |
| 1950 | }; | 1950 | }; |
| 1951 | switch (term) { | 1951 | switch (term) { |
| 1952 | .Exited => |code| { | 1952 | .Exited => |code| { |
| ... | @@ -1974,7 +1974,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_comp_progress_node: * | ... | @@ -1974,7 +1974,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_comp_progress_node: * |
| 1974 | const stderr = try stderr_reader.readAllAlloc(arena, 10 * 1024 * 1024); | 1974 | const stderr = try stderr_reader.readAllAlloc(arena, 10 * 1024 * 1024); |
| 1975 | 1975 | ||
| 1976 | const term = child.wait() catch |err| { | 1976 | 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) }); |
| 1978 | }; | 1978 | }; |
| 1979 | 1979 | ||
| 1980 | switch (term) { | 1980 | switch (term) { |
| ... | @@ -1982,12 +1982,12 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_comp_progress_node: * | ... | @@ -1982,12 +1982,12 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_comp_progress_node: * |
| 1982 | if (code != 0) { | 1982 | if (code != 0) { |
| 1983 | // TODO parse clang stderr and turn it into an error message | 1983 | // TODO parse clang stderr and turn it into an error message |
| 1984 | // and then call failCObjWithOwnedErrorMsg | 1984 | // and then call failCObjWithOwnedErrorMsg |
| 1985 | log.err("clang failed with stderr: {}", .{stderr}); | 1985 | log.err("clang failed with stderr: {s}", .{stderr}); |
| 1986 | return comp.failCObj(c_object, "clang exited with code {}", .{code}); | 1986 | return comp.failCObj(c_object, "clang exited with code {d}", .{code}); |
| 1987 | } | 1987 | } |
| 1988 | }, | 1988 | }, |
| 1989 | else => { | 1989 | else => { |
| 1990 | log.err("clang terminated with stderr: {}", .{stderr}); | 1990 | log.err("clang terminated with stderr: {s}", .{stderr}); |
| 1991 | return comp.failCObj(c_object, "clang terminated unexpectedly", .{}); | 1991 | return comp.failCObj(c_object, "clang terminated unexpectedly", .{}); |
| 1992 | }, | 1992 | }, |
| 1993 | } | 1993 | } |
| ... | @@ -1999,7 +1999,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_comp_progress_node: * | ... | @@ -1999,7 +1999,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_comp_progress_node: * |
| 1999 | try man.addDepFilePost(zig_cache_tmp_dir, dep_basename); | 1999 | try man.addDepFilePost(zig_cache_tmp_dir, dep_basename); |
| 2000 | // Just to save disk space, we delete the file because it is never needed again. | 2000 | // Just to save disk space, we delete the file because it is never needed again. |
| 2001 | zig_cache_tmp_dir.deleteFile(dep_basename) catch |err| { | 2001 | 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) }); |
| 2003 | }; | 2003 | }; |
| 2004 | } | 2004 | } |
| 2005 | 2005 | ||
| ... | @@ -2015,7 +2015,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_comp_progress_node: * | ... | @@ -2015,7 +2015,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_comp_progress_node: * |
| 2015 | try std.fs.rename(zig_cache_tmp_dir, tmp_basename, o_dir, o_basename); | 2015 | try std.fs.rename(zig_cache_tmp_dir, tmp_basename, o_dir, o_basename); |
| 2016 | 2016 | ||
| 2017 | man.writeManifest() catch |err| { | 2017 | 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) }); |
| 2019 | }; | 2019 | }; |
| 2020 | break :blk digest; | 2020 | break :blk digest; |
| 2021 | }; | 2021 | }; |
| ... | @@ -2034,7 +2034,7 @@ pub fn tmpFilePath(comp: *Compilation, arena: *Allocator, suffix: []const u8) er | ... | @@ -2034,7 +2034,7 @@ pub fn tmpFilePath(comp: *Compilation, arena: *Allocator, suffix: []const u8) er |
| 2034 | const s = std.fs.path.sep_str; | 2034 | const s = std.fs.path.sep_str; |
| 2035 | const rand_int = std.crypto.random.int(u64); | 2035 | const rand_int = std.crypto.random.int(u64); |
| 2036 | if (comp.local_cache_directory.path) |p| { | 2036 | 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 }); |
| 2038 | } else { | 2038 | } else { |
| 2039 | return std.fmt.allocPrint(arena, "tmp" ++ s ++ "{x}-{s}", .{ rand_int, suffix }); | 2039 | return std.fmt.allocPrint(arena, "tmp" ++ s ++ "{x}-{s}", .{ rand_int, suffix }); |
| 2040 | } | 2040 | } |
| ... | @@ -2144,7 +2144,7 @@ pub fn addCCArgs( | ... | @@ -2144,7 +2144,7 @@ pub fn addCCArgs( |
| 2144 | } | 2144 | } |
| 2145 | const mcmodel = comp.bin_file.options.machine_code_model; | 2145 | const mcmodel = comp.bin_file.options.machine_code_model; |
| 2146 | if (mcmodel != .default) { | 2146 | 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)})); |
| 2148 | } | 2148 | } |
| 2149 | 2149 | ||
| 2150 | switch (target.os.tag) { | 2150 | switch (target.os.tag) { |
| ... | @@ -2497,22 +2497,22 @@ fn detectLibCIncludeDirs( | ... | @@ -2497,22 +2497,22 @@ fn detectLibCIncludeDirs( |
| 2497 | const s = std.fs.path.sep_str; | 2497 | const s = std.fs.path.sep_str; |
| 2498 | const arch_include_dir = try std.fmt.allocPrint( | 2498 | const arch_include_dir = try std.fmt.allocPrint( |
| 2499 | arena, | 2499 | arena, |
| 2500 | "{}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{}-{}-{}", | 2500 | "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{s}-{s}-{s}", |
| 2501 | .{ zig_lib_dir, arch_name, os_name, abi_name }, | 2501 | .{ zig_lib_dir, arch_name, os_name, abi_name }, |
| 2502 | ); | 2502 | ); |
| 2503 | const generic_include_dir = try std.fmt.allocPrint( | 2503 | const generic_include_dir = try std.fmt.allocPrint( |
| 2504 | arena, | 2504 | arena, |
| 2505 | "{}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "generic-{}", | 2505 | "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "generic-{s}", |
| 2506 | .{ zig_lib_dir, generic_name }, | 2506 | .{ zig_lib_dir, generic_name }, |
| 2507 | ); | 2507 | ); |
| 2508 | const arch_os_include_dir = try std.fmt.allocPrint( | 2508 | const arch_os_include_dir = try std.fmt.allocPrint( |
| 2509 | arena, | 2509 | arena, |
| 2510 | "{}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{}-{}-any", | 2510 | "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{s}-{s}-any", |
| 2511 | .{ zig_lib_dir, @tagName(target.cpu.arch), os_name }, | 2511 | .{ zig_lib_dir, @tagName(target.cpu.arch), os_name }, |
| 2512 | ); | 2512 | ); |
| 2513 | const generic_os_include_dir = try std.fmt.allocPrint( | 2513 | const generic_os_include_dir = try std.fmt.allocPrint( |
| 2514 | arena, | 2514 | arena, |
| 2515 | "{}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "any-{}-any", | 2515 | "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "any-{s}-any", |
| 2516 | .{ zig_lib_dir, os_name }, | 2516 | .{ zig_lib_dir, os_name }, |
| 2517 | ); | 2517 | ); |
| 2518 | 2518 | ||
| ... | @@ -2631,9 +2631,9 @@ fn updateBuiltinZigFile(comp: *Compilation, mod: *Module) !void { | ... | @@ -2631,9 +2631,9 @@ fn updateBuiltinZigFile(comp: *Compilation, mod: *Module) !void { |
| 2631 | 2631 | ||
| 2632 | pub fn dump_argv(argv: []const []const u8) void { | 2632 | pub fn dump_argv(argv: []const []const u8) void { |
| 2633 | for (argv[0 .. argv.len - 1]) |arg| { | 2633 | for (argv[0 .. argv.len - 1]) |arg| { |
| 2634 | std.debug.print("{} ", .{arg}); | 2634 | std.debug.print("{s} ", .{arg}); |
| 2635 | } | 2635 | } |
| 2636 | std.debug.print("{}\n", .{argv[argv.len - 1]}); | 2636 | std.debug.print("{s}\n", .{argv[argv.len - 1]}); |
| 2637 | } | 2637 | } |
| 2638 | 2638 | ||
| 2639 | pub fn generateBuiltinZigSource(comp: *Compilation, allocator: *Allocator) ![]u8 { | 2639 | pub fn generateBuiltinZigSource(comp: *Compilation, allocator: *Allocator) ![]u8 { |
| ... | @@ -2653,15 +2653,15 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: *Allocator) ![]u8 | ... | @@ -2653,15 +2653,15 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: *Allocator) ![]u8 |
| 2653 | \\pub const arch = Target.current.cpu.arch; | 2653 | \\pub const arch = Target.current.cpu.arch; |
| 2654 | \\/// Deprecated | 2654 | \\/// Deprecated |
| 2655 | \\pub const endian = Target.current.cpu.arch.endian(); | 2655 | \\pub const endian = Target.current.cpu.arch.endian(); |
| 2656 | \\pub const output_mode = OutputMode.{}; | 2656 | \\pub const output_mode = OutputMode.{z}; |
| 2657 | \\pub const link_mode = LinkMode.{}; | 2657 | \\pub const link_mode = LinkMode.{z}; |
| 2658 | \\pub const is_test = {}; | 2658 | \\pub const is_test = {}; |
| 2659 | \\pub const single_threaded = {}; | 2659 | \\pub const single_threaded = {}; |
| 2660 | \\pub const abi = Abi.{}; | 2660 | \\pub const abi = Abi.{z}; |
| 2661 | \\pub const cpu: Cpu = Cpu{{ | 2661 | \\pub const cpu: Cpu = Cpu{{ |
| 2662 | \\ .arch = .{}, | 2662 | \\ .arch = .{z}, |
| 2663 | \\ .model = &Target.{}.cpu.{}, | 2663 | \\ .model = &Target.{z}.cpu.{z}, |
| 2664 | \\ .features = Target.{}.featureSet(&[_]Target.{}.Feature{{ | 2664 | \\ .features = Target.{z}.featureSet(&[_]Target.{z}.Feature{{ |
| 2665 | \\ | 2665 | \\ |
| 2666 | , .{ | 2666 | , .{ |
| 2667 | @tagName(comp.bin_file.options.output_mode), | 2667 | @tagName(comp.bin_file.options.output_mode), |
| ... | @@ -2692,7 +2692,7 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: *Allocator) ![]u8 | ... | @@ -2692,7 +2692,7 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: *Allocator) ![]u8 |
| 2692 | \\ }}), | 2692 | \\ }}), |
| 2693 | \\}}; | 2693 | \\}}; |
| 2694 | \\pub const os = Os{{ | 2694 | \\pub const os = Os{{ |
| 2695 | \\ .tag = .{}, | 2695 | \\ .tag = .{z}, |
| 2696 | \\ .version_range = .{{ | 2696 | \\ .version_range = .{{ |
| 2697 | , | 2697 | , |
| 2698 | .{@tagName(target.os.tag)}, | 2698 | .{@tagName(target.os.tag)}, |
| ... | @@ -2778,8 +2778,8 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: *Allocator) ![]u8 | ... | @@ -2778,8 +2778,8 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: *Allocator) ![]u8 |
| 2778 | (comp.bin_file.options.skip_linker_dependencies and comp.bin_file.options.parent_compilation_link_libc); | 2778 | (comp.bin_file.options.skip_linker_dependencies and comp.bin_file.options.parent_compilation_link_libc); |
| 2779 | 2779 | ||
| 2780 | try buffer.writer().print( | 2780 | try buffer.writer().print( |
| 2781 | \\pub const object_format = ObjectFormat.{}; | 2781 | \\pub const object_format = ObjectFormat.{z}; |
| 2782 | \\pub const mode = Mode.{}; | 2782 | \\pub const mode = Mode.{z}; |
| 2783 | \\pub const link_libc = {}; | 2783 | \\pub const link_libc = {}; |
| 2784 | \\pub const link_libcpp = {}; | 2784 | \\pub const link_libcpp = {}; |
| 2785 | \\pub const have_error_return_tracing = {}; | 2785 | \\pub const have_error_return_tracing = {}; |
| ... | @@ -2787,7 +2787,7 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: *Allocator) ![]u8 | ... | @@ -2787,7 +2787,7 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: *Allocator) ![]u8 |
| 2787 | \\pub const position_independent_code = {}; | 2787 | \\pub const position_independent_code = {}; |
| 2788 | \\pub const position_independent_executable = {}; | 2788 | \\pub const position_independent_executable = {}; |
| 2789 | \\pub const strip_debug_info = {}; | 2789 | \\pub const strip_debug_info = {}; |
| 2790 | \\pub const code_model = CodeModel.{}; | 2790 | \\pub const code_model = CodeModel.{z}; |
| 2791 | \\ | 2791 | \\ |
| 2792 | , .{ | 2792 | , .{ |
| 2793 | @tagName(comp.bin_file.options.object_format), | 2793 | @tagName(comp.bin_file.options.object_format), |
| ... | @@ -3013,7 +3013,7 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node | ... | @@ -3013,7 +3013,7 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node |
| 3013 | id_symlink_basename, | 3013 | id_symlink_basename, |
| 3014 | &prev_digest_buf, | 3014 | &prev_digest_buf, |
| 3015 | ) catch |err| blk: { | 3015 | ) 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) }); |
| 3017 | // Handle this as a cache miss. | 3017 | // Handle this as a cache miss. |
| 3018 | break :blk prev_digest_buf[0..0]; | 3018 | break :blk prev_digest_buf[0..0]; |
| 3019 | }; | 3019 | }; |
| ... | @@ -3021,7 +3021,7 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node | ... | @@ -3021,7 +3021,7 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node |
| 3021 | if (!mem.eql(u8, prev_digest[0..digest.len], &digest)) | 3021 | if (!mem.eql(u8, prev_digest[0..digest.len], &digest)) |
| 3022 | break :hit; | 3022 | break :hit; |
| 3023 | 3023 | ||
| 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 }); |
| 3025 | var flags_bytes: [1]u8 = undefined; | 3025 | var flags_bytes: [1]u8 = undefined; |
| 3026 | _ = std.fmt.hexToBytes(&flags_bytes, prev_digest[digest.len..]) catch { | 3026 | _ = std.fmt.hexToBytes(&flags_bytes, prev_digest[digest.len..]) catch { |
| 3027 | log.warn("bad cache stage1 digest: '{s}'", .{prev_digest}); | 3027 | log.warn("bad cache stage1 digest: '{s}'", .{prev_digest}); |
| ... | @@ -3044,7 +3044,7 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node | ... | @@ -3044,7 +3044,7 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node |
| 3044 | mod.stage1_flags = @bitCast(@TypeOf(mod.stage1_flags), flags_bytes[0]); | 3044 | mod.stage1_flags = @bitCast(@TypeOf(mod.stage1_flags), flags_bytes[0]); |
| 3045 | return; | 3045 | return; |
| 3046 | } | 3046 | } |
| 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 }); |
| 3048 | man.unhit(prev_hash_state, input_file_count); | 3048 | man.unhit(prev_hash_state, input_file_count); |
| 3049 | } | 3049 | } |
| 3050 | 3050 | ||
| ... | @@ -3189,7 +3189,7 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node | ... | @@ -3189,7 +3189,7 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node |
| 3189 | // Update the small file with the digest. If it fails we can continue; it only | 3189 | // Update the small file with the digest. If it fails we can continue; it only |
| 3190 | // means that the next invocation will have an unnecessary cache miss. | 3190 | // means that the next invocation will have an unnecessary cache miss. |
| 3191 | const stage1_flags_byte = @bitCast(u8, mod.stage1_flags); | 3191 | 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}", .{ |
| 3193 | mod.root_pkg.root_src_path, digest, stage1_flags_byte, | 3193 | mod.root_pkg.root_src_path, digest, stage1_flags_byte, |
| 3194 | }); | 3194 | }); |
| 3195 | var digest_plus_flags: [digest.len + 2]u8 = undefined; | 3195 | var digest_plus_flags: [digest.len + 2]u8 = undefined; |
| ... | @@ -3202,11 +3202,11 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node | ... | @@ -3202,11 +3202,11 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node |
| 3202 | digest_plus_flags, stage1_flags_byte, mod.stage1_flags.have_winmain_crt_startup, | 3202 | digest_plus_flags, stage1_flags_byte, mod.stage1_flags.have_winmain_crt_startup, |
| 3203 | }); | 3203 | }); |
| 3204 | Cache.writeSmallFile(directory.handle, id_symlink_basename, &digest_plus_flags) catch |err| { | 3204 | 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)}); |
| 3206 | }; | 3206 | }; |
| 3207 | // Failure here only means an unnecessary cache miss. | 3207 | // Failure here only means an unnecessary cache miss. |
| 3208 | man.writeManifest() catch |err| { | 3208 | 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)}); |
| 3210 | }; | 3210 | }; |
| 3211 | // We hang on to this lock so that the output file path can be used without | 3211 | // We hang on to this lock so that the output file path can be used without |
| 3212 | // other processes clobbering it. | 3212 | // other processes clobbering it. |
src/DepTokenizer.zig+4-4| ... | @@ -366,14 +366,14 @@ pub const Token = union(enum) { | ... | @@ -366,14 +366,14 @@ pub const Token = union(enum) { |
| 366 | .incomplete_quoted_prerequisite, | 366 | .incomplete_quoted_prerequisite, |
| 367 | .incomplete_target, | 367 | .incomplete_target, |
| 368 | => |index_and_bytes| { | 368 | => |index_and_bytes| { |
| 369 | try writer.print("{} '", .{self.errStr()}); | 369 | try writer.print("{s} '", .{self.errStr()}); |
| 370 | if (self == .incomplete_target) { | 370 | if (self == .incomplete_target) { |
| 371 | const tmp = Token{ .target_must_resolve = index_and_bytes.bytes }; | 371 | const tmp = Token{ .target_must_resolve = index_and_bytes.bytes }; |
| 372 | try tmp.resolve(writer); | 372 | try tmp.resolve(writer); |
| 373 | } else { | 373 | } else { |
| 374 | try printCharValues(writer, index_and_bytes.bytes); | 374 | try printCharValues(writer, index_and_bytes.bytes); |
| 375 | } | 375 | } |
| 376 | try writer.print("' at position {}", .{index_and_bytes.index}); | 376 | try writer.print("' at position {d}", .{index_and_bytes.index}); |
| 377 | }, | 377 | }, |
| 378 | .invalid_target, | 378 | .invalid_target, |
| 379 | .bad_target_escape, | 379 | .bad_target_escape, |
| ... | @@ -383,7 +383,7 @@ pub const Token = union(enum) { | ... | @@ -383,7 +383,7 @@ pub const Token = union(enum) { |
| 383 | => |index_and_char| { | 383 | => |index_and_char| { |
| 384 | try writer.writeAll("illegal char "); | 384 | try writer.writeAll("illegal char "); |
| 385 | try printUnderstandableChar(writer, index_and_char.char); | 385 | 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() }); |
| 387 | }, | 387 | }, |
| 388 | } | 388 | } |
| 389 | } | 389 | } |
| ... | @@ -943,7 +943,7 @@ fn printSection(out: anytype, label: []const u8, bytes: []const u8) !void { | ... | @@ -943,7 +943,7 @@ fn printSection(out: anytype, label: []const u8, bytes: []const u8) !void { |
| 943 | 943 | ||
| 944 | fn printLabel(out: anytype, label: []const u8, bytes: []const u8) !void { | 944 | fn printLabel(out: anytype, label: []const u8, bytes: []const u8) !void { |
| 945 | var buf: [80]u8 = undefined; | 945 | 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 }); |
| 947 | try out.writeAll(text); | 947 | try out.writeAll(text); |
| 948 | var i: usize = text.len; | 948 | var i: usize = text.len; |
| 949 | const end = 79; | 949 | const end = 79; |
src/Module.zig+25-25| ... | @@ -248,7 +248,7 @@ pub const Decl = struct { | ... | @@ -248,7 +248,7 @@ pub const Decl = struct { |
| 248 | 248 | ||
| 249 | pub fn dump(self: *Decl) void { | 249 | pub fn dump(self: *Decl) void { |
| 250 | const loc = std.zig.findLineColumn(self.scope.source.bytes, self.src); | 250 | 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}", .{ |
| 252 | self.scope.sub_file_path, | 252 | self.scope.sub_file_path, |
| 253 | loc.line + 1, | 253 | loc.line + 1, |
| 254 | loc.column + 1, | 254 | loc.column + 1, |
| ... | @@ -308,7 +308,7 @@ pub const Fn = struct { | ... | @@ -308,7 +308,7 @@ pub const Fn = struct { |
| 308 | 308 | ||
| 309 | /// For debugging purposes. | 309 | /// For debugging purposes. |
| 310 | pub fn dump(self: *Fn, mod: Module) void { | 310 | 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}); |
| 312 | switch (self.analysis) { | 312 | switch (self.analysis) { |
| 313 | .queued => { | 313 | .queued => { |
| 314 | std.debug.print("queued\n", .{}); | 314 | std.debug.print("queued\n", .{}); |
| ... | @@ -632,7 +632,7 @@ pub const Scope = struct { | ... | @@ -632,7 +632,7 @@ pub const Scope = struct { |
| 632 | 632 | ||
| 633 | pub fn dumpSrc(self: *File, src: usize) void { | 633 | pub fn dumpSrc(self: *File, src: usize) void { |
| 634 | const loc = std.zig.findLineColumn(self.source.bytes, src); | 634 | 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 }); |
| 636 | } | 636 | } |
| 637 | 637 | ||
| 638 | pub fn getSource(self: *File, module: *Module) ![:0]const u8 { | 638 | pub fn getSource(self: *File, module: *Module) ![:0]const u8 { |
| ... | @@ -730,7 +730,7 @@ pub const Scope = struct { | ... | @@ -730,7 +730,7 @@ pub const Scope = struct { |
| 730 | 730 | ||
| 731 | pub fn dumpSrc(self: *ZIRModule, src: usize) void { | 731 | pub fn dumpSrc(self: *ZIRModule, src: usize) void { |
| 732 | const loc = std.zig.findLineColumn(self.source.bytes, src); | 732 | 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 }); |
| 734 | } | 734 | } |
| 735 | 735 | ||
| 736 | pub fn getSource(self: *ZIRModule, module: *Module) ![:0]const u8 { | 736 | pub fn getSource(self: *ZIRModule, module: *Module) ![:0]const u8 { |
| ... | @@ -918,7 +918,7 @@ pub fn ensureDeclAnalyzed(self: *Module, decl: *Decl) InnerError!void { | ... | @@ -918,7 +918,7 @@ pub fn ensureDeclAnalyzed(self: *Module, decl: *Decl) InnerError!void { |
| 918 | .complete => return, | 918 | .complete => return, |
| 919 | 919 | ||
| 920 | .outdated => blk: { | 920 | .outdated => blk: { |
| 921 | log.debug("re-analyzing {}\n", .{decl.name}); | 921 | log.debug("re-analyzing {s}\n", .{decl.name}); |
| 922 | 922 | ||
| 923 | // The exports this Decl performs will be re-discovered, so we remove them here | 923 | // The exports this Decl performs will be re-discovered, so we remove them here |
| 924 | // prior to re-analysis. | 924 | // prior to re-analysis. |
| ... | @@ -953,7 +953,7 @@ pub fn ensureDeclAnalyzed(self: *Module, decl: *Decl) InnerError!void { | ... | @@ -953,7 +953,7 @@ pub fn ensureDeclAnalyzed(self: *Module, decl: *Decl) InnerError!void { |
| 953 | self.failed_decls.putAssumeCapacityNoClobber(decl, try Compilation.ErrorMsg.create( | 953 | self.failed_decls.putAssumeCapacityNoClobber(decl, try Compilation.ErrorMsg.create( |
| 954 | self.gpa, | 954 | self.gpa, |
| 955 | decl.src(), | 955 | decl.src(), |
| 956 | "unable to analyze: {}", | 956 | "unable to analyze: {s}", |
| 957 | .{@errorName(err)}, | 957 | .{@errorName(err)}, |
| 958 | )); | 958 | )); |
| 959 | decl.analysis = .sema_failure_retryable; | 959 | decl.analysis = .sema_failure_retryable; |
| ... | @@ -1475,7 +1475,7 @@ fn getSrcModule(self: *Module, root_scope: *Scope.ZIRModule) !*zir.Module { | ... | @@ -1475,7 +1475,7 @@ fn getSrcModule(self: *Module, root_scope: *Scope.ZIRModule) !*zir.Module { |
| 1475 | if (zir_module.error_msg) |src_err_msg| { | 1475 | if (zir_module.error_msg) |src_err_msg| { |
| 1476 | self.failed_files.putAssumeCapacityNoClobber( | 1476 | self.failed_files.putAssumeCapacityNoClobber( |
| 1477 | &root_scope.base, | 1477 | &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}), |
| 1479 | ); | 1479 | ); |
| 1480 | root_scope.status = .unloaded_parse_failure; | 1480 | root_scope.status = .unloaded_parse_failure; |
| 1481 | return error.AnalysisFail; | 1481 | return error.AnalysisFail; |
| ... | @@ -1581,7 +1581,7 @@ pub fn analyzeContainer(self: *Module, container_scope: *Scope.Container) !void | ... | @@ -1581,7 +1581,7 @@ pub fn analyzeContainer(self: *Module, container_scope: *Scope.Container) !void |
| 1581 | decl.src_index = decl_i; | 1581 | decl.src_index = decl_i; |
| 1582 | if (deleted_decls.remove(decl) == null) { | 1582 | if (deleted_decls.remove(decl) == null) { |
| 1583 | decl.analysis = .sema_failure; | 1583 | 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}); |
| 1585 | errdefer err_msg.destroy(self.gpa); | 1585 | errdefer err_msg.destroy(self.gpa); |
| 1586 | try self.failed_decls.putNoClobber(self.gpa, decl, err_msg); | 1586 | try self.failed_decls.putNoClobber(self.gpa, decl, err_msg); |
| 1587 | } else { | 1587 | } else { |
| ... | @@ -1623,7 +1623,7 @@ pub fn analyzeContainer(self: *Module, container_scope: *Scope.Container) !void | ... | @@ -1623,7 +1623,7 @@ pub fn analyzeContainer(self: *Module, container_scope: *Scope.Container) !void |
| 1623 | decl.src_index = decl_i; | 1623 | decl.src_index = decl_i; |
| 1624 | if (deleted_decls.remove(decl) == null) { | 1624 | if (deleted_decls.remove(decl) == null) { |
| 1625 | decl.analysis = .sema_failure; | 1625 | 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}); |
| 1627 | errdefer err_msg.destroy(self.gpa); | 1627 | errdefer err_msg.destroy(self.gpa); |
| 1628 | try self.failed_decls.putNoClobber(self.gpa, decl, err_msg); | 1628 | try self.failed_decls.putNoClobber(self.gpa, decl, err_msg); |
| 1629 | } else if (!srcHashEql(decl.contents_hash, contents_hash)) { | 1629 | } else if (!srcHashEql(decl.contents_hash, contents_hash)) { |
| ... | @@ -1641,7 +1641,7 @@ pub fn analyzeContainer(self: *Module, container_scope: *Scope.Container) !void | ... | @@ -1641,7 +1641,7 @@ pub fn analyzeContainer(self: *Module, container_scope: *Scope.Container) !void |
| 1641 | } | 1641 | } |
| 1642 | } else if (src_decl.castTag(.Comptime)) |comptime_node| { | 1642 | } else if (src_decl.castTag(.Comptime)) |comptime_node| { |
| 1643 | const name_index = self.getNextAnonNameIndex(); | 1643 | 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}); |
| 1645 | defer self.gpa.free(name); | 1645 | defer self.gpa.free(name); |
| 1646 | 1646 | ||
| 1647 | const name_hash = container_scope.fullyQualifiedNameHash(name); | 1647 | const name_hash = container_scope.fullyQualifiedNameHash(name); |
| ... | @@ -1663,7 +1663,7 @@ pub fn analyzeContainer(self: *Module, container_scope: *Scope.Container) !void | ... | @@ -1663,7 +1663,7 @@ pub fn analyzeContainer(self: *Module, container_scope: *Scope.Container) !void |
| 1663 | // Handle explicitly deleted decls from the source code. Not to be confused | 1663 | // Handle explicitly deleted decls from the source code. Not to be confused |
| 1664 | // with when we delete decls because they are no longer referenced. | 1664 | // with when we delete decls because they are no longer referenced. |
| 1665 | for (deleted_decls.items()) |entry| { | 1665 | 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}); |
| 1667 | try self.deleteDecl(entry.key); | 1667 | try self.deleteDecl(entry.key); |
| 1668 | } | 1668 | } |
| 1669 | } | 1669 | } |
| ... | @@ -1716,7 +1716,7 @@ pub fn analyzeRootZIRModule(self: *Module, root_scope: *Scope.ZIRModule) !void { | ... | @@ -1716,7 +1716,7 @@ pub fn analyzeRootZIRModule(self: *Module, root_scope: *Scope.ZIRModule) !void { |
| 1716 | // Handle explicitly deleted decls from the source code. Not to be confused | 1716 | // Handle explicitly deleted decls from the source code. Not to be confused |
| 1717 | // with when we delete decls because they are no longer referenced. | 1717 | // with when we delete decls because they are no longer referenced. |
| 1718 | for (deleted_decls.items()) |entry| { | 1718 | 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}); |
| 1720 | try self.deleteDecl(entry.key); | 1720 | try self.deleteDecl(entry.key); |
| 1721 | } | 1721 | } |
| 1722 | } | 1722 | } |
| ... | @@ -1728,7 +1728,7 @@ pub fn deleteDecl(self: *Module, decl: *Decl) !void { | ... | @@ -1728,7 +1728,7 @@ pub fn deleteDecl(self: *Module, decl: *Decl) !void { |
| 1728 | // not be present in the set, and this does nothing. | 1728 | // not be present in the set, and this does nothing. |
| 1729 | decl.scope.removeDecl(decl); | 1729 | decl.scope.removeDecl(decl); |
| 1730 | 1730 | ||
| 1731 | log.debug("deleting decl '{}'\n", .{decl.name}); | 1731 | log.debug("deleting decl '{s}'\n", .{decl.name}); |
| 1732 | const name_hash = decl.fullyQualifiedNameHash(); | 1732 | const name_hash = decl.fullyQualifiedNameHash(); |
| 1733 | self.decl_table.removeAssertDiscard(name_hash); | 1733 | self.decl_table.removeAssertDiscard(name_hash); |
| 1734 | // Remove itself from its dependencies, because we are about to destroy the decl pointer. | 1734 | // 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 { | ... | @@ -1819,17 +1819,17 @@ pub fn analyzeFnBody(self: *Module, decl: *Decl, func: *Fn) !void { |
| 1819 | const fn_zir = func.analysis.queued; | 1819 | const fn_zir = func.analysis.queued; |
| 1820 | defer fn_zir.arena.promote(self.gpa).deinit(); | 1820 | defer fn_zir.arena.promote(self.gpa).deinit(); |
| 1821 | func.analysis = .{ .in_progress = {} }; | 1821 | 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}); |
| 1823 | 1823 | ||
| 1824 | try zir_sema.analyzeBody(self, &inner_block.base, fn_zir.body); | 1824 | try zir_sema.analyzeBody(self, &inner_block.base, fn_zir.body); |
| 1825 | 1825 | ||
| 1826 | const instructions = try arena.allocator.dupe(*Inst, inner_block.instructions.items); | 1826 | const instructions = try arena.allocator.dupe(*Inst, inner_block.instructions.items); |
| 1827 | func.analysis = .{ .success = .{ .instructions = instructions } }; | 1827 | func.analysis = .{ .success = .{ .instructions = instructions } }; |
| 1828 | log.debug("set {} to success\n", .{decl.name}); | 1828 | log.debug("set {s} to success\n", .{decl.name}); |
| 1829 | } | 1829 | } |
| 1830 | 1830 | ||
| 1831 | fn markOutdatedDecl(self: *Module, decl: *Decl) !void { | 1831 | fn markOutdatedDecl(self: *Module, decl: *Decl) !void { |
| 1832 | log.debug("mark {} outdated\n", .{decl.name}); | 1832 | log.debug("mark {s} outdated\n", .{decl.name}); |
| 1833 | try self.comp.work_queue.writeItem(.{ .analyze_decl = decl }); | 1833 | try self.comp.work_queue.writeItem(.{ .analyze_decl = decl }); |
| 1834 | if (self.failed_decls.remove(decl)) |entry| { | 1834 | if (self.failed_decls.remove(decl)) |entry| { |
| 1835 | entry.value.destroy(self.gpa); | 1835 | entry.value.destroy(self.gpa); |
| ... | @@ -1991,7 +1991,7 @@ pub fn analyzeExport( | ... | @@ -1991,7 +1991,7 @@ pub fn analyzeExport( |
| 1991 | self.failed_exports.putAssumeCapacityNoClobber(new_export, try Compilation.ErrorMsg.create( | 1991 | self.failed_exports.putAssumeCapacityNoClobber(new_export, try Compilation.ErrorMsg.create( |
| 1992 | self.gpa, | 1992 | self.gpa, |
| 1993 | src, | 1993 | src, |
| 1994 | "exported symbol collision: {}", | 1994 | "exported symbol collision: {s}", |
| 1995 | .{symbol_name}, | 1995 | .{symbol_name}, |
| 1996 | )); | 1996 | )); |
| 1997 | // TODO: add a note | 1997 | // TODO: add a note |
| ... | @@ -2007,7 +2007,7 @@ pub fn analyzeExport( | ... | @@ -2007,7 +2007,7 @@ pub fn analyzeExport( |
| 2007 | self.failed_exports.putAssumeCapacityNoClobber(new_export, try Compilation.ErrorMsg.create( | 2007 | self.failed_exports.putAssumeCapacityNoClobber(new_export, try Compilation.ErrorMsg.create( |
| 2008 | self.gpa, | 2008 | self.gpa, |
| 2009 | src, | 2009 | src, |
| 2010 | "unable to export: {}", | 2010 | "unable to export: {s}", |
| 2011 | .{@errorName(err)}, | 2011 | .{@errorName(err)}, |
| 2012 | )); | 2012 | )); |
| 2013 | new_export.status = .failed_retryable; | 2013 | new_export.status = .failed_retryable; |
| ... | @@ -2277,7 +2277,7 @@ pub fn createAnonymousDecl( | ... | @@ -2277,7 +2277,7 @@ pub fn createAnonymousDecl( |
| 2277 | ) !*Decl { | 2277 | ) !*Decl { |
| 2278 | const name_index = self.getNextAnonNameIndex(); | 2278 | const name_index = self.getNextAnonNameIndex(); |
| 2279 | const scope_decl = scope.decl().?; | 2279 | 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 }); |
| 2281 | defer self.gpa.free(name); | 2281 | defer self.gpa.free(name); |
| 2282 | const name_hash = scope.namespace().fullyQualifiedNameHash(name); | 2282 | const name_hash = scope.namespace().fullyQualifiedNameHash(name); |
| 2283 | const src_hash: std.zig.SrcHash = undefined; | 2283 | const src_hash: std.zig.SrcHash = undefined; |
| ... | @@ -2384,7 +2384,7 @@ pub fn analyzeDeref(self: *Module, scope: *Scope, src: usize, ptr: *Inst, ptr_sr | ... | @@ -2384,7 +2384,7 @@ pub fn analyzeDeref(self: *Module, scope: *Scope, src: usize, ptr: *Inst, ptr_sr |
| 2384 | 2384 | ||
| 2385 | pub fn analyzeDeclRefByName(self: *Module, scope: *Scope, src: usize, decl_name: []const u8) InnerError!*Inst { | 2385 | pub fn analyzeDeclRefByName(self: *Module, scope: *Scope, src: usize, decl_name: []const u8) InnerError!*Inst { |
| 2386 | const decl = self.lookupDeclName(scope, decl_name) orelse | 2386 | 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}); |
| 2388 | return self.analyzeDeclRef(scope, src, decl); | 2388 | return self.analyzeDeclRef(scope, src, decl); |
| 2389 | } | 2389 | } |
| 2390 | 2390 | ||
| ... | @@ -2555,7 +2555,7 @@ pub fn cmpNumeric( | ... | @@ -2555,7 +2555,7 @@ pub fn cmpNumeric( |
| 2555 | 2555 | ||
| 2556 | if (lhs_ty_tag == .Vector and rhs_ty_tag == .Vector) { | 2556 | if (lhs_ty_tag == .Vector and rhs_ty_tag == .Vector) { |
| 2557 | if (lhs.ty.arrayLen() != rhs.ty.arrayLen()) { | 2557 | 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}", .{ |
| 2559 | lhs.ty.arrayLen(), | 2559 | lhs.ty.arrayLen(), |
| 2560 | rhs.ty.arrayLen(), | 2560 | rhs.ty.arrayLen(), |
| 2561 | }); | 2561 | }); |
| ... | @@ -2700,7 +2700,7 @@ pub fn cmpNumeric( | ... | @@ -2700,7 +2700,7 @@ pub fn cmpNumeric( |
| 2700 | const dest_type = if (dest_float_type) |ft| ft else blk: { | 2700 | const dest_type = if (dest_float_type) |ft| ft else blk: { |
| 2701 | const max_bits = std.math.max(lhs_bits, rhs_bits); | 2701 | const max_bits = std.math.max(lhs_bits, rhs_bits); |
| 2702 | const casted_bits = std.math.cast(u16, max_bits) catch |err| switch (err) { | 2702 | 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}), |
| 2704 | }; | 2704 | }; |
| 2705 | break :blk try self.makeIntType(scope, dest_int_is_signed, casted_bits); | 2705 | break :blk try self.makeIntType(scope, dest_int_is_signed, casted_bits); |
| 2706 | }; | 2706 | }; |
| ... | @@ -3319,7 +3319,7 @@ pub fn dumpInst(self: *Module, scope: *Scope, inst: *Inst) void { | ... | @@ -3319,7 +3319,7 @@ pub fn dumpInst(self: *Module, scope: *Scope, inst: *Inst) void { |
| 3319 | const source = zir_module.getSource(self) catch @panic("dumpInst failed to get source"); | 3319 | const source = zir_module.getSource(self) catch @panic("dumpInst failed to get source"); |
| 3320 | const loc = std.zig.findLineColumn(source, inst.src); | 3320 | const loc = std.zig.findLineColumn(source, inst.src); |
| 3321 | if (inst.tag == .constant) { | 3321 | 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", .{ |
| 3323 | inst.ty, | 3323 | inst.ty, |
| 3324 | inst.castTag(.constant).?.val, | 3324 | inst.castTag(.constant).?.val, |
| 3325 | zir_module.subFilePath(), | 3325 | zir_module.subFilePath(), |
| ... | @@ -3327,7 +3327,7 @@ pub fn dumpInst(self: *Module, scope: *Scope, inst: *Inst) void { | ... | @@ -3327,7 +3327,7 @@ pub fn dumpInst(self: *Module, scope: *Scope, inst: *Inst) void { |
| 3327 | loc.column + 1, | 3327 | loc.column + 1, |
| 3328 | }); | 3328 | }); |
| 3329 | } else if (inst.deaths == 0) { | 3329 | } else if (inst.deaths == 0) { |
| 3330 | std.debug.print("{} ty={} src={}:{}:{}\n", .{ | 3330 | std.debug.print("{s} ty={} src={s}:{d}:{d}\n", .{ |
| 3331 | @tagName(inst.tag), | 3331 | @tagName(inst.tag), |
| 3332 | inst.ty, | 3332 | inst.ty, |
| 3333 | zir_module.subFilePath(), | 3333 | zir_module.subFilePath(), |
| ... | @@ -3335,7 +3335,7 @@ pub fn dumpInst(self: *Module, scope: *Scope, inst: *Inst) void { | ... | @@ -3335,7 +3335,7 @@ pub fn dumpInst(self: *Module, scope: *Scope, inst: *Inst) void { |
| 3335 | loc.column + 1, | 3335 | loc.column + 1, |
| 3336 | }); | 3336 | }); |
| 3337 | } else { | 3337 | } else { |
| 3338 | std.debug.print("{} ty={} deaths={b} src={}:{}:{}\n", .{ | 3338 | std.debug.print("{s} ty={} deaths={b} src={s}:{d}:{d}\n", .{ |
| 3339 | @tagName(inst.tag), | 3339 | @tagName(inst.tag), |
| 3340 | inst.ty, | 3340 | inst.ty, |
| 3341 | inst.deaths, | 3341 | inst.deaths, |
src/astgen.zig+9-9| ... | @@ -385,7 +385,7 @@ fn breakExpr(mod: *Module, parent_scope: *Scope, node: *ast.Node.ControlFlowExpr | ... | @@ -385,7 +385,7 @@ fn breakExpr(mod: *Module, parent_scope: *Scope, node: *ast.Node.ControlFlowExpr |
| 385 | .local_ptr => scope = scope.cast(Scope.LocalPtr).?.parent, | 385 | .local_ptr => scope = scope.cast(Scope.LocalPtr).?.parent, |
| 386 | else => if (node.getLabel()) |break_label| { | 386 | else => if (node.getLabel()) |break_label| { |
| 387 | const label_name = try identifierTokenString(mod, parent_scope, break_label); | 387 | 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}); |
| 389 | } else { | 389 | } else { |
| 390 | return mod.failTok(parent_scope, src, "break expression outside loop", .{}); | 390 | return mod.failTok(parent_scope, src, "break expression outside loop", .{}); |
| 391 | }, | 391 | }, |
| ... | @@ -427,7 +427,7 @@ fn continueExpr(mod: *Module, parent_scope: *Scope, node: *ast.Node.ControlFlowE | ... | @@ -427,7 +427,7 @@ fn continueExpr(mod: *Module, parent_scope: *Scope, node: *ast.Node.ControlFlowE |
| 427 | .local_ptr => scope = scope.cast(Scope.LocalPtr).?.parent, | 427 | .local_ptr => scope = scope.cast(Scope.LocalPtr).?.parent, |
| 428 | else => if (node.getLabel()) |break_label| { | 428 | else => if (node.getLabel()) |break_label| { |
| 429 | const label_name = try identifierTokenString(mod, parent_scope, break_label); | 429 | 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}); |
| 431 | } else { | 431 | } else { |
| 432 | return mod.failTok(parent_scope, src, "continue expression outside loop", .{}); | 432 | return mod.failTok(parent_scope, src, "continue expression outside loop", .{}); |
| 433 | }, | 433 | }, |
| ... | @@ -560,14 +560,14 @@ fn varDecl( | ... | @@ -560,14 +560,14 @@ fn varDecl( |
| 560 | .local_val => { | 560 | .local_val => { |
| 561 | const local_val = s.cast(Scope.LocalVal).?; | 561 | const local_val = s.cast(Scope.LocalVal).?; |
| 562 | if (mem.eql(u8, local_val.name, ident_name)) { | 562 | 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}); |
| 564 | } | 564 | } |
| 565 | s = local_val.parent; | 565 | s = local_val.parent; |
| 566 | }, | 566 | }, |
| 567 | .local_ptr => { | 567 | .local_ptr => { |
| 568 | const local_ptr = s.cast(Scope.LocalPtr).?; | 568 | const local_ptr = s.cast(Scope.LocalPtr).?; |
| 569 | if (mem.eql(u8, local_ptr.name, ident_name)) { | 569 | 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}); |
| 571 | } | 571 | } |
| 572 | s = local_ptr.parent; | 572 | s = local_ptr.parent; |
| 573 | }, | 573 | }, |
| ... | @@ -578,7 +578,7 @@ fn varDecl( | ... | @@ -578,7 +578,7 @@ fn varDecl( |
| 578 | 578 | ||
| 579 | // Namespace vars shadowing detection | 579 | // Namespace vars shadowing detection |
| 580 | if (mod.lookupDeclName(scope, ident_name)) |_| { | 580 | 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}); |
| 582 | } | 582 | } |
| 583 | const init_node = node.getInitNode() orelse | 583 | const init_node = node.getInitNode() orelse |
| 584 | return mod.fail(scope, name_src, "variables must be initialized", .{}); | 584 | 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 | ... | @@ -1955,7 +1955,7 @@ fn identifier(mod: *Module, scope: *Scope, rl: ResultLoc, ident: *ast.Node.OneTo |
| 1955 | error.Overflow => return mod.failNode( | 1955 | error.Overflow => return mod.failNode( |
| 1956 | scope, | 1956 | scope, |
| 1957 | &ident.base, | 1957 | &ident.base, |
| 1958 | "primitive integer type '{}' exceeds maximum bit width of 65535", | 1958 | "primitive integer type '{s}' exceeds maximum bit width of 65535", |
| 1959 | .{ident_name}, | 1959 | .{ident_name}, |
| 1960 | ), | 1960 | ), |
| 1961 | error.InvalidCharacter => break :integer, | 1961 | error.InvalidCharacter => break :integer, |
| ... | @@ -2010,7 +2010,7 @@ fn identifier(mod: *Module, scope: *Scope, rl: ResultLoc, ident: *ast.Node.OneTo | ... | @@ -2010,7 +2010,7 @@ fn identifier(mod: *Module, scope: *Scope, rl: ResultLoc, ident: *ast.Node.OneTo |
| 2010 | return rlWrapPtr(mod, scope, rl, try addZIRInst(mod, scope, src, zir.Inst.DeclValInModule, .{ .decl = decl }, .{})); | 2010 | return rlWrapPtr(mod, scope, rl, try addZIRInst(mod, scope, src, zir.Inst.DeclValInModule, .{ .decl = decl }, .{})); |
| 2011 | } | 2011 | } |
| 2012 | 2012 | ||
| 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}); |
| 2014 | } | 2014 | } |
| 2015 | 2015 | ||
| 2016 | fn stringLiteral(mod: *Module, scope: *Scope, str_lit: *ast.Node.OneToken) InnerError!*zir.Inst { | 2016 | fn 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 | ... | @@ -2204,7 +2204,7 @@ fn ensureBuiltinParamCount(mod: *Module, scope: *Scope, call: *ast.Node.BuiltinC |
| 2204 | return; | 2204 | return; |
| 2205 | 2205 | ||
| 2206 | const s = if (count == 1) "" else "s"; | 2206 | 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 }); |
| 2208 | } | 2208 | } |
| 2209 | 2209 | ||
| 2210 | fn simpleCast( | 2210 | fn simpleCast( |
| ... | @@ -2383,7 +2383,7 @@ fn builtinCall(mod: *Module, scope: *Scope, rl: ResultLoc, call: *ast.Node.Built | ... | @@ -2383,7 +2383,7 @@ fn builtinCall(mod: *Module, scope: *Scope, rl: ResultLoc, call: *ast.Node.Built |
| 2383 | } else if (mem.eql(u8, builtin_name, "@compileError")) { | 2383 | } else if (mem.eql(u8, builtin_name, "@compileError")) { |
| 2384 | return compileError(mod, scope, call); | 2384 | return compileError(mod, scope, call); |
| 2385 | } else { | 2385 | } 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}); |
| 2387 | } | 2387 | } |
| 2388 | } | 2388 | } |
| 2389 | 2389 |
src/codegen.zig+19-19| ... | @@ -228,7 +228,7 @@ pub fn generateSymbol( | ... | @@ -228,7 +228,7 @@ pub fn generateSymbol( |
| 228 | .fail = try ErrorMsg.create( | 228 | .fail = try ErrorMsg.create( |
| 229 | bin_file.allocator, | 229 | bin_file.allocator, |
| 230 | src, | 230 | src, |
| 231 | "TODO implement generateSymbol for type '{}'", | 231 | "TODO implement generateSymbol for type '{s}'", |
| 232 | .{@tagName(t)}, | 232 | .{@tagName(t)}, |
| 233 | ), | 233 | ), |
| 234 | }; | 234 | }; |
| ... | @@ -2029,7 +2029,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { | ... | @@ -2029,7 +2029,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 2029 | }); | 2029 | }); |
| 2030 | break :blk 0x84; | 2030 | break :blk 0x84; |
| 2031 | }, | 2031 | }, |
| 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) }), |
| 2033 | }; | 2033 | }; |
| 2034 | self.code.appendSliceAssumeCapacity(&[_]u8{ 0x0f, opcode }); | 2034 | self.code.appendSliceAssumeCapacity(&[_]u8{ 0x0f, opcode }); |
| 2035 | const reloc = Reloc{ .rel32 = self.code.items.len }; | 2035 | const reloc = Reloc{ .rel32 = self.code.items.len }; |
| ... | @@ -2376,11 +2376,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { | ... | @@ -2376,11 +2376,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 2376 | .arm, .armeb => { | 2376 | .arm, .armeb => { |
| 2377 | for (inst.inputs) |input, i| { | 2377 | for (inst.inputs) |input, i| { |
| 2378 | if (input.len < 3 or input[0] != '{' or input[input.len - 1] != '}') { | 2378 | 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}); |
| 2380 | } | 2380 | } |
| 2381 | const reg_name = input[1 .. input.len - 1]; | 2381 | const reg_name = input[1 .. input.len - 1]; |
| 2382 | const reg = parseRegName(reg_name) orelse | 2382 | 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}); |
| 2384 | const arg = try self.resolveInst(inst.args[i]); | 2384 | const arg = try self.resolveInst(inst.args[i]); |
| 2385 | try self.genSetReg(inst.base.src, reg, arg); | 2385 | try self.genSetReg(inst.base.src, reg, arg); |
| 2386 | } | 2386 | } |
| ... | @@ -2393,11 +2393,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { | ... | @@ -2393,11 +2393,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 2393 | 2393 | ||
| 2394 | if (inst.output) |output| { | 2394 | if (inst.output) |output| { |
| 2395 | if (output.len < 4 or output[0] != '=' or output[1] != '{' or output[output.len - 1] != '}') { | 2395 | 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}); |
| 2397 | } | 2397 | } |
| 2398 | const reg_name = output[2 .. output.len - 1]; | 2398 | const reg_name = output[2 .. output.len - 1]; |
| 2399 | const reg = parseRegName(reg_name) orelse | 2399 | 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}); |
| 2401 | return MCValue{ .register = reg }; | 2401 | return MCValue{ .register = reg }; |
| 2402 | } else { | 2402 | } else { |
| 2403 | return MCValue.none; | 2403 | return MCValue.none; |
| ... | @@ -2406,11 +2406,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { | ... | @@ -2406,11 +2406,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 2406 | .aarch64 => { | 2406 | .aarch64 => { |
| 2407 | for (inst.inputs) |input, i| { | 2407 | for (inst.inputs) |input, i| { |
| 2408 | if (input.len < 3 or input[0] != '{' or input[input.len - 1] != '}') { | 2408 | 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}); |
| 2410 | } | 2410 | } |
| 2411 | const reg_name = input[1 .. input.len - 1]; | 2411 | const reg_name = input[1 .. input.len - 1]; |
| 2412 | const reg = parseRegName(reg_name) orelse | 2412 | 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}); |
| 2414 | const arg = try self.resolveInst(inst.args[i]); | 2414 | const arg = try self.resolveInst(inst.args[i]); |
| 2415 | try self.genSetReg(inst.base.src, reg, arg); | 2415 | try self.genSetReg(inst.base.src, reg, arg); |
| 2416 | } | 2416 | } |
| ... | @@ -2425,11 +2425,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { | ... | @@ -2425,11 +2425,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 2425 | 2425 | ||
| 2426 | if (inst.output) |output| { | 2426 | if (inst.output) |output| { |
| 2427 | if (output.len < 4 or output[0] != '=' or output[1] != '{' or output[output.len - 1] != '}') { | 2427 | 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}); |
| 2429 | } | 2429 | } |
| 2430 | const reg_name = output[2 .. output.len - 1]; | 2430 | const reg_name = output[2 .. output.len - 1]; |
| 2431 | const reg = parseRegName(reg_name) orelse | 2431 | 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}); |
| 2433 | return MCValue{ .register = reg }; | 2433 | return MCValue{ .register = reg }; |
| 2434 | } else { | 2434 | } else { |
| 2435 | return MCValue.none; | 2435 | return MCValue.none; |
| ... | @@ -2438,11 +2438,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { | ... | @@ -2438,11 +2438,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 2438 | .riscv64 => { | 2438 | .riscv64 => { |
| 2439 | for (inst.inputs) |input, i| { | 2439 | for (inst.inputs) |input, i| { |
| 2440 | if (input.len < 3 or input[0] != '{' or input[input.len - 1] != '}') { | 2440 | 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}); |
| 2442 | } | 2442 | } |
| 2443 | const reg_name = input[1 .. input.len - 1]; | 2443 | const reg_name = input[1 .. input.len - 1]; |
| 2444 | const reg = parseRegName(reg_name) orelse | 2444 | 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}); |
| 2446 | const arg = try self.resolveInst(inst.args[i]); | 2446 | const arg = try self.resolveInst(inst.args[i]); |
| 2447 | try self.genSetReg(inst.base.src, reg, arg); | 2447 | try self.genSetReg(inst.base.src, reg, arg); |
| 2448 | } | 2448 | } |
| ... | @@ -2455,11 +2455,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { | ... | @@ -2455,11 +2455,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 2455 | 2455 | ||
| 2456 | if (inst.output) |output| { | 2456 | if (inst.output) |output| { |
| 2457 | if (output.len < 4 or output[0] != '=' or output[1] != '{' or output[output.len - 1] != '}') { | 2457 | 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}); |
| 2459 | } | 2459 | } |
| 2460 | const reg_name = output[2 .. output.len - 1]; | 2460 | const reg_name = output[2 .. output.len - 1]; |
| 2461 | const reg = parseRegName(reg_name) orelse | 2461 | 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}); |
| 2463 | return MCValue{ .register = reg }; | 2463 | return MCValue{ .register = reg }; |
| 2464 | } else { | 2464 | } else { |
| 2465 | return MCValue.none; | 2465 | return MCValue.none; |
| ... | @@ -2468,11 +2468,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { | ... | @@ -2468,11 +2468,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 2468 | .x86_64, .i386 => { | 2468 | .x86_64, .i386 => { |
| 2469 | for (inst.inputs) |input, i| { | 2469 | for (inst.inputs) |input, i| { |
| 2470 | if (input.len < 3 or input[0] != '{' or input[input.len - 1] != '}') { | 2470 | 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}); |
| 2472 | } | 2472 | } |
| 2473 | const reg_name = input[1 .. input.len - 1]; | 2473 | const reg_name = input[1 .. input.len - 1]; |
| 2474 | const reg = parseRegName(reg_name) orelse | 2474 | 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}); |
| 2476 | const arg = try self.resolveInst(inst.args[i]); | 2476 | const arg = try self.resolveInst(inst.args[i]); |
| 2477 | try self.genSetReg(inst.base.src, reg, arg); | 2477 | try self.genSetReg(inst.base.src, reg, arg); |
| 2478 | } | 2478 | } |
| ... | @@ -2485,11 +2485,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { | ... | @@ -2485,11 +2485,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 2485 | 2485 | ||
| 2486 | if (inst.output) |output| { | 2486 | if (inst.output) |output| { |
| 2487 | if (output.len < 4 or output[0] != '=' or output[1] != '{' or output[output.len - 1] != '}') { | 2487 | 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}); |
| 2489 | } | 2489 | } |
| 2490 | const reg_name = output[2 .. output.len - 1]; | 2490 | const reg_name = output[2 .. output.len - 1]; |
| 2491 | const reg = parseRegName(reg_name) orelse | 2491 | 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}); |
| 2493 | return MCValue{ .register = reg }; | 2493 | return MCValue{ .register = reg }; |
| 2494 | } else { | 2494 | } else { |
| 2495 | return MCValue.none; | 2495 | return MCValue.none; |
| ... | @@ -3417,7 +3417,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { | ... | @@ -3417,7 +3417,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 3417 | next_int_reg += 1; | 3417 | next_int_reg += 1; |
| 3418 | } | 3418 | } |
| 3419 | }, | 3419 | }, |
| 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())}), |
| 3421 | } | 3421 | } |
| 3422 | } | 3422 | } |
| 3423 | result.stack_byte_count = next_stack_offset; | 3423 | result.stack_byte_count = next_stack_offset; |
src/codegen/c.zig+8-8| ... | @@ -235,7 +235,7 @@ fn renderFunctionSignature( | ... | @@ -235,7 +235,7 @@ fn renderFunctionSignature( |
| 235 | try writer.writeAll(", "); | 235 | try writer.writeAll(", "); |
| 236 | } | 236 | } |
| 237 | try renderType(ctx, writer, tv.ty.fnParamType(index)); | 237 | try renderType(ctx, writer, tv.ty.fnParamType(index)); |
| 238 | try writer.print(" arg{}", .{index}); | 238 | try writer.print(" arg{d}", .{index}); |
| 239 | } | 239 | } |
| 240 | } | 240 | } |
| 241 | try writer.writeByte(')'); | 241 | try writer.writeByte(')'); |
| ... | @@ -383,7 +383,7 @@ const Context = struct { | ... | @@ -383,7 +383,7 @@ const Context = struct { |
| 383 | } | 383 | } |
| 384 | 384 | ||
| 385 | fn name(self: *Context) ![]u8 { | 385 | 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}); |
| 387 | self.unnamed_index += 1; | 387 | self.unnamed_index += 1; |
| 388 | return val; | 388 | return val; |
| 389 | } | 389 | } |
| ... | @@ -420,7 +420,7 @@ fn genAlloc(ctx: *Context, file: *C, alloc: *Inst.NoOp) !?[]u8 { | ... | @@ -420,7 +420,7 @@ fn genAlloc(ctx: *Context, file: *C, alloc: *Inst.NoOp) !?[]u8 { |
| 420 | } | 420 | } |
| 421 | 421 | ||
| 422 | fn genArg(ctx: *Context) !?[]u8 { | 422 | fn 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}); |
| 424 | ctx.argdex += 1; | 424 | ctx.argdex += 1; |
| 425 | return name; | 425 | return name; |
| 426 | } | 426 | } |
| ... | @@ -528,7 +528,7 @@ fn genCall(ctx: *Context, file: *C, inst: *Inst.Call) !?[]u8 { | ... | @@ -528,7 +528,7 @@ fn genCall(ctx: *Context, file: *C, inst: *Inst.Call) !?[]u8 { |
| 528 | try renderValue(ctx, writer, arg.ty, val); | 528 | try renderValue(ctx, writer, arg.ty, val); |
| 529 | } else { | 529 | } else { |
| 530 | const val = try ctx.resolveInst(arg); | 530 | const val = try ctx.resolveInst(arg); |
| 531 | try writer.print("{}", .{val}); | 531 | try writer.print("{s}", .{val}); |
| 532 | } | 532 | } |
| 533 | } | 533 | } |
| 534 | } | 534 | } |
| ... | @@ -587,7 +587,7 @@ fn genAsm(ctx: *Context, file: *C, as: *Inst.Assembly) !?[]u8 { | ... | @@ -587,7 +587,7 @@ fn genAsm(ctx: *Context, file: *C, as: *Inst.Assembly) !?[]u8 { |
| 587 | const arg = as.args[index]; | 587 | const arg = as.args[index]; |
| 588 | try writer.writeAll("register "); | 588 | try writer.writeAll("register "); |
| 589 | try renderType(ctx, writer, arg.ty); | 589 | try renderType(ctx, writer, arg.ty); |
| 590 | try writer.print(" {}_constant __asm__(\"{}\") = ", .{ reg, reg }); | 590 | try writer.print(" {s}_constant __asm__(\"{s}\") = ", .{ reg, reg }); |
| 591 | // TODO merge constant handling into inst_map as well | 591 | // TODO merge constant handling into inst_map as well |
| 592 | if (arg.castTag(.constant)) |c| { | 592 | if (arg.castTag(.constant)) |c| { |
| 593 | try renderValue(ctx, writer, arg.ty, c.val); | 593 | try renderValue(ctx, writer, arg.ty, c.val); |
| ... | @@ -597,13 +597,13 @@ fn genAsm(ctx: *Context, file: *C, as: *Inst.Assembly) !?[]u8 { | ... | @@ -597,13 +597,13 @@ fn genAsm(ctx: *Context, file: *C, as: *Inst.Assembly) !?[]u8 { |
| 597 | if (!gop.found_existing) { | 597 | if (!gop.found_existing) { |
| 598 | return ctx.fail(ctx.decl.src(), "Internal error in C backend: asm argument not found in inst_map", .{}); | 598 | return ctx.fail(ctx.decl.src(), "Internal error in C backend: asm argument not found in inst_map", .{}); |
| 599 | } | 599 | } |
| 600 | try writer.print("{};\n ", .{gop.entry.value}); | 600 | try writer.print("{s};\n ", .{gop.entry.value}); |
| 601 | } | 601 | } |
| 602 | } else { | 602 | } else { |
| 603 | return ctx.fail(ctx.decl.src(), "TODO non-explicit inline asm regs", .{}); | 603 | return ctx.fail(ctx.decl.src(), "TODO non-explicit inline asm regs", .{}); |
| 604 | } | 604 | } |
| 605 | } | 605 | } |
| 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 }); |
| 607 | if (as.output) |o| { | 607 | if (as.output) |o| { |
| 608 | return ctx.fail(ctx.decl.src(), "TODO inline asm output", .{}); | 608 | return ctx.fail(ctx.decl.src(), "TODO inline asm output", .{}); |
| 609 | } | 609 | } |
| ... | @@ -619,7 +619,7 @@ fn genAsm(ctx: *Context, file: *C, as: *Inst.Assembly) !?[]u8 { | ... | @@ -619,7 +619,7 @@ fn genAsm(ctx: *Context, file: *C, as: *Inst.Assembly) !?[]u8 { |
| 619 | if (index > 0) { | 619 | if (index > 0) { |
| 620 | try writer.writeAll(", "); | 620 | try writer.writeAll(", "); |
| 621 | } | 621 | } |
| 622 | try writer.print("\"\"({}_constant)", .{reg}); | 622 | try writer.print("\"\"({s}_constant)", .{reg}); |
| 623 | } else { | 623 | } else { |
| 624 | // This is blocked by the earlier test | 624 | // This is blocked by the earlier test |
| 625 | unreachable; | 625 | unreachable; |
src/glibc.zig+21-21| ... | @@ -72,7 +72,7 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError! | ... | @@ -72,7 +72,7 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError! |
| 72 | errdefer version_table.deinit(gpa); | 72 | errdefer version_table.deinit(gpa); |
| 73 | 73 | ||
| 74 | var glibc_dir = zig_lib_dir.openDir("libc" ++ path.sep_str ++ "glibc", .{}) catch |err| { | 74 | 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)}); |
| 76 | return error.ZigInstallationCorrupt; | 76 | return error.ZigInstallationCorrupt; |
| 77 | }; | 77 | }; |
| 78 | defer glibc_dir.close(); | 78 | defer glibc_dir.close(); |
| ... | @@ -81,7 +81,7 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError! | ... | @@ -81,7 +81,7 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError! |
| 81 | const vers_txt_contents = glibc_dir.readFileAlloc(gpa, "vers.txt", max_txt_size) catch |err| switch (err) { | 81 | const vers_txt_contents = glibc_dir.readFileAlloc(gpa, "vers.txt", max_txt_size) catch |err| switch (err) { |
| 82 | error.OutOfMemory => return error.OutOfMemory, | 82 | error.OutOfMemory => return error.OutOfMemory, |
| 83 | else => { | 83 | else => { |
| 84 | std.log.err("unable to read vers.txt: {}", .{@errorName(err)}); | 84 | std.log.err("unable to read vers.txt: {s}", .{@errorName(err)}); |
| 85 | return error.ZigInstallationCorrupt; | 85 | return error.ZigInstallationCorrupt; |
| 86 | }, | 86 | }, |
| 87 | }; | 87 | }; |
| ... | @@ -91,7 +91,7 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError! | ... | @@ -91,7 +91,7 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError! |
| 91 | const fns_txt_contents = glibc_dir.readFileAlloc(arena, "fns.txt", max_txt_size) catch |err| switch (err) { | 91 | const fns_txt_contents = glibc_dir.readFileAlloc(arena, "fns.txt", max_txt_size) catch |err| switch (err) { |
| 92 | error.OutOfMemory => return error.OutOfMemory, | 92 | error.OutOfMemory => return error.OutOfMemory, |
| 93 | else => { | 93 | else => { |
| 94 | std.log.err("unable to read fns.txt: {}", .{@errorName(err)}); | 94 | std.log.err("unable to read fns.txt: {s}", .{@errorName(err)}); |
| 95 | return error.ZigInstallationCorrupt; | 95 | return error.ZigInstallationCorrupt; |
| 96 | }, | 96 | }, |
| 97 | }; | 97 | }; |
| ... | @@ -99,7 +99,7 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError! | ... | @@ -99,7 +99,7 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError! |
| 99 | const abi_txt_contents = glibc_dir.readFileAlloc(gpa, "abi.txt", max_txt_size) catch |err| switch (err) { | 99 | const abi_txt_contents = glibc_dir.readFileAlloc(gpa, "abi.txt", max_txt_size) catch |err| switch (err) { |
| 100 | error.OutOfMemory => return error.OutOfMemory, | 100 | error.OutOfMemory => return error.OutOfMemory, |
| 101 | else => { | 101 | else => { |
| 102 | std.log.err("unable to read abi.txt: {}", .{@errorName(err)}); | 102 | std.log.err("unable to read abi.txt: {s}", .{@errorName(err)}); |
| 103 | return error.ZigInstallationCorrupt; | 103 | return error.ZigInstallationCorrupt; |
| 104 | }, | 104 | }, |
| 105 | }; | 105 | }; |
| ... | @@ -111,12 +111,12 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError! | ... | @@ -111,12 +111,12 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError! |
| 111 | while (it.next()) |line| : (line_i += 1) { | 111 | while (it.next()) |line| : (line_i += 1) { |
| 112 | const prefix = "GLIBC_"; | 112 | const prefix = "GLIBC_"; |
| 113 | if (!mem.startsWith(u8, line, prefix)) { | 113 | 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}); |
| 115 | return error.ZigInstallationCorrupt; | 115 | return error.ZigInstallationCorrupt; |
| 116 | } | 116 | } |
| 117 | const adjusted_line = line[prefix.len..]; | 117 | const adjusted_line = line[prefix.len..]; |
| 118 | const ver = std.builtin.Version.parse(adjusted_line) catch |err| { | 118 | 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) }); |
| 120 | return error.ZigInstallationCorrupt; | 120 | return error.ZigInstallationCorrupt; |
| 121 | }; | 121 | }; |
| 122 | try all_versions.append(arena, ver); | 122 | try all_versions.append(arena, ver); |
| ... | @@ -128,15 +128,15 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError! | ... | @@ -128,15 +128,15 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError! |
| 128 | while (file_it.next()) |line| : (line_i += 1) { | 128 | while (file_it.next()) |line| : (line_i += 1) { |
| 129 | var line_it = mem.tokenize(line, " "); | 129 | var line_it = mem.tokenize(line, " "); |
| 130 | const fn_name = line_it.next() orelse { | 130 | 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}); |
| 132 | return error.ZigInstallationCorrupt; | 132 | return error.ZigInstallationCorrupt; |
| 133 | }; | 133 | }; |
| 134 | const lib_name = line_it.next() orelse { | 134 | 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}); |
| 136 | return error.ZigInstallationCorrupt; | 136 | return error.ZigInstallationCorrupt; |
| 137 | }; | 137 | }; |
| 138 | const lib = findLib(lib_name) orelse { | 138 | 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 }); |
| 140 | return error.ZigInstallationCorrupt; | 140 | return error.ZigInstallationCorrupt; |
| 141 | }; | 141 | }; |
| 142 | try all_functions.append(arena, .{ | 142 | try all_functions.append(arena, .{ |
| ... | @@ -158,27 +158,27 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError! | ... | @@ -158,27 +158,27 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError! |
| 158 | while (line_it.next()) |target_string| { | 158 | while (line_it.next()) |target_string| { |
| 159 | var component_it = mem.tokenize(target_string, "-"); | 159 | var component_it = mem.tokenize(target_string, "-"); |
| 160 | const arch_name = component_it.next() orelse { | 160 | 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}); |
| 162 | return error.ZigInstallationCorrupt; | 162 | return error.ZigInstallationCorrupt; |
| 163 | }; | 163 | }; |
| 164 | const os_name = component_it.next() orelse { | 164 | 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}); |
| 166 | return error.ZigInstallationCorrupt; | 166 | return error.ZigInstallationCorrupt; |
| 167 | }; | 167 | }; |
| 168 | const abi_name = component_it.next() orelse { | 168 | 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}); |
| 170 | return error.ZigInstallationCorrupt; | 170 | return error.ZigInstallationCorrupt; |
| 171 | }; | 171 | }; |
| 172 | const arch_tag = std.meta.stringToEnum(std.Target.Cpu.Arch, arch_name) orelse { | 172 | 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 }); |
| 174 | return error.ZigInstallationCorrupt; | 174 | return error.ZigInstallationCorrupt; |
| 175 | }; | 175 | }; |
| 176 | if (!mem.eql(u8, os_name, "linux")) { | 176 | 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 }); |
| 178 | return error.ZigInstallationCorrupt; | 178 | return error.ZigInstallationCorrupt; |
| 179 | } | 179 | } |
| 180 | const abi_tag = std.meta.stringToEnum(std.Target.Abi, abi_name) orelse { | 180 | 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 }); |
| 182 | return error.ZigInstallationCorrupt; | 182 | return error.ZigInstallationCorrupt; |
| 183 | }; | 183 | }; |
| 184 | 184 | ||
| ... | @@ -193,7 +193,7 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError! | ... | @@ -193,7 +193,7 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError! |
| 193 | }; | 193 | }; |
| 194 | for (ver_list_base) |*ver_list| { | 194 | for (ver_list_base) |*ver_list| { |
| 195 | const line = file_it.next() orelse { | 195 | 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}); |
| 197 | return error.ZigInstallationCorrupt; | 197 | return error.ZigInstallationCorrupt; |
| 198 | }; | 198 | }; |
| 199 | line_i += 1; | 199 | line_i += 1; |
| ... | @@ -206,12 +206,12 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError! | ... | @@ -206,12 +206,12 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError! |
| 206 | while (line_it.next()) |version_index_string| { | 206 | while (line_it.next()) |version_index_string| { |
| 207 | if (ver_list.len >= ver_list.versions.len) { | 207 | if (ver_list.len >= ver_list.versions.len) { |
| 208 | // If this happens with legit data, increase the array len in the type. | 208 | // 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}); |
| 210 | return error.ZigInstallationCorrupt; | 210 | return error.ZigInstallationCorrupt; |
| 211 | } | 211 | } |
| 212 | const version_index = std.fmt.parseInt(u8, version_index_string, 10) catch |err| { | 212 | const version_index = std.fmt.parseInt(u8, version_index_string, 10) catch |err| { |
| 213 | // If this happens with legit data, increase the size of the integer type in the struct. | 213 | // 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) }); |
| 215 | return error.ZigInstallationCorrupt; | 215 | return error.ZigInstallationCorrupt; |
| 216 | }; | 216 | }; |
| 217 | 217 | ||
| ... | @@ -531,7 +531,7 @@ fn add_include_dirs(comp: *Compilation, arena: *Allocator, args: *std.ArrayList( | ... | @@ -531,7 +531,7 @@ fn add_include_dirs(comp: *Compilation, arena: *Allocator, args: *std.ArrayList( |
| 531 | try args.append(try path.join(arena, &[_][]const u8{ comp.zig_lib_directory.path.?, lib_libc ++ "glibc" })); | 531 | try args.append(try path.join(arena, &[_][]const u8{ comp.zig_lib_directory.path.?, lib_libc ++ "glibc" })); |
| 532 | 532 | ||
| 533 | try args.append("-I"); | 533 | 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}", .{ |
| 535 | comp.zig_lib_directory.path.?, @tagName(arch), @tagName(target.os.tag), @tagName(target.abi), | 535 | comp.zig_lib_directory.path.?, @tagName(arch), @tagName(target.os.tag), @tagName(target.abi), |
| 536 | })); | 536 | })); |
| 537 | 537 | ||
| ... | @@ -539,7 +539,7 @@ fn add_include_dirs(comp: *Compilation, arena: *Allocator, args: *std.ArrayList( | ... | @@ -539,7 +539,7 @@ fn add_include_dirs(comp: *Compilation, arena: *Allocator, args: *std.ArrayList( |
| 539 | try args.append(try lib_path(comp, arena, lib_libc ++ "include" ++ s ++ "generic-glibc")); | 539 | try args.append(try lib_path(comp, arena, lib_libc ++ "include" ++ s ++ "generic-glibc")); |
| 540 | 540 | ||
| 541 | try args.append("-I"); | 541 | 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", .{ |
| 543 | comp.zig_lib_directory.path.?, @tagName(arch), | 543 | comp.zig_lib_directory.path.?, @tagName(arch), |
| 544 | })); | 544 | })); |
| 545 | 545 | ||
| ... | @@ -881,7 +881,7 @@ pub fn buildSharedObjects(comp: *Compilation) !void { | ... | @@ -881,7 +881,7 @@ pub fn buildSharedObjects(comp: *Compilation) !void { |
| 881 | if (o_directory.handle.createFile(ok_basename, .{})) |file| { | 881 | if (o_directory.handle.createFile(ok_basename, .{})) |file| { |
| 882 | file.close(); | 882 | file.close(); |
| 883 | } else |err| { | 883 | } 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)}); |
| 885 | } | 885 | } |
| 886 | } | 886 | } |
| 887 | 887 |
src/libc_installation.zig+16-16| ... | @@ -83,7 +83,7 @@ pub const LibCInstallation = struct { | ... | @@ -83,7 +83,7 @@ pub const LibCInstallation = struct { |
| 83 | } | 83 | } |
| 84 | inline for (fields) |field, i| { | 84 | inline for (fields) |field, i| { |
| 85 | if (!found_keys[i].found) { | 85 | if (!found_keys[i].found) { |
| 86 | log.err("missing field: {}\n", .{field.name}); | 86 | log.err("missing field: {s}\n", .{field.name}); |
| 87 | return error.ParseError; | 87 | return error.ParseError; |
| 88 | } | 88 | } |
| 89 | } | 89 | } |
| ... | @@ -96,18 +96,18 @@ pub const LibCInstallation = struct { | ... | @@ -96,18 +96,18 @@ pub const LibCInstallation = struct { |
| 96 | return error.ParseError; | 96 | return error.ParseError; |
| 97 | } | 97 | } |
| 98 | if (self.crt_dir == null and !is_darwin) { | 98 | 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)}); |
| 100 | return error.ParseError; | 100 | return error.ParseError; |
| 101 | } | 101 | } |
| 102 | if (self.msvc_lib_dir == null and is_windows and !is_gnu) { | 102 | 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", .{ |
| 104 | @tagName(Target.current.os.tag), | 104 | @tagName(Target.current.os.tag), |
| 105 | @tagName(Target.current.abi), | 105 | @tagName(Target.current.abi), |
| 106 | }); | 106 | }); |
| 107 | return error.ParseError; | 107 | return error.ParseError; |
| 108 | } | 108 | } |
| 109 | if (self.kernel32_lib_dir == null and is_windows and !is_gnu) { | 109 | 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", .{ |
| 111 | @tagName(Target.current.os.tag), | 111 | @tagName(Target.current.os.tag), |
| 112 | @tagName(Target.current.abi), | 112 | @tagName(Target.current.abi), |
| 113 | }); | 113 | }); |
| ... | @@ -128,25 +128,25 @@ pub const LibCInstallation = struct { | ... | @@ -128,25 +128,25 @@ pub const LibCInstallation = struct { |
| 128 | try out.print( | 128 | try out.print( |
| 129 | \\# The directory that contains `stdlib.h`. | 129 | \\# The directory that contains `stdlib.h`. |
| 130 | \\# On POSIX-like systems, include directories be found with: `cc -E -Wp,-v -xc /dev/null` | 130 | \\# On POSIX-like systems, include directories be found with: `cc -E -Wp,-v -xc /dev/null` |
| 131 | \\include_dir={} | 131 | \\include_dir={s} |
| 132 | \\ | 132 | \\ |
| 133 | \\# The system-specific include directory. May be the same as `include_dir`. | 133 | \\# The system-specific include directory. May be the same as `include_dir`. |
| 134 | \\# On Windows it's the directory that includes `vcruntime.h`. | 134 | \\# On Windows it's the directory that includes `vcruntime.h`. |
| 135 | \\# On POSIX it's the directory that includes `sys/errno.h`. | 135 | \\# On POSIX it's the directory that includes `sys/errno.h`. |
| 136 | \\sys_include_dir={} | 136 | \\sys_include_dir={s} |
| 137 | \\ | 137 | \\ |
| 138 | \\# The directory that contains `crt1.o` or `crt2.o`. | 138 | \\# The directory that contains `crt1.o` or `crt2.o`. |
| 139 | \\# On POSIX, can be found with `cc -print-file-name=crt1.o`. | 139 | \\# On POSIX, can be found with `cc -print-file-name=crt1.o`. |
| 140 | \\# Not needed when targeting MacOS. | 140 | \\# Not needed when targeting MacOS. |
| 141 | \\crt_dir={} | 141 | \\crt_dir={s} |
| 142 | \\ | 142 | \\ |
| 143 | \\# The directory that contains `vcruntime.lib`. | 143 | \\# The directory that contains `vcruntime.lib`. |
| 144 | \\# Only needed when targeting MSVC on Windows. | 144 | \\# Only needed when targeting MSVC on Windows. |
| 145 | \\msvc_lib_dir={} | 145 | \\msvc_lib_dir={s} |
| 146 | \\ | 146 | \\ |
| 147 | \\# The directory that contains `kernel32.lib`. | 147 | \\# The directory that contains `kernel32.lib`. |
| 148 | \\# Only needed when targeting MSVC on Windows. | 148 | \\# Only needed when targeting MSVC on Windows. |
| 149 | \\kernel32_lib_dir={} | 149 | \\kernel32_lib_dir={s} |
| 150 | \\ | 150 | \\ |
| 151 | , .{ | 151 | , .{ |
| 152 | include_dir, | 152 | include_dir, |
| ... | @@ -338,7 +338,7 @@ pub const LibCInstallation = struct { | ... | @@ -338,7 +338,7 @@ pub const LibCInstallation = struct { |
| 338 | 338 | ||
| 339 | for (searches) |search| { | 339 | for (searches) |search| { |
| 340 | result_buf.shrink(0); | 340 | 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 }); |
| 342 | 342 | ||
| 343 | var dir = fs.cwd().openDir(result_buf.items, .{}) catch |err| switch (err) { | 343 | var dir = fs.cwd().openDir(result_buf.items, .{}) catch |err| switch (err) { |
| 344 | error.FileNotFound, | 344 | error.FileNotFound, |
| ... | @@ -384,7 +384,7 @@ pub const LibCInstallation = struct { | ... | @@ -384,7 +384,7 @@ pub const LibCInstallation = struct { |
| 384 | 384 | ||
| 385 | for (searches) |search| { | 385 | for (searches) |search| { |
| 386 | result_buf.shrink(0); | 386 | 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 }); |
| 388 | 388 | ||
| 389 | var dir = fs.cwd().openDir(result_buf.items, .{}) catch |err| switch (err) { | 389 | var dir = fs.cwd().openDir(result_buf.items, .{}) catch |err| switch (err) { |
| 390 | error.FileNotFound, | 390 | error.FileNotFound, |
| ... | @@ -439,7 +439,7 @@ pub const LibCInstallation = struct { | ... | @@ -439,7 +439,7 @@ pub const LibCInstallation = struct { |
| 439 | for (searches) |search| { | 439 | for (searches) |search| { |
| 440 | result_buf.shrink(0); | 440 | result_buf.shrink(0); |
| 441 | const stream = result_buf.outStream(); | 441 | 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 }); |
| 443 | 443 | ||
| 444 | var dir = fs.cwd().openDir(result_buf.items, .{}) catch |err| switch (err) { | 444 | var dir = fs.cwd().openDir(result_buf.items, .{}) catch |err| switch (err) { |
| 445 | error.FileNotFound, | 445 | error.FileNotFound, |
| ... | @@ -520,7 +520,7 @@ fn ccPrintFileName(args: CCPrintFileNameOptions) ![:0]u8 { | ... | @@ -520,7 +520,7 @@ fn ccPrintFileName(args: CCPrintFileNameOptions) ![:0]u8 { |
| 520 | const allocator = args.allocator; | 520 | const allocator = args.allocator; |
| 521 | 521 | ||
| 522 | const cc_exe = std.os.getenvZ("CC") orelse default_cc_exe; | 522 | 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}); |
| 524 | defer allocator.free(arg1); | 524 | defer allocator.free(arg1); |
| 525 | const argv = [_][]const u8{ cc_exe, arg1 }; | 525 | const argv = [_][]const u8{ cc_exe, arg1 }; |
| 526 | 526 | ||
| ... | @@ -584,17 +584,17 @@ fn printVerboseInvocation( | ... | @@ -584,17 +584,17 @@ fn printVerboseInvocation( |
| 584 | if (!verbose) return; | 584 | if (!verbose) return; |
| 585 | 585 | ||
| 586 | if (search_basename) |s| { | 586 | 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}); |
| 588 | } else { | 588 | } else { |
| 589 | std.debug.warn("Zig attempted to find the path to native system libc headers by executing this command:\n", .{}); | 589 | std.debug.warn("Zig attempted to find the path to native system libc headers by executing this command:\n", .{}); |
| 590 | } | 590 | } |
| 591 | for (argv) |arg, i| { | 591 | for (argv) |arg, i| { |
| 592 | if (i != 0) std.debug.warn(" ", .{}); | 592 | if (i != 0) std.debug.warn(" ", .{}); |
| 593 | std.debug.warn("{}", .{arg}); | 593 | std.debug.warn("{s}", .{arg}); |
| 594 | } | 594 | } |
| 595 | std.debug.warn("\n", .{}); | 595 | std.debug.warn("\n", .{}); |
| 596 | if (stderr) |s| { | 596 | if (stderr) |s| { |
| 597 | std.debug.warn("Output:\n==========\n{}\n==========\n", .{s}); | 597 | std.debug.warn("Output:\n==========\n{s}\n==========\n", .{s}); |
| 598 | } | 598 | } |
| 599 | } | 599 | } |
| 600 | 600 |
src/link.zig+5-5| ... | @@ -523,7 +523,7 @@ pub const File = struct { | ... | @@ -523,7 +523,7 @@ pub const File = struct { |
| 523 | id_symlink_basename, | 523 | id_symlink_basename, |
| 524 | &prev_digest_buf, | 524 | &prev_digest_buf, |
| 525 | ) catch |err| b: { | 525 | ) 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) }); |
| 527 | break :b prev_digest_buf[0..0]; | 527 | break :b prev_digest_buf[0..0]; |
| 528 | }; | 528 | }; |
| 529 | if (mem.eql(u8, prev_digest, &digest)) { | 529 | if (mem.eql(u8, prev_digest, &digest)) { |
| ... | @@ -560,9 +560,9 @@ pub const File = struct { | ... | @@ -560,9 +560,9 @@ pub const File = struct { |
| 560 | const full_out_path_z = try arena.dupeZ(u8, full_out_path); | 560 | const full_out_path_z = try arena.dupeZ(u8, full_out_path); |
| 561 | 561 | ||
| 562 | if (base.options.verbose_link) { | 562 | 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}); |
| 564 | for (object_files.items) |arg| { | 564 | for (object_files.items) |arg| { |
| 565 | std.debug.print(" {}", .{arg}); | 565 | std.debug.print(" {s}", .{arg}); |
| 566 | } | 566 | } |
| 567 | std.debug.print("\n", .{}); | 567 | std.debug.print("\n", .{}); |
| 568 | } | 568 | } |
| ... | @@ -574,11 +574,11 @@ pub const File = struct { | ... | @@ -574,11 +574,11 @@ pub const File = struct { |
| 574 | 574 | ||
| 575 | if (!base.options.disable_lld_caching) { | 575 | if (!base.options.disable_lld_caching) { |
| 576 | Cache.writeSmallFile(directory.handle, id_symlink_basename, &digest) catch |err| { | 576 | 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)}); |
| 578 | }; | 578 | }; |
| 579 | 579 | ||
| 580 | man.writeManifest() catch |err| { | 580 | 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)}); |
| 582 | }; | 582 | }; |
| 583 | 583 | ||
| 584 | base.lock = man.toOwnedLock(); | 584 | base.lock = man.toOwnedLock(); |
src/link/C.zig+1-1| ... | @@ -112,7 +112,7 @@ pub fn flushModule(self: *C, comp: *Compilation) !void { | ... | @@ -112,7 +112,7 @@ pub fn flushModule(self: *C, comp: *Compilation) !void { |
| 112 | try writer.writeByte('\n'); | 112 | try writer.writeByte('\n'); |
| 113 | } | 113 | } |
| 114 | if (self.constants.items.len > 0) { | 114 | if (self.constants.items.len > 0) { |
| 115 | try writer.print("{}\n", .{self.constants.items}); | 115 | try writer.print("{s}\n", .{self.constants.items}); |
| 116 | } | 116 | } |
| 117 | if (self.main.items.len > 1) { | 117 | if (self.main.items.len > 1) { |
| 118 | const last_two = self.main.items[self.main.items.len - 2 ..]; | 118 | 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 { | ... | @@ -686,7 +686,7 @@ pub fn updateDecl(self: *Coff, module: *Module, decl: *Module.Decl) !void { |
| 686 | if (need_realloc) { | 686 | if (need_realloc) { |
| 687 | const curr_vaddr = self.getDeclVAddr(decl); | 687 | const curr_vaddr = self.getDeclVAddr(decl); |
| 688 | const vaddr = try self.growTextBlock(&decl.link.coff, code.len, required_alignment); | 688 | 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 }); |
| 690 | if (vaddr != curr_vaddr) { | 690 | if (vaddr != curr_vaddr) { |
| 691 | log.debug(" (writing new offset table entry)\n", .{}); | 691 | log.debug(" (writing new offset table entry)\n", .{}); |
| 692 | self.offset_table.items[decl.link.coff.offset_table_index] = vaddr; | 692 | 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 { | ... | @@ -697,7 +697,7 @@ pub fn updateDecl(self: *Coff, module: *Module, decl: *Module.Decl) !void { |
| 697 | } | 697 | } |
| 698 | } else { | 698 | } else { |
| 699 | const vaddr = try self.allocateTextBlock(&decl.link.coff, code.len, required_alignment); | 699 | 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 }); |
| 701 | errdefer self.freeTextBlock(&decl.link.coff); | 701 | errdefer self.freeTextBlock(&decl.link.coff); |
| 702 | self.offset_table.items[decl.link.coff.offset_table_index] = vaddr; | 702 | self.offset_table.items[decl.link.coff.offset_table_index] = vaddr; |
| 703 | try self.writeOffsetTableEntry(decl.link.coff.offset_table_index); | 703 | try self.writeOffsetTableEntry(decl.link.coff.offset_table_index); |
| ... | @@ -880,7 +880,7 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void { | ... | @@ -880,7 +880,7 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void { |
| 880 | id_symlink_basename, | 880 | id_symlink_basename, |
| 881 | &prev_digest_buf, | 881 | &prev_digest_buf, |
| 882 | ) catch |err| blk: { | 882 | ) 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) }); |
| 884 | // Handle this as a cache miss. | 884 | // Handle this as a cache miss. |
| 885 | break :blk prev_digest_buf[0..0]; | 885 | break :blk prev_digest_buf[0..0]; |
| 886 | }; | 886 | }; |
| ... | @@ -1236,11 +1236,11 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void { | ... | @@ -1236,11 +1236,11 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void { |
| 1236 | // Update the file with the digest. If it fails we can continue; it only | 1236 | // Update the file with the digest. If it fails we can continue; it only |
| 1237 | // means that the next invocation will have an unnecessary cache miss. | 1237 | // means that the next invocation will have an unnecessary cache miss. |
| 1238 | Cache.writeSmallFile(directory.handle, id_symlink_basename, &digest) catch |err| { | 1238 | 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)}); |
| 1240 | }; | 1240 | }; |
| 1241 | // Again failure here only means an unnecessary cache miss. | 1241 | // Again failure here only means an unnecessary cache miss. |
| 1242 | man.writeManifest() catch |err| { | 1242 | 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)}); |
| 1244 | }; | 1244 | }; |
| 1245 | // We hang on to this lock so that the output file path can be used without | 1245 | // We hang on to this lock so that the output file path can be used without |
| 1246 | // other processes clobbering it. | 1246 | // other processes clobbering it. |
src/link/Elf.zig+12-12| ... | @@ -1362,7 +1362,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { | ... | @@ -1362,7 +1362,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { |
| 1362 | id_symlink_basename, | 1362 | id_symlink_basename, |
| 1363 | &prev_digest_buf, | 1363 | &prev_digest_buf, |
| 1364 | ) catch |err| blk: { | 1364 | ) 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) }); |
| 1366 | // Handle this as a cache miss. | 1366 | // Handle this as a cache miss. |
| 1367 | break :blk prev_digest_buf[0..0]; | 1367 | break :blk prev_digest_buf[0..0]; |
| 1368 | }; | 1368 | }; |
| ... | @@ -1396,7 +1396,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { | ... | @@ -1396,7 +1396,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { |
| 1396 | 1396 | ||
| 1397 | if (self.base.options.output_mode == .Exe) { | 1397 | if (self.base.options.output_mode == .Exe) { |
| 1398 | try argv.append("-z"); | 1398 | 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})); |
| 1400 | } | 1400 | } |
| 1401 | 1401 | ||
| 1402 | if (self.base.options.image_base_override) |image_base| { | 1402 | if (self.base.options.image_base_override) |image_base| { |
| ... | @@ -1438,7 +1438,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { | ... | @@ -1438,7 +1438,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { |
| 1438 | if (getLDMOption(target)) |ldm| { | 1438 | if (getLDMOption(target)) |ldm| { |
| 1439 | // Any target ELF will use the freebsd osabi if suffixed with "_fbsd". | 1439 | // Any target ELF will use the freebsd osabi if suffixed with "_fbsd". |
| 1440 | const arg = if (target.os.tag == .freebsd) | 1440 | const arg = if (target.os.tag == .freebsd) |
| 1441 | try std.fmt.allocPrint(arena, "{}_fbsd", .{ldm}) | 1441 | try std.fmt.allocPrint(arena, "{s}_fbsd", .{ldm}) |
| 1442 | else | 1442 | else |
| 1443 | ldm; | 1443 | ldm; |
| 1444 | try argv.append("-m"); | 1444 | try argv.append("-m"); |
| ... | @@ -1599,7 +1599,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { | ... | @@ -1599,7 +1599,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { |
| 1599 | // (the check for that needs to be earlier), but they could be full paths to .so files, in which | 1599 | // (the check for that needs to be earlier), but they could be full paths to .so files, in which |
| 1600 | // case we want to avoid prepending "-l". | 1600 | // case we want to avoid prepending "-l". |
| 1601 | const ext = Compilation.classifyFileExt(link_lib); | 1601 | 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}); |
| 1603 | argv.appendAssumeCapacity(arg); | 1603 | argv.appendAssumeCapacity(arg); |
| 1604 | } | 1604 | } |
| 1605 | 1605 | ||
| ... | @@ -1733,11 +1733,11 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { | ... | @@ -1733,11 +1733,11 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { |
| 1733 | // Update the file with the digest. If it fails we can continue; it only | 1733 | // Update the file with the digest. If it fails we can continue; it only |
| 1734 | // means that the next invocation will have an unnecessary cache miss. | 1734 | // means that the next invocation will have an unnecessary cache miss. |
| 1735 | Cache.writeSmallFile(directory.handle, id_symlink_basename, &digest) catch |err| { | 1735 | 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)}); |
| 1737 | }; | 1737 | }; |
| 1738 | // Again failure here only means an unnecessary cache miss. | 1738 | // Again failure here only means an unnecessary cache miss. |
| 1739 | man.writeManifest() catch |err| { | 1739 | 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)}); |
| 1741 | }; | 1741 | }; |
| 1742 | // We hang on to this lock so that the output file path can be used without | 1742 | // We hang on to this lock so that the output file path can be used without |
| 1743 | // other processes clobbering it. | 1743 | // other processes clobbering it. |
| ... | @@ -2082,10 +2082,10 @@ pub fn allocateDeclIndexes(self: *Elf, decl: *Module.Decl) !void { | ... | @@ -2082,10 +2082,10 @@ pub fn allocateDeclIndexes(self: *Elf, decl: *Module.Decl) !void { |
| 2082 | try self.offset_table.ensureCapacity(self.base.allocator, self.offset_table.items.len + 1); | 2082 | try self.offset_table.ensureCapacity(self.base.allocator, self.offset_table.items.len + 1); |
| 2083 | 2083 | ||
| 2084 | if (self.local_symbol_free_list.popOrNull()) |i| { | 2084 | 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 }); |
| 2086 | decl.link.elf.local_sym_index = i; | 2086 | decl.link.elf.local_sym_index = i; |
| 2087 | } else { | 2087 | } 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 }); |
| 2089 | decl.link.elf.local_sym_index = @intCast(u32, self.local_symbols.items.len); | 2089 | decl.link.elf.local_sym_index = @intCast(u32, self.local_symbols.items.len); |
| 2090 | _ = self.local_symbols.addOneAssumeCapacity(); | 2090 | _ = self.local_symbols.addOneAssumeCapacity(); |
| 2091 | } | 2091 | } |
| ... | @@ -2182,7 +2182,7 @@ pub fn updateDecl(self: *Elf, module: *Module, decl: *Module.Decl) !void { | ... | @@ -2182,7 +2182,7 @@ pub fn updateDecl(self: *Elf, module: *Module, decl: *Module.Decl) !void { |
| 2182 | if (zir_dumps.len != 0) { | 2182 | if (zir_dumps.len != 0) { |
| 2183 | for (zir_dumps) |fn_name| { | 2183 | for (zir_dumps) |fn_name| { |
| 2184 | if (mem.eql(u8, mem.spanZ(decl.name), fn_name)) { | 2184 | 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}); |
| 2186 | typed_value.val.castTag(.function).?.data.dump(module.*); | 2186 | typed_value.val.castTag(.function).?.data.dump(module.*); |
| 2187 | } | 2187 | } |
| 2188 | } | 2188 | } |
| ... | @@ -2300,7 +2300,7 @@ pub fn updateDecl(self: *Elf, module: *Module, decl: *Module.Decl) !void { | ... | @@ -2300,7 +2300,7 @@ pub fn updateDecl(self: *Elf, module: *Module, decl: *Module.Decl) !void { |
| 2300 | !mem.isAlignedGeneric(u64, local_sym.st_value, required_alignment); | 2300 | !mem.isAlignedGeneric(u64, local_sym.st_value, required_alignment); |
| 2301 | if (need_realloc) { | 2301 | if (need_realloc) { |
| 2302 | const vaddr = try self.growTextBlock(&decl.link.elf, code.len, required_alignment); | 2302 | 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 }); |
| 2304 | if (vaddr != local_sym.st_value) { | 2304 | if (vaddr != local_sym.st_value) { |
| 2305 | local_sym.st_value = vaddr; | 2305 | local_sym.st_value = vaddr; |
| 2306 | 2306 | ||
| ... | @@ -2322,7 +2322,7 @@ pub fn updateDecl(self: *Elf, module: *Module, decl: *Module.Decl) !void { | ... | @@ -2322,7 +2322,7 @@ pub fn updateDecl(self: *Elf, module: *Module, decl: *Module.Decl) !void { |
| 2322 | const decl_name = mem.spanZ(decl.name); | 2322 | const decl_name = mem.spanZ(decl.name); |
| 2323 | const name_str_index = try self.makeString(decl_name); | 2323 | const name_str_index = try self.makeString(decl_name); |
| 2324 | const vaddr = try self.allocateTextBlock(&decl.link.elf, code.len, required_alignment); | 2324 | 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 }); |
| 2326 | errdefer self.freeTextBlock(&decl.link.elf); | 2326 | errdefer self.freeTextBlock(&decl.link.elf); |
| 2327 | 2327 | ||
| 2328 | local_sym.* = .{ | 2328 | local_sym.* = .{ |
| ... | @@ -2432,7 +2432,7 @@ pub fn updateDecl(self: *Elf, module: *Module, decl: *Module.Decl) !void { | ... | @@ -2432,7 +2432,7 @@ pub fn updateDecl(self: *Elf, module: *Module, decl: *Module.Decl) !void { |
| 2432 | if (needed_size > self.allocatedSize(debug_line_sect.sh_offset)) { | 2432 | if (needed_size > self.allocatedSize(debug_line_sect.sh_offset)) { |
| 2433 | const new_offset = self.findFreeSpace(needed_size, 1); | 2433 | const new_offset = self.findFreeSpace(needed_size, 1); |
| 2434 | const existing_size = last_src_fn.off; | 2434 | 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", .{ |
| 2436 | existing_size, | 2436 | existing_size, |
| 2437 | debug_line_sect.sh_offset, | 2437 | debug_line_sect.sh_offset, |
| 2438 | new_offset, | 2438 | new_offset, |
src/link/MachO.zig+12-12| ... | @@ -520,7 +520,7 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { | ... | @@ -520,7 +520,7 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { |
| 520 | id_symlink_basename, | 520 | id_symlink_basename, |
| 521 | &prev_digest_buf, | 521 | &prev_digest_buf, |
| 522 | ) catch |err| blk: { | 522 | ) 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) }); |
| 524 | // Handle this as a cache miss. | 524 | // Handle this as a cache miss. |
| 525 | break :blk prev_digest_buf[0..0]; | 525 | break :blk prev_digest_buf[0..0]; |
| 526 | }; | 526 | }; |
| ... | @@ -620,7 +620,7 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { | ... | @@ -620,7 +620,7 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { |
| 620 | try argv.append(cur_vers); | 620 | try argv.append(cur_vers); |
| 621 | } | 621 | } |
| 622 | 622 | ||
| 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}); |
| 624 | try argv.append("-install_name"); | 624 | try argv.append("-install_name"); |
| 625 | try argv.append(dylib_install_name); | 625 | try argv.append(dylib_install_name); |
| 626 | } | 626 | } |
| ... | @@ -706,7 +706,7 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { | ... | @@ -706,7 +706,7 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { |
| 706 | // (the check for that needs to be earlier), but they could be full paths to .dylib files, in which | 706 | // (the check for that needs to be earlier), but they could be full paths to .dylib files, in which |
| 707 | // case we want to avoid prepending "-l". | 707 | // case we want to avoid prepending "-l". |
| 708 | const ext = Compilation.classifyFileExt(link_lib); | 708 | 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}); |
| 710 | argv.appendAssumeCapacity(arg); | 710 | argv.appendAssumeCapacity(arg); |
| 711 | } | 711 | } |
| 712 | 712 | ||
| ... | @@ -759,15 +759,15 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { | ... | @@ -759,15 +759,15 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { |
| 759 | self.base.allocator.free(result.stderr); | 759 | self.base.allocator.free(result.stderr); |
| 760 | } | 760 | } |
| 761 | if (result.stdout.len != 0) { | 761 | if (result.stdout.len != 0) { |
| 762 | log.warn("unexpected LD stdout: {}", .{result.stdout}); | 762 | log.warn("unexpected LD stdout: {s}", .{result.stdout}); |
| 763 | } | 763 | } |
| 764 | if (result.stderr.len != 0) { | 764 | if (result.stderr.len != 0) { |
| 765 | log.warn("unexpected LD stderr: {}", .{result.stderr}); | 765 | log.warn("unexpected LD stderr: {s}", .{result.stderr}); |
| 766 | } | 766 | } |
| 767 | if (result.term != .Exited or result.term.Exited != 0) { | 767 | if (result.term != .Exited or result.term.Exited != 0) { |
| 768 | // TODO parse this output and surface with the Compilation API rather than | 768 | // TODO parse this output and surface with the Compilation API rather than |
| 769 | // directly outputting to stderr here. | 769 | // directly outputting to stderr here. |
| 770 | log.err("{}", .{result.stderr}); | 770 | log.err("{s}", .{result.stderr}); |
| 771 | return error.LDReportedFailure; | 771 | return error.LDReportedFailure; |
| 772 | } | 772 | } |
| 773 | } else { | 773 | } else { |
| ... | @@ -980,11 +980,11 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { | ... | @@ -980,11 +980,11 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { |
| 980 | // Update the file with the digest. If it fails we can continue; it only | 980 | // Update the file with the digest. If it fails we can continue; it only |
| 981 | // means that the next invocation will have an unnecessary cache miss. | 981 | // means that the next invocation will have an unnecessary cache miss. |
| 982 | Cache.writeSmallFile(directory.handle, id_symlink_basename, &digest) catch |err| { | 982 | 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)}); |
| 984 | }; | 984 | }; |
| 985 | // Again failure here only means an unnecessary cache miss. | 985 | // Again failure here only means an unnecessary cache miss. |
| 986 | man.writeManifest() catch |err| { | 986 | 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)}); |
| 988 | }; | 988 | }; |
| 989 | // We hang on to this lock so that the output file path can be used without | 989 | // We hang on to this lock so that the output file path can be used without |
| 990 | // other processes clobbering it. | 990 | // other processes clobbering it. |
| ... | @@ -1088,10 +1088,10 @@ pub fn allocateDeclIndexes(self: *MachO, decl: *Module.Decl) !void { | ... | @@ -1088,10 +1088,10 @@ pub fn allocateDeclIndexes(self: *MachO, decl: *Module.Decl) !void { |
| 1088 | try self.offset_table.ensureCapacity(self.base.allocator, self.offset_table.items.len + 1); | 1088 | try self.offset_table.ensureCapacity(self.base.allocator, self.offset_table.items.len + 1); |
| 1089 | 1089 | ||
| 1090 | if (self.local_symbol_free_list.popOrNull()) |i| { | 1090 | 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 }); |
| 1092 | decl.link.macho.local_sym_index = i; | 1092 | decl.link.macho.local_sym_index = i; |
| 1093 | } else { | 1093 | } 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 }); |
| 1095 | decl.link.macho.local_sym_index = @intCast(u32, self.local_symbols.items.len); | 1095 | decl.link.macho.local_sym_index = @intCast(u32, self.local_symbols.items.len); |
| 1096 | _ = self.local_symbols.addOneAssumeCapacity(); | 1096 | _ = self.local_symbols.addOneAssumeCapacity(); |
| 1097 | } | 1097 | } |
| ... | @@ -1165,7 +1165,7 @@ pub fn updateDecl(self: *MachO, module: *Module, decl: *Module.Decl) !void { | ... | @@ -1165,7 +1165,7 @@ pub fn updateDecl(self: *MachO, module: *Module, decl: *Module.Decl) !void { |
| 1165 | const need_realloc = code.len > capacity or !mem.isAlignedGeneric(u64, symbol.n_value, required_alignment); | 1165 | const need_realloc = code.len > capacity or !mem.isAlignedGeneric(u64, symbol.n_value, required_alignment); |
| 1166 | if (need_realloc) { | 1166 | if (need_realloc) { |
| 1167 | const vaddr = try self.growTextBlock(&decl.link.macho, code.len, required_alignment); | 1167 | 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 }); |
| 1169 | if (vaddr != symbol.n_value) { | 1169 | if (vaddr != symbol.n_value) { |
| 1170 | symbol.n_value = vaddr; | 1170 | symbol.n_value = vaddr; |
| 1171 | log.debug(" (writing new offset table entry)", .{}); | 1171 | log.debug(" (writing new offset table entry)", .{}); |
| ... | @@ -1188,7 +1188,7 @@ pub fn updateDecl(self: *MachO, module: *Module, decl: *Module.Decl) !void { | ... | @@ -1188,7 +1188,7 @@ pub fn updateDecl(self: *MachO, module: *Module, decl: *Module.Decl) !void { |
| 1188 | const decl_name = mem.spanZ(decl.name); | 1188 | const decl_name = mem.spanZ(decl.name); |
| 1189 | const name_str_index = try self.makeString(decl_name); | 1189 | const name_str_index = try self.makeString(decl_name); |
| 1190 | const addr = try self.allocateTextBlock(&decl.link.macho, code.len, required_alignment); | 1190 | 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 }); |
| 1192 | errdefer self.freeTextBlock(&decl.link.macho); | 1192 | errdefer self.freeTextBlock(&decl.link.macho); |
| 1193 | 1193 | ||
| 1194 | symbol.* = .{ | 1194 | symbol.* = .{ |
src/link/Wasm.zig+3-3| ... | @@ -321,7 +321,7 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void { | ... | @@ -321,7 +321,7 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void { |
| 321 | id_symlink_basename, | 321 | id_symlink_basename, |
| 322 | &prev_digest_buf, | 322 | &prev_digest_buf, |
| 323 | ) catch |err| blk: { | 323 | ) 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) }); |
| 325 | // Handle this as a cache miss. | 325 | // Handle this as a cache miss. |
| 326 | break :blk prev_digest_buf[0..0]; | 326 | break :blk prev_digest_buf[0..0]; |
| 327 | }; | 327 | }; |
| ... | @@ -463,11 +463,11 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void { | ... | @@ -463,11 +463,11 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void { |
| 463 | // Update the file with the digest. If it fails we can continue; it only | 463 | // Update the file with the digest. If it fails we can continue; it only |
| 464 | // means that the next invocation will have an unnecessary cache miss. | 464 | // means that the next invocation will have an unnecessary cache miss. |
| 465 | Cache.writeSmallFile(directory.handle, id_symlink_basename, &digest) catch |err| { | 465 | 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)}); |
| 467 | }; | 467 | }; |
| 468 | // Again failure here only means an unnecessary cache miss. | 468 | // Again failure here only means an unnecessary cache miss. |
| 469 | man.writeManifest() catch |err| { | 469 | 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)}); |
| 471 | }; | 471 | }; |
| 472 | // We hang on to this lock so that the output file path can be used without | 472 | // We hang on to this lock so that the output file path can be used without |
| 473 | // other processes clobbering it. | 473 | // other processes clobbering it. |
src/liveness.zig+2-1| ... | @@ -1,6 +1,7 @@ | ... | @@ -1,6 +1,7 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const ir = @import("ir.zig"); | 2 | const ir = @import("ir.zig"); |
| 3 | const trace = @import("tracy.zig").trace; | 3 | const trace = @import("tracy.zig").trace; |
| 4 | const log = std.log.scoped(.liveness); | ||
| 4 | 5 | ||
| 5 | /// Perform Liveness Analysis over the `Body`. Each `Inst` will have its `deaths` field populated. | 6 | /// Perform Liveness Analysis over the `Body`. Each `Inst` will have its `deaths` field populated. |
| 6 | pub fn analyze( | 7 | pub fn analyze( |
| ... | @@ -248,5 +249,5 @@ fn analyzeInst( | ... | @@ -248,5 +249,5 @@ fn analyzeInst( |
| 248 | @panic("Handle liveness analysis for instructions with many parameters"); | 249 | @panic("Handle liveness analysis for instructions with many parameters"); |
| 249 | } | 250 | } |
| 250 | 251 | ||
| 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 }); |
| 252 | } | 253 | } |
src/llvm_backend.zig+1-1| ... | @@ -132,7 +132,7 @@ pub fn targetTriple(allocator: *Allocator, target: std.Target) ![:0]u8 { | ... | @@ -132,7 +132,7 @@ pub fn targetTriple(allocator: *Allocator, target: std.Target) ![:0]u8 { |
| 132 | .macabi => "macabi", | 132 | .macabi => "macabi", |
| 133 | }; | 133 | }; |
| 134 | 134 | ||
| 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 }); |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | pub const LLVMIRModule = struct { | 138 | pub const LLVMIRModule = struct { |
src/main.zig+121-121| ... | @@ -118,7 +118,7 @@ pub fn main() anyerror!void { | ... | @@ -118,7 +118,7 @@ pub fn main() anyerror!void { |
| 118 | 118 | ||
| 119 | pub fn mainArgs(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !void { | 119 | pub fn mainArgs(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !void { |
| 120 | if (args.len <= 1) { | 120 | if (args.len <= 1) { |
| 121 | std.log.info("{}", .{usage}); | 121 | std.log.info("{s}", .{usage}); |
| 122 | fatal("expected command argument", .{}); | 122 | fatal("expected command argument", .{}); |
| 123 | } | 123 | } |
| 124 | 124 | ||
| ... | @@ -204,8 +204,8 @@ pub fn mainArgs(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v | ... | @@ -204,8 +204,8 @@ pub fn mainArgs(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v |
| 204 | } else if (mem.eql(u8, cmd, "help") or mem.eql(u8, cmd, "-h") or mem.eql(u8, cmd, "--help")) { | 204 | } else if (mem.eql(u8, cmd, "help") or mem.eql(u8, cmd, "-h") or mem.eql(u8, cmd, "--help")) { |
| 205 | try io.getStdOut().writeAll(usage); | 205 | try io.getStdOut().writeAll(usage); |
| 206 | } else { | 206 | } else { |
| 207 | std.log.info("{}", .{usage}); | 207 | std.log.info("{s}", .{usage}); |
| 208 | fatal("unknown command: {}", .{args[1]}); | 208 | fatal("unknown command: {s}", .{args[1]}); |
| 209 | } | 209 | } |
| 210 | } | 210 | } |
| 211 | 211 | ||
| ... | @@ -615,7 +615,7 @@ fn buildOutputType( | ... | @@ -615,7 +615,7 @@ fn buildOutputType( |
| 615 | fatal("unexpected end-of-parameter mark: --", .{}); | 615 | fatal("unexpected end-of-parameter mark: --", .{}); |
| 616 | } | 616 | } |
| 617 | } else if (mem.eql(u8, arg, "--pkg-begin")) { | 617 | } 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}); |
| 619 | i += 1; | 619 | i += 1; |
| 620 | const pkg_name = args[i]; | 620 | const pkg_name = args[i]; |
| 621 | i += 1; | 621 | i += 1; |
| ... | @@ -626,7 +626,7 @@ fn buildOutputType( | ... | @@ -626,7 +626,7 @@ fn buildOutputType( |
| 626 | fs.path.dirname(pkg_path), | 626 | fs.path.dirname(pkg_path), |
| 627 | fs.path.basename(pkg_path), | 627 | fs.path.basename(pkg_path), |
| 628 | ) catch |err| { | 628 | ) 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) }); |
| 630 | }; | 630 | }; |
| 631 | new_cur_pkg.parent = cur_pkg; | 631 | new_cur_pkg.parent = cur_pkg; |
| 632 | try cur_pkg.add(gpa, pkg_name, new_cur_pkg); | 632 | try cur_pkg.add(gpa, pkg_name, new_cur_pkg); |
| ... | @@ -635,7 +635,7 @@ fn buildOutputType( | ... | @@ -635,7 +635,7 @@ fn buildOutputType( |
| 635 | cur_pkg = cur_pkg.parent orelse | 635 | cur_pkg = cur_pkg.parent orelse |
| 636 | fatal("encountered --pkg-end with no matching --pkg-begin", .{}); | 636 | fatal("encountered --pkg-end with no matching --pkg-begin", .{}); |
| 637 | } else if (mem.eql(u8, arg, "--main-pkg-path")) { | 637 | } 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}); |
| 639 | i += 1; | 639 | i += 1; |
| 640 | main_pkg_path = args[i]; | 640 | main_pkg_path = args[i]; |
| 641 | } else if (mem.eql(u8, arg, "-cflags")) { | 641 | } else if (mem.eql(u8, arg, "-cflags")) { |
| ... | @@ -653,10 +653,10 @@ fn buildOutputType( | ... | @@ -653,10 +653,10 @@ fn buildOutputType( |
| 653 | i += 1; | 653 | i += 1; |
| 654 | const next_arg = args[i]; | 654 | const next_arg = args[i]; |
| 655 | color = std.meta.stringToEnum(Color, next_arg) orelse { | 655 | 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}); |
| 657 | }; | 657 | }; |
| 658 | } else if (mem.eql(u8, arg, "--subsystem")) { | 658 | } 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}); |
| 660 | i += 1; | 660 | i += 1; |
| 661 | if (mem.eql(u8, args[i], "console")) { | 661 | if (mem.eql(u8, args[i], "console")) { |
| 662 | subsystem = .Console; | 662 | subsystem = .Console; |
| ... | @@ -689,51 +689,51 @@ fn buildOutputType( | ... | @@ -689,51 +689,51 @@ fn buildOutputType( |
| 689 | }); | 689 | }); |
| 690 | } | 690 | } |
| 691 | } else if (mem.eql(u8, arg, "-O")) { | 691 | } 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}); |
| 693 | i += 1; | 693 | i += 1; |
| 694 | optimize_mode_string = args[i]; | 694 | optimize_mode_string = args[i]; |
| 695 | } else if (mem.eql(u8, arg, "--stack")) { | 695 | } 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}); |
| 697 | i += 1; | 697 | i += 1; |
| 698 | stack_size_override = std.fmt.parseUnsigned(u64, args[i], 0) catch |err| { | 698 | 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) }); |
| 700 | }; | 700 | }; |
| 701 | } else if (mem.eql(u8, arg, "--image-base")) { | 701 | } 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}); |
| 703 | i += 1; | 703 | i += 1; |
| 704 | image_base_override = std.fmt.parseUnsigned(u64, args[i], 0) catch |err| { | 704 | 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) }); |
| 706 | }; | 706 | }; |
| 707 | } else if (mem.eql(u8, arg, "--name")) { | 707 | } 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}); |
| 709 | i += 1; | 709 | i += 1; |
| 710 | provided_name = args[i]; | 710 | provided_name = args[i]; |
| 711 | } else if (mem.eql(u8, arg, "-rpath")) { | 711 | } 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}); |
| 713 | i += 1; | 713 | i += 1; |
| 714 | try rpath_list.append(args[i]); | 714 | try rpath_list.append(args[i]); |
| 715 | } else if (mem.eql(u8, arg, "--library-directory") or mem.eql(u8, arg, "-L")) { | 715 | } 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}); |
| 717 | i += 1; | 717 | i += 1; |
| 718 | try lib_dirs.append(args[i]); | 718 | try lib_dirs.append(args[i]); |
| 719 | } else if (mem.eql(u8, arg, "-F")) { | 719 | } 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}); |
| 721 | i += 1; | 721 | i += 1; |
| 722 | try framework_dirs.append(args[i]); | 722 | try framework_dirs.append(args[i]); |
| 723 | } else if (mem.eql(u8, arg, "-framework")) { | 723 | } 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}); |
| 725 | i += 1; | 725 | i += 1; |
| 726 | try frameworks.append(args[i]); | 726 | try frameworks.append(args[i]); |
| 727 | } else if (mem.eql(u8, arg, "-T") or mem.eql(u8, arg, "--script")) { | 727 | } 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}); |
| 729 | i += 1; | 729 | i += 1; |
| 730 | linker_script = args[i]; | 730 | linker_script = args[i]; |
| 731 | } else if (mem.eql(u8, arg, "--version-script")) { | 731 | } 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}); |
| 733 | i += 1; | 733 | i += 1; |
| 734 | version_script = args[i]; | 734 | version_script = args[i]; |
| 735 | } else if (mem.eql(u8, arg, "--library") or mem.eql(u8, arg, "-l")) { | 735 | } 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}); |
| 737 | // We don't know whether this library is part of libc or libc++ until we resolve the target. | 737 | // We don't know whether this library is part of libc or libc++ until we resolve the target. |
| 738 | // So we simply append to the list for now. | 738 | // So we simply append to the list for now. |
| 739 | i += 1; | 739 | i += 1; |
| ... | @@ -743,7 +743,7 @@ fn buildOutputType( | ... | @@ -743,7 +743,7 @@ fn buildOutputType( |
| 743 | mem.eql(u8, arg, "-I") or | 743 | mem.eql(u8, arg, "-I") or |
| 744 | mem.eql(u8, arg, "-dirafter")) | 744 | mem.eql(u8, arg, "-dirafter")) |
| 745 | { | 745 | { |
| 746 | if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg}); | 746 | if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg}); |
| 747 | i += 1; | 747 | i += 1; |
| 748 | try clang_argv.append(arg); | 748 | try clang_argv.append(arg); |
| 749 | try clang_argv.append(args[i]); | 749 | try clang_argv.append(args[i]); |
| ... | @@ -753,19 +753,19 @@ fn buildOutputType( | ... | @@ -753,19 +753,19 @@ fn buildOutputType( |
| 753 | } | 753 | } |
| 754 | i += 1; | 754 | i += 1; |
| 755 | version = std.builtin.Version.parse(args[i]) catch |err| { | 755 | 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) }); |
| 757 | }; | 757 | }; |
| 758 | have_version = true; | 758 | have_version = true; |
| 759 | } else if (mem.eql(u8, arg, "-target")) { | 759 | } 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}); |
| 761 | i += 1; | 761 | i += 1; |
| 762 | target_arch_os_abi = args[i]; | 762 | target_arch_os_abi = args[i]; |
| 763 | } else if (mem.eql(u8, arg, "-mcpu")) { | 763 | } 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}); |
| 765 | i += 1; | 765 | i += 1; |
| 766 | target_mcpu = args[i]; | 766 | target_mcpu = args[i]; |
| 767 | } else if (mem.eql(u8, arg, "-mcmodel")) { | 767 | } 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}); |
| 769 | i += 1; | 769 | i += 1; |
| 770 | machine_code_model = parseCodeModel(args[i]); | 770 | machine_code_model = parseCodeModel(args[i]); |
| 771 | } else if (mem.startsWith(u8, arg, "-ofmt=")) { | 771 | } else if (mem.startsWith(u8, arg, "-ofmt=")) { |
| ... | @@ -777,35 +777,35 @@ fn buildOutputType( | ... | @@ -777,35 +777,35 @@ fn buildOutputType( |
| 777 | } else if (mem.startsWith(u8, arg, "-O")) { | 777 | } else if (mem.startsWith(u8, arg, "-O")) { |
| 778 | optimize_mode_string = arg["-O".len..]; | 778 | optimize_mode_string = arg["-O".len..]; |
| 779 | } else if (mem.eql(u8, arg, "--dynamic-linker")) { | 779 | } 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}); |
| 781 | i += 1; | 781 | i += 1; |
| 782 | target_dynamic_linker = args[i]; | 782 | target_dynamic_linker = args[i]; |
| 783 | } else if (mem.eql(u8, arg, "--libc")) { | 783 | } 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}); |
| 785 | i += 1; | 785 | i += 1; |
| 786 | libc_paths_file = args[i]; | 786 | libc_paths_file = args[i]; |
| 787 | } else if (mem.eql(u8, arg, "--test-filter")) { | 787 | } 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}); |
| 789 | i += 1; | 789 | i += 1; |
| 790 | test_filter = args[i]; | 790 | test_filter = args[i]; |
| 791 | } else if (mem.eql(u8, arg, "--test-name-prefix")) { | 791 | } 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}); |
| 793 | i += 1; | 793 | i += 1; |
| 794 | test_name_prefix = args[i]; | 794 | test_name_prefix = args[i]; |
| 795 | } else if (mem.eql(u8, arg, "--test-cmd")) { | 795 | } 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}); |
| 797 | i += 1; | 797 | i += 1; |
| 798 | try test_exec_args.append(args[i]); | 798 | try test_exec_args.append(args[i]); |
| 799 | } else if (mem.eql(u8, arg, "--cache-dir")) { | 799 | } 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}); |
| 801 | i += 1; | 801 | i += 1; |
| 802 | override_local_cache_dir = args[i]; | 802 | override_local_cache_dir = args[i]; |
| 803 | } else if (mem.eql(u8, arg, "--global-cache-dir")) { | 803 | } 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}); |
| 805 | i += 1; | 805 | i += 1; |
| 806 | override_global_cache_dir = args[i]; | 806 | override_global_cache_dir = args[i]; |
| 807 | } else if (mem.eql(u8, arg, "--override-lib-dir")) { | 807 | } 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}); |
| 809 | i += 1; | 809 | i += 1; |
| 810 | override_lib_dir = args[i]; | 810 | override_lib_dir = args[i]; |
| 811 | } else if (mem.eql(u8, arg, "-fcompiler-rt")) { | 811 | } else if (mem.eql(u8, arg, "-fcompiler-rt")) { |
| ... | @@ -968,7 +968,7 @@ fn buildOutputType( | ... | @@ -968,7 +968,7 @@ fn buildOutputType( |
| 968 | { | 968 | { |
| 969 | try clang_argv.append(arg); | 969 | try clang_argv.append(arg); |
| 970 | } else { | 970 | } else { |
| 971 | fatal("unrecognized parameter: '{}'", .{arg}); | 971 | fatal("unrecognized parameter: '{s}'", .{arg}); |
| 972 | } | 972 | } |
| 973 | } else switch (Compilation.classifyFileExt(arg)) { | 973 | } else switch (Compilation.classifyFileExt(arg)) { |
| 974 | .object, .static_library, .shared_library => { | 974 | .object, .static_library, .shared_library => { |
| ... | @@ -982,19 +982,19 @@ fn buildOutputType( | ... | @@ -982,19 +982,19 @@ fn buildOutputType( |
| 982 | }, | 982 | }, |
| 983 | .zig, .zir => { | 983 | .zig, .zir => { |
| 984 | if (root_src_file) |other| { | 984 | 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 }); |
| 986 | } else { | 986 | } else { |
| 987 | root_src_file = arg; | 987 | root_src_file = arg; |
| 988 | } | 988 | } |
| 989 | }, | 989 | }, |
| 990 | .unknown => { | 990 | .unknown => { |
| 991 | fatal("unrecognized file extension of parameter '{}'", .{arg}); | 991 | fatal("unrecognized file extension of parameter '{s}'", .{arg}); |
| 992 | }, | 992 | }, |
| 993 | } | 993 | } |
| 994 | } | 994 | } |
| 995 | if (optimize_mode_string) |s| { | 995 | if (optimize_mode_string) |s| { |
| 996 | optimize_mode = std.meta.stringToEnum(std.builtin.Mode, s) orelse | 996 | optimize_mode = std.meta.stringToEnum(std.builtin.Mode, s) orelse |
| 997 | fatal("unrecognized optimization mode: '{}'", .{s}); | 997 | fatal("unrecognized optimization mode: '{s}'", .{s}); |
| 998 | } | 998 | } |
| 999 | }, | 999 | }, |
| 1000 | .cc, .cpp => { | 1000 | .cc, .cpp => { |
| ... | @@ -1018,7 +1018,7 @@ fn buildOutputType( | ... | @@ -1018,7 +1018,7 @@ fn buildOutputType( |
| 1018 | var it = ClangArgIterator.init(arena, all_args); | 1018 | var it = ClangArgIterator.init(arena, all_args); |
| 1019 | while (it.has_next) { | 1019 | while (it.has_next) { |
| 1020 | it.next() catch |err| { | 1020 | 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)}); |
| 1022 | }; | 1022 | }; |
| 1023 | switch (it.zig_equivalent) { | 1023 | switch (it.zig_equivalent) { |
| 1024 | .target => target_arch_os_abi = it.only_arg, // example: -target riscv64-linux-unknown | 1024 | .target => target_arch_os_abi = it.only_arg, // example: -target riscv64-linux-unknown |
| ... | @@ -1038,7 +1038,7 @@ fn buildOutputType( | ... | @@ -1038,7 +1038,7 @@ fn buildOutputType( |
| 1038 | }, | 1038 | }, |
| 1039 | .zig, .zir => { | 1039 | .zig, .zir => { |
| 1040 | if (root_src_file) |other| { | 1040 | 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 }); |
| 1042 | } else { | 1042 | } else { |
| 1043 | root_src_file = it.only_arg; | 1043 | root_src_file = it.only_arg; |
| 1044 | } | 1044 | } |
| ... | @@ -1153,7 +1153,7 @@ fn buildOutputType( | ... | @@ -1153,7 +1153,7 @@ fn buildOutputType( |
| 1153 | if (mem.eql(u8, arg, "-soname")) { | 1153 | if (mem.eql(u8, arg, "-soname")) { |
| 1154 | i += 1; | 1154 | i += 1; |
| 1155 | if (i >= linker_args.items.len) { | 1155 | if (i >= linker_args.items.len) { |
| 1156 | fatal("expected linker arg after '{}'", .{arg}); | 1156 | fatal("expected linker arg after '{s}'", .{arg}); |
| 1157 | } | 1157 | } |
| 1158 | const name = linker_args.items[i]; | 1158 | const name = linker_args.items[i]; |
| 1159 | soname = .{ .yes = name }; | 1159 | soname = .{ .yes = name }; |
| ... | @@ -1185,7 +1185,7 @@ fn buildOutputType( | ... | @@ -1185,7 +1185,7 @@ fn buildOutputType( |
| 1185 | } else if (mem.eql(u8, arg, "-rpath")) { | 1185 | } else if (mem.eql(u8, arg, "-rpath")) { |
| 1186 | i += 1; | 1186 | i += 1; |
| 1187 | if (i >= linker_args.items.len) { | 1187 | if (i >= linker_args.items.len) { |
| 1188 | fatal("expected linker arg after '{}'", .{arg}); | 1188 | fatal("expected linker arg after '{s}'", .{arg}); |
| 1189 | } | 1189 | } |
| 1190 | try rpath_list.append(linker_args.items[i]); | 1190 | try rpath_list.append(linker_args.items[i]); |
| 1191 | } else if (mem.eql(u8, arg, "-I") or | 1191 | } else if (mem.eql(u8, arg, "-I") or |
| ... | @@ -1194,7 +1194,7 @@ fn buildOutputType( | ... | @@ -1194,7 +1194,7 @@ fn buildOutputType( |
| 1194 | { | 1194 | { |
| 1195 | i += 1; | 1195 | i += 1; |
| 1196 | if (i >= linker_args.items.len) { | 1196 | if (i >= linker_args.items.len) { |
| 1197 | fatal("expected linker arg after '{}'", .{arg}); | 1197 | fatal("expected linker arg after '{s}'", .{arg}); |
| 1198 | } | 1198 | } |
| 1199 | target_dynamic_linker = linker_args.items[i]; | 1199 | target_dynamic_linker = linker_args.items[i]; |
| 1200 | } else if (mem.eql(u8, arg, "-E") or | 1200 | } else if (mem.eql(u8, arg, "-E") or |
| ... | @@ -1205,7 +1205,7 @@ fn buildOutputType( | ... | @@ -1205,7 +1205,7 @@ fn buildOutputType( |
| 1205 | } else if (mem.eql(u8, arg, "--version-script")) { | 1205 | } else if (mem.eql(u8, arg, "--version-script")) { |
| 1206 | i += 1; | 1206 | i += 1; |
| 1207 | if (i >= linker_args.items.len) { | 1207 | if (i >= linker_args.items.len) { |
| 1208 | fatal("expected linker arg after '{}'", .{arg}); | 1208 | fatal("expected linker arg after '{s}'", .{arg}); |
| 1209 | } | 1209 | } |
| 1210 | version_script = linker_args.items[i]; | 1210 | version_script = linker_args.items[i]; |
| 1211 | } else if (mem.startsWith(u8, arg, "-O")) { | 1211 | } else if (mem.startsWith(u8, arg, "-O")) { |
| ... | @@ -1227,7 +1227,7 @@ fn buildOutputType( | ... | @@ -1227,7 +1227,7 @@ fn buildOutputType( |
| 1227 | } else if (mem.eql(u8, arg, "-z")) { | 1227 | } else if (mem.eql(u8, arg, "-z")) { |
| 1228 | i += 1; | 1228 | i += 1; |
| 1229 | if (i >= linker_args.items.len) { | 1229 | if (i >= linker_args.items.len) { |
| 1230 | fatal("expected linker arg after '{}'", .{arg}); | 1230 | fatal("expected linker arg after '{s}'", .{arg}); |
| 1231 | } | 1231 | } |
| 1232 | const z_arg = linker_args.items[i]; | 1232 | const z_arg = linker_args.items[i]; |
| 1233 | if (mem.eql(u8, z_arg, "nodelete")) { | 1233 | if (mem.eql(u8, z_arg, "nodelete")) { |
| ... | @@ -1235,44 +1235,44 @@ fn buildOutputType( | ... | @@ -1235,44 +1235,44 @@ fn buildOutputType( |
| 1235 | } else if (mem.eql(u8, z_arg, "defs")) { | 1235 | } else if (mem.eql(u8, z_arg, "defs")) { |
| 1236 | linker_z_defs = true; | 1236 | linker_z_defs = true; |
| 1237 | } else { | 1237 | } else { |
| 1238 | warn("unsupported linker arg: -z {}", .{z_arg}); | 1238 | warn("unsupported linker arg: -z {s}", .{z_arg}); |
| 1239 | } | 1239 | } |
| 1240 | } else if (mem.eql(u8, arg, "--major-image-version")) { | 1240 | } else if (mem.eql(u8, arg, "--major-image-version")) { |
| 1241 | i += 1; | 1241 | i += 1; |
| 1242 | if (i >= linker_args.items.len) { | 1242 | if (i >= linker_args.items.len) { |
| 1243 | fatal("expected linker arg after '{}'", .{arg}); | 1243 | fatal("expected linker arg after '{s}'", .{arg}); |
| 1244 | } | 1244 | } |
| 1245 | version.major = std.fmt.parseUnsigned(u32, linker_args.items[i], 10) catch |err| { | 1245 | 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) }); |
| 1247 | }; | 1247 | }; |
| 1248 | have_version = true; | 1248 | have_version = true; |
| 1249 | } else if (mem.eql(u8, arg, "--minor-image-version")) { | 1249 | } else if (mem.eql(u8, arg, "--minor-image-version")) { |
| 1250 | i += 1; | 1250 | i += 1; |
| 1251 | if (i >= linker_args.items.len) { | 1251 | if (i >= linker_args.items.len) { |
| 1252 | fatal("expected linker arg after '{}'", .{arg}); | 1252 | fatal("expected linker arg after '{s}'", .{arg}); |
| 1253 | } | 1253 | } |
| 1254 | version.minor = std.fmt.parseUnsigned(u32, linker_args.items[i], 10) catch |err| { | 1254 | 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) }); |
| 1256 | }; | 1256 | }; |
| 1257 | have_version = true; | 1257 | have_version = true; |
| 1258 | } else if (mem.eql(u8, arg, "--stack")) { | 1258 | } else if (mem.eql(u8, arg, "--stack")) { |
| 1259 | i += 1; | 1259 | i += 1; |
| 1260 | if (i >= linker_args.items.len) { | 1260 | if (i >= linker_args.items.len) { |
| 1261 | fatal("expected linker arg after '{}'", .{arg}); | 1261 | fatal("expected linker arg after '{s}'", .{arg}); |
| 1262 | } | 1262 | } |
| 1263 | stack_size_override = std.fmt.parseUnsigned(u64, linker_args.items[i], 0) catch |err| { | 1263 | 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) }); |
| 1265 | }; | 1265 | }; |
| 1266 | } else if (mem.eql(u8, arg, "--image-base")) { | 1266 | } else if (mem.eql(u8, arg, "--image-base")) { |
| 1267 | i += 1; | 1267 | i += 1; |
| 1268 | if (i >= linker_args.items.len) { | 1268 | if (i >= linker_args.items.len) { |
| 1269 | fatal("expected linker arg after '{}'", .{arg}); | 1269 | fatal("expected linker arg after '{s}'", .{arg}); |
| 1270 | } | 1270 | } |
| 1271 | image_base_override = std.fmt.parseUnsigned(u64, linker_args.items[i], 0) catch |err| { | 1271 | 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) }); |
| 1273 | }; | 1273 | }; |
| 1274 | } else { | 1274 | } else { |
| 1275 | warn("unsupported linker arg: {}", .{arg}); | 1275 | warn("unsupported linker arg: {s}", .{arg}); |
| 1276 | } | 1276 | } |
| 1277 | } | 1277 | } |
| 1278 | 1278 | ||
| ... | @@ -1328,7 +1328,7 @@ fn buildOutputType( | ... | @@ -1328,7 +1328,7 @@ fn buildOutputType( |
| 1328 | } | 1328 | } |
| 1329 | 1329 | ||
| 1330 | if (arg_mode == .translate_c and c_source_files.items.len != 1) { | 1330 | 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}); |
| 1332 | } | 1332 | } |
| 1333 | 1333 | ||
| 1334 | if (root_src_file == null and arg_mode == .zig_test) { | 1334 | if (root_src_file == null and arg_mode == .zig_test) { |
| ... | @@ -1373,25 +1373,25 @@ fn buildOutputType( | ... | @@ -1373,25 +1373,25 @@ fn buildOutputType( |
| 1373 | help: { | 1373 | help: { |
| 1374 | var help_text = std.ArrayList(u8).init(arena); | 1374 | var help_text = std.ArrayList(u8).init(arena); |
| 1375 | for (diags.arch.?.allCpuModels()) |cpu| { | 1375 | 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; |
| 1377 | } | 1377 | } |
| 1378 | std.log.info("Available CPUs for architecture '{}': {}", .{ | 1378 | std.log.info("Available CPUs for architecture '{s}': {s}", .{ |
| 1379 | @tagName(diags.arch.?), help_text.items, | 1379 | @tagName(diags.arch.?), help_text.items, |
| 1380 | }); | 1380 | }); |
| 1381 | } | 1381 | } |
| 1382 | fatal("Unknown CPU: '{}'", .{diags.cpu_name.?}); | 1382 | fatal("Unknown CPU: '{s}'", .{diags.cpu_name.?}); |
| 1383 | }, | 1383 | }, |
| 1384 | error.UnknownCpuFeature => { | 1384 | error.UnknownCpuFeature => { |
| 1385 | help: { | 1385 | help: { |
| 1386 | var help_text = std.ArrayList(u8).init(arena); | 1386 | var help_text = std.ArrayList(u8).init(arena); |
| 1387 | for (diags.arch.?.allFeaturesList()) |feature| { | 1387 | 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; |
| 1389 | } | 1389 | } |
| 1390 | std.log.info("Available CPU features for architecture '{}': {}", .{ | 1390 | std.log.info("Available CPU features for architecture '{s}': {s}", .{ |
| 1391 | @tagName(diags.arch.?), help_text.items, | 1391 | @tagName(diags.arch.?), help_text.items, |
| 1392 | }); | 1392 | }); |
| 1393 | } | 1393 | } |
| 1394 | fatal("Unknown CPU feature: '{}'", .{diags.unknown_feature_name}); | 1394 | fatal("Unknown CPU feature: '{s}'", .{diags.unknown_feature_name}); |
| 1395 | }, | 1395 | }, |
| 1396 | else => |e| return e, | 1396 | else => |e| return e, |
| 1397 | }; | 1397 | }; |
| ... | @@ -1431,10 +1431,10 @@ fn buildOutputType( | ... | @@ -1431,10 +1431,10 @@ fn buildOutputType( |
| 1431 | 1431 | ||
| 1432 | if (cross_target.isNativeOs() and (system_libs.items.len != 0 or want_native_include_dirs)) { | 1432 | if (cross_target.isNativeOs() and (system_libs.items.len != 0 or want_native_include_dirs)) { |
| 1433 | const paths = std.zig.system.NativePaths.detect(arena) catch |err| { | 1433 | 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)}); |
| 1435 | }; | 1435 | }; |
| 1436 | for (paths.warnings.items) |warning| { | 1436 | for (paths.warnings.items) |warning| { |
| 1437 | warn("{}", .{warning}); | 1437 | warn("{s}", .{warning}); |
| 1438 | } | 1438 | } |
| 1439 | 1439 | ||
| 1440 | const has_sysroot = if (comptime std.Target.current.isDarwin()) outer: { | 1440 | const has_sysroot = if (comptime std.Target.current.isDarwin()) outer: { |
| ... | @@ -1492,7 +1492,7 @@ fn buildOutputType( | ... | @@ -1492,7 +1492,7 @@ fn buildOutputType( |
| 1492 | } else if (mem.eql(u8, ofmt, "raw")) { | 1492 | } else if (mem.eql(u8, ofmt, "raw")) { |
| 1493 | break :blk .raw; | 1493 | break :blk .raw; |
| 1494 | } else { | 1494 | } else { |
| 1495 | fatal("unsupported object format: {}", .{ofmt}); | 1495 | fatal("unsupported object format: {s}", .{ofmt}); |
| 1496 | } | 1496 | } |
| 1497 | }; | 1497 | }; |
| 1498 | 1498 | ||
| ... | @@ -1562,7 +1562,7 @@ fn buildOutputType( | ... | @@ -1562,7 +1562,7 @@ fn buildOutputType( |
| 1562 | } | 1562 | } |
| 1563 | if (fs.path.dirname(full_path)) |dirname| { | 1563 | if (fs.path.dirname(full_path)) |dirname| { |
| 1564 | const handle = fs.cwd().openDir(dirname, .{}) catch |err| { | 1564 | 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) }); |
| 1566 | }; | 1566 | }; |
| 1567 | cleanup_emit_bin_dir = handle; | 1567 | cleanup_emit_bin_dir = handle; |
| 1568 | break :b Compilation.EmitLoc{ | 1568 | break :b Compilation.EmitLoc{ |
| ... | @@ -1585,19 +1585,19 @@ fn buildOutputType( | ... | @@ -1585,19 +1585,19 @@ fn buildOutputType( |
| 1585 | }, | 1585 | }, |
| 1586 | }; | 1586 | }; |
| 1587 | 1587 | ||
| 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}); |
| 1589 | var emit_h_resolved = try emit_h.resolve(default_h_basename); | 1589 | var emit_h_resolved = try emit_h.resolve(default_h_basename); |
| 1590 | defer emit_h_resolved.deinit(); | 1590 | defer emit_h_resolved.deinit(); |
| 1591 | 1591 | ||
| 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}); |
| 1593 | var emit_asm_resolved = try emit_asm.resolve(default_asm_basename); | 1593 | var emit_asm_resolved = try emit_asm.resolve(default_asm_basename); |
| 1594 | defer emit_asm_resolved.deinit(); | 1594 | defer emit_asm_resolved.deinit(); |
| 1595 | 1595 | ||
| 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}); |
| 1597 | var emit_llvm_ir_resolved = try emit_llvm_ir.resolve(default_llvm_ir_basename); | 1597 | var emit_llvm_ir_resolved = try emit_llvm_ir.resolve(default_llvm_ir_basename); |
| 1598 | defer emit_llvm_ir_resolved.deinit(); | 1598 | defer emit_llvm_ir_resolved.deinit(); |
| 1599 | 1599 | ||
| 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}); |
| 1601 | var emit_analysis_resolved = try emit_analysis.resolve(default_analysis_basename); | 1601 | var emit_analysis_resolved = try emit_analysis.resolve(default_analysis_basename); |
| 1602 | defer emit_analysis_resolved.deinit(); | 1602 | defer emit_analysis_resolved.deinit(); |
| 1603 | 1603 | ||
| ... | @@ -1609,10 +1609,10 @@ fn buildOutputType( | ... | @@ -1609,10 +1609,10 @@ fn buildOutputType( |
| 1609 | .yes_default_path => blk: { | 1609 | .yes_default_path => blk: { |
| 1610 | if (root_src_file) |rsf| { | 1610 | if (root_src_file) |rsf| { |
| 1611 | if (mem.endsWith(u8, rsf, ".zir")) { | 1611 | 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}); |
| 1613 | } | 1613 | } |
| 1614 | } | 1614 | } |
| 1615 | break :blk try std.fmt.allocPrint(arena, "{}.zir", .{root_name}); | 1615 | break :blk try std.fmt.allocPrint(arena, "{s}.zir", .{root_name}); |
| 1616 | }, | 1616 | }, |
| 1617 | .yes => |p| p, | 1617 | .yes => |p| p, |
| 1618 | }; | 1618 | }; |
| ... | @@ -1642,7 +1642,7 @@ fn buildOutputType( | ... | @@ -1642,7 +1642,7 @@ fn buildOutputType( |
| 1642 | } | 1642 | } |
| 1643 | else | 1643 | else |
| 1644 | introspect.findZigLibDirFromSelfExe(arena, self_exe_path) catch |err| { | 1644 | 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)}); |
| 1646 | }; | 1646 | }; |
| 1647 | defer zig_lib_directory.handle.close(); | 1647 | defer zig_lib_directory.handle.close(); |
| 1648 | 1648 | ||
| ... | @@ -1655,7 +1655,7 @@ fn buildOutputType( | ... | @@ -1655,7 +1655,7 @@ fn buildOutputType( |
| 1655 | 1655 | ||
| 1656 | if (libc_paths_file) |paths_file| { | 1656 | if (libc_paths_file) |paths_file| { |
| 1657 | libc_installation = LibCInstallation.parse(gpa, paths_file) catch |err| { | 1657 | 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)}); |
| 1659 | }; | 1659 | }; |
| 1660 | } | 1660 | } |
| 1661 | 1661 | ||
| ... | @@ -1791,7 +1791,7 @@ fn buildOutputType( | ... | @@ -1791,7 +1791,7 @@ fn buildOutputType( |
| 1791 | .disable_lld_caching = !have_enable_cache, | 1791 | .disable_lld_caching = !have_enable_cache, |
| 1792 | .subsystem = subsystem, | 1792 | .subsystem = subsystem, |
| 1793 | }) catch |err| { | 1793 | }) catch |err| { |
| 1794 | fatal("unable to create compilation: {}", .{@errorName(err)}); | 1794 | fatal("unable to create compilation: {s}", .{@errorName(err)}); |
| 1795 | }; | 1795 | }; |
| 1796 | var comp_destroyed = false; | 1796 | var comp_destroyed = false; |
| 1797 | defer if (!comp_destroyed) comp.destroy(); | 1797 | defer if (!comp_destroyed) comp.destroy(); |
| ... | @@ -1914,12 +1914,12 @@ fn buildOutputType( | ... | @@ -1914,12 +1914,12 @@ fn buildOutputType( |
| 1914 | if (!watch) return cleanExit(); | 1914 | if (!watch) return cleanExit(); |
| 1915 | } else { | 1915 | } else { |
| 1916 | const cmd = try argvCmd(arena, argv.items); | 1916 | 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 }); |
| 1918 | } | 1918 | } |
| 1919 | }, | 1919 | }, |
| 1920 | else => { | 1920 | else => { |
| 1921 | const cmd = try argvCmd(arena, argv.items); | 1921 | 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}); |
| 1923 | }, | 1923 | }, |
| 1924 | } | 1924 | } |
| 1925 | }, | 1925 | }, |
| ... | @@ -1936,7 +1936,7 @@ fn buildOutputType( | ... | @@ -1936,7 +1936,7 @@ fn buildOutputType( |
| 1936 | try stderr.print("(zig) ", .{}); | 1936 | try stderr.print("(zig) ", .{}); |
| 1937 | try comp.makeBinFileExecutable(); | 1937 | try comp.makeBinFileExecutable(); |
| 1938 | if (stdin.readUntilDelimiterOrEof(&repl_buf, '\n') catch |err| { | 1938 | 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)}); |
| 1940 | continue; | 1940 | continue; |
| 1941 | }) |line| { | 1941 | }) |line| { |
| 1942 | const actual_line = mem.trimRight(u8, line, "\r\n "); | 1942 | const actual_line = mem.trimRight(u8, line, "\r\n "); |
| ... | @@ -1954,7 +1954,7 @@ fn buildOutputType( | ... | @@ -1954,7 +1954,7 @@ fn buildOutputType( |
| 1954 | } else if (mem.eql(u8, actual_line, "help")) { | 1954 | } else if (mem.eql(u8, actual_line, "help")) { |
| 1955 | try stderr.writeAll(repl_help); | 1955 | try stderr.writeAll(repl_help); |
| 1956 | } else { | 1956 | } else { |
| 1957 | try stderr.print("unknown command: {}\n", .{actual_line}); | 1957 | try stderr.print("unknown command: {s}\n", .{actual_line}); |
| 1958 | } | 1958 | } |
| 1959 | } else { | 1959 | } else { |
| 1960 | break; | 1960 | break; |
| ... | @@ -2012,14 +2012,14 @@ fn cmdTranslateC(comp: *Compilation, arena: *Allocator, enable_cache: bool) !voi | ... | @@ -2012,14 +2012,14 @@ fn cmdTranslateC(comp: *Compilation, arena: *Allocator, enable_cache: bool) !voi |
| 2012 | assert(comp.c_source_files.len == 1); | 2012 | assert(comp.c_source_files.len == 1); |
| 2013 | const c_source_file = comp.c_source_files[0]; | 2013 | const c_source_file = comp.c_source_files[0]; |
| 2014 | 2014 | ||
| 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}); |
| 2016 | 2016 | ||
| 2017 | var man: Cache.Manifest = comp.obtainCObjectCacheManifest(); | 2017 | var man: Cache.Manifest = comp.obtainCObjectCacheManifest(); |
| 2018 | defer if (enable_cache) man.deinit(); | 2018 | defer if (enable_cache) man.deinit(); |
| 2019 | 2019 | ||
| 2020 | man.hash.add(@as(u16, 0xb945)); // Random number to distinguish translate-c from compiling C objects | 2020 | man.hash.add(@as(u16, 0xb945)); // Random number to distinguish translate-c from compiling C objects |
| 2021 | _ = man.addFile(c_source_file.src_path, null) catch |err| { | 2021 | _ = 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) }); |
| 2023 | }; | 2023 | }; |
| 2024 | 2024 | ||
| 2025 | const digest = if (try man.hit()) man.final() else digest: { | 2025 | const digest = if (try man.hit()) man.final() else digest: { |
| ... | @@ -2034,7 +2034,7 @@ fn cmdTranslateC(comp: *Compilation, arena: *Allocator, enable_cache: bool) !voi | ... | @@ -2034,7 +2034,7 @@ fn cmdTranslateC(comp: *Compilation, arena: *Allocator, enable_cache: bool) !voi |
| 2034 | break :blk null; | 2034 | break :blk null; |
| 2035 | 2035 | ||
| 2036 | const c_src_basename = fs.path.basename(c_source_file.src_path); | 2036 | 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}); |
| 2038 | const out_dep_path = try comp.tmpFilePath(arena, dep_basename); | 2038 | const out_dep_path = try comp.tmpFilePath(arena, dep_basename); |
| 2039 | break :blk out_dep_path; | 2039 | break :blk out_dep_path; |
| 2040 | }; | 2040 | }; |
| ... | @@ -2069,7 +2069,7 @@ fn cmdTranslateC(comp: *Compilation, arena: *Allocator, enable_cache: bool) !voi | ... | @@ -2069,7 +2069,7 @@ fn cmdTranslateC(comp: *Compilation, arena: *Allocator, enable_cache: bool) !voi |
| 2069 | 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", .{}), | 2069 | 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", .{}), |
| 2070 | error.SemanticAnalyzeFail => { | 2070 | error.SemanticAnalyzeFail => { |
| 2071 | for (clang_errors) |clang_err| { | 2071 | for (clang_errors) |clang_err| { |
| 2072 | std.debug.print("{}:{}:{}: {}\n", .{ | 2072 | std.debug.print("{s}:{d}:{d}: {s}\n", .{ |
| 2073 | if (clang_err.filename_ptr) |p| p[0..clang_err.filename_len] else "(no file)", | 2073 | if (clang_err.filename_ptr) |p| p[0..clang_err.filename_len] else "(no file)", |
| 2074 | clang_err.line + 1, | 2074 | clang_err.line + 1, |
| 2075 | clang_err.column + 1, | 2075 | clang_err.column + 1, |
| ... | @@ -2087,7 +2087,7 @@ fn cmdTranslateC(comp: *Compilation, arena: *Allocator, enable_cache: bool) !voi | ... | @@ -2087,7 +2087,7 @@ fn cmdTranslateC(comp: *Compilation, arena: *Allocator, enable_cache: bool) !voi |
| 2087 | try man.addDepFilePost(zig_cache_tmp_dir, dep_basename); | 2087 | try man.addDepFilePost(zig_cache_tmp_dir, dep_basename); |
| 2088 | // Just to save disk space, we delete the file because it is never needed again. | 2088 | // Just to save disk space, we delete the file because it is never needed again. |
| 2089 | zig_cache_tmp_dir.deleteFile(dep_basename) catch |err| { | 2089 | 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) }); |
| 2091 | }; | 2091 | }; |
| 2092 | } | 2092 | } |
| 2093 | 2093 | ||
| ... | @@ -2102,7 +2102,7 @@ fn cmdTranslateC(comp: *Compilation, arena: *Allocator, enable_cache: bool) !voi | ... | @@ -2102,7 +2102,7 @@ fn cmdTranslateC(comp: *Compilation, arena: *Allocator, enable_cache: bool) !voi |
| 2102 | _ = try std.zig.render(comp.gpa, bos.writer(), tree); | 2102 | _ = try std.zig.render(comp.gpa, bos.writer(), tree); |
| 2103 | try bos.flush(); | 2103 | try bos.flush(); |
| 2104 | 2104 | ||
| 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)}); |
| 2106 | 2106 | ||
| 2107 | break :digest digest; | 2107 | break :digest digest; |
| 2108 | }; | 2108 | }; |
| ... | @@ -2111,7 +2111,7 @@ fn cmdTranslateC(comp: *Compilation, arena: *Allocator, enable_cache: bool) !voi | ... | @@ -2111,7 +2111,7 @@ fn cmdTranslateC(comp: *Compilation, arena: *Allocator, enable_cache: bool) !voi |
| 2111 | const full_zig_path = try comp.local_cache_directory.join(arena, &[_][]const u8{ | 2111 | const full_zig_path = try comp.local_cache_directory.join(arena, &[_][]const u8{ |
| 2112 | "o", &digest, translated_zig_basename, | 2112 | "o", &digest, translated_zig_basename, |
| 2113 | }); | 2113 | }); |
| 2114 | try io.getStdOut().writer().print("{}\n", .{full_zig_path}); | 2114 | try io.getStdOut().writer().print("{s}\n", .{full_zig_path}); |
| 2115 | return cleanExit(); | 2115 | return cleanExit(); |
| 2116 | } else { | 2116 | } else { |
| 2117 | const out_zig_path = try fs.path.join(arena, &[_][]const u8{ "o", &digest, translated_zig_basename }); | 2117 | 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 { | ... | @@ -2148,10 +2148,10 @@ pub fn cmdLibC(gpa: *Allocator, args: []const []const u8) !void { |
| 2148 | try stdout.writeAll(usage_libc); | 2148 | try stdout.writeAll(usage_libc); |
| 2149 | return cleanExit(); | 2149 | return cleanExit(); |
| 2150 | } else { | 2150 | } else { |
| 2151 | fatal("unrecognized parameter: '{}'", .{arg}); | 2151 | fatal("unrecognized parameter: '{s}'", .{arg}); |
| 2152 | } | 2152 | } |
| 2153 | } else if (input_file != null) { | 2153 | } else if (input_file != null) { |
| 2154 | fatal("unexpected extra parameter: '{}'", .{arg}); | 2154 | fatal("unexpected extra parameter: '{s}'", .{arg}); |
| 2155 | } else { | 2155 | } else { |
| 2156 | input_file = arg; | 2156 | input_file = arg; |
| 2157 | } | 2157 | } |
| ... | @@ -2159,7 +2159,7 @@ pub fn cmdLibC(gpa: *Allocator, args: []const []const u8) !void { | ... | @@ -2159,7 +2159,7 @@ pub fn cmdLibC(gpa: *Allocator, args: []const []const u8) !void { |
| 2159 | } | 2159 | } |
| 2160 | if (input_file) |libc_file| { | 2160 | if (input_file) |libc_file| { |
| 2161 | var libc = LibCInstallation.parse(gpa, libc_file) catch |err| { | 2161 | 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)}); |
| 2163 | }; | 2163 | }; |
| 2164 | defer libc.deinit(gpa); | 2164 | defer libc.deinit(gpa); |
| 2165 | } else { | 2165 | } else { |
| ... | @@ -2167,7 +2167,7 @@ pub fn cmdLibC(gpa: *Allocator, args: []const []const u8) !void { | ... | @@ -2167,7 +2167,7 @@ pub fn cmdLibC(gpa: *Allocator, args: []const []const u8) !void { |
| 2167 | .allocator = gpa, | 2167 | .allocator = gpa, |
| 2168 | .verbose = true, | 2168 | .verbose = true, |
| 2169 | }) catch |err| { | 2169 | }) catch |err| { |
| 2170 | fatal("unable to detect native libc: {}", .{@errorName(err)}); | 2170 | fatal("unable to detect native libc: {s}", .{@errorName(err)}); |
| 2171 | }; | 2171 | }; |
| 2172 | defer libc.deinit(gpa); | 2172 | defer libc.deinit(gpa); |
| 2173 | 2173 | ||
| ... | @@ -2205,16 +2205,16 @@ pub fn cmdInit( | ... | @@ -2205,16 +2205,16 @@ pub fn cmdInit( |
| 2205 | try io.getStdOut().writeAll(usage_init); | 2205 | try io.getStdOut().writeAll(usage_init); |
| 2206 | return cleanExit(); | 2206 | return cleanExit(); |
| 2207 | } else { | 2207 | } else { |
| 2208 | fatal("unrecognized parameter: '{}'", .{arg}); | 2208 | fatal("unrecognized parameter: '{s}'", .{arg}); |
| 2209 | } | 2209 | } |
| 2210 | } else { | 2210 | } else { |
| 2211 | fatal("unexpected extra parameter: '{}'", .{arg}); | 2211 | fatal("unexpected extra parameter: '{s}'", .{arg}); |
| 2212 | } | 2212 | } |
| 2213 | } | 2213 | } |
| 2214 | } | 2214 | } |
| 2215 | const self_exe_path = try fs.selfExePathAlloc(arena); | 2215 | const self_exe_path = try fs.selfExePathAlloc(arena); |
| 2216 | var zig_lib_directory = introspect.findZigLibDirFromSelfExe(arena, self_exe_path) catch |err| { | 2216 | 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)}); |
| 2218 | }; | 2218 | }; |
| 2219 | defer zig_lib_directory.handle.close(); | 2219 | defer zig_lib_directory.handle.close(); |
| 2220 | 2220 | ||
| ... | @@ -2232,7 +2232,7 @@ pub fn cmdInit( | ... | @@ -2232,7 +2232,7 @@ pub fn cmdInit( |
| 2232 | 2232 | ||
| 2233 | const max_bytes = 10 * 1024 * 1024; | 2233 | const max_bytes = 10 * 1024 * 1024; |
| 2234 | const build_zig_contents = template_dir.readFileAlloc(arena, "build.zig", max_bytes) catch |err| { | 2234 | 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)}); |
| 2236 | }; | 2236 | }; |
| 2237 | var modified_build_zig_contents = std.ArrayList(u8).init(arena); | 2237 | var modified_build_zig_contents = std.ArrayList(u8).init(arena); |
| 2238 | try modified_build_zig_contents.ensureCapacity(build_zig_contents.len); | 2238 | try modified_build_zig_contents.ensureCapacity(build_zig_contents.len); |
| ... | @@ -2244,13 +2244,13 @@ pub fn cmdInit( | ... | @@ -2244,13 +2244,13 @@ pub fn cmdInit( |
| 2244 | } | 2244 | } |
| 2245 | } | 2245 | } |
| 2246 | const main_zig_contents = template_dir.readFileAlloc(arena, "src" ++ s ++ "main.zig", max_bytes) catch |err| { | 2246 | 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)}); |
| 2248 | }; | 2248 | }; |
| 2249 | if (fs.cwd().access("build.zig", .{})) |_| { | 2249 | if (fs.cwd().access("build.zig", .{})) |_| { |
| 2250 | fatal("existing build.zig file would be overwritten", .{}); | 2250 | fatal("existing build.zig file would be overwritten", .{}); |
| 2251 | } else |err| switch (err) { | 2251 | } else |err| switch (err) { |
| 2252 | error.FileNotFound => {}, | 2252 | 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)}), |
| 2254 | } | 2254 | } |
| 2255 | var src_dir = try fs.cwd().makeOpenPath("src", .{}); | 2255 | var src_dir = try fs.cwd().makeOpenPath("src", .{}); |
| 2256 | defer src_dir.close(); | 2256 | defer src_dir.close(); |
| ... | @@ -2311,23 +2311,23 @@ pub fn cmdBuild(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v | ... | @@ -2311,23 +2311,23 @@ pub fn cmdBuild(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v |
| 2311 | const arg = args[i]; | 2311 | const arg = args[i]; |
| 2312 | if (mem.startsWith(u8, arg, "-")) { | 2312 | if (mem.startsWith(u8, arg, "-")) { |
| 2313 | if (mem.eql(u8, arg, "--build-file")) { | 2313 | 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}); |
| 2315 | i += 1; | 2315 | i += 1; |
| 2316 | build_file = args[i]; | 2316 | build_file = args[i]; |
| 2317 | continue; | 2317 | continue; |
| 2318 | } else if (mem.eql(u8, arg, "--override-lib-dir")) { | 2318 | } 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}); |
| 2320 | i += 1; | 2320 | i += 1; |
| 2321 | override_lib_dir = args[i]; | 2321 | override_lib_dir = args[i]; |
| 2322 | try child_argv.appendSlice(&[_][]const u8{ arg, args[i] }); | 2322 | try child_argv.appendSlice(&[_][]const u8{ arg, args[i] }); |
| 2323 | continue; | 2323 | continue; |
| 2324 | } else if (mem.eql(u8, arg, "--cache-dir")) { | 2324 | } 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}); |
| 2326 | i += 1; | 2326 | i += 1; |
| 2327 | override_local_cache_dir = args[i]; | 2327 | override_local_cache_dir = args[i]; |
| 2328 | continue; | 2328 | continue; |
| 2329 | } else if (mem.eql(u8, arg, "--global-cache-dir")) { | 2329 | } 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}); |
| 2331 | i += 1; | 2331 | i += 1; |
| 2332 | override_global_cache_dir = args[i]; | 2332 | override_global_cache_dir = args[i]; |
| 2333 | continue; | 2333 | continue; |
| ... | @@ -2344,7 +2344,7 @@ pub fn cmdBuild(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v | ... | @@ -2344,7 +2344,7 @@ pub fn cmdBuild(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v |
| 2344 | } | 2344 | } |
| 2345 | else | 2345 | else |
| 2346 | introspect.findZigLibDirFromSelfExe(arena, self_exe_path) catch |err| { | 2346 | 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)}); |
| 2348 | }; | 2348 | }; |
| 2349 | defer zig_lib_directory.handle.close(); | 2349 | defer zig_lib_directory.handle.close(); |
| 2350 | 2350 | ||
| ... | @@ -2385,7 +2385,7 @@ pub fn cmdBuild(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v | ... | @@ -2385,7 +2385,7 @@ pub fn cmdBuild(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v |
| 2385 | } else |err| switch (err) { | 2385 | } else |err| switch (err) { |
| 2386 | error.FileNotFound => { | 2386 | error.FileNotFound => { |
| 2387 | dirname = fs.path.dirname(dirname) orelse { | 2387 | dirname = fs.path.dirname(dirname) orelse { |
| 2388 | std.log.info("{}", .{ | 2388 | std.log.info("{s}", .{ |
| 2389 | \\Initialize a 'build.zig' template file with `zig init-lib` or `zig init-exe`, | 2389 | \\Initialize a 'build.zig' template file with `zig init-lib` or `zig init-exe`, |
| 2390 | \\or see `zig --help` for more options. | 2390 | \\or see `zig --help` for more options. |
| 2391 | }); | 2391 | }); |
| ... | @@ -2467,7 +2467,7 @@ pub fn cmdBuild(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v | ... | @@ -2467,7 +2467,7 @@ pub fn cmdBuild(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v |
| 2467 | .self_exe_path = self_exe_path, | 2467 | .self_exe_path = self_exe_path, |
| 2468 | .thread_pool = &thread_pool, | 2468 | .thread_pool = &thread_pool, |
| 2469 | }) catch |err| { | 2469 | }) catch |err| { |
| 2470 | fatal("unable to create compilation: {}", .{@errorName(err)}); | 2470 | fatal("unable to create compilation: {s}", .{@errorName(err)}); |
| 2471 | }; | 2471 | }; |
| 2472 | defer comp.destroy(); | 2472 | defer comp.destroy(); |
| 2473 | 2473 | ||
| ... | @@ -2493,11 +2493,11 @@ pub fn cmdBuild(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v | ... | @@ -2493,11 +2493,11 @@ pub fn cmdBuild(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v |
| 2493 | .Exited => |code| { | 2493 | .Exited => |code| { |
| 2494 | if (code == 0) return cleanExit(); | 2494 | if (code == 0) return cleanExit(); |
| 2495 | const cmd = try argvCmd(arena, child_argv); | 2495 | 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 }); |
| 2497 | }, | 2497 | }, |
| 2498 | else => { | 2498 | else => { |
| 2499 | const cmd = try argvCmd(arena, child_argv); | 2499 | 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}); |
| 2501 | }, | 2501 | }, |
| 2502 | } | 2502 | } |
| 2503 | } | 2503 | } |
| ... | @@ -2564,14 +2564,14 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { | ... | @@ -2564,14 +2564,14 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { |
| 2564 | i += 1; | 2564 | i += 1; |
| 2565 | const next_arg = args[i]; | 2565 | const next_arg = args[i]; |
| 2566 | color = std.meta.stringToEnum(Color, next_arg) orelse { | 2566 | 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}); |
| 2568 | }; | 2568 | }; |
| 2569 | } else if (mem.eql(u8, arg, "--stdin")) { | 2569 | } else if (mem.eql(u8, arg, "--stdin")) { |
| 2570 | stdin_flag = true; | 2570 | stdin_flag = true; |
| 2571 | } else if (mem.eql(u8, arg, "--check")) { | 2571 | } else if (mem.eql(u8, arg, "--check")) { |
| 2572 | check_flag = true; | 2572 | check_flag = true; |
| 2573 | } else { | 2573 | } else { |
| 2574 | fatal("unrecognized parameter: '{}'", .{arg}); | 2574 | fatal("unrecognized parameter: '{s}'", .{arg}); |
| 2575 | } | 2575 | } |
| 2576 | } else { | 2576 | } else { |
| 2577 | try input_files.append(arg); | 2577 | try input_files.append(arg); |
| ... | @@ -2590,7 +2590,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { | ... | @@ -2590,7 +2590,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { |
| 2590 | defer gpa.free(source_code); | 2590 | defer gpa.free(source_code); |
| 2591 | 2591 | ||
| 2592 | const tree = std.zig.parse(gpa, source_code) catch |err| { | 2592 | const tree = std.zig.parse(gpa, source_code) catch |err| { |
| 2593 | fatal("error parsing stdin: {}", .{err}); | 2593 | fatal("error parsing stdin: {s}", .{err}); |
| 2594 | }; | 2594 | }; |
| 2595 | defer tree.deinit(); | 2595 | defer tree.deinit(); |
| 2596 | 2596 | ||
| ... | @@ -2629,7 +2629,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { | ... | @@ -2629,7 +2629,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { |
| 2629 | for (input_files.items) |file_path| { | 2629 | for (input_files.items) |file_path| { |
| 2630 | // Get the real path here to avoid Windows failing on relative file paths with . or .. in them. | 2630 | // Get the real path here to avoid Windows failing on relative file paths with . or .. in them. |
| 2631 | const real_path = fs.realpathAlloc(gpa, file_path) catch |err| { | 2631 | 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) }); |
| 2633 | }; | 2633 | }; |
| 2634 | defer gpa.free(real_path); | 2634 | defer gpa.free(real_path); |
| 2635 | 2635 | ||
| ... | @@ -2668,7 +2668,7 @@ fn fmtPath(fmt: *Fmt, file_path: []const u8, check_mode: bool, dir: fs.Dir, sub_ | ... | @@ -2668,7 +2668,7 @@ fn fmtPath(fmt: *Fmt, file_path: []const u8, check_mode: bool, dir: fs.Dir, sub_ |
| 2668 | fmtPathFile(fmt, file_path, check_mode, dir, sub_path) catch |err| switch (err) { | 2668 | fmtPathFile(fmt, file_path, check_mode, dir, sub_path) catch |err| switch (err) { |
| 2669 | error.IsDir, error.AccessDenied => return fmtPathDir(fmt, file_path, check_mode, dir, sub_path), | 2669 | error.IsDir, error.AccessDenied => return fmtPathDir(fmt, file_path, check_mode, dir, sub_path), |
| 2670 | else => { | 2670 | else => { |
| 2671 | warn("unable to format '{}': {}", .{ file_path, err }); | 2671 | warn("unable to format '{s}': {s}", .{ file_path, @errorName(err) }); |
| 2672 | fmt.any_error = true; | 2672 | fmt.any_error = true; |
| 2673 | return; | 2673 | return; |
| 2674 | }, | 2674 | }, |
| ... | @@ -2702,7 +2702,7 @@ fn fmtPathDir( | ... | @@ -2702,7 +2702,7 @@ fn fmtPathDir( |
| 2702 | try fmtPathDir(fmt, full_path, check_mode, dir, entry.name); | 2702 | try fmtPathDir(fmt, full_path, check_mode, dir, entry.name); |
| 2703 | } else { | 2703 | } else { |
| 2704 | fmtPathFile(fmt, full_path, check_mode, dir, entry.name) catch |err| { | 2704 | 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) }); |
| 2706 | fmt.any_error = true; | 2706 | fmt.any_error = true; |
| 2707 | return; | 2707 | return; |
| 2708 | }; | 2708 | }; |
| ... | @@ -2761,7 +2761,7 @@ fn fmtPathFile( | ... | @@ -2761,7 +2761,7 @@ fn fmtPathFile( |
| 2761 | const anything_changed = try std.zig.render(fmt.gpa, io.null_out_stream, tree); | 2761 | const anything_changed = try std.zig.render(fmt.gpa, io.null_out_stream, tree); |
| 2762 | if (anything_changed) { | 2762 | if (anything_changed) { |
| 2763 | const stdout = io.getStdOut().writer(); | 2763 | const stdout = io.getStdOut().writer(); |
| 2764 | try stdout.print("{}\n", .{file_path}); | 2764 | try stdout.print("{s}\n", .{file_path}); |
| 2765 | fmt.any_error = true; | 2765 | fmt.any_error = true; |
| 2766 | } | 2766 | } |
| 2767 | } else { | 2767 | } else { |
| ... | @@ -2779,7 +2779,7 @@ fn fmtPathFile( | ... | @@ -2779,7 +2779,7 @@ fn fmtPathFile( |
| 2779 | try af.file.writeAll(fmt.out_buffer.items); | 2779 | try af.file.writeAll(fmt.out_buffer.items); |
| 2780 | try af.finish(); | 2780 | try af.finish(); |
| 2781 | const stdout = io.getStdOut().writer(); | 2781 | const stdout = io.getStdOut().writer(); |
| 2782 | try stdout.print("{}\n", .{file_path}); | 2782 | try stdout.print("{s}\n", .{file_path}); |
| 2783 | } | 2783 | } |
| 2784 | } | 2784 | } |
| 2785 | 2785 | ||
| ... | @@ -2812,7 +2812,7 @@ fn printErrMsgToFile( | ... | @@ -2812,7 +2812,7 @@ fn printErrMsgToFile( |
| 2812 | const text = text_buf.items; | 2812 | const text = text_buf.items; |
| 2813 | 2813 | ||
| 2814 | const stream = file.outStream(); | 2814 | 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 }); |
| 2816 | 2816 | ||
| 2817 | if (!color_on) return; | 2817 | if (!color_on) return; |
| 2818 | 2818 | ||
| ... | @@ -2984,7 +2984,7 @@ pub const ClangArgIterator = struct { | ... | @@ -2984,7 +2984,7 @@ pub const ClangArgIterator = struct { |
| 2984 | const max_bytes = 10 * 1024 * 1024; // 10 MiB of command line arguments is a reasonable limit | 2984 | const max_bytes = 10 * 1024 * 1024; // 10 MiB of command line arguments is a reasonable limit |
| 2985 | const resp_file_path = arg[1..]; | 2985 | const resp_file_path = arg[1..]; |
| 2986 | const resp_contents = fs.cwd().readFileAlloc(allocator, resp_file_path, max_bytes) catch |err| { | 2986 | 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) }); |
| 2988 | }; | 2988 | }; |
| 2989 | defer allocator.free(resp_contents); | 2989 | defer allocator.free(resp_contents); |
| 2990 | // TODO is there a specification for this file format? Let's find it and make this parsing more robust | 2990 | // 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 { | ... | @@ -3057,7 +3057,7 @@ pub const ClangArgIterator = struct { |
| 3057 | const prefix_len = clang_arg.matchStartsWith(arg); | 3057 | const prefix_len = clang_arg.matchStartsWith(arg); |
| 3058 | if (prefix_len == arg.len) { | 3058 | if (prefix_len == arg.len) { |
| 3059 | if (self.next_index >= self.argv.len) { | 3059 | if (self.next_index >= self.argv.len) { |
| 3060 | fatal("Expected parameter after '{}'", .{arg}); | 3060 | fatal("Expected parameter after '{s}'", .{arg}); |
| 3061 | } | 3061 | } |
| 3062 | self.only_arg = self.argv[self.next_index]; | 3062 | self.only_arg = self.argv[self.next_index]; |
| 3063 | self.incrementArgIndex(); | 3063 | self.incrementArgIndex(); |
| ... | @@ -3078,7 +3078,7 @@ pub const ClangArgIterator = struct { | ... | @@ -3078,7 +3078,7 @@ pub const ClangArgIterator = struct { |
| 3078 | if (prefix_len != 0) { | 3078 | if (prefix_len != 0) { |
| 3079 | self.only_arg = arg[prefix_len..]; | 3079 | self.only_arg = arg[prefix_len..]; |
| 3080 | if (self.next_index >= self.argv.len) { | 3080 | if (self.next_index >= self.argv.len) { |
| 3081 | fatal("Expected parameter after '{}'", .{arg}); | 3081 | fatal("Expected parameter after '{s}'", .{arg}); |
| 3082 | } | 3082 | } |
| 3083 | self.second_arg = self.argv[self.next_index]; | 3083 | self.second_arg = self.argv[self.next_index]; |
| 3084 | self.incrementArgIndex(); | 3084 | self.incrementArgIndex(); |
| ... | @@ -3089,7 +3089,7 @@ pub const ClangArgIterator = struct { | ... | @@ -3089,7 +3089,7 @@ pub const ClangArgIterator = struct { |
| 3089 | }, | 3089 | }, |
| 3090 | .separate => if (clang_arg.matchEql(arg) > 0) { | 3090 | .separate => if (clang_arg.matchEql(arg) > 0) { |
| 3091 | if (self.next_index >= self.argv.len) { | 3091 | if (self.next_index >= self.argv.len) { |
| 3092 | fatal("Expected parameter after '{}'", .{arg}); | 3092 | fatal("Expected parameter after '{s}'", .{arg}); |
| 3093 | } | 3093 | } |
| 3094 | self.only_arg = self.argv[self.next_index]; | 3094 | self.only_arg = self.argv[self.next_index]; |
| 3095 | self.incrementArgIndex(); | 3095 | self.incrementArgIndex(); |
| ... | @@ -3115,7 +3115,7 @@ pub const ClangArgIterator = struct { | ... | @@ -3115,7 +3115,7 @@ pub const ClangArgIterator = struct { |
| 3115 | }, | 3115 | }, |
| 3116 | } | 3116 | } |
| 3117 | else { | 3117 | else { |
| 3118 | fatal("Unknown Clang option: '{}'", .{arg}); | 3118 | fatal("Unknown Clang option: '{s}'", .{arg}); |
| 3119 | } | 3119 | } |
| 3120 | } | 3120 | } |
| 3121 | 3121 | ||
| ... | @@ -3143,7 +3143,7 @@ pub const ClangArgIterator = struct { | ... | @@ -3143,7 +3143,7 @@ pub const ClangArgIterator = struct { |
| 3143 | 3143 | ||
| 3144 | fn parseCodeModel(arg: []const u8) std.builtin.CodeModel { | 3144 | fn parseCodeModel(arg: []const u8) std.builtin.CodeModel { |
| 3145 | return std.meta.stringToEnum(std.builtin.CodeModel, arg) orelse | 3145 | return std.meta.stringToEnum(std.builtin.CodeModel, arg) orelse |
| 3146 | fatal("unsupported machine code model: '{}'", .{arg}); | 3146 | fatal("unsupported machine code model: '{s}'", .{arg}); |
| 3147 | } | 3147 | } |
| 3148 | 3148 | ||
| 3149 | /// Raise the open file descriptor limit. Ask and ye shall receive. | 3149 | /// 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 | ... | @@ -3263,7 +3263,7 @@ fn detectNativeTargetInfo(gpa: *Allocator, cross_target: std.zig.CrossTarget) !s |
| 3263 | // CPU model & feature detection is todo so here we rely on LLVM. | 3263 | // CPU model & feature detection is todo so here we rely on LLVM. |
| 3264 | // https://github.com/ziglang/zig/issues/4591 | 3264 | // https://github.com/ziglang/zig/issues/4591 |
| 3265 | if (!build_options.have_llvm) | 3265 | 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)}); |
| 3267 | 3267 | ||
| 3268 | const llvm = @import("llvm_bindings.zig"); | 3268 | const llvm = @import("llvm_bindings.zig"); |
| 3269 | const llvm_cpu_name = llvm.GetHostCPUName(); | 3269 | 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 { | ... | @@ -381,7 +381,7 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void { |
| 381 | 381 | ||
| 382 | const term = child.wait() catch |err| { | 382 | const term = child.wait() catch |err| { |
| 383 | // TODO surface a proper error here | 383 | // 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) }); |
| 385 | return error.ClangPreprocessorFailed; | 385 | return error.ClangPreprocessorFailed; |
| 386 | }; | 386 | }; |
| 387 | 387 | ||
| ... | @@ -395,7 +395,7 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void { | ... | @@ -395,7 +395,7 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void { |
| 395 | }, | 395 | }, |
| 396 | else => { | 396 | else => { |
| 397 | // TODO surface a proper error here | 397 | // 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}); |
| 399 | return error.ClangPreprocessorFailed; | 399 | return error.ClangPreprocessorFailed; |
| 400 | }, | 400 | }, |
| 401 | } | 401 | } |
src/musl.zig+4-4| ... | @@ -155,21 +155,21 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { | ... | @@ -155,21 +155,21 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { |
| 155 | if (!is_arch_specific) { | 155 | if (!is_arch_specific) { |
| 156 | // Look for an arch specific override. | 156 | // Look for an arch specific override. |
| 157 | override_path.shrinkRetainingCapacity(0); | 157 | 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", .{ |
| 159 | dirname, arch_name, noextbasename, | 159 | dirname, arch_name, noextbasename, |
| 160 | }); | 160 | }); |
| 161 | if (source_table.contains(override_path.items)) | 161 | if (source_table.contains(override_path.items)) |
| 162 | continue; | 162 | continue; |
| 163 | 163 | ||
| 164 | override_path.shrinkRetainingCapacity(0); | 164 | 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", .{ |
| 166 | dirname, arch_name, noextbasename, | 166 | dirname, arch_name, noextbasename, |
| 167 | }); | 167 | }); |
| 168 | if (source_table.contains(override_path.items)) | 168 | if (source_table.contains(override_path.items)) |
| 169 | continue; | 169 | continue; |
| 170 | 170 | ||
| 171 | override_path.shrinkRetainingCapacity(0); | 171 | 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", .{ |
| 173 | dirname, arch_name, noextbasename, | 173 | dirname, arch_name, noextbasename, |
| 174 | }); | 174 | }); |
| 175 | if (source_table.contains(override_path.items)) | 175 | if (source_table.contains(override_path.items)) |
| ... | @@ -322,7 +322,7 @@ fn add_cc_args( | ... | @@ -322,7 +322,7 @@ fn add_cc_args( |
| 322 | const target = comp.getTarget(); | 322 | const target = comp.getTarget(); |
| 323 | const arch_name = target_util.archMuslName(target.cpu.arch); | 323 | const arch_name = target_util.archMuslName(target.cpu.arch); |
| 324 | const os_name = @tagName(target.os.tag); | 324 | 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 }); |
| 326 | const o_arg = if (want_O3) "-O3" else "-Os"; | 326 | const o_arg = if (want_O3) "-O3" else "-Os"; |
| 327 | 327 | ||
| 328 | try args.appendSlice(&[_][]const u8{ | 328 | 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 | ... | @@ -9,7 +9,7 @@ pub fn cmdEnv(gpa: *Allocator, args: []const []const u8, stdout: std.fs.File.Wri |
| 9 | defer gpa.free(self_exe_path); | 9 | defer gpa.free(self_exe_path); |
| 10 | 10 | ||
| 11 | var zig_lib_directory = introspect.findZigLibDirFromSelfExe(gpa, self_exe_path) catch |err| { | 11 | 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)}); |
| 13 | }; | 13 | }; |
| 14 | defer gpa.free(zig_lib_directory.path.?); | 14 | defer gpa.free(zig_lib_directory.path.?); |
| 15 | defer zig_lib_directory.handle.close(); | 15 | defer zig_lib_directory.handle.close(); |
src/print_targets.zig+2-2| ... | @@ -18,7 +18,7 @@ pub fn cmdTargets( | ... | @@ -18,7 +18,7 @@ pub fn cmdTargets( |
| 18 | native_target: Target, | 18 | native_target: Target, |
| 19 | ) !void { | 19 | ) !void { |
| 20 | var zig_lib_directory = introspect.findZigLibDir(allocator) catch |err| { | 20 | 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)}); |
| 22 | }; | 22 | }; |
| 23 | defer zig_lib_directory.handle.close(); | 23 | defer zig_lib_directory.handle.close(); |
| 24 | defer allocator.free(zig_lib_directory.path.?); | 24 | defer allocator.free(zig_lib_directory.path.?); |
| ... | @@ -61,7 +61,7 @@ pub fn cmdTargets( | ... | @@ -61,7 +61,7 @@ pub fn cmdTargets( |
| 61 | try jws.objectField("libc"); | 61 | try jws.objectField("libc"); |
| 62 | try jws.beginArray(); | 62 | try jws.beginArray(); |
| 63 | for (target.available_libcs) |libc| { | 63 | for (target.available_libcs) |libc| { |
| 64 | const tmp = try std.fmt.allocPrint(allocator, "{}-{}-{}", .{ | 64 | const tmp = try std.fmt.allocPrint(allocator, "{s}-{s}-{s}", .{ |
| 65 | @tagName(libc.arch), @tagName(libc.os), @tagName(libc.abi), | 65 | @tagName(libc.arch), @tagName(libc.os), @tagName(libc.abi), |
| 66 | }); | 66 | }); |
| 67 | defer allocator.free(tmp); | 67 | 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 { | ... | @@ -37,14 +37,14 @@ pub export fn main(argc: c_int, argv: [*][*:0]u8) c_int { |
| 37 | defer arena_instance.deinit(); | 37 | defer arena_instance.deinit(); |
| 38 | const arena = &arena_instance.allocator; | 38 | const arena = &arena_instance.allocator; |
| 39 | 39 | ||
| 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"}); |
| 41 | for (args) |*arg, i| { | 41 | for (args) |*arg, i| { |
| 42 | arg.* = mem.spanZ(argv[i]); | 42 | arg.* = mem.spanZ(argv[i]); |
| 43 | } | 43 | } |
| 44 | if (std.builtin.mode == .Debug) { | 44 | if (std.builtin.mode == .Debug) { |
| 45 | stage2.mainArgs(gpa, arena, args) catch unreachable; | 45 | stage2.mainArgs(gpa, arena, args) catch unreachable; |
| 46 | } else { | 46 | } else { |
| 47 | stage2.mainArgs(gpa, arena, args) catch |err| fatal("{}", .{@errorName(err)}); | 47 | stage2.mainArgs(gpa, arena, args) catch |err| fatal("{s}", .{@errorName(err)}); |
| 48 | } | 48 | } |
| 49 | return 0; | 49 | return 0; |
| 50 | } | 50 | } |
src/test.zig+1-1| ... | @@ -660,7 +660,7 @@ pub const TestContext = struct { | ... | @@ -660,7 +660,7 @@ pub const TestContext = struct { |
| 660 | } | 660 | } |
| 661 | } | 661 | } |
| 662 | if (comp.bin_file.cast(link.File.C)) |c_file| { | 662 | 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", .{ |
| 664 | c_file.main.items, | 664 | c_file.main.items, |
| 665 | }); | 665 | }); |
| 666 | } | 666 | } |
src/translate_c.zig+46-46| ... | @@ -136,7 +136,7 @@ const Scope = struct { | ... | @@ -136,7 +136,7 @@ const Scope = struct { |
| 136 | var proposed_name = name_copy; | 136 | var proposed_name = name_copy; |
| 137 | while (scope.contains(proposed_name)) { | 137 | while (scope.contains(proposed_name)) { |
| 138 | scope.mangle_count += 1; | 138 | 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 }); |
| 140 | } | 140 | } |
| 141 | try scope.variables.append(.{ .name = name_copy, .alias = proposed_name }); | 141 | try scope.variables.append(.{ .name = name_copy, .alias = proposed_name }); |
| 142 | return proposed_name; | 142 | return proposed_name; |
| ... | @@ -290,7 +290,7 @@ pub const Context = struct { | ... | @@ -290,7 +290,7 @@ pub const Context = struct { |
| 290 | 290 | ||
| 291 | const line = c.source_manager.getSpellingLineNumber(spelling_loc); | 291 | const line = c.source_manager.getSpellingLineNumber(spelling_loc); |
| 292 | const column = c.source_manager.getSpellingColumnNumber(spelling_loc); | 292 | 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 }); |
| 294 | } | 294 | } |
| 295 | 295 | ||
| 296 | fn createCall(c: *Context, fn_expr: *ast.Node, params_len: ast.NodeIndex) !*ast.Node.Call { | 296 | fn createCall(c: *Context, fn_expr: *ast.Node, params_len: ast.NodeIndex) !*ast.Node.Call { |
| ... | @@ -440,7 +440,7 @@ pub fn translate( | ... | @@ -440,7 +440,7 @@ pub fn translate( |
| 440 | mem.copy(*ast.Node, root_node.decls(), context.root_decls.items); | 440 | mem.copy(*ast.Node, root_node.decls(), context.root_decls.items); |
| 441 | 441 | ||
| 442 | if (false) { | 442 | 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}); |
| 444 | for (context.token_ids.items) |token| { | 444 | for (context.token_ids.items) |token| { |
| 445 | std.debug.warn("{}\n", .{token}); | 445 | std.debug.warn("{}\n", .{token}); |
| 446 | } | 446 | } |
| ... | @@ -530,7 +530,7 @@ fn declVisitor(c: *Context, decl: *const clang.Decl) Error!void { | ... | @@ -530,7 +530,7 @@ fn declVisitor(c: *Context, decl: *const clang.Decl) Error!void { |
| 530 | }, | 530 | }, |
| 531 | else => { | 531 | else => { |
| 532 | const decl_name = try c.str(decl.getDeclKindName()); | 532 | 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}); |
| 534 | }, | 534 | }, |
| 535 | } | 535 | } |
| 536 | } | 536 | } |
| ... | @@ -625,7 +625,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const clang.FunctionDecl) Error!void { | ... | @@ -625,7 +625,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const clang.FunctionDecl) Error!void { |
| 625 | const param_name = if (param.name_token) |name_tok| | 625 | const param_name = if (param.name_token) |name_tok| |
| 626 | tokenSlice(c, name_tok) | 626 | tokenSlice(c, name_tok) |
| 627 | else | 627 | 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}); |
| 629 | 629 | ||
| 630 | const c_param = fn_decl.getParamDecl(param_id); | 630 | const c_param = fn_decl.getParamDecl(param_id); |
| 631 | const qual_type = c_param.getOriginalType(); | 631 | const qual_type = c_param.getOriginalType(); |
| ... | @@ -634,7 +634,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const clang.FunctionDecl) Error!void { | ... | @@ -634,7 +634,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const clang.FunctionDecl) Error!void { |
| 634 | const mangled_param_name = try block_scope.makeMangledName(c, param_name); | 634 | const mangled_param_name = try block_scope.makeMangledName(c, param_name); |
| 635 | 635 | ||
| 636 | if (!is_const) { | 636 | 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}); |
| 638 | const arg_name = try block_scope.makeMangledName(c, bare_arg_name); | 638 | const arg_name = try block_scope.makeMangledName(c, bare_arg_name); |
| 639 | 639 | ||
| 640 | const mut_tok = try appendToken(c, .Keyword_var, "var"); | 640 | 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 | ... | @@ -727,7 +727,7 @@ fn visitVarDecl(c: *Context, var_decl: *const clang.VarDecl, mangled_name: ?[]co |
| 727 | 727 | ||
| 728 | // TODO https://github.com/ziglang/zig/issues/3756 | 728 | // TODO https://github.com/ziglang/zig/issues/3756 |
| 729 | // TODO https://github.com/ziglang/zig/issues/1802 | 729 | // 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; |
| 731 | const var_decl_loc = var_decl.getLocation(); | 731 | const var_decl_loc = var_decl.getLocation(); |
| 732 | 732 | ||
| 733 | const qual_type = var_decl.getTypeSourceInfo_getType(); | 733 | const qual_type = var_decl.getTypeSourceInfo_getType(); |
| ... | @@ -808,7 +808,7 @@ fn visitVarDecl(c: *Context, var_decl: *const clang.VarDecl, mangled_name: ?[]co | ... | @@ -808,7 +808,7 @@ fn visitVarDecl(c: *Context, var_decl: *const clang.VarDecl, mangled_name: ?[]co |
| 808 | _ = try appendToken(rp.c, .LParen, "("); | 808 | _ = try appendToken(rp.c, .LParen, "("); |
| 809 | const expr = try transCreateNodeStringLiteral( | 809 | const expr = try transCreateNodeStringLiteral( |
| 810 | rp.c, | 810 | 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]}), |
| 812 | ); | 812 | ); |
| 813 | _ = try appendToken(rp.c, .RParen, ")"); | 813 | _ = try appendToken(rp.c, .RParen, ")"); |
| 814 | 814 | ||
| ... | @@ -887,7 +887,7 @@ fn transTypeDef(c: *Context, typedef_decl: *const clang.TypedefNameDecl, top_lev | ... | @@ -887,7 +887,7 @@ fn transTypeDef(c: *Context, typedef_decl: *const clang.TypedefNameDecl, top_lev |
| 887 | 887 | ||
| 888 | // TODO https://github.com/ziglang/zig/issues/3756 | 888 | // TODO https://github.com/ziglang/zig/issues/3756 |
| 889 | // TODO https://github.com/ziglang/zig/issues/1802 | 889 | // 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; |
| 891 | if (checkForBuiltinTypedef(checked_name)) |builtin| { | 891 | if (checkForBuiltinTypedef(checked_name)) |builtin| { |
| 892 | return transTypeDefAsBuiltin(c, typedef_decl, builtin); | 892 | return transTypeDefAsBuiltin(c, typedef_decl, builtin); |
| 893 | } | 893 | } |
| ... | @@ -945,7 +945,7 @@ fn transRecordDecl(c: *Context, record_decl: *const clang.RecordDecl) Error!?*as | ... | @@ -945,7 +945,7 @@ fn transRecordDecl(c: *Context, record_decl: *const clang.RecordDecl) Error!?*as |
| 945 | // Record declarations such as `struct {...} x` have no name but they're not | 945 | // Record declarations such as `struct {...} x` have no name but they're not |
| 946 | // anonymous hence here isAnonymousStructOrUnion is not needed | 946 | // anonymous hence here isAnonymousStructOrUnion is not needed |
| 947 | if (bare_name.len == 0) { | 947 | 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()}); |
| 949 | is_unnamed = true; | 949 | is_unnamed = true; |
| 950 | } | 950 | } |
| 951 | 951 | ||
| ... | @@ -958,11 +958,11 @@ fn transRecordDecl(c: *Context, record_decl: *const clang.RecordDecl) Error!?*as | ... | @@ -958,11 +958,11 @@ fn transRecordDecl(c: *Context, record_decl: *const clang.RecordDecl) Error!?*as |
| 958 | container_kind_name = "struct"; | 958 | container_kind_name = "struct"; |
| 959 | container_kind = .Keyword_struct; | 959 | container_kind = .Keyword_struct; |
| 960 | } else { | 960 | } 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}); |
| 962 | return null; | 962 | return null; |
| 963 | } | 963 | } |
| 964 | 964 | ||
| 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 }); |
| 966 | _ = try c.decl_table.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), name); | 966 | _ = try c.decl_table.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), name); |
| 967 | 967 | ||
| 968 | const visib_tok = if (!is_unnamed) try appendToken(c, .Keyword_pub, "pub") else null; | 968 | 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 | ... | @@ -1003,7 +1003,7 @@ fn transRecordDecl(c: *Context, record_decl: *const clang.RecordDecl) Error!?*as |
| 1003 | _ = try c.opaque_demotes.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), {}); | 1003 | _ = try c.opaque_demotes.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), {}); |
| 1004 | const opaque_type = try transCreateNodeOpaqueType(c); | 1004 | const opaque_type = try transCreateNodeOpaqueType(c); |
| 1005 | semicolon = try appendToken(c, .Semicolon, ";"); | 1005 | 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}); |
| 1007 | break :blk opaque_type; | 1007 | break :blk opaque_type; |
| 1008 | } | 1008 | } |
| 1009 | 1009 | ||
| ... | @@ -1011,7 +1011,7 @@ fn transRecordDecl(c: *Context, record_decl: *const clang.RecordDecl) Error!?*as | ... | @@ -1011,7 +1011,7 @@ fn transRecordDecl(c: *Context, record_decl: *const clang.RecordDecl) Error!?*as |
| 1011 | _ = try c.opaque_demotes.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), {}); | 1011 | _ = try c.opaque_demotes.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), {}); |
| 1012 | const opaque_type = try transCreateNodeOpaqueType(c); | 1012 | const opaque_type = try transCreateNodeOpaqueType(c); |
| 1013 | semicolon = try appendToken(c, .Semicolon, ";"); | 1013 | 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}); |
| 1015 | break :blk opaque_type; | 1015 | break :blk opaque_type; |
| 1016 | } | 1016 | } |
| 1017 | 1017 | ||
| ... | @@ -1019,7 +1019,7 @@ fn transRecordDecl(c: *Context, record_decl: *const clang.RecordDecl) Error!?*as | ... | @@ -1019,7 +1019,7 @@ fn transRecordDecl(c: *Context, record_decl: *const clang.RecordDecl) Error!?*as |
| 1019 | var raw_name = try c.str(@ptrCast(*const clang.NamedDecl, field_decl).getName_bytes_begin()); | 1019 | var raw_name = try c.str(@ptrCast(*const clang.NamedDecl, field_decl).getName_bytes_begin()); |
| 1020 | if (field_decl.isAnonymousStructOrUnion() or raw_name.len == 0) { | 1020 | if (field_decl.isAnonymousStructOrUnion() or raw_name.len == 0) { |
| 1021 | // Context.getMangle() is not used here because doing so causes unpredictable field names for anonymous fields. | 1021 | // 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}); |
| 1023 | unnamed_field_count += 1; | 1023 | unnamed_field_count += 1; |
| 1024 | is_anon = true; | 1024 | is_anon = true; |
| 1025 | } | 1025 | } |
| ... | @@ -1030,7 +1030,7 @@ fn transRecordDecl(c: *Context, record_decl: *const clang.RecordDecl) Error!?*as | ... | @@ -1030,7 +1030,7 @@ fn transRecordDecl(c: *Context, record_decl: *const clang.RecordDecl) Error!?*as |
| 1030 | _ = try c.opaque_demotes.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), {}); | 1030 | _ = try c.opaque_demotes.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), {}); |
| 1031 | const opaque_type = try transCreateNodeOpaqueType(c); | 1031 | const opaque_type = try transCreateNodeOpaqueType(c); |
| 1032 | semicolon = try appendToken(c, .Semicolon, ";"); | 1032 | 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 }); |
| 1034 | break :blk opaque_type; | 1034 | break :blk opaque_type; |
| 1035 | }, | 1035 | }, |
| 1036 | else => |e| return e, | 1036 | else => |e| return e, |
| ... | @@ -1110,11 +1110,11 @@ fn transEnumDecl(c: *Context, enum_decl: *const clang.EnumDecl) Error!?*ast.Node | ... | @@ -1110,11 +1110,11 @@ fn transEnumDecl(c: *Context, enum_decl: *const clang.EnumDecl) Error!?*ast.Node |
| 1110 | var bare_name = try c.str(@ptrCast(*const clang.NamedDecl, enum_decl).getName_bytes_begin()); | 1110 | var bare_name = try c.str(@ptrCast(*const clang.NamedDecl, enum_decl).getName_bytes_begin()); |
| 1111 | var is_unnamed = false; | 1111 | var is_unnamed = false; |
| 1112 | if (bare_name.len == 0) { | 1112 | 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()}); |
| 1114 | is_unnamed = true; | 1114 | is_unnamed = true; |
| 1115 | } | 1115 | } |
| 1116 | 1116 | ||
| 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}); |
| 1118 | _ = try c.decl_table.put(c.gpa, @ptrToInt(enum_decl.getCanonicalDecl()), name); | 1118 | _ = try c.decl_table.put(c.gpa, @ptrToInt(enum_decl.getCanonicalDecl()), name); |
| 1119 | 1119 | ||
| 1120 | const visib_tok = if (!is_unnamed) try appendToken(c, .Keyword_pub, "pub") else null; | 1120 | const visib_tok = if (!is_unnamed) try appendToken(c, .Keyword_pub, "pub") else null; |
| ... | @@ -1385,7 +1385,7 @@ fn transStmt( | ... | @@ -1385,7 +1385,7 @@ fn transStmt( |
| 1385 | rp, | 1385 | rp, |
| 1386 | error.UnsupportedTranslation, | 1386 | error.UnsupportedTranslation, |
| 1387 | stmt.getBeginLoc(), | 1387 | stmt.getBeginLoc(), |
| 1388 | "TODO implement translation of stmt class {}", | 1388 | "TODO implement translation of stmt class {s}", |
| 1389 | .{@tagName(sc)}, | 1389 | .{@tagName(sc)}, |
| 1390 | ); | 1390 | ); |
| 1391 | }, | 1391 | }, |
| ... | @@ -1684,7 +1684,7 @@ fn transDeclStmtOne( | ... | @@ -1684,7 +1684,7 @@ fn transDeclStmtOne( |
| 1684 | rp, | 1684 | rp, |
| 1685 | error.UnsupportedTranslation, | 1685 | error.UnsupportedTranslation, |
| 1686 | decl.getLocation(), | 1686 | decl.getLocation(), |
| 1687 | "TODO implement translation of DeclStmt kind {}", | 1687 | "TODO implement translation of DeclStmt kind {s}", |
| 1688 | .{@tagName(kind)}, | 1688 | .{@tagName(kind)}, |
| 1689 | ), | 1689 | ), |
| 1690 | } | 1690 | } |
| ... | @@ -1782,7 +1782,7 @@ fn transImplicitCastExpr( | ... | @@ -1782,7 +1782,7 @@ fn transImplicitCastExpr( |
| 1782 | rp, | 1782 | rp, |
| 1783 | error.UnsupportedTranslation, | 1783 | error.UnsupportedTranslation, |
| 1784 | @ptrCast(*const clang.Stmt, expr).getBeginLoc(), | 1784 | @ptrCast(*const clang.Stmt, expr).getBeginLoc(), |
| 1785 | "TODO implement translation of CastKind {}", | 1785 | "TODO implement translation of CastKind {s}", |
| 1786 | .{@tagName(kind)}, | 1786 | .{@tagName(kind)}, |
| 1787 | ), | 1787 | ), |
| 1788 | } | 1788 | } |
| ... | @@ -2043,7 +2043,7 @@ fn transStringLiteral( | ... | @@ -2043,7 +2043,7 @@ fn transStringLiteral( |
| 2043 | rp, | 2043 | rp, |
| 2044 | error.UnsupportedTranslation, | 2044 | error.UnsupportedTranslation, |
| 2045 | @ptrCast(*const clang.Stmt, stmt).getBeginLoc(), | 2045 | @ptrCast(*const clang.Stmt, stmt).getBeginLoc(), |
| 2046 | "TODO: support string literal kind {}", | 2046 | "TODO: support string literal kind {s}", |
| 2047 | .{kind}, | 2047 | .{kind}, |
| 2048 | ), | 2048 | ), |
| 2049 | } | 2049 | } |
| ... | @@ -2168,7 +2168,6 @@ fn transCCast( | ... | @@ -2168,7 +2168,6 @@ fn transCCast( |
| 2168 | // @boolToInt returns either a comptime_int or a u1 | 2168 | // @boolToInt returns either a comptime_int or a u1 |
| 2169 | // TODO: if dst_type is 1 bit & signed (bitfield) we need @bitCast | 2169 | // TODO: if dst_type is 1 bit & signed (bitfield) we need @bitCast |
| 2170 | // instead of @as | 2170 | // instead of @as |
| 2171 | |||
| 2172 | const builtin_node = try rp.c.createBuiltinCall("@boolToInt", 1); | 2171 | const builtin_node = try rp.c.createBuiltinCall("@boolToInt", 1); |
| 2173 | builtin_node.params()[0] = expr; | 2172 | builtin_node.params()[0] = expr; |
| 2174 | builtin_node.rparen_token = try appendToken(rp.c, .RParen, ")"); | 2173 | builtin_node.rparen_token = try appendToken(rp.c, .RParen, ")"); |
| ... | @@ -2455,7 +2454,7 @@ fn transInitListExpr( | ... | @@ -2455,7 +2454,7 @@ fn transInitListExpr( |
| 2455 | ); | 2454 | ); |
| 2456 | } else { | 2455 | } else { |
| 2457 | const type_name = rp.c.str(qual_type.getTypeClassName()); | 2456 | 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}); |
| 2459 | } | 2458 | } |
| 2460 | } | 2459 | } |
| 2461 | 2460 | ||
| ... | @@ -3957,7 +3956,7 @@ fn qualTypeToLog2IntRef(rp: RestorePoint, qt: clang.QualType, source_loc: clang. | ... | @@ -3957,7 +3956,7 @@ fn qualTypeToLog2IntRef(rp: RestorePoint, qt: clang.QualType, source_loc: clang. |
| 3957 | const node = try rp.c.arena.create(ast.Node.OneToken); | 3956 | const node = try rp.c.arena.create(ast.Node.OneToken); |
| 3958 | node.* = .{ | 3957 | node.* = .{ |
| 3959 | .base = .{ .tag = .IntegerLiteral }, | 3958 | .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}), |
| 3961 | }; | 3960 | }; |
| 3962 | return &node.base; | 3961 | return &node.base; |
| 3963 | } | 3962 | } |
| ... | @@ -4433,7 +4432,8 @@ fn transCreateNodeBoolLiteral(c: *Context, value: bool) !*ast.Node { | ... | @@ -4433,7 +4432,8 @@ fn transCreateNodeBoolLiteral(c: *Context, value: bool) !*ast.Node { |
| 4433 | } | 4432 | } |
| 4434 | 4433 | ||
| 4435 | fn transCreateNodeInt(c: *Context, int: anytype) !*ast.Node { | 4434 | fn 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}); | ||
| 4437 | const node = try c.arena.create(ast.Node.OneToken); | 4437 | const node = try c.arena.create(ast.Node.OneToken); |
| 4438 | node.* = .{ | 4438 | node.* = .{ |
| 4439 | .base = .{ .tag = .IntegerLiteral }, | 4439 | .base = .{ .tag = .IntegerLiteral }, |
| ... | @@ -4442,8 +4442,8 @@ fn transCreateNodeInt(c: *Context, int: anytype) !*ast.Node { | ... | @@ -4442,8 +4442,8 @@ fn transCreateNodeInt(c: *Context, int: anytype) !*ast.Node { |
| 4442 | return &node.base; | 4442 | return &node.base; |
| 4443 | } | 4443 | } |
| 4444 | 4444 | ||
| 4445 | fn transCreateNodeFloat(c: *Context, int: anytype) !*ast.Node { | 4445 | fn transCreateNodeFloat(c: *Context, str: []const u8) !*ast.Node { |
| 4446 | const token = try appendTokenFmt(c, .FloatLiteral, "{}", .{int}); | 4446 | const token = try appendTokenFmt(c, .FloatLiteral, "{s}", .{str}); |
| 4447 | const node = try c.arena.create(ast.Node.OneToken); | 4447 | const node = try c.arena.create(ast.Node.OneToken); |
| 4448 | node.* = .{ | 4448 | node.* = .{ |
| 4449 | .base = .{ .tag = .FloatLiteral }, | 4449 | .base = .{ .tag = .FloatLiteral }, |
| ... | @@ -4484,7 +4484,7 @@ fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: *ast.Node, proto_a | ... | @@ -4484,7 +4484,7 @@ fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: *ast.Node, proto_a |
| 4484 | _ = try appendToken(c, .Comma, ","); | 4484 | _ = try appendToken(c, .Comma, ","); |
| 4485 | } | 4485 | } |
| 4486 | const param_name_tok = param.name_token orelse | 4486 | 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()}); |
| 4488 | 4488 | ||
| 4489 | _ = try appendToken(c, .Colon, ":"); | 4489 | _ = try appendToken(c, .Colon, ":"); |
| 4490 | 4490 | ||
| ... | @@ -4916,7 +4916,7 @@ fn transType(rp: RestorePoint, ty: *const clang.Type, source_loc: clang.SourceLo | ... | @@ -4916,7 +4916,7 @@ fn transType(rp: RestorePoint, ty: *const clang.Type, source_loc: clang.SourceLo |
| 4916 | }, | 4916 | }, |
| 4917 | else => { | 4917 | else => { |
| 4918 | const type_name = rp.c.str(ty.getTypeClassName()); | 4918 | 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}); |
| 4920 | }, | 4920 | }, |
| 4921 | } | 4921 | } |
| 4922 | } | 4922 | } |
| ... | @@ -4999,7 +4999,7 @@ fn transCC( | ... | @@ -4999,7 +4999,7 @@ fn transCC( |
| 4999 | rp, | 4999 | rp, |
| 5000 | error.UnsupportedType, | 5000 | error.UnsupportedType, |
| 5001 | source_loc, | 5001 | source_loc, |
| 5002 | "unsupported calling convention: {}", | 5002 | "unsupported calling convention: {s}", |
| 5003 | .{@tagName(clang_cc)}, | 5003 | .{@tagName(clang_cc)}, |
| 5004 | ), | 5004 | ), |
| 5005 | } | 5005 | } |
| ... | @@ -5117,7 +5117,7 @@ fn finishTransFnProto( | ... | @@ -5117,7 +5117,7 @@ fn finishTransFnProto( |
| 5117 | _ = try appendToken(rp.c, .LParen, "("); | 5117 | _ = try appendToken(rp.c, .LParen, "("); |
| 5118 | const expr = try transCreateNodeStringLiteral( | 5118 | const expr = try transCreateNodeStringLiteral( |
| 5119 | rp.c, | 5119 | 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]}), |
| 5121 | ); | 5121 | ); |
| 5122 | _ = try appendToken(rp.c, .RParen, ")"); | 5122 | _ = try appendToken(rp.c, .RParen, ")"); |
| 5123 | 5123 | ||
| ... | @@ -5214,7 +5214,7 @@ fn revertAndWarn( | ... | @@ -5214,7 +5214,7 @@ fn revertAndWarn( |
| 5214 | 5214 | ||
| 5215 | fn emitWarning(c: *Context, loc: clang.SourceLocation, comptime format: []const u8, args: anytype) !void { | 5215 | fn emitWarning(c: *Context, loc: clang.SourceLocation, comptime format: []const u8, args: anytype) !void { |
| 5216 | const args_prefix = .{c.locStr(loc)}; | 5216 | 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); |
| 5218 | } | 5218 | } |
| 5219 | 5219 | ||
| 5220 | pub fn failDecl(c: *Context, loc: clang.SourceLocation, name: []const u8, comptime format: []const u8, args: anytype) !void { | 5220 | pub 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 | ... | @@ -5228,7 +5228,7 @@ pub fn failDecl(c: *Context, loc: clang.SourceLocation, name: []const u8, compti |
| 5228 | const msg_tok = try appendTokenFmt(c, .StringLiteral, "\"" ++ format ++ "\"", args); | 5228 | const msg_tok = try appendTokenFmt(c, .StringLiteral, "\"" ++ format ++ "\"", args); |
| 5229 | const rparen_tok = try appendToken(c, .RParen, ")"); | 5229 | const rparen_tok = try appendToken(c, .RParen, ")"); |
| 5230 | const semi_tok = try appendToken(c, .Semicolon, ";"); | 5230 | const semi_tok = try appendToken(c, .Semicolon, ";"); |
| 5231 | _ = try appendTokenFmt(c, .LineComment, "// {}", .{c.locStr(loc)}); | 5231 | _ = try appendTokenFmt(c, .LineComment, "// {s}", .{c.locStr(loc)}); |
| 5232 | 5232 | ||
| 5233 | const msg_node = try c.arena.create(ast.Node.OneToken); | 5233 | const msg_node = try c.arena.create(ast.Node.OneToken); |
| 5234 | msg_node.* = .{ | 5234 | msg_node.* = .{ |
| ... | @@ -5258,7 +5258,7 @@ pub fn failDecl(c: *Context, loc: clang.SourceLocation, name: []const u8, compti | ... | @@ -5258,7 +5258,7 @@ pub fn failDecl(c: *Context, loc: clang.SourceLocation, name: []const u8, compti |
| 5258 | 5258 | ||
| 5259 | fn appendToken(c: *Context, token_id: Token.Id, bytes: []const u8) !ast.TokenIndex { | 5259 | fn appendToken(c: *Context, token_id: Token.Id, bytes: []const u8) !ast.TokenIndex { |
| 5260 | std.debug.assert(token_id != .Identifier); // use appendIdentifier | 5260 | std.debug.assert(token_id != .Identifier); // use appendIdentifier |
| 5261 | return appendTokenFmt(c, token_id, "{}", .{bytes}); | 5261 | return appendTokenFmt(c, token_id, "{s}", .{bytes}); |
| 5262 | } | 5262 | } |
| 5263 | 5263 | ||
| 5264 | fn appendTokenFmt(c: *Context, token_id: Token.Id, comptime format: []const u8, args: anytype) !ast.TokenIndex { | 5264 | fn 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 { | ... | @@ -5329,7 +5329,7 @@ fn transCreateNodeIdentifier(c: *Context, name: []const u8) !*ast.Node { |
| 5329 | } | 5329 | } |
| 5330 | 5330 | ||
| 5331 | fn transCreateNodeIdentifierUnchecked(c: *Context, name: []const u8) !*ast.Node { | 5331 | fn 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}); |
| 5333 | const identifier = try c.arena.create(ast.Node.OneToken); | 5333 | const identifier = try c.arena.create(ast.Node.OneToken); |
| 5334 | identifier.* = .{ | 5334 | identifier.* = .{ |
| 5335 | .base = .{ .tag = .Identifier }, | 5335 | .base = .{ .tag = .Identifier }, |
| ... | @@ -5390,7 +5390,7 @@ fn transPreprocessorEntities(c: *Context, unit: *clang.ASTUnit) Error!void { | ... | @@ -5390,7 +5390,7 @@ fn transPreprocessorEntities(c: *Context, unit: *clang.ASTUnit) Error!void { |
| 5390 | const name = try c.str(raw_name); | 5390 | const name = try c.str(raw_name); |
| 5391 | // TODO https://github.com/ziglang/zig/issues/3756 | 5391 | // TODO https://github.com/ziglang/zig/issues/3756 |
| 5392 | // TODO https://github.com/ziglang/zig/issues/1802 | 5392 | // 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; |
| 5394 | if (scope.containsNow(mangled_name)) { | 5394 | if (scope.containsNow(mangled_name)) { |
| 5395 | continue; | 5395 | continue; |
| 5396 | } | 5396 | } |
| ... | @@ -5468,7 +5468,7 @@ fn transMacroDefine(c: *Context, m: *MacroCtx) ParseError!void { | ... | @@ -5468,7 +5468,7 @@ fn transMacroDefine(c: *Context, m: *MacroCtx) ParseError!void { |
| 5468 | const init_node = try parseCExpr(c, m, scope); | 5468 | const init_node = try parseCExpr(c, m, scope); |
| 5469 | const last = m.next().?; | 5469 | const last = m.next().?; |
| 5470 | if (last != .Eof and last != .Nl) | 5470 | 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)}); |
| 5472 | 5472 | ||
| 5473 | const semicolon_token = try appendToken(c, .Semicolon, ";"); | 5473 | const semicolon_token = try appendToken(c, .Semicolon, ";"); |
| 5474 | const node = try ast.Node.VarDecl.create(c.arena, .{ | 5474 | const node = try ast.Node.VarDecl.create(c.arena, .{ |
| ... | @@ -5540,7 +5540,7 @@ fn transMacroFnDefine(c: *Context, m: *MacroCtx) ParseError!void { | ... | @@ -5540,7 +5540,7 @@ fn transMacroFnDefine(c: *Context, m: *MacroCtx) ParseError!void { |
| 5540 | const expr = try parseCExpr(c, m, scope); | 5540 | const expr = try parseCExpr(c, m, scope); |
| 5541 | const last = m.next().?; | 5541 | const last = m.next().?; |
| 5542 | if (last != .Eof and last != .Nl) | 5542 | 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)}); |
| 5544 | _ = try appendToken(c, .Semicolon, ";"); | 5544 | _ = try appendToken(c, .Semicolon, ";"); |
| 5545 | const type_of_arg = if (!expr.tag.isBlock()) expr else blk: { | 5545 | const type_of_arg = if (!expr.tag.isBlock()) expr else blk: { |
| 5546 | const stmts = expr.blockStatements(); | 5546 | const stmts = expr.blockStatements(); |
| ... | @@ -5623,11 +5623,11 @@ fn parseCNumLit(c: *Context, m: *MacroCtx) ParseError!*ast.Node { | ... | @@ -5623,11 +5623,11 @@ fn parseCNumLit(c: *Context, m: *MacroCtx) ParseError!*ast.Node { |
| 5623 | switch (lit_bytes[1]) { | 5623 | switch (lit_bytes[1]) { |
| 5624 | '0'...'7' => { | 5624 | '0'...'7' => { |
| 5625 | // Octal | 5625 | // 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}); |
| 5627 | }, | 5627 | }, |
| 5628 | 'X' => { | 5628 | 'X' => { |
| 5629 | // Hexadecimal with capital X, valid in C but not in Zig | 5629 | // 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..]}); |
| 5631 | }, | 5631 | }, |
| 5632 | else => {}, | 5632 | else => {}, |
| 5633 | } | 5633 | } |
| ... | @@ -5659,7 +5659,7 @@ fn parseCNumLit(c: *Context, m: *MacroCtx) ParseError!*ast.Node { | ... | @@ -5659,7 +5659,7 @@ fn parseCNumLit(c: *Context, m: *MacroCtx) ParseError!*ast.Node { |
| 5659 | }, | 5659 | }, |
| 5660 | .FloatLiteral => |suffix| { | 5660 | .FloatLiteral => |suffix| { |
| 5661 | if (lit_bytes[0] == '.') | 5661 | 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}); |
| 5663 | if (suffix == .none) { | 5663 | if (suffix == .none) { |
| 5664 | return transCreateNodeFloat(c, lit_bytes); | 5664 | return transCreateNodeFloat(c, lit_bytes); |
| 5665 | } | 5665 | } |
| ... | @@ -5916,11 +5916,11 @@ fn parseCPrimaryExprInner(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!* | ... | @@ -5916,11 +5916,11 @@ fn parseCPrimaryExprInner(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!* |
| 5916 | // struct Foo will be declared as struct_Foo by transRecordDecl | 5916 | // struct Foo will be declared as struct_Foo by transRecordDecl |
| 5917 | const next_id = m.next().?; | 5917 | const next_id = m.next().?; |
| 5918 | if (next_id != .Identifier) { | 5918 | 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)}); |
| 5920 | return error.ParseError; | 5920 | return error.ParseError; |
| 5921 | } | 5921 | } |
| 5922 | 5922 | ||
| 5923 | const ident_token = try appendTokenFmt(c, .Identifier, "{}_{}", .{ slice, m.slice() }); | 5923 | const ident_token = try appendTokenFmt(c, .Identifier, "{s}_{s}", .{ slice, m.slice() }); |
| 5924 | const identifier = try c.arena.create(ast.Node.OneToken); | 5924 | const identifier = try c.arena.create(ast.Node.OneToken); |
| 5925 | identifier.* = .{ | 5925 | identifier.* = .{ |
| 5926 | .base = .{ .tag = .Identifier }, | 5926 | .base = .{ .tag = .Identifier }, |
| ... | @@ -5937,7 +5937,7 @@ fn parseCPrimaryExprInner(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!* | ... | @@ -5937,7 +5937,7 @@ fn parseCPrimaryExprInner(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!* |
| 5937 | 5937 | ||
| 5938 | const next_id = m.next().?; | 5938 | const next_id = m.next().?; |
| 5939 | if (next_id != .RParen) { | 5939 | 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)}); |
| 5941 | return error.ParseError; | 5941 | return error.ParseError; |
| 5942 | } | 5942 | } |
| 5943 | var saw_l_paren = false; | 5943 | var saw_l_paren = false; |
| ... | @@ -5995,7 +5995,7 @@ fn parseCPrimaryExprInner(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!* | ... | @@ -5995,7 +5995,7 @@ fn parseCPrimaryExprInner(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!* |
| 5995 | return &group_node.base; | 5995 | return &group_node.base; |
| 5996 | }, | 5996 | }, |
| 5997 | else => { | 5997 | 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)}); |
| 5999 | return error.ParseError; | 5999 | return error.ParseError; |
| 6000 | }, | 6000 | }, |
| 6001 | } | 6001 | } |
src/type.zig+4-4| ... | @@ -558,21 +558,21 @@ pub const Type = extern union { | ... | @@ -558,21 +558,21 @@ pub const Type = extern union { |
| 558 | }, | 558 | }, |
| 559 | .array_u8 => { | 559 | .array_u8 => { |
| 560 | const len = ty.castTag(.array_u8).?.data; | 560 | const len = ty.castTag(.array_u8).?.data; |
| 561 | return out_stream.print("[{}]u8", .{len}); | 561 | return out_stream.print("[{d}]u8", .{len}); |
| 562 | }, | 562 | }, |
| 563 | .array_u8_sentinel_0 => { | 563 | .array_u8_sentinel_0 => { |
| 564 | const len = ty.castTag(.array_u8_sentinel_0).?.data; | 564 | 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}); |
| 566 | }, | 566 | }, |
| 567 | .array => { | 567 | .array => { |
| 568 | const payload = ty.castTag(.array).?.data; | 568 | const payload = ty.castTag(.array).?.data; |
| 569 | try out_stream.print("[{}]", .{payload.len}); | 569 | try out_stream.print("[{d}]", .{payload.len}); |
| 570 | ty = payload.elem_type; | 570 | ty = payload.elem_type; |
| 571 | continue; | 571 | continue; |
| 572 | }, | 572 | }, |
| 573 | .array_sentinel => { | 573 | .array_sentinel => { |
| 574 | const payload = ty.castTag(.array_sentinel).?.data; | 574 | 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 }); |
| 576 | ty = payload.elem_type; | 576 | ty = payload.elem_type; |
| 577 | continue; | 577 | continue; |
| 578 | }, | 578 | }, |
src/value.zig+2-2| ... | @@ -464,7 +464,7 @@ pub const Value = extern union { | ... | @@ -464,7 +464,7 @@ pub const Value = extern union { |
| 464 | .ty => return val.castTag(.ty).?.data.format("", options, out_stream), | 464 | .ty => return val.castTag(.ty).?.data.format("", options, out_stream), |
| 465 | .int_type => { | 465 | .int_type => { |
| 466 | const int_type = val.castTag(.int_type).?.data; | 466 | const int_type = val.castTag(.int_type).?.data; |
| 467 | return out_stream.print("{}{}", .{ | 467 | return out_stream.print("{s}{d}", .{ |
| 468 | if (int_type.signed) "s" else "u", | 468 | if (int_type.signed) "s" else "u", |
| 469 | int_type.bits, | 469 | int_type.bits, |
| 470 | }); | 470 | }); |
| ... | @@ -507,7 +507,7 @@ pub const Value = extern union { | ... | @@ -507,7 +507,7 @@ pub const Value = extern union { |
| 507 | } | 507 | } |
| 508 | return out_stream.writeAll("}"); | 508 | return out_stream.writeAll("}"); |
| 509 | }, | 509 | }, |
| 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}), |
| 511 | .inferred_alloc => return out_stream.writeAll("(inferred allocation value)"), | 511 | .inferred_alloc => return out_stream.writeAll("(inferred allocation value)"), |
| 512 | }; | 512 | }; |
| 513 | } | 513 | } |
src/zir.zig+31-32| ... | @@ -1150,7 +1150,7 @@ pub const Module = struct { | ... | @@ -1150,7 +1150,7 @@ pub const Module = struct { |
| 1150 | 1150 | ||
| 1151 | for (self.decls) |decl, i| { | 1151 | for (self.decls) |decl, i| { |
| 1152 | write.next_instr_index = 0; | 1152 | write.next_instr_index = 0; |
| 1153 | try stream.print("@{} ", .{decl.name}); | 1153 | try stream.print("@{s} ", .{decl.name}); |
| 1154 | try write.writeInstToStream(stream, decl.inst); | 1154 | try write.writeInstToStream(stream, decl.inst); |
| 1155 | try stream.writeByte('\n'); | 1155 | try stream.writeByte('\n'); |
| 1156 | } | 1156 | } |
| ... | @@ -1206,13 +1206,13 @@ const Writer = struct { | ... | @@ -1206,13 +1206,13 @@ const Writer = struct { |
| 1206 | if (@typeInfo(arg_field.field_type) == .Optional) { | 1206 | if (@typeInfo(arg_field.field_type) == .Optional) { |
| 1207 | if (@field(inst.kw_args, arg_field.name)) |non_optional| { | 1207 | if (@field(inst.kw_args, arg_field.name)) |non_optional| { |
| 1208 | if (need_comma) try stream.writeAll(", "); | 1208 | if (need_comma) try stream.writeAll(", "); |
| 1209 | try stream.print("{}=", .{arg_field.name}); | 1209 | try stream.print("{s}=", .{arg_field.name}); |
| 1210 | try self.writeParamToStream(stream, &non_optional); | 1210 | try self.writeParamToStream(stream, &non_optional); |
| 1211 | need_comma = true; | 1211 | need_comma = true; |
| 1212 | } | 1212 | } |
| 1213 | } else { | 1213 | } else { |
| 1214 | if (need_comma) try stream.writeAll(", "); | 1214 | if (need_comma) try stream.writeAll(", "); |
| 1215 | try stream.print("{}=", .{arg_field.name}); | 1215 | try stream.print("{s}=", .{arg_field.name}); |
| 1216 | try self.writeParamToStream(stream, &@field(inst.kw_args, arg_field.name)); | 1216 | try self.writeParamToStream(stream, &@field(inst.kw_args, arg_field.name)); |
| 1217 | need_comma = true; | 1217 | need_comma = true; |
| 1218 | } | 1218 | } |
| ... | @@ -1257,12 +1257,12 @@ const Writer = struct { | ... | @@ -1257,12 +1257,12 @@ const Writer = struct { |
| 1257 | self.next_instr_index += 1; | 1257 | self.next_instr_index += 1; |
| 1258 | try self.inst_table.putNoClobber(inst, .{ .inst = inst, .index = my_i, .name = undefined }); | 1258 | try self.inst_table.putNoClobber(inst, .{ .inst = inst, .index = my_i, .name = undefined }); |
| 1259 | try stream.writeByteNTimes(' ', self.indent); | 1259 | try stream.writeByteNTimes(' ', self.indent); |
| 1260 | try stream.print("%{} ", .{my_i}); | 1260 | try stream.print("%{d} ", .{my_i}); |
| 1261 | if (inst.cast(Inst.Block)) |block| { | 1261 | 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}); |
| 1263 | try self.block_table.put(block, name); | 1263 | try self.block_table.put(block, name); |
| 1264 | } else if (inst.cast(Inst.Loop)) |loop| { | 1264 | } 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}); |
| 1266 | try self.loop_table.put(loop, name); | 1266 | try self.loop_table.put(loop, name); |
| 1267 | } | 1267 | } |
| 1268 | self.indent += 2; | 1268 | self.indent += 2; |
| ... | @@ -1332,18 +1332,18 @@ const Writer = struct { | ... | @@ -1332,18 +1332,18 @@ const Writer = struct { |
| 1332 | fn writeInstParamToStream(self: *Writer, stream: anytype, inst: *Inst) !void { | 1332 | fn writeInstParamToStream(self: *Writer, stream: anytype, inst: *Inst) !void { |
| 1333 | if (self.inst_table.get(inst)) |info| { | 1333 | if (self.inst_table.get(inst)) |info| { |
| 1334 | if (info.index) |i| { | 1334 | if (info.index) |i| { |
| 1335 | try stream.print("%{}", .{info.index}); | 1335 | try stream.print("%{d}", .{info.index}); |
| 1336 | } else { | 1336 | } else { |
| 1337 | try stream.print("@{}", .{info.name}); | 1337 | try stream.print("@{s}", .{info.name}); |
| 1338 | } | 1338 | } |
| 1339 | } else if (inst.cast(Inst.DeclVal)) |decl_val| { | 1339 | } 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}); |
| 1341 | } else if (inst.cast(Inst.DeclValInModule)) |decl_val| { | 1341 | } 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}); |
| 1343 | } else { | 1343 | } else { |
| 1344 | // This should be unreachable in theory, but since ZIR is used for debugging the compiler | 1344 | // This should be unreachable in theory, but since ZIR is used for debugging the compiler |
| 1345 | // we output some debug text instead. | 1345 | // we output some debug text instead. |
| 1346 | try stream.print("?{}?", .{@tagName(inst.tag)}); | 1346 | try stream.print("?{s}?", .{@tagName(inst.tag)}); |
| 1347 | } | 1347 | } |
| 1348 | } | 1348 | } |
| 1349 | }; | 1349 | }; |
| ... | @@ -1424,7 +1424,7 @@ const Parser = struct { | ... | @@ -1424,7 +1424,7 @@ const Parser = struct { |
| 1424 | const decl = try parseInstruction(self, &body_context, ident); | 1424 | const decl = try parseInstruction(self, &body_context, ident); |
| 1425 | const ident_index = body_context.instructions.items.len; | 1425 | const ident_index = body_context.instructions.items.len; |
| 1426 | if (try body_context.name_map.fetchPut(ident, decl.inst)) |_| { | 1426 | 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}); |
| 1428 | } | 1428 | } |
| 1429 | try body_context.instructions.append(decl.inst); | 1429 | try body_context.instructions.append(decl.inst); |
| 1430 | continue; | 1430 | continue; |
| ... | @@ -1510,7 +1510,7 @@ const Parser = struct { | ... | @@ -1510,7 +1510,7 @@ const Parser = struct { |
| 1510 | const decl = try parseInstruction(self, null, ident); | 1510 | const decl = try parseInstruction(self, null, ident); |
| 1511 | const ident_index = self.decls.items.len; | 1511 | const ident_index = self.decls.items.len; |
| 1512 | if (try self.global_name_map.fetchPut(ident, decl.inst)) |_| { | 1512 | 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}); |
| 1514 | } | 1514 | } |
| 1515 | try self.decls.append(self.allocator, decl); | 1515 | try self.decls.append(self.allocator, decl); |
| 1516 | }, | 1516 | }, |
| ... | @@ -1538,7 +1538,7 @@ const Parser = struct { | ... | @@ -1538,7 +1538,7 @@ const Parser = struct { |
| 1538 | for (bytes) |byte| { | 1538 | for (bytes) |byte| { |
| 1539 | if (self.source[self.i] != byte) { | 1539 | if (self.source[self.i] != byte) { |
| 1540 | self.i = start; | 1540 | self.i = start; |
| 1541 | return self.fail("expected '{}'", .{bytes}); | 1541 | return self.fail("expected '{s}'", .{bytes}); |
| 1542 | } | 1542 | } |
| 1543 | self.i += 1; | 1543 | self.i += 1; |
| 1544 | } | 1544 | } |
| ... | @@ -1585,7 +1585,7 @@ const Parser = struct { | ... | @@ -1585,7 +1585,7 @@ const Parser = struct { |
| 1585 | return parseInstructionGeneric(self, field.name, tag.Type(), tag, body_ctx, name, contents_start); | 1585 | return parseInstructionGeneric(self, field.name, tag.Type(), tag, body_ctx, name, contents_start); |
| 1586 | } | 1586 | } |
| 1587 | } | 1587 | } |
| 1588 | return self.fail("unknown instruction '{}'", .{fn_name}); | 1588 | return self.fail("unknown instruction '{s}'", .{fn_name}); |
| 1589 | } | 1589 | } |
| 1590 | 1590 | ||
| 1591 | fn parseInstructionGeneric( | 1591 | fn parseInstructionGeneric( |
| ... | @@ -1621,7 +1621,7 @@ const Parser = struct { | ... | @@ -1621,7 +1621,7 @@ const Parser = struct { |
| 1621 | self.i += 1; | 1621 | self.i += 1; |
| 1622 | skipSpace(self); | 1622 | skipSpace(self); |
| 1623 | } else if (self.source[self.i] == ')') { | 1623 | } 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}); |
| 1625 | } | 1625 | } |
| 1626 | @field(inst_specific.positionals, arg_field.name) = try parseParameterGeneric( | 1626 | @field(inst_specific.positionals, arg_field.name) = try parseParameterGeneric( |
| 1627 | self, | 1627 | self, |
| ... | @@ -1648,7 +1648,7 @@ const Parser = struct { | ... | @@ -1648,7 +1648,7 @@ const Parser = struct { |
| 1648 | break; | 1648 | break; |
| 1649 | } | 1649 | } |
| 1650 | } else { | 1650 | } else { |
| 1651 | return self.fail("unrecognized keyword parameter: '{}'", .{name}); | 1651 | return self.fail("unrecognized keyword parameter: '{s}'", .{name}); |
| 1652 | } | 1652 | } |
| 1653 | skipSpace(self); | 1653 | skipSpace(self); |
| 1654 | } | 1654 | } |
| ... | @@ -1660,7 +1660,6 @@ const Parser = struct { | ... | @@ -1660,7 +1660,6 @@ const Parser = struct { |
| 1660 | .contents_hash = std.zig.hashSrc(self.source[contents_start..self.i]), | 1660 | .contents_hash = std.zig.hashSrc(self.source[contents_start..self.i]), |
| 1661 | .inst = &inst_specific.base, | 1661 | .inst = &inst_specific.base, |
| 1662 | }; | 1662 | }; |
| 1663 | //std.debug.warn("parsed {} = '{}'\n", .{ inst_specific.base.name, inst_specific.base.contents }); | ||
| 1664 | 1663 | ||
| 1665 | return decl; | 1664 | return decl; |
| 1666 | } | 1665 | } |
| ... | @@ -1672,7 +1671,7 @@ const Parser = struct { | ... | @@ -1672,7 +1671,7 @@ const Parser = struct { |
| 1672 | ' ', '\n', ',', ')' => { | 1671 | ' ', '\n', ',', ')' => { |
| 1673 | const enum_name = self.source[start..self.i]; | 1672 | const enum_name = self.source[start..self.i]; |
| 1674 | return std.meta.stringToEnum(T, enum_name) orelse { | 1673 | 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) }); |
| 1676 | }; | 1675 | }; |
| 1677 | }, | 1676 | }, |
| 1678 | 0 => return self.failByte(0), | 1677 | 0 => return self.failByte(0), |
| ... | @@ -1710,7 +1709,7 @@ const Parser = struct { | ... | @@ -1710,7 +1709,7 @@ const Parser = struct { |
| 1710 | BigIntConst => return self.parseIntegerLiteral(), | 1709 | BigIntConst => return self.parseIntegerLiteral(), |
| 1711 | usize => { | 1710 | usize => { |
| 1712 | const big_int = try self.parseIntegerLiteral(); | 1711 | 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)}); |
| 1714 | }, | 1713 | }, |
| 1715 | TypedValue => return self.fail("'const' is a special instruction; not legal in ZIR text", .{}), | 1714 | TypedValue => return self.fail("'const' is a special instruction; not legal in ZIR text", .{}), |
| 1716 | *IrModule.Decl => return self.fail("'declval_in_module' is a special instruction; not legal in ZIR text", .{}), | 1715 | *IrModule.Decl => return self.fail("'declval_in_module' is a special instruction; not legal in ZIR text", .{}), |
| ... | @@ -1759,7 +1758,7 @@ const Parser = struct { | ... | @@ -1759,7 +1758,7 @@ const Parser = struct { |
| 1759 | }, | 1758 | }, |
| 1760 | else => @compileError("Unimplemented: ir parseParameterGeneric for type " ++ @typeName(T)), | 1759 | else => @compileError("Unimplemented: ir parseParameterGeneric for type " ++ @typeName(T)), |
| 1761 | } | 1760 | } |
| 1762 | return self.fail("TODO parse parameter {}", .{@typeName(T)}); | 1761 | return self.fail("TODO parse parameter {s}", .{@typeName(T)}); |
| 1763 | } | 1762 | } |
| 1764 | 1763 | ||
| 1765 | fn parseParameterInst(self: *Parser, body_ctx: ?*Body) !*Inst { | 1764 | fn parseParameterInst(self: *Parser, body_ctx: ?*Body) !*Inst { |
| ... | @@ -1788,7 +1787,7 @@ const Parser = struct { | ... | @@ -1788,7 +1787,7 @@ const Parser = struct { |
| 1788 | const src = name_start - 1; | 1787 | const src = name_start - 1; |
| 1789 | if (local_ref) { | 1788 | if (local_ref) { |
| 1790 | self.i = src; | 1789 | self.i = src; |
| 1791 | return self.fail("unrecognized identifier: {}", .{bad_name}); | 1790 | return self.fail("unrecognized identifier: {s}", .{bad_name}); |
| 1792 | } else { | 1791 | } else { |
| 1793 | const declval = try self.arena.allocator.create(Inst.DeclVal); | 1792 | const declval = try self.arena.allocator.create(Inst.DeclVal); |
| 1794 | declval.* = .{ | 1793 | declval.* = .{ |
| ... | @@ -1805,7 +1804,7 @@ const Parser = struct { | ... | @@ -1805,7 +1804,7 @@ const Parser = struct { |
| 1805 | } | 1804 | } |
| 1806 | 1805 | ||
| 1807 | fn generateName(self: *Parser) ![]u8 { | 1806 | 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}); |
| 1809 | self.unnamed_index += 1; | 1808 | self.unnamed_index += 1; |
| 1810 | return result; | 1809 | return result; |
| 1811 | } | 1810 | } |
| ... | @@ -1873,7 +1872,7 @@ pub fn dumpFn(old_module: IrModule, module_fn: *IrModule.Fn) void { | ... | @@ -1873,7 +1872,7 @@ pub fn dumpFn(old_module: IrModule, module_fn: *IrModule.Fn) void { |
| 1873 | 1872 | ||
| 1874 | const fn_ty = module_fn.owner_decl.typed_value.most_recent.typed_value.ty; | 1873 | const fn_ty = module_fn.owner_decl.typed_value.most_recent.typed_value.ty; |
| 1875 | _ = ctx.emitFn(module_fn, 0, fn_ty) catch |err| { | 1874 | _ = 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)}); |
| 1877 | return; | 1876 | return; |
| 1878 | }; | 1877 | }; |
| 1879 | var module = Module{ | 1878 | var module = Module{ |
| ... | @@ -2203,7 +2202,7 @@ const EmitZIR = struct { | ... | @@ -2203,7 +2202,7 @@ const EmitZIR = struct { |
| 2203 | }; | 2202 | }; |
| 2204 | return self.emitStringLiteral(src, bytes); | 2203 | return self.emitStringLiteral(src, bytes); |
| 2205 | }, | 2204 | }, |
| 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)}), |
| 2207 | } | 2206 | } |
| 2208 | }, | 2207 | }, |
| 2209 | .ComptimeInt => return self.emitComptimeIntVal(src, typed_value.val), | 2208 | .ComptimeInt => return self.emitComptimeIntVal(src, typed_value.val), |
| ... | @@ -2274,7 +2273,7 @@ const EmitZIR = struct { | ... | @@ -2274,7 +2273,7 @@ const EmitZIR = struct { |
| 2274 | }; | 2273 | }; |
| 2275 | return self.emitUnnamedDecl(&inst.base); | 2274 | return self.emitUnnamedDecl(&inst.base); |
| 2276 | }, | 2275 | }, |
| 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)}), |
| 2278 | } | 2277 | } |
| 2279 | } | 2278 | } |
| 2280 | 2279 | ||
| ... | @@ -2865,7 +2864,7 @@ const EmitZIR = struct { | ... | @@ -2865,7 +2864,7 @@ const EmitZIR = struct { |
| 2865 | 2864 | ||
| 2866 | fn autoName(self: *EmitZIR) ![]u8 { | 2865 | fn autoName(self: *EmitZIR) ![]u8 { |
| 2867 | while (true) { | 2866 | 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}); |
| 2869 | self.next_auto_name += 1; | 2868 | self.next_auto_name += 1; |
| 2870 | const gop = try self.names.getOrPut(proposed_name); | 2869 | const gop = try self.names.getOrPut(proposed_name); |
| 2871 | if (!gop.found_existing) { | 2870 | if (!gop.found_existing) { |
| ... | @@ -2947,25 +2946,25 @@ pub fn dumpZir(allocator: *Allocator, kind: []const u8, decl_name: [*:0]const u8 | ... | @@ -2947,25 +2946,25 @@ pub fn dumpZir(allocator: *Allocator, kind: []const u8, decl_name: [*:0]const u8 |
| 2947 | try write.inst_table.ensureCapacity(@intCast(u32, instructions.len)); | 2946 | try write.inst_table.ensureCapacity(@intCast(u32, instructions.len)); |
| 2948 | 2947 | ||
| 2949 | const stderr = std.io.getStdErr().outStream(); | 2948 | 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 }); |
| 2951 | 2950 | ||
| 2952 | for (instructions) |inst| { | 2951 | for (instructions) |inst| { |
| 2953 | const my_i = write.next_instr_index; | 2952 | const my_i = write.next_instr_index; |
| 2954 | write.next_instr_index += 1; | 2953 | write.next_instr_index += 1; |
| 2955 | 2954 | ||
| 2956 | if (inst.cast(Inst.Block)) |block| { | 2955 | 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}); |
| 2958 | try write.block_table.put(block, name); | 2957 | try write.block_table.put(block, name); |
| 2959 | } else if (inst.cast(Inst.Loop)) |loop| { | 2958 | } 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}); |
| 2961 | try write.loop_table.put(loop, name); | 2960 | try write.loop_table.put(loop, name); |
| 2962 | } | 2961 | } |
| 2963 | 2962 | ||
| 2964 | try write.inst_table.putNoClobber(inst, .{ .inst = inst, .index = my_i, .name = "inst" }); | 2963 | 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}); |
| 2966 | try write.writeInstToStream(stderr, inst); | 2965 | try write.writeInstToStream(stderr, inst); |
| 2967 | try stderr.writeByte('\n'); | 2966 | try stderr.writeByte('\n'); |
| 2968 | } | 2967 | } |
| 2969 | 2968 | ||
| 2970 | try stderr.print("}} // {} {s}\n\n", .{ kind, decl_name }); | 2969 | try stderr.print("}} // {s} {s}\n\n", .{ kind, decl_name }); |
| 2971 | } | 2970 | } |
src/zir_sema.zig+24-24| ... | @@ -274,7 +274,7 @@ pub fn resolveInst(mod: *Module, scope: *Scope, old_inst: *zir.Inst) InnerError! | ... | @@ -274,7 +274,7 @@ pub fn resolveInst(mod: *Module, scope: *Scope, old_inst: *zir.Inst) InnerError! |
| 274 | const entry = if (old_inst.cast(zir.Inst.DeclVal)) |declval| blk: { | 274 | const entry = if (old_inst.cast(zir.Inst.DeclVal)) |declval| blk: { |
| 275 | const decl_name = declval.positionals.name; | 275 | const decl_name = declval.positionals.name; |
| 276 | const entry = zir_module.contents.module.findDecl(decl_name) orelse | 276 | 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}); |
| 278 | break :blk entry; | 278 | break :blk entry; |
| 279 | } else blk: { | 279 | } else blk: { |
| 280 | // If this assert trips, the instruction that was referenced did not get | 280 | // 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) | ... | @@ -535,7 +535,7 @@ fn analyzeInstParamType(mod: *Module, scope: *Scope, inst: *zir.Inst.ParamType) |
| 535 | // TODO support C-style var args | 535 | // TODO support C-style var args |
| 536 | const param_count = fn_ty.fnParamLen(); | 536 | const param_count = fn_ty.fnParamLen(); |
| 537 | if (arg_index >= param_count) { | 537 | 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)", .{ |
| 539 | arg_index, | 539 | arg_index, |
| 540 | fn_ty, | 540 | fn_ty, |
| 541 | param_count, | 541 | param_count, |
| ... | @@ -564,14 +564,14 @@ fn analyzeInstStr(mod: *Module, scope: *Scope, str_inst: *zir.Inst.Str) InnerErr | ... | @@ -564,14 +564,14 @@ fn analyzeInstStr(mod: *Module, scope: *Scope, str_inst: *zir.Inst.Str) InnerErr |
| 564 | fn analyzeInstExport(mod: *Module, scope: *Scope, export_inst: *zir.Inst.Export) InnerError!*Inst { | 564 | fn analyzeInstExport(mod: *Module, scope: *Scope, export_inst: *zir.Inst.Export) InnerError!*Inst { |
| 565 | const symbol_name = try resolveConstString(mod, scope, export_inst.positionals.symbol_name); | 565 | const symbol_name = try resolveConstString(mod, scope, export_inst.positionals.symbol_name); |
| 566 | const exported_decl = mod.lookupDeclName(scope, export_inst.positionals.decl_name) orelse | 566 | 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}); |
| 568 | try mod.analyzeExport(scope, export_inst.base.src, symbol_name, exported_decl); | 568 | try mod.analyzeExport(scope, export_inst.base.src, symbol_name, exported_decl); |
| 569 | return mod.constVoid(scope, export_inst.base.src); | 569 | return mod.constVoid(scope, export_inst.base.src); |
| 570 | } | 570 | } |
| 571 | 571 | ||
| 572 | fn analyzeInstCompileError(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { | 572 | fn analyzeInstCompileError(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { |
| 573 | const msg = try resolveConstString(mod, scope, inst.positionals.operand); | 573 | 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}); |
| 575 | } | 575 | } |
| 576 | 576 | ||
| 577 | fn analyzeInstArg(mod: *Module, scope: *Scope, inst: *zir.Inst.Arg) InnerError!*Inst { | 577 | fn 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!* | ... | @@ -580,7 +580,7 @@ fn analyzeInstArg(mod: *Module, scope: *Scope, inst: *zir.Inst.Arg) InnerError!* |
| 580 | const param_index = b.instructions.items.len; | 580 | const param_index = b.instructions.items.len; |
| 581 | const param_count = fn_ty.fnParamLen(); | 581 | const param_count = fn_ty.fnParamLen(); |
| 582 | if (param_index >= param_count) { | 582 | 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}", .{ |
| 584 | param_index, | 584 | param_index, |
| 585 | param_count, | 585 | param_count, |
| 586 | }); | 586 | }); |
| ... | @@ -790,7 +790,7 @@ fn analyzeInstCall(mod: *Module, scope: *Scope, inst: *zir.Inst.Call) InnerError | ... | @@ -790,7 +790,7 @@ fn analyzeInstCall(mod: *Module, scope: *Scope, inst: *zir.Inst.Call) InnerError |
| 790 | return mod.fail( | 790 | return mod.fail( |
| 791 | scope, | 791 | scope, |
| 792 | inst.positionals.func.src, | 792 | inst.positionals.func.src, |
| 793 | "expected at least {} argument(s), found {}", | 793 | "expected at least {d} argument(s), found {d}", |
| 794 | .{ fn_params_len, call_params_len }, | 794 | .{ fn_params_len, call_params_len }, |
| 795 | ); | 795 | ); |
| 796 | } | 796 | } |
| ... | @@ -800,7 +800,7 @@ fn analyzeInstCall(mod: *Module, scope: *Scope, inst: *zir.Inst.Call) InnerError | ... | @@ -800,7 +800,7 @@ fn analyzeInstCall(mod: *Module, scope: *Scope, inst: *zir.Inst.Call) InnerError |
| 800 | return mod.fail( | 800 | return mod.fail( |
| 801 | scope, | 801 | scope, |
| 802 | inst.positionals.func.src, | 802 | inst.positionals.func.src, |
| 803 | "expected {} argument(s), found {}", | 803 | "expected {d} argument(s), found {d}", |
| 804 | .{ fn_params_len, call_params_len }, | 804 | .{ fn_params_len, call_params_len }, |
| 805 | ); | 805 | ); |
| 806 | } | 806 | } |
| ... | @@ -918,7 +918,7 @@ fn analyzeInstErrorSet(mod: *Module, scope: *Scope, inst: *zir.Inst.ErrorSet) In | ... | @@ -918,7 +918,7 @@ fn analyzeInstErrorSet(mod: *Module, scope: *Scope, inst: *zir.Inst.ErrorSet) In |
| 918 | for (inst.positionals.fields) |field_name| { | 918 | for (inst.positionals.fields) |field_name| { |
| 919 | const entry = try mod.getErrorValue(field_name); | 919 | const entry = try mod.getErrorValue(field_name); |
| 920 | if (payload.data.fields.fetchPutAssumeCapacity(entry.key, entry.value)) |prev| { | 920 | 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}); |
| 922 | } | 922 | } |
| 923 | } | 923 | } |
| 924 | // TODO create name in format "error:line:column" | 924 | // TODO create name in format "error:line:column" |
| ... | @@ -1068,7 +1068,7 @@ fn analyzeInstFieldPtr(mod: *Module, scope: *Scope, fieldptr: *zir.Inst.FieldPtr | ... | @@ -1068,7 +1068,7 @@ fn analyzeInstFieldPtr(mod: *Module, scope: *Scope, fieldptr: *zir.Inst.FieldPtr |
| 1068 | return mod.fail( | 1068 | return mod.fail( |
| 1069 | scope, | 1069 | scope, |
| 1070 | fieldptr.positionals.field_name.src, | 1070 | fieldptr.positionals.field_name.src, |
| 1071 | "no member named '{}' in '{}'", | 1071 | "no member named '{s}' in '{}'", |
| 1072 | .{ field_name, elem_ty }, | 1072 | .{ field_name, elem_ty }, |
| 1073 | ); | 1073 | ); |
| 1074 | } | 1074 | } |
| ... | @@ -1089,7 +1089,7 @@ fn analyzeInstFieldPtr(mod: *Module, scope: *Scope, fieldptr: *zir.Inst.FieldPtr | ... | @@ -1089,7 +1089,7 @@ fn analyzeInstFieldPtr(mod: *Module, scope: *Scope, fieldptr: *zir.Inst.FieldPtr |
| 1089 | return mod.fail( | 1089 | return mod.fail( |
| 1090 | scope, | 1090 | scope, |
| 1091 | fieldptr.positionals.field_name.src, | 1091 | fieldptr.positionals.field_name.src, |
| 1092 | "no member named '{}' in '{}'", | 1092 | "no member named '{s}' in '{}'", |
| 1093 | .{ field_name, elem_ty }, | 1093 | .{ field_name, elem_ty }, |
| 1094 | ); | 1094 | ); |
| 1095 | } | 1095 | } |
| ... | @@ -1107,7 +1107,7 @@ fn analyzeInstFieldPtr(mod: *Module, scope: *Scope, fieldptr: *zir.Inst.FieldPtr | ... | @@ -1107,7 +1107,7 @@ fn analyzeInstFieldPtr(mod: *Module, scope: *Scope, fieldptr: *zir.Inst.FieldPtr |
| 1107 | // TODO resolve inferred error sets | 1107 | // TODO resolve inferred error sets |
| 1108 | const entry = if (val.castTag(.error_set)) |payload| | 1108 | const entry = if (val.castTag(.error_set)) |payload| |
| 1109 | (payload.data.fields.getEntry(field_name) orelse | 1109 | (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 })).* |
| 1111 | else | 1111 | else |
| 1112 | try mod.getErrorValue(field_name); | 1112 | try mod.getErrorValue(field_name); |
| 1113 | 1113 | ||
| ... | @@ -1135,9 +1135,9 @@ fn analyzeInstFieldPtr(mod: *Module, scope: *Scope, fieldptr: *zir.Inst.FieldPtr | ... | @@ -1135,9 +1135,9 @@ fn analyzeInstFieldPtr(mod: *Module, scope: *Scope, fieldptr: *zir.Inst.FieldPtr |
| 1135 | } | 1135 | } |
| 1136 | 1136 | ||
| 1137 | if (&container_scope.file_scope.base == mod.root_scope) { | 1137 | 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}); |
| 1139 | } else { | 1139 | } 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 }); |
| 1141 | } | 1141 | } |
| 1142 | }, | 1142 | }, |
| 1143 | else => return mod.fail(scope, fieldptr.base.src, "type '{}' does not support field access", .{child_type}), | 1143 | 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 | ... | @@ -1503,14 +1503,14 @@ fn analyzeInstImport(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerErr |
| 1503 | 1503 | ||
| 1504 | const file_scope = mod.analyzeImport(scope, inst.base.src, operand) catch |err| switch (err) { | 1504 | const file_scope = mod.analyzeImport(scope, inst.base.src, operand) catch |err| switch (err) { |
| 1505 | error.ImportOutsidePkgPath => { | 1505 | 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}); |
| 1507 | }, | 1507 | }, |
| 1508 | error.FileNotFound => { | 1508 | 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}); |
| 1510 | }, | 1510 | }, |
| 1511 | else => { | 1511 | else => { |
| 1512 | // TODO user friendly error to string | 1512 | // 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) }); |
| 1514 | }, | 1514 | }, |
| 1515 | }; | 1515 | }; |
| 1516 | return mod.constType(scope, inst.base.src, file_scope.root_container.ty); | 1516 | 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 | ... | @@ -1545,7 +1545,7 @@ fn analyzeInstBitwise(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerE |
| 1545 | 1545 | ||
| 1546 | if (lhs.ty.zigTypeTag() == .Vector and rhs.ty.zigTypeTag() == .Vector) { | 1546 | if (lhs.ty.zigTypeTag() == .Vector and rhs.ty.zigTypeTag() == .Vector) { |
| 1547 | if (lhs.ty.arrayLen() != rhs.ty.arrayLen()) { | 1547 | 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}", .{ |
| 1549 | lhs.ty.arrayLen(), | 1549 | lhs.ty.arrayLen(), |
| 1550 | rhs.ty.arrayLen(), | 1550 | rhs.ty.arrayLen(), |
| 1551 | }); | 1551 | }); |
| ... | @@ -1620,7 +1620,7 @@ fn analyzeInstArithmetic(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) Inn | ... | @@ -1620,7 +1620,7 @@ fn analyzeInstArithmetic(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) Inn |
| 1620 | 1620 | ||
| 1621 | if (lhs.ty.zigTypeTag() == .Vector and rhs.ty.zigTypeTag() == .Vector) { | 1621 | if (lhs.ty.zigTypeTag() == .Vector and rhs.ty.zigTypeTag() == .Vector) { |
| 1622 | if (lhs.ty.arrayLen() != rhs.ty.arrayLen()) { | 1622 | 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}", .{ |
| 1624 | lhs.ty.arrayLen(), | 1624 | lhs.ty.arrayLen(), |
| 1625 | rhs.ty.arrayLen(), | 1625 | rhs.ty.arrayLen(), |
| 1626 | }); | 1626 | }); |
| ... | @@ -1637,7 +1637,7 @@ fn analyzeInstArithmetic(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) Inn | ... | @@ -1637,7 +1637,7 @@ fn analyzeInstArithmetic(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) Inn |
| 1637 | const is_float = scalar_tag == .Float or scalar_tag == .ComptimeFloat; | 1637 | const is_float = scalar_tag == .Float or scalar_tag == .ComptimeFloat; |
| 1638 | 1638 | ||
| 1639 | if (!is_int and !(is_float and floatOpAllowed(inst.base.tag))) { | 1639 | 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()) }); |
| 1641 | } | 1641 | } |
| 1642 | 1642 | ||
| 1643 | if (casted_lhs.value()) |lhs_val| { | 1643 | if (casted_lhs.value()) |lhs_val| { |
| ... | @@ -1656,7 +1656,7 @@ fn analyzeInstArithmetic(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) Inn | ... | @@ -1656,7 +1656,7 @@ fn analyzeInstArithmetic(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) Inn |
| 1656 | const ir_tag = switch (inst.base.tag) { | 1656 | const ir_tag = switch (inst.base.tag) { |
| 1657 | .add => Inst.Tag.add, | 1657 | .add => Inst.Tag.add, |
| 1658 | .sub => Inst.Tag.sub, | 1658 | .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)}), |
| 1660 | }; | 1660 | }; |
| 1661 | 1661 | ||
| 1662 | return mod.addBinOp(b, inst.base.src, scalar_type, ir_tag, casted_lhs, casted_rhs); | 1662 | 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 | ... | @@ -1689,7 +1689,7 @@ fn analyzeInstComptimeOp(mod: *Module, scope: *Scope, res_type: Type, inst: *zir |
| 1689 | mod.floatSub(scope, res_type, inst.base.src, lhs_val, rhs_val); | 1689 | mod.floatSub(scope, res_type, inst.base.src, lhs_val, rhs_val); |
| 1690 | break :blk val; | 1690 | break :blk val; |
| 1691 | }, | 1691 | }, |
| 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)}), |
| 1693 | }; | 1693 | }; |
| 1694 | 1694 | ||
| 1695 | return mod.constInst(scope, inst.base.src, .{ | 1695 | return mod.constInst(scope, inst.base.src, .{ |
| ... | @@ -1781,7 +1781,7 @@ fn analyzeInstCmp( | ... | @@ -1781,7 +1781,7 @@ fn analyzeInstCmp( |
| 1781 | return mod.fail(scope, inst.base.src, "TODO implement equality comparison between a union's tag value and an enum literal", .{}); | 1781 | return mod.fail(scope, inst.base.src, "TODO implement equality comparison between a union's tag value and an enum literal", .{}); |
| 1782 | } else if (lhs_ty_tag == .ErrorSet and rhs_ty_tag == .ErrorSet) { | 1782 | } else if (lhs_ty_tag == .ErrorSet and rhs_ty_tag == .ErrorSet) { |
| 1783 | if (!is_equality_cmp) { | 1783 | 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)}); |
| 1785 | } | 1785 | } |
| 1786 | return mod.fail(scope, inst.base.src, "TODO implement equality comparison between errors", .{}); | 1786 | return mod.fail(scope, inst.base.src, "TODO implement equality comparison between errors", .{}); |
| 1787 | } else if (lhs.ty.isNumeric() and rhs.ty.isNumeric()) { | 1787 | } else if (lhs.ty.isNumeric() and rhs.ty.isNumeric()) { |
| ... | @@ -1791,7 +1791,7 @@ fn analyzeInstCmp( | ... | @@ -1791,7 +1791,7 @@ fn analyzeInstCmp( |
| 1791 | return mod.cmpNumeric(scope, inst.base.src, lhs, rhs, op); | 1791 | return mod.cmpNumeric(scope, inst.base.src, lhs, rhs, op); |
| 1792 | } else if (lhs_ty_tag == .Type and rhs_ty_tag == .Type) { | 1792 | } else if (lhs_ty_tag == .Type and rhs_ty_tag == .Type) { |
| 1793 | if (!is_equality_cmp) { | 1793 | 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)}); |
| 1795 | } | 1795 | } |
| 1796 | return mod.constBool(scope, inst.base.src, lhs.value().?.eql(rhs.value().?) == (op == .eq)); | 1796 | return mod.constBool(scope, inst.base.src, lhs.value().?.eql(rhs.value().?) == (op == .eq)); |
| 1797 | } | 1797 | } |
| ... | @@ -1962,7 +1962,7 @@ fn analyzeDeclVal(mod: *Module, scope: *Scope, inst: *zir.Inst.DeclVal) InnerErr | ... | @@ -1962,7 +1962,7 @@ fn analyzeDeclVal(mod: *Module, scope: *Scope, inst: *zir.Inst.DeclVal) InnerErr |
| 1962 | const decl_name = inst.positionals.name; | 1962 | const decl_name = inst.positionals.name; |
| 1963 | const zir_module = scope.namespace().cast(Scope.ZIRModule).?; | 1963 | const zir_module = scope.namespace().cast(Scope.ZIRModule).?; |
| 1964 | const src_decl = zir_module.contents.module.findDecl(decl_name) orelse | 1964 | 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}); |
| 1966 | 1966 | ||
| 1967 | const decl = try resolveCompleteZirDecl(mod, scope, src_decl.decl); | 1967 | const decl = try resolveCompleteZirDecl(mod, scope, src_decl.decl); |
| 1968 | 1968 |
test/compare_output.zig+2-2| ... | @@ -453,7 +453,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -453,7 +453,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 453 | \\ _ = args_it.skip(); | 453 | \\ _ = args_it.skip(); |
| 454 | \\ while (args_it.next(allocator)) |arg_or_err| : (index += 1) { | 454 | \\ while (args_it.next(allocator)) |arg_or_err| : (index += 1) { |
| 455 | \\ const arg = try arg_or_err; | 455 | \\ const arg = try arg_or_err; |
| 456 | \\ try stdout.print("{}: {}\n", .{index, arg}); | 456 | \\ try stdout.print("{}: {s}\n", .{index, arg}); |
| 457 | \\ } | 457 | \\ } |
| 458 | \\} | 458 | \\} |
| 459 | , | 459 | , |
| ... | @@ -492,7 +492,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -492,7 +492,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 492 | \\ _ = args_it.skip(); | 492 | \\ _ = args_it.skip(); |
| 493 | \\ while (args_it.next(allocator)) |arg_or_err| : (index += 1) { | 493 | \\ while (args_it.next(allocator)) |arg_or_err| : (index += 1) { |
| 494 | \\ const arg = try arg_or_err; | 494 | \\ const arg = try arg_or_err; |
| 495 | \\ try stdout.print("{}: {}\n", .{index, arg}); | 495 | \\ try stdout.print("{}: {s}\n", .{index, arg}); |
| 496 | \\ } | 496 | \\ } |
| 497 | \\} | 497 | \\} |
| 498 | , | 498 | , |
test/src/compare_output.zig+3-3| ... | @@ -97,7 +97,7 @@ pub const CompareOutputContext = struct { | ... | @@ -97,7 +97,7 @@ pub const CompareOutputContext = struct { |
| 97 | 97 | ||
| 98 | switch (case.special) { | 98 | switch (case.special) { |
| 99 | Special.Asm => { | 99 | 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}", .{ |
| 101 | case.name, | 101 | case.name, |
| 102 | }) catch unreachable; | 102 | }) catch unreachable; |
| 103 | if (self.test_filter) |filter| { | 103 | if (self.test_filter) |filter| { |
| ... | @@ -116,7 +116,7 @@ pub const CompareOutputContext = struct { | ... | @@ -116,7 +116,7 @@ pub const CompareOutputContext = struct { |
| 116 | }, | 116 | }, |
| 117 | Special.None => { | 117 | Special.None => { |
| 118 | for (self.modes) |mode| { | 118 | 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})", .{ |
| 120 | "compare-output", | 120 | "compare-output", |
| 121 | case.name, | 121 | case.name, |
| 122 | @tagName(mode), | 122 | @tagName(mode), |
| ... | @@ -141,7 +141,7 @@ pub const CompareOutputContext = struct { | ... | @@ -141,7 +141,7 @@ pub const CompareOutputContext = struct { |
| 141 | } | 141 | } |
| 142 | }, | 142 | }, |
| 143 | Special.RuntimeSafety => { | 143 | 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; |
| 145 | if (self.test_filter) |filter| { | 145 | if (self.test_filter) |filter| { |
| 146 | if (mem.indexOf(u8, annotated_case_name, filter) == null) return; | 146 | if (mem.indexOf(u8, annotated_case_name, filter) == null) return; |
| 147 | } | 147 | } |
test/src/run_translated_c.zig+4-4| ... | @@ -77,7 +77,7 @@ pub const RunTranslatedCContext = struct { | ... | @@ -77,7 +77,7 @@ pub const RunTranslatedCContext = struct { |
| 77 | pub fn addCase(self: *RunTranslatedCContext, case: *const TestCase) void { | 77 | pub fn addCase(self: *RunTranslatedCContext, case: *const TestCase) void { |
| 78 | const b = self.b; | 78 | const b = self.b; |
| 79 | 79 | ||
| 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; |
| 81 | if (self.test_filter) |filter| { | 81 | if (self.test_filter) |filter| { |
| 82 | if (mem.indexOf(u8, annotated_case_name, filter) == null) return; | 82 | if (mem.indexOf(u8, annotated_case_name, filter) == null) return; |
| 83 | } | 83 | } |
| ... | @@ -92,13 +92,13 @@ pub const RunTranslatedCContext = struct { | ... | @@ -92,13 +92,13 @@ pub const RunTranslatedCContext = struct { |
| 92 | .basename = case.sources.items[0].filename, | 92 | .basename = case.sources.items[0].filename, |
| 93 | }, | 93 | }, |
| 94 | }); | 94 | }); |
| 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}); |
| 96 | const exe = translate_c.addExecutable(); | 96 | const exe = translate_c.addExecutable(); |
| 97 | exe.setTarget(self.target); | 97 | 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}); |
| 99 | exe.linkLibC(); | 99 | exe.linkLibC(); |
| 100 | const run = exe.run(); | 100 | 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}); |
| 102 | if (!case.allow_warnings) { | 102 | if (!case.allow_warnings) { |
| 103 | run.expectStdErrEqual(""); | 103 | run.expectStdErrEqual(""); |
| 104 | } | 104 | } |
test/src/translate_c.zig+1-1| ... | @@ -99,7 +99,7 @@ pub const TranslateCContext = struct { | ... | @@ -99,7 +99,7 @@ pub const TranslateCContext = struct { |
| 99 | const b = self.b; | 99 | const b = self.b; |
| 100 | 100 | ||
| 101 | const translate_c_cmd = "translate-c"; | 101 | 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; |
| 103 | if (self.test_filter) |filter| { | 103 | if (self.test_filter) |filter| { |
| 104 | if (mem.indexOf(u8, annotated_case_name, filter) == null) return; | 104 | if (mem.indexOf(u8, annotated_case_name, filter) == null) return; |
| 105 | } | 105 | } |
test/stage1/behavior.zig+1-1| ... | @@ -141,5 +141,5 @@ comptime { | ... | @@ -141,5 +141,5 @@ comptime { |
| 141 | _ = @import("behavior/while.zig"); | 141 | _ = @import("behavior/while.zig"); |
| 142 | _ = @import("behavior/widening.zig"); | 142 | _ = @import("behavior/widening.zig"); |
| 143 | _ = @import("behavior/src.zig"); | 143 | _ = @import("behavior/src.zig"); |
| 144 | _ = @import("behavior/translate_c_macros.zig"); | 144 | // _ = @import("behavior/translate_c_macros.zig"); |
| 145 | } | 145 | } |
test/stage1/behavior/async_fn.zig+2-1| ... | @@ -2,6 +2,7 @@ const std = @import("std"); | ... | @@ -2,6 +2,7 @@ const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const expect = std.testing.expect; | 3 | const expect = std.testing.expect; |
| 4 | const expectEqual = std.testing.expectEqual; | 4 | const expectEqual = std.testing.expectEqual; |
| 5 | const expectEqualStrings = std.testing.expectEqualStrings; | ||
| 5 | const expectError = std.testing.expectError; | 6 | const expectError = std.testing.expectError; |
| 6 | 7 | ||
| 7 | var global_x: i32 = 1; | 8 | var global_x: i32 = 1; |
| ... | @@ -541,7 +542,7 @@ test "pass string literal to async function" { | ... | @@ -541,7 +542,7 @@ test "pass string literal to async function" { |
| 541 | fn hello(msg: []const u8) void { | 542 | fn hello(msg: []const u8) void { |
| 542 | frame = @frame(); | 543 | frame = @frame(); |
| 543 | suspend; | 544 | suspend; |
| 544 | expectEqual(@as([]const u8, "hello"), msg); | 545 | expectEqualStrings("hello", msg); |
| 545 | ok = true; | 546 | ok = true; |
| 546 | } | 547 | } |
| 547 | }; | 548 | }; |
test/tests.zig+31-31| ... | @@ -482,7 +482,7 @@ pub fn addPkgTests( | ... | @@ -482,7 +482,7 @@ pub fn addPkgTests( |
| 482 | is_wasmtime_enabled: bool, | 482 | is_wasmtime_enabled: bool, |
| 483 | glibc_dir: ?[]const u8, | 483 | glibc_dir: ?[]const u8, |
| 484 | ) *build.Step { | 484 | ) *build.Step { |
| 485 | const step = b.step(b.fmt("test-{}", .{name}), desc); | 485 | const step = b.step(b.fmt("test-{s}", .{name}), desc); |
| 486 | 486 | ||
| 487 | for (test_targets) |test_target| { | 487 | for (test_targets) |test_target| { |
| 488 | if (skip_non_native and !test_target.target.isNative()) | 488 | if (skip_non_native and !test_target.target.isNative()) |
| ... | @@ -523,7 +523,7 @@ pub fn addPkgTests( | ... | @@ -523,7 +523,7 @@ pub fn addPkgTests( |
| 523 | 523 | ||
| 524 | const these_tests = b.addTest(root_src); | 524 | const these_tests = b.addTest(root_src); |
| 525 | const single_threaded_txt = if (test_target.single_threaded) "single" else "multi"; | 525 | 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} ", .{ |
| 527 | name, | 527 | name, |
| 528 | triple_prefix, | 528 | triple_prefix, |
| 529 | @tagName(test_target.mode), | 529 | @tagName(test_target.mode), |
| ... | @@ -570,7 +570,7 @@ pub const StackTracesContext = struct { | ... | @@ -570,7 +570,7 @@ pub const StackTracesContext = struct { |
| 570 | const expect_for_mode = expect[@enumToInt(mode)]; | 570 | const expect_for_mode = expect[@enumToInt(mode)]; |
| 571 | if (expect_for_mode.len == 0) continue; | 571 | if (expect_for_mode.len == 0) continue; |
| 572 | 572 | ||
| 573 | const annotated_case_name = fmt.allocPrint(self.b.allocator, "{} {} ({})", .{ | 573 | const annotated_case_name = fmt.allocPrint(self.b.allocator, "{s} {s} ({s})", .{ |
| 574 | "stack-trace", | 574 | "stack-trace", |
| 575 | name, | 575 | name, |
| 576 | @tagName(mode), | 576 | @tagName(mode), |
| ... | @@ -637,7 +637,7 @@ pub const StackTracesContext = struct { | ... | @@ -637,7 +637,7 @@ pub const StackTracesContext = struct { |
| 637 | defer args.deinit(); | 637 | defer args.deinit(); |
| 638 | args.append(full_exe_path) catch unreachable; | 638 | args.append(full_exe_path) catch unreachable; |
| 639 | 639 | ||
| 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 }); |
| 641 | 641 | ||
| 642 | const child = std.ChildProcess.init(args.items, b.allocator) catch unreachable; | 642 | const child = std.ChildProcess.init(args.items, b.allocator) catch unreachable; |
| 643 | defer child.deinit(); | 643 | defer child.deinit(); |
| ... | @@ -650,7 +650,7 @@ pub const StackTracesContext = struct { | ... | @@ -650,7 +650,7 @@ pub const StackTracesContext = struct { |
| 650 | if (b.verbose) { | 650 | if (b.verbose) { |
| 651 | printInvocation(args.items); | 651 | printInvocation(args.items); |
| 652 | } | 652 | } |
| 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) }); |
| 654 | 654 | ||
| 655 | const stdout = child.stdout.?.inStream().readAllAlloc(b.allocator, max_stdout_size) catch unreachable; | 655 | const stdout = child.stdout.?.inStream().readAllAlloc(b.allocator, max_stdout_size) catch unreachable; |
| 656 | defer b.allocator.free(stdout); | 656 | defer b.allocator.free(stdout); |
| ... | @@ -659,14 +659,14 @@ pub const StackTracesContext = struct { | ... | @@ -659,14 +659,14 @@ pub const StackTracesContext = struct { |
| 659 | var stderr = stderrFull; | 659 | var stderr = stderrFull; |
| 660 | 660 | ||
| 661 | const term = child.wait() catch |err| { | 661 | 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) }); |
| 663 | }; | 663 | }; |
| 664 | 664 | ||
| 665 | switch (term) { | 665 | switch (term) { |
| 666 | .Exited => |code| { | 666 | .Exited => |code| { |
| 667 | const expect_code: u32 = 1; | 667 | const expect_code: u32 = 1; |
| 668 | if (code != expect_code) { | 668 | 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", .{ |
| 670 | full_exe_path, | 670 | full_exe_path, |
| 671 | code, | 671 | code, |
| 672 | expect_code, | 672 | expect_code, |
| ... | @@ -676,17 +676,17 @@ pub const StackTracesContext = struct { | ... | @@ -676,17 +676,17 @@ pub const StackTracesContext = struct { |
| 676 | } | 676 | } |
| 677 | }, | 677 | }, |
| 678 | .Signal => |signum| { | 678 | .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 }); |
| 680 | printInvocation(args.items); | 680 | printInvocation(args.items); |
| 681 | return error.TestFailed; | 681 | return error.TestFailed; |
| 682 | }, | 682 | }, |
| 683 | .Stopped => |signum| { | 683 | .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 }); |
| 685 | printInvocation(args.items); | 685 | printInvocation(args.items); |
| 686 | return error.TestFailed; | 686 | return error.TestFailed; |
| 687 | }, | 687 | }, |
| 688 | .Unknown => |code| { | 688 | .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 }); |
| 690 | printInvocation(args.items); | 690 | printInvocation(args.items); |
| 691 | return error.TestFailed; | 691 | return error.TestFailed; |
| 692 | }, | 692 | }, |
| ... | @@ -732,9 +732,9 @@ pub const StackTracesContext = struct { | ... | @@ -732,9 +732,9 @@ pub const StackTracesContext = struct { |
| 732 | warn( | 732 | warn( |
| 733 | \\ | 733 | \\ |
| 734 | \\========= Expected this output: ========= | 734 | \\========= Expected this output: ========= |
| 735 | \\{} | 735 | \\{s} |
| 736 | \\================================================ | 736 | \\================================================ |
| 737 | \\{} | 737 | \\{s} |
| 738 | \\ | 738 | \\ |
| 739 | , .{ self.expect_output, got }); | 739 | , .{ self.expect_output, got }); |
| 740 | return error.TestFailed; | 740 | return error.TestFailed; |
| ... | @@ -856,7 +856,7 @@ pub const CompileErrorContext = struct { | ... | @@ -856,7 +856,7 @@ pub const CompileErrorContext = struct { |
| 856 | zig_args.append("-O") catch unreachable; | 856 | zig_args.append("-O") catch unreachable; |
| 857 | zig_args.append(@tagName(self.build_mode)) catch unreachable; | 857 | zig_args.append(@tagName(self.build_mode)) catch unreachable; |
| 858 | 858 | ||
| 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 }); |
| 860 | 860 | ||
| 861 | if (b.verbose) { | 861 | if (b.verbose) { |
| 862 | printInvocation(zig_args.items); | 862 | printInvocation(zig_args.items); |
| ... | @@ -870,7 +870,7 @@ pub const CompileErrorContext = struct { | ... | @@ -870,7 +870,7 @@ pub const CompileErrorContext = struct { |
| 870 | child.stdout_behavior = .Pipe; | 870 | child.stdout_behavior = .Pipe; |
| 871 | child.stderr_behavior = .Pipe; | 871 | child.stderr_behavior = .Pipe; |
| 872 | 872 | ||
| 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) }); |
| 874 | 874 | ||
| 875 | var stdout_buf = ArrayList(u8).init(b.allocator); | 875 | var stdout_buf = ArrayList(u8).init(b.allocator); |
| 876 | var stderr_buf = ArrayList(u8).init(b.allocator); | 876 | var stderr_buf = ArrayList(u8).init(b.allocator); |
| ... | @@ -879,7 +879,7 @@ pub const CompileErrorContext = struct { | ... | @@ -879,7 +879,7 @@ pub const CompileErrorContext = struct { |
| 879 | child.stderr.?.inStream().readAllArrayList(&stderr_buf, max_stdout_size) catch unreachable; | 879 | child.stderr.?.inStream().readAllArrayList(&stderr_buf, max_stdout_size) catch unreachable; |
| 880 | 880 | ||
| 881 | const term = child.wait() catch |err| { | 881 | 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) }); |
| 883 | }; | 883 | }; |
| 884 | switch (term) { | 884 | switch (term) { |
| 885 | .Exited => |code| { | 885 | .Exited => |code| { |
| ... | @@ -889,7 +889,7 @@ pub const CompileErrorContext = struct { | ... | @@ -889,7 +889,7 @@ pub const CompileErrorContext = struct { |
| 889 | } | 889 | } |
| 890 | }, | 890 | }, |
| 891 | else => { | 891 | else => { |
| 892 | warn("Process {} terminated unexpectedly\n", .{b.zig_exe}); | 892 | warn("Process {s} terminated unexpectedly\n", .{b.zig_exe}); |
| 893 | printInvocation(zig_args.items); | 893 | printInvocation(zig_args.items); |
| 894 | return error.TestFailed; | 894 | return error.TestFailed; |
| 895 | }, | 895 | }, |
| ... | @@ -903,7 +903,7 @@ pub const CompileErrorContext = struct { | ... | @@ -903,7 +903,7 @@ pub const CompileErrorContext = struct { |
| 903 | \\ | 903 | \\ |
| 904 | \\Expected empty stdout, instead found: | 904 | \\Expected empty stdout, instead found: |
| 905 | \\================================================ | 905 | \\================================================ |
| 906 | \\{} | 906 | \\{s} |
| 907 | \\================================================ | 907 | \\================================================ |
| 908 | \\ | 908 | \\ |
| 909 | , .{stdout}); | 909 | , .{stdout}); |
| ... | @@ -926,7 +926,7 @@ pub const CompileErrorContext = struct { | ... | @@ -926,7 +926,7 @@ pub const CompileErrorContext = struct { |
| 926 | if (!ok) { | 926 | if (!ok) { |
| 927 | warn("\n======== Expected these compile errors: ========\n", .{}); | 927 | warn("\n======== Expected these compile errors: ========\n", .{}); |
| 928 | for (self.case.expected_errors.items) |expected| { | 928 | for (self.case.expected_errors.items) |expected| { |
| 929 | warn("{}\n", .{expected}); | 929 | warn("{s}\n", .{expected}); |
| 930 | } | 930 | } |
| 931 | } | 931 | } |
| 932 | } else { | 932 | } else { |
| ... | @@ -935,7 +935,7 @@ pub const CompileErrorContext = struct { | ... | @@ -935,7 +935,7 @@ pub const CompileErrorContext = struct { |
| 935 | warn( | 935 | warn( |
| 936 | \\ | 936 | \\ |
| 937 | \\=========== Expected compile error: ============ | 937 | \\=========== Expected compile error: ============ |
| 938 | \\{} | 938 | \\{s} |
| 939 | \\ | 939 | \\ |
| 940 | , .{expected}); | 940 | , .{expected}); |
| 941 | ok = false; | 941 | ok = false; |
| ... | @@ -947,7 +947,7 @@ pub const CompileErrorContext = struct { | ... | @@ -947,7 +947,7 @@ pub const CompileErrorContext = struct { |
| 947 | if (!ok) { | 947 | if (!ok) { |
| 948 | warn( | 948 | warn( |
| 949 | \\================= Full output: ================= | 949 | \\================= Full output: ================= |
| 950 | \\{} | 950 | \\{s} |
| 951 | \\ | 951 | \\ |
| 952 | , .{stderr}); | 952 | , .{stderr}); |
| 953 | return error.TestFailed; | 953 | return error.TestFailed; |
| ... | @@ -1023,7 +1023,7 @@ pub const CompileErrorContext = struct { | ... | @@ -1023,7 +1023,7 @@ pub const CompileErrorContext = struct { |
| 1023 | pub fn addCase(self: *CompileErrorContext, case: *const TestCase) void { | 1023 | pub fn addCase(self: *CompileErrorContext, case: *const TestCase) void { |
| 1024 | const b = self.b; | 1024 | const b = self.b; |
| 1025 | 1025 | ||
| 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}", .{ |
| 1027 | case.name, | 1027 | case.name, |
| 1028 | }) catch unreachable; | 1028 | }) catch unreachable; |
| 1029 | if (self.test_filter) |filter| { | 1029 | if (self.test_filter) |filter| { |
| ... | @@ -1058,7 +1058,7 @@ pub const StandaloneContext = struct { | ... | @@ -1058,7 +1058,7 @@ pub const StandaloneContext = struct { |
| 1058 | pub fn addBuildFile(self: *StandaloneContext, build_file: []const u8) void { | 1058 | pub fn addBuildFile(self: *StandaloneContext, build_file: []const u8) void { |
| 1059 | const b = self.b; | 1059 | const b = self.b; |
| 1060 | 1060 | ||
| 1061 | const annotated_case_name = b.fmt("build {} (Debug)", .{build_file}); | 1061 | const annotated_case_name = b.fmt("build {s} (Debug)", .{build_file}); |
| 1062 | if (self.test_filter) |filter| { | 1062 | if (self.test_filter) |filter| { |
| 1063 | if (mem.indexOf(u8, annotated_case_name, filter) == null) return; | 1063 | if (mem.indexOf(u8, annotated_case_name, filter) == null) return; |
| 1064 | } | 1064 | } |
| ... | @@ -1079,7 +1079,7 @@ pub const StandaloneContext = struct { | ... | @@ -1079,7 +1079,7 @@ pub const StandaloneContext = struct { |
| 1079 | 1079 | ||
| 1080 | const run_cmd = b.addSystemCommand(zig_args.items); | 1080 | const run_cmd = b.addSystemCommand(zig_args.items); |
| 1081 | 1081 | ||
| 1082 | const log_step = b.addLog("PASS {}\n", .{annotated_case_name}); | 1082 | const log_step = b.addLog("PASS {s}\n", .{annotated_case_name}); |
| 1083 | log_step.step.dependOn(&run_cmd.step); | 1083 | log_step.step.dependOn(&run_cmd.step); |
| 1084 | 1084 | ||
| 1085 | self.step.dependOn(&log_step.step); | 1085 | self.step.dependOn(&log_step.step); |
| ... | @@ -1089,7 +1089,7 @@ pub const StandaloneContext = struct { | ... | @@ -1089,7 +1089,7 @@ pub const StandaloneContext = struct { |
| 1089 | const b = self.b; | 1089 | const b = self.b; |
| 1090 | 1090 | ||
| 1091 | for (self.modes) |mode| { | 1091 | 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})", .{ |
| 1093 | root_src, | 1093 | root_src, |
| 1094 | @tagName(mode), | 1094 | @tagName(mode), |
| 1095 | }) catch unreachable; | 1095 | }) catch unreachable; |
| ... | @@ -1103,7 +1103,7 @@ pub const StandaloneContext = struct { | ... | @@ -1103,7 +1103,7 @@ pub const StandaloneContext = struct { |
| 1103 | exe.linkSystemLibrary("c"); | 1103 | exe.linkSystemLibrary("c"); |
| 1104 | } | 1104 | } |
| 1105 | 1105 | ||
| 1106 | const log_step = b.addLog("PASS {}\n", .{annotated_case_name}); | 1106 | const log_step = b.addLog("PASS {s}\n", .{annotated_case_name}); |
| 1107 | log_step.step.dependOn(&exe.step); | 1107 | log_step.step.dependOn(&exe.step); |
| 1108 | 1108 | ||
| 1109 | self.step.dependOn(&log_step.step); | 1109 | self.step.dependOn(&log_step.step); |
| ... | @@ -1172,7 +1172,7 @@ pub const GenHContext = struct { | ... | @@ -1172,7 +1172,7 @@ pub const GenHContext = struct { |
| 1172 | const self = @fieldParentPtr(GenHCmpOutputStep, "step", step); | 1172 | const self = @fieldParentPtr(GenHCmpOutputStep, "step", step); |
| 1173 | const b = self.context.b; | 1173 | const b = self.context.b; |
| 1174 | 1174 | ||
| 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 }); |
| 1176 | 1176 | ||
| 1177 | const full_h_path = self.obj.getOutputHPath(); | 1177 | const full_h_path = self.obj.getOutputHPath(); |
| 1178 | const actual_h = try io.readFileAlloc(b.allocator, full_h_path); | 1178 | const actual_h = try io.readFileAlloc(b.allocator, full_h_path); |
| ... | @@ -1182,9 +1182,9 @@ pub const GenHContext = struct { | ... | @@ -1182,9 +1182,9 @@ pub const GenHContext = struct { |
| 1182 | warn( | 1182 | warn( |
| 1183 | \\ | 1183 | \\ |
| 1184 | \\========= Expected this output: ================ | 1184 | \\========= Expected this output: ================ |
| 1185 | \\{} | 1185 | \\{s} |
| 1186 | \\========= But found: =========================== | 1186 | \\========= But found: =========================== |
| 1187 | \\{} | 1187 | \\{s} |
| 1188 | \\ | 1188 | \\ |
| 1189 | , .{ expected_line, actual_h }); | 1189 | , .{ expected_line, actual_h }); |
| 1190 | return error.TestFailed; | 1190 | return error.TestFailed; |
| ... | @@ -1196,7 +1196,7 @@ pub const GenHContext = struct { | ... | @@ -1196,7 +1196,7 @@ pub const GenHContext = struct { |
| 1196 | 1196 | ||
| 1197 | fn printInvocation(args: []const []const u8) void { | 1197 | fn printInvocation(args: []const []const u8) void { |
| 1198 | for (args) |arg| { | 1198 | for (args) |arg| { |
| 1199 | warn("{} ", .{arg}); | 1199 | warn("{s} ", .{arg}); |
| 1200 | } | 1200 | } |
| 1201 | warn("\n", .{}); | 1201 | warn("\n", .{}); |
| 1202 | } | 1202 | } |
| ... | @@ -1232,7 +1232,7 @@ pub const GenHContext = struct { | ... | @@ -1232,7 +1232,7 @@ pub const GenHContext = struct { |
| 1232 | const b = self.b; | 1232 | const b = self.b; |
| 1233 | 1233 | ||
| 1234 | const mode = builtin.Mode.Debug; | 1234 | 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; |
| 1236 | if (self.test_filter) |filter| { | 1236 | if (self.test_filter) |filter| { |
| 1237 | if (mem.indexOf(u8, annotated_case_name, filter) == null) return; | 1237 | if (mem.indexOf(u8, annotated_case_name, filter) == null) return; |
| 1238 | } | 1238 | } |
| ... | @@ -1253,7 +1253,7 @@ pub const GenHContext = struct { | ... | @@ -1253,7 +1253,7 @@ pub const GenHContext = struct { |
| 1253 | 1253 | ||
| 1254 | fn printInvocation(args: []const []const u8) void { | 1254 | fn printInvocation(args: []const []const u8) void { |
| 1255 | for (args) |arg| { | 1255 | for (args) |arg| { |
| 1256 | warn("{} ", .{arg}); | 1256 | warn("{s} ", .{arg}); |
| 1257 | } | 1257 | } |
| 1258 | warn("\n", .{}); | 1258 | warn("\n", .{}); |
| 1259 | } | 1259 | } |