| author | |
| committer | |
| log | dd973fb365dbbe11ce5beac8b4889bfab3fddc4d |
| tree | e82adf746186ec50e1aa11c5bd9f4a677e93046d |
| parent | 5a06fdfa5525920810005e73eaa1b6e79a6472ca |
32 files changed, 771 insertions(+), 231 deletions(-)
lib/std/SemanticVersion.zig+4-4| ... | @@ -164,8 +164,8 @@ pub fn format( | ... | @@ -164,8 +164,8 @@ pub fn format( |
| 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, "{}.{}.{}", .{ 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/array_list_sentineled.zig created+229| ... | @@ -0,0 +1,229 @@ | ||
| 1 | // SPDX-License-Identifier: MIT | ||
| 2 | // Copyright (c) 2015-2020 Zig Contributors | ||
| 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. | ||
| 4 | // The MIT license requires this copyright notice to be included in all copies | ||
| 5 | // and substantial portions of the software. | ||
| 6 | const std = @import("std.zig"); | ||
| 7 | const debug = std.debug; | ||
| 8 | const mem = std.mem; | ||
| 9 | const Allocator = mem.Allocator; | ||
| 10 | const assert = debug.assert; | ||
| 11 | const testing = std.testing; | ||
| 12 | const ArrayList = std.ArrayList; | ||
| 13 | |||
| 14 | /// A contiguous, growable list of items in memory, with a sentinel after them. | ||
| 15 | /// The sentinel is maintained when appending, resizing, etc. | ||
| 16 | /// If you do not need a sentinel, consider using `ArrayList` instead. | ||
| 17 | pub fn ArrayListSentineled(comptime T: type, comptime sentinel: T) type { | ||
| 18 | return struct { | ||
| 19 | list: ArrayList(T), | ||
| 20 | |||
| 21 | const Self = @This(); | ||
| 22 | |||
| 23 | /// Must deinitialize with deinit. | ||
| 24 | pub fn init(allocator: *Allocator, m: []const T) !Self { | ||
| 25 | var self = try initSize(allocator, m.len); | ||
| 26 | mem.copy(T, self.list.items, m); | ||
| 27 | return self; | ||
| 28 | } | ||
| 29 | |||
| 30 | /// Initialize memory to size bytes of undefined values. | ||
| 31 | /// Must deinitialize with deinit. | ||
| 32 | pub fn initSize(allocator: *Allocator, size: usize) !Self { | ||
| 33 | var self = initNull(allocator); | ||
| 34 | try self.resize(size); | ||
| 35 | return self; | ||
| 36 | } | ||
| 37 | |||
| 38 | /// Initialize with capacity to hold at least num bytes. | ||
| 39 | /// Must deinitialize with deinit. | ||
| 40 | pub fn initCapacity(allocator: *Allocator, num: usize) !Self { | ||
| 41 | var self = Self{ .list = try ArrayList(T).initCapacity(allocator, num + 1) }; | ||
| 42 | self.list.appendAssumeCapacity(sentinel); | ||
| 43 | return self; | ||
| 44 | } | ||
| 45 | |||
| 46 | /// Must deinitialize with deinit. | ||
| 47 | /// None of the other operations are valid until you do one of these: | ||
| 48 | /// * `replaceContents` | ||
| 49 | /// * `resize` | ||
| 50 | pub fn initNull(allocator: *Allocator) Self { | ||
| 51 | return Self{ .list = ArrayList(T).init(allocator) }; | ||
| 52 | } | ||
| 53 | |||
| 54 | /// Must deinitialize with deinit. | ||
| 55 | pub fn initFromBuffer(buffer: Self) !Self { | ||
| 56 | return Self.init(buffer.list.allocator, buffer.span()); | ||
| 57 | } | ||
| 58 | |||
| 59 | /// Takes ownership of the passed in slice. The slice must have been | ||
| 60 | /// allocated with `allocator`. | ||
| 61 | /// Must deinitialize with deinit. | ||
| 62 | pub fn fromOwnedSlice(allocator: *Allocator, slice: []T) !Self { | ||
| 63 | var self = Self{ .list = ArrayList(T).fromOwnedSlice(allocator, slice) }; | ||
| 64 | try self.list.append(sentinel); | ||
| 65 | return self; | ||
| 66 | } | ||
| 67 | |||
| 68 | /// The caller owns the returned memory. The list becomes null and is safe to `deinit`. | ||
| 69 | pub fn toOwnedSlice(self: *Self) [:sentinel]T { | ||
| 70 | const allocator = self.list.allocator; | ||
| 71 | const result = self.list.toOwnedSlice(); | ||
| 72 | self.* = initNull(allocator); | ||
| 73 | return result[0 .. result.len - 1 :sentinel]; | ||
| 74 | } | ||
| 75 | |||
| 76 | /// Only works when `T` is `u8`. | ||
| 77 | pub fn allocPrint(allocator: *Allocator, comptime format: []const u8, args: anytype) !Self { | ||
| 78 | const size = std.math.cast(usize, std.fmt.count(format, args)) catch |err| switch (err) { | ||
| 79 | error.Overflow => return error.OutOfMemory, | ||
| 80 | }; | ||
| 81 | var self = try Self.initSize(allocator, size); | ||
| 82 | assert((std.fmt.bufPrint(self.list.items, format, args) catch unreachable).len == size); | ||
| 83 | return self; | ||
| 84 | } | ||
| 85 | |||
| 86 | pub fn deinit(self: *Self) void { | ||
| 87 | self.list.deinit(); | ||
| 88 | } | ||
| 89 | |||
| 90 | pub fn span(self: anytype) @TypeOf(self.list.items[0..:sentinel]) { | ||
| 91 | return self.list.items[0..self.len() :sentinel]; | ||
| 92 | } | ||
| 93 | |||
| 94 | pub fn shrink(self: *Self, new_len: usize) void { | ||
| 95 | assert(new_len <= self.len()); | ||
| 96 | self.list.shrink(new_len + 1); | ||
| 97 | self.list.items[self.len()] = sentinel; | ||
| 98 | } | ||
| 99 | |||
| 100 | pub fn resize(self: *Self, new_len: usize) !void { | ||
| 101 | try self.list.resize(new_len + 1); | ||
| 102 | self.list.items[self.len()] = sentinel; | ||
| 103 | } | ||
| 104 | |||
| 105 | pub fn isNull(self: Self) bool { | ||
| 106 | return self.list.items.len == 0; | ||
| 107 | } | ||
| 108 | |||
| 109 | pub fn len(self: Self) usize { | ||
| 110 | return self.list.items.len - 1; | ||
| 111 | } | ||
| 112 | |||
| 113 | pub fn capacity(self: Self) usize { | ||
| 114 | return if (self.list.capacity > 0) | ||
| 115 | self.list.capacity - 1 | ||
| 116 | else | ||
| 117 | 0; | ||
| 118 | } | ||
| 119 | |||
| 120 | pub fn appendSlice(self: *Self, m: []const T) !void { | ||
| 121 | const old_len = self.len(); | ||
| 122 | try self.resize(old_len + m.len); | ||
| 123 | mem.copy(T, self.list.items[old_len..], m); | ||
| 124 | } | ||
| 125 | |||
| 126 | pub fn append(self: *Self, byte: T) !void { | ||
| 127 | const old_len = self.len(); | ||
| 128 | try self.resize(old_len + 1); | ||
| 129 | self.list.items[old_len] = byte; | ||
| 130 | } | ||
| 131 | |||
| 132 | pub fn eql(self: Self, m: []const T) bool { | ||
| 133 | return mem.eql(T, self.span(), m); | ||
| 134 | } | ||
| 135 | |||
| 136 | pub fn startsWith(self: Self, m: []const T) bool { | ||
| 137 | if (self.len() < m.len) return false; | ||
| 138 | return mem.eql(T, self.list.items[0..m.len], m); | ||
| 139 | } | ||
| 140 | |||
| 141 | pub fn endsWith(self: Self, m: []const T) bool { | ||
| 142 | const l = self.len(); | ||
| 143 | if (l < m.len) return false; | ||
| 144 | const start = l - m.len; | ||
| 145 | return mem.eql(T, self.list.items[start..l], m); | ||
| 146 | } | ||
| 147 | |||
| 148 | pub fn replaceContents(self: *Self, m: []const T) !void { | ||
| 149 | try self.resize(m.len); | ||
| 150 | mem.copy(T, self.list.items, m); | ||
| 151 | } | ||
| 152 | |||
| 153 | /// Initializes an OutStream which will append to the list. | ||
| 154 | /// This function may be called only when `T` is `u8`. | ||
| 155 | pub fn outStream(self: *Self) std.io.OutStream(*Self, error{OutOfMemory}, appendWrite) { | ||
| 156 | return .{ .context = self }; | ||
| 157 | } | ||
| 158 | |||
| 159 | /// Same as `append` except it returns the number of bytes written, which is always the same | ||
| 160 | /// as `m.len`. The purpose of this function existing is to match `std.io.OutStream` API. | ||
| 161 | /// This function may be called only when `T` is `u8`. | ||
| 162 | pub fn appendWrite(self: *Self, m: []const u8) !usize { | ||
| 163 | try self.appendSlice(m); | ||
| 164 | return m.len; | ||
| 165 | } | ||
| 166 | }; | ||
| 167 | } | ||
| 168 | |||
| 169 | test "simple" { | ||
| 170 | var buf = try ArrayListSentineled(u8, 0).init(testing.allocator, ""); | ||
| 171 | defer buf.deinit(); | ||
| 172 | |||
| 173 | testing.expect(buf.len() == 0); | ||
| 174 | try buf.appendSlice("hello"); | ||
| 175 | try buf.appendSlice(" "); | ||
| 176 | try buf.appendSlice("world"); | ||
| 177 | testing.expect(buf.eql("hello world")); | ||
| 178 | testing.expect(mem.eql(u8, mem.spanZ(buf.span().ptr), buf.span())); | ||
| 179 | |||
| 180 | var buf2 = try ArrayListSentineled(u8, 0).initFromBuffer(buf); | ||
| 181 | defer buf2.deinit(); | ||
| 182 | testing.expect(buf.eql(buf2.span())); | ||
| 183 | |||
| 184 | testing.expect(buf.startsWith("hell")); | ||
| 185 | testing.expect(buf.endsWith("orld")); | ||
| 186 | |||
| 187 | try buf2.resize(4); | ||
| 188 | testing.expect(buf.startsWith(buf2.span())); | ||
| 189 | } | ||
| 190 | |||
| 191 | test "initSize" { | ||
| 192 | var buf = try ArrayListSentineled(u8, 0).initSize(testing.allocator, 3); | ||
| 193 | defer buf.deinit(); | ||
| 194 | testing.expect(buf.len() == 3); | ||
| 195 | try buf.appendSlice("hello"); | ||
| 196 | testing.expect(mem.eql(u8, buf.span()[3..], "hello")); | ||
| 197 | } | ||
| 198 | |||
| 199 | test "initCapacity" { | ||
| 200 | var buf = try ArrayListSentineled(u8, 0).initCapacity(testing.allocator, 10); | ||
| 201 | defer buf.deinit(); | ||
| 202 | testing.expect(buf.len() == 0); | ||
| 203 | testing.expect(buf.capacity() >= 10); | ||
| 204 | const old_cap = buf.capacity(); | ||
| 205 | try buf.appendSlice("hello"); | ||
| 206 | testing.expect(buf.len() == 5); | ||
| 207 | testing.expect(buf.capacity() == old_cap); | ||
| 208 | testing.expect(mem.eql(u8, buf.span(), "hello")); | ||
| 209 | } | ||
| 210 | |||
| 211 | test "print" { | ||
| 212 | var buf = try ArrayListSentineled(u8, 0).init(testing.allocator, ""); | ||
| 213 | defer buf.deinit(); | ||
| 214 | |||
| 215 | try buf.outStream().print("Hello {d} the {s}", .{ 2, "world" }); | ||
| 216 | testing.expect(buf.eql("Hello 2 the world")); | ||
| 217 | } | ||
| 218 | |||
| 219 | test "outStream" { | ||
| 220 | var buffer = try ArrayListSentineled(u8, 0).initSize(testing.allocator, 0); | ||
| 221 | defer buffer.deinit(); | ||
| 222 | const buf_stream = buffer.outStream(); | ||
| 223 | |||
| 224 | const x: i32 = 42; | ||
| 225 | const y: i32 = 1234; | ||
| 226 | try buf_stream.print("x: {}\ny: {}\n", .{ x, y }); | ||
| 227 | |||
| 228 | testing.expect(mem.eql(u8, buffer.span(), "x: 42\ny: 1234\n")); | ||
| 229 | } | ||
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/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+24-24| ... | @@ -506,12 +506,12 @@ pub fn formatType( | ... | @@ -506,12 +506,12 @@ pub fn formatType( |
| 506 | if (info.child == u8) { | 506 | if (info.child == u8) { |
| 507 | return formatText(value, fmt, options, writer); | 507 | return formatText(value, fmt, options, writer); |
| 508 | } | 508 | } |
| 509 | return format(writer, "{}@{x}", .{ @typeName(ptr_info.child), @ptrToInt(value) }); | 509 | return format(writer, "{s}@{x}", .{ @typeName(ptr_info.child), @ptrToInt(value) }); |
| 510 | }, | 510 | }, |
| 511 | .Enum, .Union, .Struct => { | 511 | .Enum, .Union, .Struct => { |
| 512 | return formatType(value.*, fmt, options, writer, max_depth); | 512 | return formatType(value.*, fmt, options, writer, max_depth); |
| 513 | }, | 513 | }, |
| 514 | else => return format(writer, "{}@{x}", .{ @typeName(ptr_info.child), @ptrToInt(value) }), | 514 | else => return format(writer, "{s}@{x}", .{ @typeName(ptr_info.child), @ptrToInt(value) }), |
| 515 | }, | 515 | }, |
| 516 | .Many, .C => { | 516 | .Many, .C => { |
| 517 | if (ptr_info.sentinel) |sentinel| { | 517 | if (ptr_info.sentinel) |sentinel| { |
| ... | @@ -522,7 +522,7 @@ pub fn formatType( | ... | @@ -522,7 +522,7 @@ pub fn formatType( |
| 522 | return formatText(mem.span(value), fmt, options, writer); | 522 | return formatText(mem.span(value), fmt, options, writer); |
| 523 | } | 523 | } |
| 524 | } | 524 | } |
| 525 | return format(writer, "{}@{x}", .{ @typeName(ptr_info.child), @ptrToInt(value) }); | 525 | return format(writer, "{s}@{x}", .{ @typeName(ptr_info.child), @ptrToInt(value) }); |
| 526 | }, | 526 | }, |
| 527 | .Slice => { | 527 | .Slice => { |
| 528 | if (max_depth == 0) { | 528 | if (max_depth == 0) { |
| ... | @@ -573,7 +573,7 @@ pub fn formatType( | ... | @@ -573,7 +573,7 @@ pub fn formatType( |
| 573 | try writer.writeAll(" }"); | 573 | try writer.writeAll(" }"); |
| 574 | }, | 574 | }, |
| 575 | .Fn => { | 575 | .Fn => { |
| 576 | return format(writer, "{}@{x}", .{ @typeName(T), @ptrToInt(value) }); | 576 | return format(writer, "{s}@{x}", .{ @typeName(T), @ptrToInt(value) }); |
| 577 | }, | 577 | }, |
| 578 | .Type => return formatBuf(@typeName(value), options, writer), | 578 | .Type => return formatBuf(@typeName(value), options, writer), |
| 579 | .EnumLiteral => { | 579 | .EnumLiteral => { |
| ... | @@ -695,7 +695,7 @@ pub fn formatText( | ... | @@ -695,7 +695,7 @@ pub fn formatText( |
| 695 | options: FormatOptions, | 695 | options: FormatOptions, |
| 696 | writer: anytype, | 696 | writer: anytype, |
| 697 | ) !void { | 697 | ) !void { |
| 698 | if (comptime std.mem.eql(u8, fmt, "s") or (fmt.len == 0)) { | 698 | if (comptime std.mem.eql(u8, fmt, "s")) { |
| 699 | return formatBuf(bytes, options, writer); | 699 | return formatBuf(bytes, options, writer); |
| 700 | } else if (comptime (std.mem.eql(u8, fmt, "x") or std.mem.eql(u8, fmt, "X"))) { | 700 | } else if (comptime (std.mem.eql(u8, fmt, "x") or std.mem.eql(u8, fmt, "X"))) { |
| 701 | for (bytes) |c| { | 701 | for (bytes) |c| { |
| ... | @@ -1559,8 +1559,8 @@ test "buffer" { | ... | @@ -1559,8 +1559,8 @@ test "buffer" { |
| 1559 | test "array" { | 1559 | test "array" { |
| 1560 | { | 1560 | { |
| 1561 | const value: [3]u8 = "abc".*; | 1561 | const value: [3]u8 = "abc".*; |
| 1562 | try testFmt("array: abc\n", "array: {}\n", .{value}); | 1562 | try testFmt("array: abc\n", "array: {s}\n", .{value}); |
| 1563 | try testFmt("array: abc\n", "array: {}\n", .{&value}); | 1563 | try testFmt("array: abc\n", "array: {s}\n", .{&value}); |
| 1564 | try testFmt("array: { 97, 98, 99 }\n", "array: {d}\n", .{value}); | 1564 | try testFmt("array: { 97, 98, 99 }\n", "array: {d}\n", .{value}); |
| 1565 | 1565 | ||
| 1566 | var buf: [100]u8 = undefined; | 1566 | var buf: [100]u8 = undefined; |
| ... | @@ -1575,7 +1575,7 @@ test "array" { | ... | @@ -1575,7 +1575,7 @@ test "array" { |
| 1575 | test "slice" { | 1575 | test "slice" { |
| 1576 | { | 1576 | { |
| 1577 | const value: []const u8 = "abc"; | 1577 | const value: []const u8 = "abc"; |
| 1578 | try testFmt("slice: abc\n", "slice: {}\n", .{value}); | 1578 | try testFmt("slice: abc\n", "slice: {s}\n", .{value}); |
| 1579 | } | 1579 | } |
| 1580 | { | 1580 | { |
| 1581 | var runtime_zero: usize = 0; | 1581 | var runtime_zero: usize = 0; |
| ... | @@ -1902,9 +1902,9 @@ fn testFmt(expected: []const u8, comptime template: []const u8, args: anytype) ! | ... | @@ -1902,9 +1902,9 @@ fn testFmt(expected: []const u8, comptime template: []const u8, args: anytype) ! |
| 1902 | if (mem.eql(u8, result, expected)) return; | 1902 | if (mem.eql(u8, result, expected)) return; |
| 1903 | 1903 | ||
| 1904 | std.debug.warn("\n====== expected this output: =========\n", .{}); | 1904 | std.debug.warn("\n====== expected this output: =========\n", .{}); |
| 1905 | std.debug.warn("{}", .{expected}); | 1905 | std.debug.warn("{s}", .{expected}); |
| 1906 | std.debug.warn("\n======== instead found this: =========\n", .{}); | 1906 | std.debug.warn("\n======== instead found this: =========\n", .{}); |
| 1907 | std.debug.warn("{}", .{result}); | 1907 | std.debug.warn("{s}", .{result}); |
| 1908 | std.debug.warn("\n======================================\n", .{}); | 1908 | std.debug.warn("\n======================================\n", .{}); |
| 1909 | return error.TestFailed; | 1909 | return error.TestFailed; |
| 1910 | } | 1910 | } |
| ... | @@ -2061,24 +2061,24 @@ test "vector" { | ... | @@ -2061,24 +2061,24 @@ test "vector" { |
| 2061 | } | 2061 | } |
| 2062 | 2062 | ||
| 2063 | test "enum-literal" { | 2063 | test "enum-literal" { |
| 2064 | try testFmt(".hello_world", "{}", .{.hello_world}); | 2064 | try testFmt(".hello_world", "{s}", .{.hello_world}); |
| 2065 | } | 2065 | } |
| 2066 | 2066 | ||
| 2067 | test "padding" { | 2067 | test "padding" { |
| 2068 | try testFmt("Simple", "{}", .{"Simple"}); | 2068 | try testFmt("Simple", "{s}", .{"Simple"}); |
| 2069 | try testFmt(" true", "{:10}", .{true}); | 2069 | try testFmt(" true", "{:10}", .{true}); |
| 2070 | try testFmt(" true", "{:>10}", .{true}); | 2070 | try testFmt(" true", "{:>10}", .{true}); |
| 2071 | try testFmt("======true", "{:=>10}", .{true}); | 2071 | try testFmt("======true", "{:=>10}", .{true}); |
| 2072 | try testFmt("true======", "{:=<10}", .{true}); | 2072 | try testFmt("true======", "{:=<10}", .{true}); |
| 2073 | try testFmt(" true ", "{:^10}", .{true}); | 2073 | try testFmt(" true ", "{:^10}", .{true}); |
| 2074 | try testFmt("===true===", "{:=^10}", .{true}); | 2074 | try testFmt("===true===", "{:=^10}", .{true}); |
| 2075 | try testFmt(" Minimum width", "{:18} width", .{"Minimum"}); | 2075 | try testFmt(" Minimum width", "{s:18} width", .{"Minimum"}); |
| 2076 | try testFmt("==================Filled", "{:=>24}", .{"Filled"}); | 2076 | try testFmt("==================Filled", "{s:=>24}", .{"Filled"}); |
| 2077 | try testFmt(" Centered ", "{:^24}", .{"Centered"}); | 2077 | try testFmt(" Centered ", "{s:^24}", .{"Centered"}); |
| 2078 | try testFmt("-", "{:-^1}", .{""}); | 2078 | try testFmt("-", "{s:-^1}", .{""}); |
| 2079 | try testFmt("==crêpe===", "{:=^10}", .{"crêpe"}); | 2079 | try testFmt("==crêpe===", "{s:=^10}", .{"crêpe"}); |
| 2080 | try testFmt("=====crêpe", "{:=>10}", .{"crêpe"}); | 2080 | try testFmt("=====crêpe", "{s:=>10}", .{"crêpe"}); |
| 2081 | try testFmt("crêpe=====", "{:=<10}", .{"crêpe"}); | 2081 | try testFmt("crêpe=====", "{s:=<10}", .{"crêpe"}); |
| 2082 | } | 2082 | } |
| 2083 | 2083 | ||
| 2084 | test "decimal float padding" { | 2084 | test "decimal float padding" { |
| ... | @@ -2107,15 +2107,15 @@ test "type" { | ... | @@ -2107,15 +2107,15 @@ test "type" { |
| 2107 | } | 2107 | } |
| 2108 | 2108 | ||
| 2109 | test "named arguments" { | 2109 | test "named arguments" { |
| 2110 | try testFmt("hello world!", "{} world{c}", .{ "hello", '!' }); | 2110 | try testFmt("hello world!", "{s} world{c}", .{ "hello", '!' }); |
| 2111 | try testFmt("hello world!", "{[greeting]} world{[punctuation]c}", .{ .punctuation = '!', .greeting = "hello" }); | 2111 | try testFmt("hello world!", "{[greeting]s} world{[punctuation]c}", .{ .punctuation = '!', .greeting = "hello" }); |
| 2112 | try testFmt("hello world!", "{[1]} world{[0]c}", .{ '!', "hello" }); | 2112 | try testFmt("hello world!", "{[1]s} world{[0]c}", .{ '!', "hello" }); |
| 2113 | } | 2113 | } |
| 2114 | 2114 | ||
| 2115 | test "runtime width specifier" { | 2115 | test "runtime width specifier" { |
| 2116 | var width: usize = 9; | 2116 | var width: usize = 9; |
| 2117 | try testFmt("~~hello~~", "{:~^[1]}", .{ "hello", width }); | 2117 | try testFmt("~~hello~~", "{s:~^[1]}", .{ "hello", width }); |
| 2118 | try testFmt("~~hello~~", "{:~^[width]}", .{ .string = "hello", .width = width }); | 2118 | try testFmt("~~hello~~", "{s:~^[width]}", .{ .string = "hello", .width = width }); |
| 2119 | } | 2119 | } |
| 2120 | 2120 | ||
| 2121 | test "runtime precision specifier" { | 2121 | test "runtime precision specifier" { |
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/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/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/progress.zig created+310| ... | @@ -0,0 +1,310 @@ | ||
| 1 | // SPDX-License-Identifier: MIT | ||
| 2 | // Copyright (c) 2015-2020 Zig Contributors | ||
| 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. | ||
| 4 | // The MIT license requires this copyright notice to be included in all copies | ||
| 5 | // and substantial portions of the software. | ||
| 6 | const std = @import("std"); | ||
| 7 | const windows = std.os.windows; | ||
| 8 | const testing = std.testing; | ||
| 9 | const assert = std.debug.assert; | ||
| 10 | |||
| 11 | /// This API is non-allocating and non-fallible. The tradeoff is that users of | ||
| 12 | /// this API must provide the storage for each `Progress.Node`. | ||
| 13 | /// Initialize the struct directly, overriding these fields as desired: | ||
| 14 | /// * `refresh_rate_ms` | ||
| 15 | /// * `initial_delay_ms` | ||
| 16 | pub const Progress = struct { | ||
| 17 | /// `null` if the current node (and its children) should | ||
| 18 | /// not print on update() | ||
| 19 | terminal: ?std.fs.File = undefined, | ||
| 20 | |||
| 21 | /// Whether the terminal supports ANSI escape codes. | ||
| 22 | supports_ansi_escape_codes: bool = false, | ||
| 23 | |||
| 24 | root: Node = undefined, | ||
| 25 | |||
| 26 | /// Keeps track of how much time has passed since the beginning. | ||
| 27 | /// Used to compare with `initial_delay_ms` and `refresh_rate_ms`. | ||
| 28 | timer: std.time.Timer = undefined, | ||
| 29 | |||
| 30 | /// When the previous refresh was written to the terminal. | ||
| 31 | /// Used to compare with `refresh_rate_ms`. | ||
| 32 | prev_refresh_timestamp: u64 = undefined, | ||
| 33 | |||
| 34 | /// This buffer represents the maximum number of bytes written to the terminal | ||
| 35 | /// with each refresh. | ||
| 36 | output_buffer: [100]u8 = undefined, | ||
| 37 | |||
| 38 | /// How many nanoseconds between writing updates to the terminal. | ||
| 39 | refresh_rate_ns: u64 = 50 * std.time.ns_per_ms, | ||
| 40 | |||
| 41 | /// How many nanoseconds to keep the output hidden | ||
| 42 | initial_delay_ns: u64 = 500 * std.time.ns_per_ms, | ||
| 43 | |||
| 44 | done: bool = true, | ||
| 45 | |||
| 46 | /// Keeps track of how many columns in the terminal have been output, so that | ||
| 47 | /// we can move the cursor back later. | ||
| 48 | columns_written: usize = undefined, | ||
| 49 | |||
| 50 | /// Represents one unit of progress. Each node can have children nodes, or | ||
| 51 | /// one can use integers with `update`. | ||
| 52 | pub const Node = struct { | ||
| 53 | context: *Progress, | ||
| 54 | parent: ?*Node, | ||
| 55 | completed_items: usize, | ||
| 56 | name: []const u8, | ||
| 57 | recently_updated_child: ?*Node = null, | ||
| 58 | |||
| 59 | /// This field may be updated freely. | ||
| 60 | estimated_total_items: ?usize, | ||
| 61 | |||
| 62 | /// Create a new child progress node. | ||
| 63 | /// Call `Node.end` when done. | ||
| 64 | /// TODO solve https://github.com/ziglang/zig/issues/2765 and then change this | ||
| 65 | /// API to set `self.parent.recently_updated_child` with the return value. | ||
| 66 | /// Until that is fixed you probably want to call `activate` on the return value. | ||
| 67 | pub fn start(self: *Node, name: []const u8, estimated_total_items: ?usize) Node { | ||
| 68 | return Node{ | ||
| 69 | .context = self.context, | ||
| 70 | .parent = self, | ||
| 71 | .completed_items = 0, | ||
| 72 | .name = name, | ||
| 73 | .estimated_total_items = estimated_total_items, | ||
| 74 | }; | ||
| 75 | } | ||
| 76 | |||
| 77 | /// This is the same as calling `start` and then `end` on the returned `Node`. | ||
| 78 | pub fn completeOne(self: *Node) void { | ||
| 79 | if (self.parent) |parent| parent.recently_updated_child = self; | ||
| 80 | self.completed_items += 1; | ||
| 81 | self.context.maybeRefresh(); | ||
| 82 | } | ||
| 83 | |||
| 84 | pub fn end(self: *Node) void { | ||
| 85 | self.context.maybeRefresh(); | ||
| 86 | if (self.parent) |parent| { | ||
| 87 | if (parent.recently_updated_child) |parent_child| { | ||
| 88 | if (parent_child == self) { | ||
| 89 | parent.recently_updated_child = null; | ||
| 90 | } | ||
| 91 | } | ||
| 92 | parent.completeOne(); | ||
| 93 | } else { | ||
| 94 | self.context.done = true; | ||
| 95 | self.context.refresh(); | ||
| 96 | } | ||
| 97 | } | ||
| 98 | |||
| 99 | /// Tell the parent node that this node is actively being worked on. | ||
| 100 | pub fn activate(self: *Node) void { | ||
| 101 | if (self.parent) |parent| parent.recently_updated_child = self; | ||
| 102 | } | ||
| 103 | }; | ||
| 104 | |||
| 105 | /// Create a new progress node. | ||
| 106 | /// Call `Node.end` when done. | ||
| 107 | /// TODO solve https://github.com/ziglang/zig/issues/2765 and then change this | ||
| 108 | /// API to return Progress rather than accept it as a parameter. | ||
| 109 | pub fn start(self: *Progress, name: []const u8, estimated_total_items: ?usize) !*Node { | ||
| 110 | const stderr = std.io.getStdErr(); | ||
| 111 | self.terminal = null; | ||
| 112 | if (stderr.supportsAnsiEscapeCodes()) { | ||
| 113 | self.terminal = stderr; | ||
| 114 | self.supports_ansi_escape_codes = true; | ||
| 115 | } else if (std.builtin.os.tag == .windows and stderr.isTty()) { | ||
| 116 | self.terminal = stderr; | ||
| 117 | } | ||
| 118 | self.root = Node{ | ||
| 119 | .context = self, | ||
| 120 | .parent = null, | ||
| 121 | .completed_items = 0, | ||
| 122 | .name = name, | ||
| 123 | .estimated_total_items = estimated_total_items, | ||
| 124 | }; | ||
| 125 | self.columns_written = 0; | ||
| 126 | self.prev_refresh_timestamp = 0; | ||
| 127 | self.timer = try std.time.Timer.start(); | ||
| 128 | self.done = false; | ||
| 129 | return &self.root; | ||
| 130 | } | ||
| 131 | |||
| 132 | /// Updates the terminal if enough time has passed since last update. | ||
| 133 | pub fn maybeRefresh(self: *Progress) void { | ||
| 134 | const now = self.timer.read(); | ||
| 135 | if (now < self.initial_delay_ns) return; | ||
| 136 | if (now - self.prev_refresh_timestamp < self.refresh_rate_ns) return; | ||
| 137 | self.refresh(); | ||
| 138 | } | ||
| 139 | |||
| 140 | /// Updates the terminal and resets `self.next_refresh_timestamp`. | ||
| 141 | pub fn refresh(self: *Progress) void { | ||
| 142 | const file = self.terminal orelse return; | ||
| 143 | |||
| 144 | const prev_columns_written = self.columns_written; | ||
| 145 | var end: usize = 0; | ||
| 146 | if (self.columns_written > 0) { | ||
| 147 | // restore the cursor position by moving the cursor | ||
| 148 | // `columns_written` cells to the left, then clear the rest of the | ||
| 149 | // line | ||
| 150 | if (self.supports_ansi_escape_codes) { | ||
| 151 | end += (std.fmt.bufPrint(self.output_buffer[end..], "\x1b[{d}D", .{self.columns_written}) catch unreachable).len; | ||
| 152 | end += (std.fmt.bufPrint(self.output_buffer[end..], "\x1b[0K", .{}) catch unreachable).len; | ||
| 153 | } else if (std.builtin.os.tag == .windows) winapi: { | ||
| 154 | var info: windows.CONSOLE_SCREEN_BUFFER_INFO = undefined; | ||
| 155 | if (windows.kernel32.GetConsoleScreenBufferInfo(file.handle, &info) != windows.TRUE) | ||
| 156 | unreachable; | ||
| 157 | |||
| 158 | var cursor_pos = windows.COORD{ | ||
| 159 | .X = info.dwCursorPosition.X - @intCast(windows.SHORT, self.columns_written), | ||
| 160 | .Y = info.dwCursorPosition.Y, | ||
| 161 | }; | ||
| 162 | |||
| 163 | if (cursor_pos.X < 0) | ||
| 164 | cursor_pos.X = 0; | ||
| 165 | |||
| 166 | const fill_chars = @intCast(windows.DWORD, info.dwSize.X - cursor_pos.X); | ||
| 167 | |||
| 168 | var written: windows.DWORD = undefined; | ||
| 169 | if (windows.kernel32.FillConsoleOutputAttribute( | ||
| 170 | file.handle, | ||
| 171 | info.wAttributes, | ||
| 172 | fill_chars, | ||
| 173 | cursor_pos, | ||
| 174 | &written, | ||
| 175 | ) != windows.TRUE) { | ||
| 176 | // Stop trying to write to this file. | ||
| 177 | self.terminal = null; | ||
| 178 | break :winapi; | ||
| 179 | } | ||
| 180 | if (windows.kernel32.FillConsoleOutputCharacterA( | ||
| 181 | file.handle, | ||
| 182 | ' ', | ||
| 183 | fill_chars, | ||
| 184 | cursor_pos, | ||
| 185 | &written, | ||
| 186 | ) != windows.TRUE) unreachable; | ||
| 187 | |||
| 188 | if (windows.kernel32.SetConsoleCursorPosition(file.handle, cursor_pos) != windows.TRUE) | ||
| 189 | unreachable; | ||
| 190 | } else unreachable; | ||
| 191 | |||
| 192 | self.columns_written = 0; | ||
| 193 | } | ||
| 194 | |||
| 195 | if (!self.done) { | ||
| 196 | var need_ellipse = false; | ||
| 197 | var maybe_node: ?*Node = &self.root; | ||
| 198 | while (maybe_node) |node| { | ||
| 199 | if (need_ellipse) { | ||
| 200 | self.bufWrite(&end, "... ", .{}); | ||
| 201 | } | ||
| 202 | need_ellipse = false; | ||
| 203 | if (node.name.len != 0 or node.estimated_total_items != null) { | ||
| 204 | if (node.name.len != 0) { | ||
| 205 | self.bufWrite(&end, "{s}", .{node.name}); | ||
| 206 | need_ellipse = true; | ||
| 207 | } | ||
| 208 | if (node.estimated_total_items) |total| { | ||
| 209 | if (need_ellipse) self.bufWrite(&end, " ", .{}); | ||
| 210 | self.bufWrite(&end, "[{d}/{d}] ", .{ node.completed_items + 1, total }); | ||
| 211 | need_ellipse = false; | ||
| 212 | } else if (node.completed_items != 0) { | ||
| 213 | if (need_ellipse) self.bufWrite(&end, " ", .{}); | ||
| 214 | self.bufWrite(&end, "[{d}] ", .{node.completed_items + 1}); | ||
| 215 | need_ellipse = false; | ||
| 216 | } | ||
| 217 | } | ||
| 218 | maybe_node = node.recently_updated_child; | ||
| 219 | } | ||
| 220 | if (need_ellipse) { | ||
| 221 | self.bufWrite(&end, "... ", .{}); | ||
| 222 | } | ||
| 223 | } | ||
| 224 | |||
| 225 | _ = file.write(self.output_buffer[0..end]) catch |e| { | ||
| 226 | // Stop trying to write to this file once it errors. | ||
| 227 | self.terminal = null; | ||
| 228 | }; | ||
| 229 | self.prev_refresh_timestamp = self.timer.read(); | ||
| 230 | } | ||
| 231 | |||
| 232 | pub fn log(self: *Progress, comptime format: []const u8, args: anytype) void { | ||
| 233 | const file = self.terminal orelse return; | ||
| 234 | self.refresh(); | ||
| 235 | file.outStream().print(format, args) catch { | ||
| 236 | self.terminal = null; | ||
| 237 | return; | ||
| 238 | }; | ||
| 239 | self.columns_written = 0; | ||
| 240 | } | ||
| 241 | |||
| 242 | fn bufWrite(self: *Progress, end: *usize, comptime format: []const u8, args: anytype) void { | ||
| 243 | if (std.fmt.bufPrint(self.output_buffer[end.*..], format, args)) |written| { | ||
| 244 | const amt = written.len; | ||
| 245 | end.* += amt; | ||
| 246 | self.columns_written += amt; | ||
| 247 | } else |err| switch (err) { | ||
| 248 | error.NoSpaceLeft => { | ||
| 249 | self.columns_written += self.output_buffer.len - end.*; | ||
| 250 | end.* = self.output_buffer.len; | ||
| 251 | }, | ||
| 252 | } | ||
| 253 | const bytes_needed_for_esc_codes_at_end = if (std.builtin.os.tag == .windows) 0 else 11; | ||
| 254 | const max_end = self.output_buffer.len - bytes_needed_for_esc_codes_at_end; | ||
| 255 | if (end.* > max_end) { | ||
| 256 | const suffix = "... "; | ||
| 257 | self.columns_written = self.columns_written - (end.* - max_end) + suffix.len; | ||
| 258 | std.mem.copy(u8, self.output_buffer[max_end..], suffix); | ||
| 259 | end.* = max_end + suffix.len; | ||
| 260 | } | ||
| 261 | } | ||
| 262 | }; | ||
| 263 | |||
| 264 | test "basic functionality" { | ||
| 265 | var disable = true; | ||
| 266 | if (disable) { | ||
| 267 | // This test is disabled because it uses time.sleep() and is therefore slow. It also | ||
| 268 | // prints bogus progress data to stderr. | ||
| 269 | return error.SkipZigTest; | ||
| 270 | } | ||
| 271 | var progress = Progress{}; | ||
| 272 | const root_node = try progress.start("", 100); | ||
| 273 | defer root_node.end(); | ||
| 274 | |||
| 275 | const sub_task_names = [_][]const u8{ | ||
| 276 | "reticulating splines", | ||
| 277 | "adjusting shoes", | ||
| 278 | "climbing towers", | ||
| 279 | "pouring juice", | ||
| 280 | }; | ||
| 281 | var next_sub_task: usize = 0; | ||
| 282 | |||
| 283 | var i: usize = 0; | ||
| 284 | while (i < 100) : (i += 1) { | ||
| 285 | var node = root_node.start(sub_task_names[next_sub_task], 5); | ||
| 286 | node.activate(); | ||
| 287 | next_sub_task = (next_sub_task + 1) % sub_task_names.len; | ||
| 288 | |||
| 289 | node.completeOne(); | ||
| 290 | std.time.sleep(5 * std.time.ns_per_ms); | ||
| 291 | node.completeOne(); | ||
| 292 | node.completeOne(); | ||
| 293 | std.time.sleep(5 * std.time.ns_per_ms); | ||
| 294 | node.completeOne(); | ||
| 295 | node.completeOne(); | ||
| 296 | std.time.sleep(5 * std.time.ns_per_ms); | ||
| 297 | |||
| 298 | node.end(); | ||
| 299 | |||
| 300 | std.time.sleep(5 * std.time.ns_per_ms); | ||
| 301 | } | ||
| 302 | { | ||
| 303 | var node = root_node.start("this is a really long name designed to activate the truncation code. let's find out if it works", null); | ||
| 304 | node.activate(); | ||
| 305 | std.time.sleep(10 * std.time.ns_per_ms); | ||
| 306 | progress.refresh(); | ||
| 307 | std.time.sleep(10 * std.time.ns_per_ms); | ||
| 308 | node.end(); | ||
| 309 | } | ||
| 310 | } | ||
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-7| ... | @@ -29,10 +29,11 @@ pub var zig_exe_path: []const u8 = undefined; | ... | @@ -29,10 +29,11 @@ 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 | std.debug.panic("expected error.{s}, found", .{@errorName(expected_error)}); | ||
| 33 | } else |actual_error| { | 34 | } else |actual_error| { |
| 34 | if (expected_error != actual_error) { | 35 | if (expected_error != actual_error) { |
| 35 | std.debug.panic("expected error.{}, found error.{}", .{ | 36 | std.debug.panic("expected error.{s}, found error.{s}", .{ |
| 36 | @errorName(expected_error), | 37 | @errorName(expected_error), |
| 37 | @errorName(actual_error), | 38 | @errorName(actual_error), |
| 38 | }); | 39 | }); |
| ... | @@ -60,7 +61,7 @@ pub fn expectEqual(expected: anytype, actual: @TypeOf(expected)) void { | ... | @@ -60,7 +61,7 @@ pub fn expectEqual(expected: anytype, actual: @TypeOf(expected)) void { |
| 60 | 61 | ||
| 61 | .Type => { | 62 | .Type => { |
| 62 | if (actual != expected) { | 63 | if (actual != expected) { |
| 63 | std.debug.panic("expected type {}, found type {}", .{ @typeName(expected), @typeName(actual) }); | 64 | std.debug.panic("expected type {s}, found type {s}", .{ @typeName(expected), @typeName(actual) }); |
| 64 | } | 65 | } |
| 65 | }, | 66 | }, |
| 66 | 67 | ||
| ... | @@ -360,7 +361,7 @@ pub fn expectEqualStrings(expected: []const u8, actual: []const u8) void { | ... | @@ -360,7 +361,7 @@ pub fn expectEqualStrings(expected: []const u8, actual: []const u8) void { |
| 360 | for (expected[0..diff_index]) |value| { | 361 | for (expected[0..diff_index]) |value| { |
| 361 | if (value == '\n') diff_line_number += 1; | 362 | if (value == '\n') diff_line_number += 1; |
| 362 | } | 363 | } |
| 363 | print("First difference occurs on line {}:\n", .{diff_line_number}); | 364 | print("First difference occurs on line {d}:\n", .{diff_line_number}); |
| 364 | 365 | ||
| 365 | print("expected:\n", .{}); | 366 | print("expected:\n", .{}); |
| 366 | printIndicatorLine(expected, diff_index); | 367 | printIndicatorLine(expected, diff_index); |
| ... | @@ -416,15 +417,15 @@ fn printWithVisibleNewlines(source: []const u8) void { | ... | @@ -416,15 +417,15 @@ fn printWithVisibleNewlines(source: []const u8) void { |
| 416 | while (std.mem.indexOf(u8, source[i..], "\n")) |nl| : (i += nl + 1) { | 417 | while (std.mem.indexOf(u8, source[i..], "\n")) |nl| : (i += nl + 1) { |
| 417 | printLine(source[i .. i + nl]); | 418 | printLine(source[i .. i + nl]); |
| 418 | } | 419 | } |
| 419 | print("{}␃\n", .{source[i..]}); // End of Text symbol (ETX) | 420 | print("{s}␃\n", .{source[i..]}); // End of Text symbol (ETX) |
| 420 | } | 421 | } |
| 421 | 422 | ||
| 422 | fn printLine(line: []const u8) void { | 423 | fn printLine(line: []const u8) void { |
| 423 | if (line.len != 0) switch (line[line.len - 1]) { | 424 | if (line.len != 0) switch (line[line.len - 1]) { |
| 424 | ' ', '\t' => print("{}⏎\n", .{line}), // Carriage return symbol, | 425 | ' ', '\t' => print("{s}⏎\n", .{line}), // Carriage return symbol, |
| 425 | else => {}, | 426 | else => {}, |
| 426 | }; | 427 | }; |
| 427 | print("{}\n", .{line}); | 428 | print("{s}\n", .{line}); |
| 428 | } | 429 | } |
| 429 | 430 | ||
| 430 | test "" { | 431 | 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+1-1| ... | @@ -3744,7 +3744,7 @@ fn testParse(source: []const u8, allocator: *mem.Allocator, anything_changed: *b | ... | @@ -3744,7 +3744,7 @@ fn testParse(source: []const u8, allocator: *mem.Allocator, anything_changed: *b |
| 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):{}:{}: 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) { |
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/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(); |
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 | } |