authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-07-03 18:30:07-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-07-07 22:43:52-07:00
log30c2921eb87c3157d52edd7d8ee874209a0f7538
tree876d4864abe53e1b43afa87b6e0f61572179ff86
parentd09b99d043cc097de569fb32938a423342490a83

compiler: update a bunch of format strings


57 files changed, 432 insertions(+), 514 deletions(-)

lib/compiler/aro/aro/Diagnostics.zig+7-6
......@@ -324,7 +324,8 @@ pub fn addExtra(
324324
325325pub fn render(comp: *Compilation, config: std.io.tty.Config) void {
326326 if (comp.diagnostics.list.items.len == 0) return;
327 var m = defaultMsgWriter(config);
327 var buffer: [1000]u8 = undefined;
328 var m = defaultMsgWriter(config, &buffer);
328329 defer m.deinit();
329330 renderMessages(comp, &m);
330331}
......@@ -525,12 +526,12 @@ fn tagKind(d: *Diagnostics, tag: Tag, langopts: LangOpts) Kind {
525526}
526527
527528const MsgWriter = struct {
528 w: *std.fs.File.Writer,
529 writer: *std.io.Writer,
529530 config: std.io.tty.Config,
530531
531532 fn init(config: std.io.tty.Config, buffer: []u8) MsgWriter {
532533 return .{
533 .w = std.debug.lockStderrWriter(buffer),
534 .writer = std.debug.lockStderrWriter(buffer),
534535 .config = config,
535536 };
536537 }
......@@ -541,15 +542,15 @@ const MsgWriter = struct {
541542 }
542543
543544 pub fn print(m: *MsgWriter, comptime fmt: []const u8, args: anytype) void {
544 m.w.interface.print(fmt, args) catch {};
545 m.writer.print(fmt, args) catch {};
545546 }
546547
547548 fn write(m: *MsgWriter, msg: []const u8) void {
548 m.w.interface.writeAll(msg) catch {};
549 m.writer.writeAll(msg) catch {};
549550 }
550551
551552 fn setColor(m: *MsgWriter, color: std.io.tty.Color) void {
552 m.config.setColor(m.w.interface, color) catch {};
553 m.config.setColor(m.writer, color) catch {};
553554 }
554555
555556 fn location(m: *MsgWriter, path: []const u8, line: u32, col: u32) void {
lib/compiler/aro/aro/Value.zig+2-1
......@@ -961,7 +961,8 @@ pub fn print(v: Value, ty: Type, comp: *const Compilation, w: anytype) @TypeOf(w
961961 switch (key) {
962962 .null => return w.writeAll("nullptr_t"),
963963 .int => |repr| switch (repr) {
964 inline else => |x| return w.print("{fd}", .{x}),
964 inline .u64, .i64 => |x| return w.print("{d}", .{x}),
965 .big_int => |x| return w.print("{fd}", .{x}),
965966 },
966967 .float => |repr| switch (repr) {
967968 .f16 => |x| return w.print("{d}", .{@round(@as(f64, @floatCast(x)) * 1000) / 1000}),
lib/std/io/Writer.zig+4
......@@ -881,6 +881,10 @@ pub fn printValue(
881881 return;
882882 },
883883 .@"union" => |info| {
884 if (fmt.len == 1 and fmt[0] == 's') {
885 try w.writeAll(@tagName(value));
886 return;
887 }
884888 if (!is_any) {
885889 if (fmt.len != 0) invalidFmtError(fmt, value);
886890 return printValue(w, ANY, options, value, max_depth);
lib/std/zig/AstGen.zig+1-7
......@@ -11305,13 +11305,7 @@ fn failWithStrLitError(
1130511305 offset: u32,
1130611306) InnerError {
1130711307 const raw_string = bytes[offset..];
11308 return failOff(
11309 astgen,
11310 token,
11311 @intCast(offset + err.offset()),
11312 "{}",
11313 .{err.fmt(raw_string)},
11314 );
11308 return failOff(astgen, token, @intCast(offset + err.offset()), "{f}", .{err.fmt(raw_string)});
1131511309}
1131611310
1131711311fn failNode(
lib/std/zig/llvm/Builder.zig+42-28
......@@ -1155,8 +1155,11 @@ pub const Attribute = union(Kind) {
11551155 const FormatData = struct {
11561156 attribute_index: Index,
11571157 builder: *const Builder,
1158 mode: Mode,
1159 const Mode = enum { default, quote, pound };
1158 flags: Flags = .{},
1159 const Flags = struct {
1160 pound: bool = false,
1161 quote: bool = false,
1162 };
11601163 };
11611164 fn format(data: FormatData, w: *Writer) Writer.Error!void {
11621165 const attribute = data.attribute_index.toAttribute(data.builder);
......@@ -1262,11 +1265,12 @@ pub const Attribute = union(Kind) {
12621265 try w.writeByte(')');
12631266 },
12641267 .alignstack => |alignment| {
1265 try w.print(" {f}", .{attribute});
1268 try w.print(" {s}", .{attribute});
12661269 const alignment_bytes = alignment.toByteUnits() orelse return;
1267 switch (data.mode) {
1268 .pound => try w.print("({d})", .{alignment_bytes}),
1269 else => try w.print("={d}", .{alignment_bytes}),
1270 if (data.flags.pound) {
1271 try w.print("={d}", .{alignment_bytes});
1272 } else {
1273 try w.print("({d})", .{alignment_bytes});
12701274 }
12711275 },
12721276 .allockind => |allockind| {
......@@ -1313,7 +1317,7 @@ pub const Attribute = union(Kind) {
13131317 vscale_range.min.toByteUnits().?,
13141318 vscale_range.max.toByteUnits() orelse 0,
13151319 }),
1316 .string => |string_attr| if (data.mode == .quote) {
1320 .string => |string_attr| if (data.flags.quote) {
13171321 try w.print(" {f}", .{string_attr.kind.fmtQ(data.builder)});
13181322 if (string_attr.value != .empty)
13191323 try w.print("={f}", .{string_attr.value.fmtQ(data.builder)});
......@@ -1595,16 +1599,18 @@ pub const Attributes = enum(u32) {
15951599 const FormatData = struct {
15961600 attributes: Attributes,
15971601 builder: *const Builder,
1602 flags: Flags = .{},
1603 const Flags = Attribute.Index.FormatData.Flags;
15981604 };
15991605 fn format(data: FormatData, w: *Writer) Writer.Error!void {
16001606 for (data.attributes.slice(data.builder)) |attribute_index| try Attribute.Index.format(.{
16011607 .attribute_index = attribute_index,
16021608 .builder = data.builder,
1603 .mode = .default,
1609 .flags = data.flags,
16041610 }, w);
16051611 }
1606 pub fn fmt(self: Attributes, builder: *const Builder) std.fmt.Formatter(FormatData, format) {
1607 return .{ .data = .{ .attributes = self, .builder = builder } };
1612 pub fn fmt(self: Attributes, builder: *const Builder, flags: FormatData.Flags) std.fmt.Formatter(FormatData, format) {
1613 return .{ .data = .{ .attributes = self, .builder = builder, .flags = flags } };
16081614 }
16091615};
16101616
......@@ -1808,7 +1814,8 @@ pub const Preemption = enum {
18081814 dso_local,
18091815 implicit_dso_local,
18101816
1811 pub fn format(self: Preemption, w: *Writer, comptime _: []const u8) Writer.Error!void {
1817 pub fn format(self: Preemption, w: *Writer, comptime f: []const u8) Writer.Error!void {
1818 comptime assert(f.len == 0);
18121819 if (self == .dso_local) try w.print(" {s}", .{@tagName(self)});
18131820 }
18141821};
......@@ -1826,8 +1833,8 @@ pub const Visibility = enum(u2) {
18261833 };
18271834 }
18281835
1829 pub fn format(self: Visibility, comptime format_string: []const u8, writer: *Writer) Writer.Error!void {
1830 comptime assert(format_string.len == 0);
1836 pub fn format(self: Visibility, writer: *Writer, comptime f: []const u8) Writer.Error!void {
1837 comptime assert(f.len == 0);
18311838 if (self != .default) try writer.print(" {s}", .{@tagName(self)});
18321839 }
18331840};
......@@ -1837,7 +1844,8 @@ pub const DllStorageClass = enum(u2) {
18371844 dllimport = 1,
18381845 dllexport = 2,
18391846
1840 pub fn format(self: DllStorageClass, w: *Writer, comptime _: []const u8) Writer.Error!void {
1847 pub fn format(self: DllStorageClass, w: *Writer, comptime f: []const u8) Writer.Error!void {
1848 comptime assert(f.len == 0);
18411849 if (self != .default) try w.print(" {s}", .{@tagName(self)});
18421850 }
18431851};
......@@ -1863,7 +1871,8 @@ pub const UnnamedAddr = enum(u2) {
18631871 unnamed_addr = 1,
18641872 local_unnamed_addr = 2,
18651873
1866 pub fn format(self: UnnamedAddr, w: *Writer, comptime _: []const u8) Writer.Error!void {
1874 pub fn format(self: UnnamedAddr, w: *Writer, comptime f: []const u8) Writer.Error!void {
1875 comptime assert(f.len == 0);
18671876 if (self != .default) try w.print(" {s}", .{@tagName(self)});
18681877 }
18691878};
......@@ -1966,7 +1975,8 @@ pub const ExternallyInitialized = enum {
19661975 default,
19671976 externally_initialized,
19681977
1969 pub fn format(self: ExternallyInitialized, w: *Writer, comptime _: []const u8) Writer.Error!void {
1978 pub fn format(self: ExternallyInitialized, w: *Writer, comptime f: []const u8) Writer.Error!void {
1979 comptime assert(f.len == 0);
19701980 if (self != .default) try w.print(" {s}", .{@tagName(self)});
19711981 }
19721982};
......@@ -2064,7 +2074,8 @@ pub const CallConv = enum(u10) {
20642074
20652075 pub const default = CallConv.ccc;
20662076
2067 pub fn format(self: CallConv, w: *Writer, comptime _: []const u8) Writer.Error!void {
2077 pub fn format(self: CallConv, w: *Writer, comptime f: []const u8) Writer.Error!void {
2078 comptime assert(f.len == 0);
20682079 switch (self) {
20692080 default => {},
20702081 .fastcc,
......@@ -7958,7 +7969,8 @@ pub const Metadata = enum(u32) {
79587969 AllCallsDescribed: bool = false,
79597970 Unused: u2 = 0,
79607971
7961 pub fn format(self: DIFlags, w: *Writer, comptime _: []const u8) Writer.Error!void {
7972 pub fn format(self: DIFlags, w: *Writer, comptime f: []const u8) Writer.Error!void {
7973 comptime assert(f.len == 0);
79627974 var need_pipe = false;
79637975 inline for (@typeInfo(DIFlags).@"struct".fields) |field| {
79647976 switch (@typeInfo(field.type)) {
......@@ -8015,7 +8027,8 @@ pub const Metadata = enum(u32) {
80158027 ObjCDirect: bool = false,
80168028 Unused: u20 = 0,
80178029
8018 pub fn format(self: DISPFlags, w: *Writer, comptime _: []const u8) Writer.Error!void {
8030 pub fn format(self: DISPFlags, w: *Writer, comptime f: []const u8) Writer.Error!void {
8031 comptime assert(f.len == 0);
80198032 var need_pipe = false;
80208033 inline for (@typeInfo(DISPFlags).@"struct".fields) |field| {
80218034 switch (@typeInfo(field.type)) {
......@@ -9469,8 +9482,9 @@ pub fn print(self: *Builder, w: *Writer) (Writer.Error || Allocator.Error)!void
94699482 \\
94709483 , .{
94719484 variable.global.fmt(self),
9472 Linkage.fmtOptional(if (global.linkage == .external and
9473 variable.init != .no_init) null else global.linkage),
9485 Linkage.fmtOptional(
9486 if (global.linkage == .external and variable.init != .no_init) null else global.linkage,
9487 ),
94749488 global.preemption,
94759489 global.visibility,
94769490 global.dll_storage_class,
......@@ -9525,7 +9539,7 @@ pub fn print(self: *Builder, w: *Writer) (Writer.Error || Allocator.Error)!void
95259539 if (function_attributes != .none) try w.print(
95269540 \\; Function Attrs:{f}
95279541 \\
9528 , .{function_attributes.fmt(self)});
9542 , .{function_attributes.fmt(self, .{})});
95299543 try w.print(
95309544 \\{s}{f}{f}{f}{f}{f}{f} {f} {f}(
95319545 , .{
......@@ -9535,7 +9549,7 @@ pub fn print(self: *Builder, w: *Writer) (Writer.Error || Allocator.Error)!void
95359549 global.visibility,
95369550 global.dll_storage_class,
95379551 function.call_conv,
9538 function.attributes.ret(self).fmt(self),
9552 function.attributes.ret(self).fmt(self, .{}),
95399553 global.type.functionReturn(self).fmt(self, .percent),
95409554 function.global.fmt(self),
95419555 });
......@@ -9545,7 +9559,7 @@ pub fn print(self: *Builder, w: *Writer) (Writer.Error || Allocator.Error)!void
95459559 \\{f}{f}
95469560 , .{
95479561 global.type.functionParameters(self)[arg].fmt(self, .percent),
9548 function.attributes.param(arg, self).fmt(self),
9562 function.attributes.param(arg, self).fmt(self, .{}),
95499563 });
95509564 if (function.instructions.len > 0)
95519565 try w.print(" {f}", .{function.arg(@intCast(arg)).fmt(function_index, self, .{})})
......@@ -9790,7 +9804,7 @@ pub fn print(self: *Builder, w: *Writer) (Writer.Error || Allocator.Error)!void
97909804 try w.print("{s}{f}{f}{f} {f} {f}(", .{
97919805 @tagName(tag),
97929806 extra.data.info.call_conv,
9793 extra.data.attributes.ret(self).fmt(self),
9807 extra.data.attributes.ret(self).fmt(self, .{}),
97949808 extra.data.callee.typeOf(function_index, self).pointerAddrSpace(self),
97959809 switch (extra.data.ty.functionKind(self)) {
97969810 .normal => ret_ty,
......@@ -9804,7 +9818,7 @@ pub fn print(self: *Builder, w: *Writer) (Writer.Error || Allocator.Error)!void
98049818 defer metadata_formatter.need_comma = undefined;
98059819 try w.print("{f}{f}{f}", .{
98069820 arg.typeOf(function_index, self).fmt(self, .percent),
9807 extra.data.attributes.param(arg_index, self).fmt(self),
9821 extra.data.attributes.param(arg_index, self).fmt(self, .{}),
98089822 try metadata_formatter.fmtLocal(" ", arg, function_index),
98099823 });
98109824 }
......@@ -10074,9 +10088,9 @@ pub fn print(self: *Builder, w: *Writer) (Writer.Error || Allocator.Error)!void
1007410088 if (need_newline) try w.writeByte('\n') else need_newline = true;
1007510089 for (0.., attribute_groups.keys()) |attribute_group_index, attribute_group|
1007610090 try w.print(
10077 \\attributes #{d} = {{{f#"} }}
10091 \\attributes #{d} = {{{f} }}
1007810092 \\
10079 , .{ attribute_group_index, attribute_group.fmt(self) });
10093 , .{ attribute_group_index, attribute_group.fmt(self, .{ .pound = true, .quote = true }) });
1008010094 }
1008110095
1008210096 if (self.metadata_named.count() > 0) {
src/Air/Liveness.zig+5-3
......@@ -1323,7 +1323,7 @@ fn analyzeOperands(
13231323 const mask = @as(Bpi, 1) << @as(OperandInt, @intCast(i));
13241324
13251325 if ((try data.live_set.fetchPut(gpa, operand, {})) == null) {
1326 log.debug("[{}] %{f}: added %{d} to live set (operand dies here)", .{ pass, @intFromEnum(inst), operand });
1326 log.debug("[{}] %{d}: added %{d} to live set (operand dies here)", .{ pass, @intFromEnum(inst), operand });
13271327 tomb_bits |= mask;
13281328 }
13291329 }
......@@ -2036,7 +2036,8 @@ fn fmtInstSet(set: *const std.AutoHashMapUnmanaged(Air.Inst.Index, void)) FmtIns
20362036const FmtInstSet = struct {
20372037 set: *const std.AutoHashMapUnmanaged(Air.Inst.Index, void),
20382038
2039 pub fn format(val: FmtInstSet, comptime _: []const u8, _: std.fmt.FormatOptions, w: anytype) !void {
2039 pub fn format(val: FmtInstSet, w: *std.io.Writer, comptime f: []const u8) std.io.Writer.Error!void {
2040 comptime assert(f.len == 0);
20402041 if (val.set.count() == 0) {
20412042 try w.writeAll("[no instructions]");
20422043 return;
......@@ -2056,7 +2057,8 @@ fn fmtInstList(list: []const Air.Inst.Index) FmtInstList {
20562057const FmtInstList = struct {
20572058 list: []const Air.Inst.Index,
20582059
2059 pub fn format(val: FmtInstList, comptime _: []const u8, _: std.fmt.FormatOptions, w: anytype) !void {
2060 pub fn format(val: FmtInstList, w: *std.io.Writer, comptime f: []const u8) std.io.Writer.Error!void {
2061 comptime assert(f.len == 0);
20602062 if (val.list.len == 0) {
20612063 try w.writeAll("[no instructions]");
20622064 return;
src/Air/Liveness/Verify.zig+12-10
......@@ -73,7 +73,7 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void {
7373 .trap, .unreach => {
7474 try self.verifyInstOperands(inst, .{ .none, .none, .none });
7575 // This instruction terminates the function, so everything should be dead
76 if (self.live.count() > 0) return invalid("%{}: instructions still alive", .{inst});
76 if (self.live.count() > 0) return invalid("%{f}: instructions still alive", .{inst});
7777 },
7878
7979 // unary
......@@ -166,7 +166,7 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void {
166166 const un_op = data[@intFromEnum(inst)].un_op;
167167 try self.verifyInstOperands(inst, .{ un_op, .none, .none });
168168 // This instruction terminates the function, so everything should be dead
169 if (self.live.count() > 0) return invalid("%{}: instructions still alive", .{inst});
169 if (self.live.count() > 0) return invalid("%{f}: instructions still alive", .{inst});
170170 },
171171 .dbg_var_ptr,
172172 .dbg_var_val,
......@@ -450,7 +450,7 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void {
450450 .repeat => {
451451 const repeat = data[@intFromEnum(inst)].repeat;
452452 const expected_live = self.loops.get(repeat.loop_inst) orelse
453 return invalid("%{}: loop %{} not in scope", .{ @intFromEnum(inst), @intFromEnum(repeat.loop_inst) });
453 return invalid("%{d}: loop %{d} not in scope", .{ @intFromEnum(inst), @intFromEnum(repeat.loop_inst) });
454454
455455 try self.verifyMatchingLiveness(repeat.loop_inst, expected_live);
456456 },
......@@ -460,7 +460,7 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void {
460460 try self.verifyOperand(inst, br.operand, self.liveness.operandDies(inst, 0));
461461
462462 const expected_live = self.loops.get(br.block_inst) orelse
463 return invalid("%{}: loop %{} not in scope", .{ @intFromEnum(inst), @intFromEnum(br.block_inst) });
463 return invalid("%{d}: loop %{d} not in scope", .{ @intFromEnum(inst), @intFromEnum(br.block_inst) });
464464
465465 try self.verifyMatchingLiveness(br.block_inst, expected_live);
466466 },
......@@ -511,7 +511,7 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void {
511511
512512 // The same stuff should be alive after the loop as before it.
513513 const gop = try self.loops.getOrPut(self.gpa, inst);
514 if (gop.found_existing) return invalid("%{}: loop already exists", .{@intFromEnum(inst)});
514 if (gop.found_existing) return invalid("%{d}: loop already exists", .{@intFromEnum(inst)});
515515 defer {
516516 var live = self.loops.fetchRemove(inst).?;
517517 live.value.deinit(self.gpa);
......@@ -560,7 +560,7 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void {
560560 // after the loop as before it.
561561 {
562562 const gop = try self.loops.getOrPut(self.gpa, inst);
563 if (gop.found_existing) return invalid("%{}: loop already exists", .{@intFromEnum(inst)});
563 if (gop.found_existing) return invalid("%{d}: loop already exists", .{@intFromEnum(inst)});
564564 gop.value_ptr.* = self.live.move();
565565 }
566566 defer {
......@@ -601,9 +601,11 @@ fn verifyOperand(self: *Verify, inst: Air.Inst.Index, op_ref: Air.Inst.Ref, dies
601601 return;
602602 };
603603 if (dies) {
604 if (!self.live.remove(operand)) return invalid("%{}: dead operand %{} reused and killed again", .{ inst, operand });
604 if (!self.live.remove(operand)) return invalid("%{f}: dead operand %{f} reused and killed again", .{
605 inst, operand,
606 });
605607 } else {
606 if (!self.live.contains(operand)) return invalid("%{}: dead operand %{} reused", .{ inst, operand });
608 if (!self.live.contains(operand)) return invalid("%{f}: dead operand %{f} reused", .{ inst, operand });
607609 }
608610}
609611
......@@ -628,9 +630,9 @@ fn verifyInst(self: *Verify, inst: Air.Inst.Index) Error!void {
628630}
629631
630632fn verifyMatchingLiveness(self: *Verify, block: Air.Inst.Index, live: LiveMap) Error!void {
631 if (self.live.count() != live.count()) return invalid("%{}: different deaths across branches", .{block});
633 if (self.live.count() != live.count()) return invalid("%{f}: different deaths across branches", .{block});
632634 var live_it = self.live.keyIterator();
633 while (live_it.next()) |live_inst| if (!live.contains(live_inst.*)) return invalid("%{}: different deaths across branches", .{block});
635 while (live_it.next()) |live_inst| if (!live.contains(live_inst.*)) return invalid("%{f}: different deaths across branches", .{block});
634636}
635637
636638fn invalid(comptime fmt: []const u8, args: anytype) error{LivenessInvalid} {
src/Air/print.zig+2-2
......@@ -518,7 +518,7 @@ const Writer = struct {
518518 if (mask_idx > 0) try s.writeAll(", ");
519519 switch (mask_elem.unwrap()) {
520520 .elem => |idx| try s.print("elem {d}", .{idx}),
521 .value => |val| try s.print("val {}", .{Value.fromInterned(val).fmtValue(w.pt)}),
521 .value => |val| try s.print("val {f}", .{Value.fromInterned(val).fmtValue(w.pt)}),
522522 }
523523 }
524524 try s.writeByte(']');
......@@ -590,7 +590,7 @@ const Writer = struct {
590590 const ip = &w.pt.zcu.intern_pool;
591591 const ty_nav = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_nav;
592592 try w.writeType(s, .fromInterned(ty_nav.ty));
593 try s.print(", '{}'", .{ip.getNav(ty_nav.nav).fqn.fmt(ip)});
593 try s.print(", '{f}'", .{ip.getNav(ty_nav.nav).fqn.fmt(ip)});
594594 }
595595
596596 fn writeAtomicLoad(w: *Writer, s: *std.io.Writer, inst: Air.Inst.Index) Error!void {
src/Compilation.zig+26-29
......@@ -729,10 +729,10 @@ pub const Directories = struct {
729729 };
730730
731731 if (std.mem.eql(u8, zig_lib.path orelse "", global_cache.path orelse "")) {
732 fatal("zig lib directory '{}' cannot be equal to global cache directory '{}'", .{ zig_lib, global_cache });
732 fatal("zig lib directory '{f}' cannot be equal to global cache directory '{f}'", .{ zig_lib, global_cache });
733733 }
734734 if (std.mem.eql(u8, zig_lib.path orelse "", local_cache.path orelse "")) {
735 fatal("zig lib directory '{}' cannot be equal to local cache directory '{}'", .{ zig_lib, local_cache });
735 fatal("zig lib directory '{f}' cannot be equal to local cache directory '{f}'", .{ zig_lib, local_cache });
736736 }
737737
738738 return .{
......@@ -2698,7 +2698,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) !void {
26982698 const prefix = man.cache.prefixes()[pp.prefix];
26992699 return comp.setMiscFailure(
27002700 .check_whole_cache,
2701 "failed to check cache: '{}{s}' {s} {s}",
2701 "failed to check cache: '{f}{s}' {s} {s}",
27022702 .{ prefix, pp.sub_path, @tagName(man.diagnostic), @errorName(op.err) },
27032703 );
27042704 },
......@@ -2915,7 +2915,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) !void {
29152915 renameTmpIntoCache(comp.dirs.local_cache, tmp_dir_sub_path, o_sub_path) catch |err| {
29162916 return comp.setMiscFailure(
29172917 .rename_results,
2918 "failed to rename compilation results ('{}{s}') into local cache ('{}{s}'): {s}",
2918 "failed to rename compilation results ('{f}{s}') into local cache ('{f}{s}'): {s}",
29192919 .{
29202920 comp.dirs.local_cache, tmp_dir_sub_path,
29212921 comp.dirs.local_cache, o_sub_path,
......@@ -2982,7 +2982,7 @@ pub fn appendFileSystemInput(comp: *Compilation, path: Compilation.Path) Allocat
29822982 break @intCast(i);
29832983 }
29842984 } else std.debug.panic(
2985 "missing prefix directory '{s}' ('{}') for '{s}'",
2985 "missing prefix directory '{s}' ('{f}') for '{s}'",
29862986 .{ @tagName(path.root), want_prefix_dir, path.sub_path },
29872987 );
29882988
......@@ -3321,7 +3321,7 @@ fn emitFromCObject(
33213321 emit_path.root_dir.handle,
33223322 emit_path.sub_path,
33233323 .{},
3324 ) catch |err| log.err("unable to copy '{}' to '{}': {s}", .{
3324 ) catch |err| log.err("unable to copy '{f}' to '{f}': {s}", .{
33253325 src_path,
33263326 emit_path,
33273327 @errorName(err),
......@@ -3669,7 +3669,7 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle {
36693669 .illegal_zig_import => try bundle.addString("this compiler implementation does not allow importing files from this directory"),
36703670 },
36713671 .src_loc = try bundle.addSourceLocation(.{
3672 .src_path = try bundle.printString("{}", .{file.path.fmt(comp)}),
3672 .src_path = try bundle.printString("{f}", .{file.path.fmt(comp)}),
36733673 .span_start = start,
36743674 .span_main = start,
36753675 .span_end = @intCast(end),
......@@ -3716,7 +3716,7 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle {
37163716 assert(!is_retryable);
37173717 // AstGen/ZoirGen succeeded with errors. Note that this may include AST errors.
37183718 _ = try file.getTree(zcu); // Tree must be loaded.
3719 const path = try std.fmt.allocPrint(gpa, "{}", .{file.path.fmt(comp)});
3719 const path = try std.fmt.allocPrint(gpa, "{f}", .{file.path.fmt(comp)});
37203720 defer gpa.free(path);
37213721 if (file.zir != null) {
37223722 try bundle.addZirErrorMessages(file.zir.?, file.tree.?, file.source.?, path);
......@@ -3771,9 +3771,8 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle {
37713771 if (!refs.contains(anal_unit)) continue;
37723772 }
37733773
3774 std.log.scoped(.zcu).debug("analysis error '{s}' reported from unit '{}'", .{
3775 error_msg.msg,
3776 zcu.fmtAnalUnit(anal_unit),
3774 std.log.scoped(.zcu).debug("analysis error '{s}' reported from unit '{f}'", .{
3775 error_msg.msg, zcu.fmtAnalUnit(anal_unit),
37773776 });
37783777
37793778 try addModuleErrorMsg(zcu, &bundle, error_msg.*, added_any_analysis_error);
......@@ -3933,9 +3932,9 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle {
39333932 // This is a compiler bug.
39343933 const stderr = std.fs.File.stderr().deprecatedWriter();
39353934 try stderr.writeAll("referenced transitive analysis errors, but none actually emitted\n");
3936 try stderr.print("{} [transitive failure]\n", .{zcu.fmtAnalUnit(failed_unit)});
3935 try stderr.print("{f} [transitive failure]\n", .{zcu.fmtAnalUnit(failed_unit)});
39373936 while (ref) |r| {
3938 try stderr.print("referenced by: {}{s}\n", .{
3937 try stderr.print("referenced by: {f}{s}\n", .{
39393938 zcu.fmtAnalUnit(r.referencer),
39403939 if (zcu.transitive_failed_analysis.contains(r.referencer)) " [transitive failure]" else "",
39413940 });
......@@ -4034,7 +4033,7 @@ pub fn addModuleErrorMsg(
40344033 const err_src_loc = module_err_msg.src_loc.upgrade(zcu);
40354034 const err_source = err_src_loc.file_scope.getSource(zcu) catch |err| {
40364035 try eb.addRootErrorMessage(.{
4037 .msg = try eb.printString("unable to load '{}': {s}", .{
4036 .msg = try eb.printString("unable to load '{f}': {s}", .{
40384037 err_src_loc.file_scope.path.fmt(zcu.comp), @errorName(err),
40394038 }),
40404039 });
......@@ -4097,7 +4096,7 @@ pub fn addModuleErrorMsg(
40974096 }
40984097
40994098 const src_loc = try eb.addSourceLocation(.{
4100 .src_path = try eb.printString("{}", .{err_src_loc.file_scope.path.fmt(zcu.comp)}),
4099 .src_path = try eb.printString("{f}", .{err_src_loc.file_scope.path.fmt(zcu.comp)}),
41014100 .span_start = err_span.start,
41024101 .span_main = err_span.main,
41034102 .span_end = err_span.end,
......@@ -4129,7 +4128,7 @@ pub fn addModuleErrorMsg(
41294128 const gop = try notes.getOrPutContext(gpa, .{
41304129 .msg = try eb.addString(module_note.msg),
41314130 .src_loc = try eb.addSourceLocation(.{
4132 .src_path = try eb.printString("{}", .{note_src_loc.file_scope.path.fmt(zcu.comp)}),
4131 .src_path = try eb.printString("{f}", .{note_src_loc.file_scope.path.fmt(zcu.comp)}),
41334132 .span_start = span.start,
41344133 .span_main = span.main,
41354134 .span_end = span.end,
......@@ -4174,7 +4173,7 @@ fn addReferenceTraceFrame(
41744173 try ref_traces.append(gpa, .{
41754174 .decl_name = try eb.printString("{s}{s}", .{ name, if (inlined) " [inlined]" else "" }),
41764175 .src_loc = try eb.addSourceLocation(.{
4177 .src_path = try eb.printString("{}", .{src.file_scope.path.fmt(zcu.comp)}),
4176 .src_path = try eb.printString("{f}", .{src.file_scope.path.fmt(zcu.comp)}),
41784177 .span_start = span.start,
41794178 .span_main = span.main,
41804179 .span_end = span.end,
......@@ -4835,7 +4834,7 @@ fn docsCopyFallible(comp: *Compilation) anyerror!void {
48354834 var out_dir = docs_path.root_dir.handle.makeOpenPath(docs_path.sub_path, .{}) catch |err| {
48364835 return comp.lockAndSetMiscFailure(
48374836 .docs_copy,
4838 "unable to create output directory '{}': {s}",
4837 "unable to create output directory '{f}': {s}",
48394838 .{ docs_path, @errorName(err) },
48404839 );
48414840 };
......@@ -4855,7 +4854,7 @@ fn docsCopyFallible(comp: *Compilation) anyerror!void {
48554854 var tar_file = out_dir.createFile("sources.tar", .{}) catch |err| {
48564855 return comp.lockAndSetMiscFailure(
48574856 .docs_copy,
4858 "unable to create '{}/sources.tar': {s}",
4857 "unable to create '{f}/sources.tar': {s}",
48594858 .{ docs_path, @errorName(err) },
48604859 );
48614860 };
......@@ -4884,7 +4883,7 @@ fn docsCopyModule(comp: *Compilation, module: *Package.Module, name: []const u8,
48844883 const root_dir, const sub_path = root.openInfo(comp.dirs);
48854884 break :d root_dir.openDir(sub_path, .{ .iterate = true });
48864885 } catch |err| {
4887 return comp.lockAndSetMiscFailure(.docs_copy, "unable to open directory '{}': {s}", .{
4886 return comp.lockAndSetMiscFailure(.docs_copy, "unable to open directory '{f}': {s}", .{
48884887 root.fmt(comp), @errorName(err),
48894888 });
48904889 };
......@@ -4906,13 +4905,13 @@ fn docsCopyModule(comp: *Compilation, module: *Package.Module, name: []const u8,
49064905 else => continue,
49074906 }
49084907 var file = mod_dir.openFile(entry.path, .{}) catch |err| {
4909 return comp.lockAndSetMiscFailure(.docs_copy, "unable to open '{}{s}': {s}", .{
4908 return comp.lockAndSetMiscFailure(.docs_copy, "unable to open '{f}{s}': {s}", .{
49104909 root.fmt(comp), entry.path, @errorName(err),
49114910 });
49124911 };
49134912 defer file.close();
49144913 archiver.writeFile(entry.path, file) catch |err| {
4915 return comp.lockAndSetMiscFailure(.docs_copy, "unable to archive '{}{s}': {s}", .{
4914 return comp.lockAndSetMiscFailure(.docs_copy, "unable to archive '{f}{s}': {s}", .{
49164915 root.fmt(comp), entry.path, @errorName(err),
49174916 });
49184917 };
......@@ -5042,7 +5041,7 @@ fn workerDocsWasmFallible(comp: *Compilation, prog_node: std.Progress.Node) anye
50425041 var out_dir = docs_path.root_dir.handle.makeOpenPath(docs_path.sub_path, .{}) catch |err| {
50435042 return comp.lockAndSetMiscFailure(
50445043 .docs_copy,
5045 "unable to create output directory '{}': {s}",
5044 "unable to create output directory '{f}': {s}",
50465045 .{ docs_path, @errorName(err) },
50475046 );
50485047 };
......@@ -5054,10 +5053,8 @@ fn workerDocsWasmFallible(comp: *Compilation, prog_node: std.Progress.Node) anye
50545053 "main.wasm",
50555054 .{},
50565055 ) catch |err| {
5057 return comp.lockAndSetMiscFailure(.docs_copy, "unable to copy '{}' to '{}': {s}", .{
5058 crt_file.full_object_path,
5059 docs_path,
5060 @errorName(err),
5056 return comp.lockAndSetMiscFailure(.docs_copy, "unable to copy '{f}' to '{f}': {s}", .{
5057 crt_file.full_object_path, docs_path, @errorName(err),
50615058 });
50625059 };
50635060}
......@@ -5130,7 +5127,7 @@ fn workerUpdateBuiltinFile(comp: *Compilation, file: *Zcu.File) void {
51305127 defer comp.mutex.unlock();
51315128 comp.setMiscFailure(
51325129 .write_builtin_zig,
5133 "unable to write '{}': {s}",
5130 "unable to write '{f}': {s}",
51345131 .{ file.path.fmt(comp), @errorName(err) },
51355132 );
51365133 };
......@@ -6033,7 +6030,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
60336030 // 24 is RT_MANIFEST
60346031 const resource_type = 24;
60356032
6036 const input = try std.fmt.allocPrint(arena, "{} {} \"{f}\"", .{
6033 const input = try std.fmt.allocPrint(arena, "{d} {d} \"{f}\"", .{
60376034 resource_id, resource_type, fmtRcEscape(src_path),
60386035 });
60396036
src/IncrementalDebugServer.zig+4-4
......@@ -142,8 +142,8 @@ fn handleCommand(zcu: *Zcu, output: *std.ArrayListUnmanaged(u8), cmd_str: []cons
142142 const create_gen = zcu.incremental_debug_state.navs.get(nav_index) orelse return w.writeAll("unknown nav index");
143143 const nav = ip.getNav(nav_index);
144144 try w.print(
145 \\name: '{}'
146 \\fqn: '{}'
145 \\name: '{f}'
146 \\fqn: '{f}'
147147 \\status: {s}
148148 \\created on generation: {d}
149149 \\
......@@ -260,7 +260,7 @@ fn handleCommand(zcu: *Zcu, output: *std.ArrayListUnmanaged(u8), cmd_str: []cons
260260 const ip_index: InternPool.Index = @enumFromInt(parseIndex(arg_str) orelse return w.writeAll("malformed ip index"));
261261 const create_gen = zcu.incremental_debug_state.types.get(ip_index) orelse return w.writeAll("unknown type");
262262 try w.print(
263 \\name: '{}'
263 \\name: '{f}'
264264 \\created on generation: {d}
265265 \\
266266 , .{
......@@ -365,7 +365,7 @@ fn printType(ty: Type, zcu: *const Zcu, w: anytype) !void {
365365 .union_type,
366366 .enum_type,
367367 .opaque_type,
368 => try w.print("{}[{d}]", .{ ty.containerTypeName(ip).fmt(ip), @intFromEnum(ty.toIntern()) }),
368 => try w.print("{f}[{d}]", .{ ty.containerTypeName(ip).fmt(ip), @intFromEnum(ty.toIntern()) }),
369369
370370 else => unreachable,
371371 }
src/InternPool.zig+1-1
......@@ -11406,7 +11406,7 @@ pub fn dumpGenericInstancesFallible(ip: *const InternPool, allocator: Allocator)
1140611406 var it = instances.iterator();
1140711407 while (it.next()) |entry| {
1140811408 const generic_fn_owner_nav = ip.getNav(ip.funcDeclInfo(entry.key_ptr.*).owner_nav);
11409 try stderr_bw.print("{f} ({}): \n", .{ generic_fn_owner_nav.name.fmt(ip), entry.value_ptr.items.len });
11409 try stderr_bw.print("{f} ({f}): \n", .{ generic_fn_owner_nav.name.fmt(ip), entry.value_ptr.items.len });
1141011410 for (entry.value_ptr.items) |index| {
1141111411 const unwrapped_index = index.unwrap(ip);
1141211412 const func = ip.extraFuncInstance(unwrapped_index.tid, unwrapped_index.getExtra(ip), unwrapped_index.getData(ip));
src/Package/Fetch.zig+11-11
......@@ -369,7 +369,7 @@ pub fn run(f: *Fetch) RunError!void {
369369 if (!std.mem.startsWith(u8, pkg_root.sub_path, expected_prefix)) {
370370 return f.fail(
371371 f.location_tok,
372 try eb.printString("dependency path outside project: '{}'", .{pkg_root}),
372 try eb.printString("dependency path outside project: '{f}'", .{pkg_root}),
373373 );
374374 }
375375 }
......@@ -436,14 +436,14 @@ pub fn run(f: *Fetch) RunError!void {
436436 }
437437 if (f.job_queue.read_only) return f.fail(
438438 f.name_tok,
439 try eb.printString("package not found at '{}{s}'", .{
439 try eb.printString("package not found at '{f}{s}'", .{
440440 cache_root, pkg_sub_path,
441441 }),
442442 );
443443 },
444444 else => |e| {
445445 try eb.addRootErrorMessage(.{
446 .msg = try eb.printString("unable to open global package cache directory '{}{s}': {s}", .{
446 .msg = try eb.printString("unable to open global package cache directory '{f}{s}': {s}", .{
447447 cache_root, pkg_sub_path, @errorName(e),
448448 }),
449449 });
......@@ -620,7 +620,7 @@ pub fn computedPackageHash(f: *const Fetch) Package.Hash {
620620 const saturated_size = std.math.cast(u32, f.computed_hash.total_size) orelse std.math.maxInt(u32);
621621 if (f.manifest) |man| {
622622 var version_buffer: [32]u8 = undefined;
623 const version: []const u8 = std.fmt.bufPrint(&version_buffer, "{}", .{man.version}) catch &version_buffer;
623 const version: []const u8 = std.fmt.bufPrint(&version_buffer, "{f}", .{man.version}) catch &version_buffer;
624624 return .init(f.computed_hash.digest, man.name, version, man.id, saturated_size);
625625 }
626626 // In the future build.zig.zon fields will be added to allow overriding these values
......@@ -638,7 +638,7 @@ fn checkBuildFileExistence(f: *Fetch) RunError!void {
638638 error.FileNotFound => {},
639639 else => |e| {
640640 try eb.addRootErrorMessage(.{
641 .msg = try eb.printString("unable to access '{}{s}': {s}", .{
641 .msg = try eb.printString("unable to access '{f}{s}': {s}", .{
642642 f.package_root, Package.build_zig_basename, @errorName(e),
643643 }),
644644 });
......@@ -663,7 +663,7 @@ fn loadManifest(f: *Fetch, pkg_root: Cache.Path) RunError!void {
663663 else => |e| {
664664 const file_path = try pkg_root.join(arena, Manifest.basename);
665665 try eb.addRootErrorMessage(.{
666 .msg = try eb.printString("unable to load package manifest '{}': {s}", .{
666 .msg = try eb.printString("unable to load package manifest '{f}': {s}", .{
667667 file_path, @errorName(e),
668668 }),
669669 });
......@@ -675,7 +675,7 @@ fn loadManifest(f: *Fetch, pkg_root: Cache.Path) RunError!void {
675675 ast.* = try std.zig.Ast.parse(arena, manifest_bytes, .zon);
676676
677677 if (ast.errors.len > 0) {
678 const file_path = try std.fmt.allocPrint(arena, "{}" ++ fs.path.sep_str ++ Manifest.basename, .{pkg_root});
678 const file_path = try std.fmt.allocPrint(arena, "{f}" ++ fs.path.sep_str ++ Manifest.basename, .{pkg_root});
679679 try std.zig.putAstErrorsIntoBundle(arena, ast.*, file_path, eb);
680680 return error.FetchFailed;
681681 }
......@@ -688,7 +688,7 @@ fn loadManifest(f: *Fetch, pkg_root: Cache.Path) RunError!void {
688688 const manifest = &f.manifest.?;
689689
690690 if (manifest.errors.len > 0) {
691 const src_path = try eb.printString("{}" ++ fs.path.sep_str ++ "{s}", .{ pkg_root, Manifest.basename });
691 const src_path = try eb.printString("{f}" ++ fs.path.sep_str ++ "{s}", .{ pkg_root, Manifest.basename });
692692 try manifest.copyErrorsIntoBundle(ast.*, src_path, eb);
693693 return error.FetchFailed;
694694 }
......@@ -843,7 +843,7 @@ fn srcLoc(
843843 const ast = f.parent_manifest_ast orelse return .none;
844844 const eb = &f.error_bundle;
845845 const start_loc = ast.tokenLocation(0, tok);
846 const src_path = try eb.printString("{}" ++ fs.path.sep_str ++ Manifest.basename, .{f.parent_package_root});
846 const src_path = try eb.printString("{f}" ++ fs.path.sep_str ++ Manifest.basename, .{f.parent_package_root});
847847 const msg_off = 0;
848848 return eb.addSourceLocation(.{
849849 .src_path = src_path,
......@@ -977,7 +977,7 @@ fn initResource(f: *Fetch, uri: std.Uri, server_header_buffer: []u8) RunError!Re
977977 if (ascii.eqlIgnoreCase(uri.scheme, "file")) {
978978 const path = try uri.path.toRawMaybeAlloc(arena);
979979 return .{ .file = f.parent_package_root.openFile(path, .{}) catch |err| {
980 return f.fail(f.location_tok, try eb.printString("unable to open '{}{s}': {s}", .{
980 return f.fail(f.location_tok, try eb.printString("unable to open '{f}{s}': {s}", .{
981981 f.parent_package_root, path, @errorName(err),
982982 }));
983983 } };
......@@ -1524,7 +1524,7 @@ fn computeHash(f: *Fetch, pkg_path: Cache.Path, filter: Filter) RunError!Compute
15241524
15251525 while (walker.next() catch |err| {
15261526 try eb.addRootErrorMessage(.{ .msg = try eb.printString(
1527 "unable to walk temporary directory '{}': {s}",
1527 "unable to walk temporary directory '{f}': {s}",
15281528 .{ pkg_path, @errorName(err) },
15291529 ) });
15301530 return error.FetchFailed;
src/Sema.zig+29-34
......@@ -1144,7 +1144,7 @@ fn analyzeBodyInner(
11441144
11451145 // The hashmap lookup in here is a little expensive, and LLVM fails to optimize it away.
11461146 if (build_options.enable_logging) {
1147 std.log.scoped(.sema_zir).debug("sema ZIR {} %{d}", .{ path: {
1147 std.log.scoped(.sema_zir).debug("sema ZIR {f} %{d}", .{ path: {
11481148 const file_index = block.src_base_inst.resolveFile(&zcu.intern_pool);
11491149 const file = zcu.fileByIndex(file_index);
11501150 break :path file.path.fmt(zcu.comp);
......@@ -2763,7 +2763,7 @@ fn zirTupleDecl(
27632763 const coerced_field_init = try sema.coerce(block, field_type, uncoerced_field_init, init_src);
27642764 const field_init_val = try sema.resolveConstDefinedValue(block, init_src, coerced_field_init, .{ .simple = .tuple_field_default_value });
27652765 if (field_init_val.canMutateComptimeVarState(zcu)) {
2766 const field_name = try zcu.intern_pool.getOrPutStringFmt(gpa, pt.tid, "{}", .{field_index}, .no_embedded_nulls);
2766 const field_name = try zcu.intern_pool.getOrPutStringFmt(gpa, pt.tid, "{d}", .{field_index}, .no_embedded_nulls);
27672767 return sema.failWithContainsReferenceToComptimeVar(block, init_src, field_name, "field default value", field_init_val);
27682768 }
27692769 break :init field_init_val.toIntern();
......@@ -5574,9 +5574,8 @@ fn zirValidateDestructure(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp
55745574
55755575 if (operand_ty.arrayLen(zcu) != extra.expect_len) {
55765576 return sema.failWithOwnedErrorMsg(block, msg: {
5577 const msg = try sema.errMsg(src, "expected {} elements for destructure, found {}", .{
5578 extra.expect_len,
5579 operand_ty.arrayLen(zcu),
5577 const msg = try sema.errMsg(src, "expected {d} elements for destructure, found {d}", .{
5578 extra.expect_len, operand_ty.arrayLen(zcu),
55805579 });
55815580 errdefer msg.destroy(sema.gpa);
55825581 try sema.errNote(destructure_src, msg, "result destructured here", .{});
......@@ -14078,7 +14077,7 @@ fn zirShl(
1407814077 });
1407914078 }
1408014079 } else if (scalar_rhs_ty.isSignedInt(zcu)) {
14081 return sema.fail(block, rhs_src, "shift by signed type '{}'", .{rhs_ty.fmt(pt)});
14080 return sema.fail(block, rhs_src, "shift by signed type '{f}'", .{rhs_ty.fmt(pt)});
1408214081 }
1408314082
1408414083 const runtime_src = if (maybe_lhs_val) |lhs_val| rs: {
......@@ -14383,7 +14382,7 @@ fn zirBitNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
1438314382 const scalar_tag = scalar_ty.zigTypeTag(zcu);
1438414383
1438514384 if (scalar_tag != .int and scalar_tag != .bool)
14386 return sema.fail(block, operand_src, "bitwise not operation on type '{}'", .{operand_ty.fmt(pt)});
14385 return sema.fail(block, operand_src, "bitwise not operation on type '{f}'", .{operand_ty.fmt(pt)});
1438714386
1438814387 return analyzeBitNot(sema, block, operand, src);
1438914388}
......@@ -16999,7 +16998,7 @@ fn zirClosureGet(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDat
1699916998 const file, const src_base_node = Zcu.LazySrcLoc.resolveBaseNode(block.src_base_inst, zcu).?;
1700016999 const tree = file.getTree(zcu) catch |err| {
1700117000 // In this case we emit a warning + a less precise source location.
17002 log.warn("unable to load {}: {s}", .{
17001 log.warn("unable to load {f}: {s}", .{
1700317002 file.path.fmt(zcu.comp), @errorName(err),
1700417003 });
1700517004 break :name null;
......@@ -17027,7 +17026,7 @@ fn zirClosureGet(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDat
1702717026 const file, const src_base_node = Zcu.LazySrcLoc.resolveBaseNode(block.src_base_inst, zcu).?;
1702817027 const tree = file.getTree(zcu) catch |err| {
1702917028 // In this case we emit a warning + a less precise source location.
17030 log.warn("unable to load {}: {s}", .{
17029 log.warn("unable to load {f}: {s}", .{
1703117030 file.path.fmt(zcu.comp), @errorName(err),
1703217031 });
1703317032 break :name null;
......@@ -18268,7 +18267,7 @@ fn zirBoolNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1826818267 const uncasted_ty = sema.typeOf(uncasted_operand);
1826918268 if (uncasted_ty.isVector(zcu)) {
1827018269 if (uncasted_ty.scalarType(zcu).zigTypeTag(zcu) != .bool) {
18271 return sema.fail(block, operand_src, "boolean not operation on type '{}'", .{
18270 return sema.fail(block, operand_src, "boolean not operation on type '{f}'", .{
1827218271 uncasted_ty.fmt(pt),
1827318272 });
1827418273 }
......@@ -19299,13 +19298,13 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1929919298
1930019299 if (host_size != 0) {
1930119300 if (bit_offset >= host_size * 8) {
19302 return sema.fail(block, bitoffset_src, "packed type '{f}' at bit offset {} starts {} bits after the end of a {} byte host integer", .{
19301 return sema.fail(block, bitoffset_src, "packed type '{f}' at bit offset {d} starts {d} bits after the end of a {d} byte host integer", .{
1930319302 elem_ty.fmt(pt), bit_offset, bit_offset - host_size * 8, host_size,
1930419303 });
1930519304 }
1930619305 const elem_bit_size = try elem_ty.bitSizeSema(pt);
1930719306 if (elem_bit_size > host_size * 8 - bit_offset) {
19308 return sema.fail(block, bitoffset_src, "packed type '{f}' at bit offset {} ends {} bits after the end of a {} byte host integer", .{
19307 return sema.fail(block, bitoffset_src, "packed type '{f}' at bit offset {d} ends {d} bits after the end of a {d} byte host integer", .{
1930919308 elem_ty.fmt(pt), bit_offset, elem_bit_size - (host_size * 8 - bit_offset), host_size,
1931019309 });
1931119310 }
......@@ -20466,7 +20465,7 @@ fn zirIntFromBool(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
2046620465 const is_vector = operand_ty.zigTypeTag(zcu) == .vector;
2046720466 const operand_scalar_ty = operand_ty.scalarType(zcu);
2046820467 if (operand_scalar_ty.toIntern() != .bool_type) {
20469 return sema.fail(block, src, "expected 'bool', found '{}'", .{operand_scalar_ty.zigTypeTag(zcu)});
20468 return sema.fail(block, src, "expected 'bool', found '{s}'", .{operand_scalar_ty.zigTypeTag(zcu)});
2047020469 }
2047120470 const len = if (is_vector) operand_ty.vectorLen(zcu) else undefined;
2047220471 const dest_ty: Type = if (is_vector) try pt.vectorType(.{ .child = .u1_type, .len = len }) else .u1;
......@@ -20749,7 +20748,7 @@ fn zirReify(
2074920748 64 => .f64,
2075020749 80 => .f80,
2075120750 128 => .f128,
20752 else => return sema.fail(block, src, "{}-bit float unsupported", .{float.bits}),
20751 else => return sema.fail(block, src, "{d}-bit float unsupported", .{float.bits}),
2075320752 };
2075420753 return Air.internedToRef(ty.toIntern());
2075520754 },
......@@ -21640,7 +21639,7 @@ fn reifyTuple(
2164021639 return sema.fail(
2164121640 block,
2164221641 src,
21643 "tuple field name '{}' does not match field index {}",
21642 "tuple field name '{d}' does not match field index {d}",
2164421643 .{ field_name_index, field_idx },
2164521644 );
2164621645 }
......@@ -22658,7 +22657,7 @@ fn ptrCastFull(
2265822657
2265922658 if (src_info.packed_offset.host_size != dest_info.packed_offset.host_size) {
2266022659 return sema.failWithOwnedErrorMsg(block, msg: {
22661 const msg = try sema.errMsg(src, "pointer host size '{}' cannot coerce into pointer host size '{}'", .{
22660 const msg = try sema.errMsg(src, "pointer host size '{d}' cannot coerce into pointer host size '{d}'", .{
2266222661 src_info.packed_offset.host_size,
2266322662 dest_info.packed_offset.host_size,
2266422663 });
......@@ -22670,7 +22669,7 @@ fn ptrCastFull(
2267022669
2267122670 if (src_info.packed_offset.bit_offset != dest_info.packed_offset.bit_offset) {
2267222671 return sema.failWithOwnedErrorMsg(block, msg: {
22673 const msg = try sema.errMsg(src, "pointer bit offset '{}' cannot coerce into pointer bit offset '{}'", .{
22672 const msg = try sema.errMsg(src, "pointer bit offset '{d}' cannot coerce into pointer bit offset '{d}'", .{
2267422673 src_info.packed_offset.bit_offset,
2267522674 dest_info.packed_offset.bit_offset,
2267622675 });
......@@ -23240,7 +23239,7 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
2324023239 return sema.fail(
2324123240 block,
2324223241 operand_src,
23243 "@byteSwap requires the number of bits to be evenly divisible by 8, but {f} has {} bits",
23242 "@byteSwap requires the number of bits to be evenly divisible by 8, but {f} has {d} bits",
2324423243 .{ scalar_ty.fmt(pt), bits },
2324523244 );
2324623245 }
......@@ -23577,7 +23576,7 @@ fn checkNumericType(
2357723576 .comptime_float, .float, .comptime_int, .int => {},
2357823577 .vector => switch (ty.childType(zcu).zigTypeTag(zcu)) {
2357923578 .comptime_float, .float, .comptime_int, .int => {},
23580 else => |t| return sema.fail(block, ty_src, "expected number, found '{}'", .{t}),
23579 else => |t| return sema.fail(block, ty_src, "expected number, found '{s}'", .{t}),
2358123580 },
2358223581 else => return sema.fail(block, ty_src, "expected number, found '{f}'", .{ty.fmt(pt)}),
2358323582 }
......@@ -24254,7 +24253,7 @@ fn analyzeShuffle(
2425424253 if (idx >= b_len) return sema.failWithOwnedErrorMsg(block, msg: {
2425524254 const msg = try sema.errMsg(mask_src, "mask element at index '{d}' selects out-of-bounds index", .{mask_idx});
2425624255 errdefer msg.destroy(sema.gpa);
24257 try sema.errNote(b_src, msg, "index '{d}' exceeds bounds of '{}' given here", .{ idx, b_ty.fmt(pt) });
24256 try sema.errNote(b_src, msg, "index '{d}' exceeds bounds of '{f}' given here", .{ idx, b_ty.fmt(pt) });
2425824257 break :msg msg;
2425924258 });
2426024259 }
......@@ -25039,7 +25038,7 @@ fn analyzeMinMax(
2503925038 try sema.checkNumericType(block, operand_src, operand_ty);
2504025039 if (operand_ty.zigTypeTag(zcu) != .vector) {
2504125040 return sema.failWithOwnedErrorMsg(block, msg: {
25042 const msg = try sema.errMsg(operand_src, "expected vector, found '{}'", .{operand_ty.fmt(pt)});
25041 const msg = try sema.errMsg(operand_src, "expected vector, found '{f}'", .{operand_ty.fmt(pt)});
2504325042 errdefer msg.destroy(zcu.gpa);
2504425043 try sema.errNote(operand_srcs[0], msg, "vector operand here", .{});
2504525044 break :msg msg;
......@@ -25047,7 +25046,7 @@ fn analyzeMinMax(
2504725046 }
2504825047 if (operand_ty.vectorLen(zcu) != vec_len) {
2504925048 return sema.failWithOwnedErrorMsg(block, msg: {
25050 const msg = try sema.errMsg(operand_src, "expected vector of length '{d}', found '{}'", .{ vec_len, operand_ty.fmt(pt) });
25049 const msg = try sema.errMsg(operand_src, "expected vector of length '{d}', found '{f}'", .{ vec_len, operand_ty.fmt(pt) });
2505125050 errdefer msg.destroy(zcu.gpa);
2505225051 try sema.errNote(operand_srcs[0], msg, "vector of length '{d}' here", .{vec_len});
2505325052 break :msg msg;
......@@ -25060,7 +25059,7 @@ fn analyzeMinMax(
2506025059 const operand_ty = sema.typeOf(operand);
2506125060 if (operand_ty.zigTypeTag(zcu) == .vector) {
2506225061 return sema.failWithOwnedErrorMsg(block, msg: {
25063 const msg = try sema.errMsg(operand_srcs[0], "expected vector, found '{}'", .{first_operand_ty.fmt(pt)});
25062 const msg = try sema.errMsg(operand_srcs[0], "expected vector, found '{f}'", .{first_operand_ty.fmt(pt)});
2506425063 errdefer msg.destroy(zcu.gpa);
2506525064 try sema.errNote(operand_src, msg, "vector operand here", .{});
2506625065 break :msg msg;
......@@ -29163,7 +29162,7 @@ fn coerceExtra(
2916329162 // return sema.fail(
2916429163 // block,
2916529164 // inst_src,
29166 // "type '{f}' cannot represent integer value '{}'",
29165 // "type '{f}' cannot represent integer value '{f}'",
2916729166 // .{ dest_ty.fmt(pt), val },
2916829167 // );
2916929168 //}
......@@ -29370,7 +29369,7 @@ fn coerceExtra(
2937029369 try sema.errNote(param_src, msg, "parameter type declared here", .{});
2937129370 }
2937229371
29373 // TODO maybe add "cannot store an error in type '{}'" note
29372 // TODO maybe add "cannot store an error in type '{f}'" note
2937429373
2937529374 break :msg msg;
2937629375 };
......@@ -29718,12 +29717,12 @@ const InMemoryCoercionResult = union(enum) {
2971829717 },
2971929718 .ptr_bit_range => |bit_range| {
2972029719 if (bit_range.actual_host != bit_range.wanted_host) {
29721 try sema.errNote(src, msg, "pointer host size '{}' cannot cast into pointer host size '{}'", .{
29720 try sema.errNote(src, msg, "pointer host size '{d}' cannot cast into pointer host size '{d}'", .{
2972229721 bit_range.actual_host, bit_range.wanted_host,
2972329722 });
2972429723 }
2972529724 if (bit_range.actual_offset != bit_range.wanted_offset) {
29726 try sema.errNote(src, msg, "pointer bit offset '{}' cannot cast into pointer bit offset '{}'", .{
29725 try sema.errNote(src, msg, "pointer bit offset '{d}' cannot cast into pointer bit offset '{d}'", .{
2972729726 bit_range.actual_offset, bit_range.wanted_offset,
2972829727 });
2972929728 }
......@@ -34840,7 +34839,7 @@ fn checkBackingIntType(sema: *Sema, block: *Block, src: LazySrcLoc, backing_int_
3484034839 return sema.fail(
3484134840 block,
3484234841 src,
34843 "backing integer type '{f}' has bit size {} but the struct fields have a total bit size of {}",
34842 "backing integer type '{f}' has bit size {d} but the struct fields have a total bit size of {d}",
3484434843 .{ backing_int_ty.fmt(pt), backing_int_ty.bitSize(zcu), fields_bit_sum },
3484534844 );
3484634845 }
......@@ -35183,11 +35182,7 @@ pub fn resolveUnionFieldTypes(sema: *Sema, ty: Type, union_type: InternPool.Load
3518335182 switch (union_type.flagsUnordered(ip).status) {
3518435183 .none => {},
3518535184 .field_types_wip => {
35186 const msg = try sema.errMsg(
35187 ty.srcLoc(zcu),
35188 "union '{f}' depends on itself",
35189 .{ty.fmt(pt)},
35190 );
35185 const msg = try sema.errMsg(ty.srcLoc(zcu), "union '{f}' depends on itself", .{ty.fmt(pt)});
3519135186 return sema.failWithOwnedErrorMsg(null, msg);
3519235187 },
3519335188 .have_field_types,
......@@ -37194,7 +37189,7 @@ fn notePathToComptimeAllocPtr(sema: *Sema, msg: *Zcu.ErrorMsg, src: LazySrcLoc,
3719437189 if (intermediate_value_count == 0) {
3719537190 try first_path.print(arena, "{fi}", .{start_value_name.fmt(ip)});
3719637191 } else {
37197 try first_path.print(arena, "v{}", .{intermediate_value_count - 1});
37192 try first_path.print(arena, "v{d}", .{intermediate_value_count - 1});
3719837193 }
3719937194
3720037195 const comptime_ptr = try sema.notePathToComptimeAllocPtrInner(val, &first_path);
src/Sema/LowerZon.zig+2-2
......@@ -513,7 +513,7 @@ fn lowerInt(
513513 switch (big_int.setFloat(val, .trunc)) {
514514 .inexact => return self.fail(
515515 node,
516 "fractional component prevents float value '{}' from coercion to type '{f}'",
516 "fractional component prevents float value '{d}' from coercion to type '{f}'",
517517 .{ val, res_ty.fmt(self.sema.pt) },
518518 ),
519519 .exact => {},
......@@ -524,7 +524,7 @@ fn lowerInt(
524524 if (!big_int.toConst().fitsInTwosComp(int_info.signedness, int_info.bits)) {
525525 return self.fail(
526526 node,
527 "type '{f}' cannot represent integer value '{}'",
527 "type '{f}' cannot represent integer value '{d}'",
528528 .{ res_ty.fmt(self.sema.pt), val },
529529 );
530530 }
src/Type.zig+10-10
......@@ -175,8 +175,8 @@ pub fn print(ty: Type, writer: *std.io.Writer, pt: Zcu.PerThread) std.io.Writer.
175175
176176 if (info.sentinel != .none) switch (info.flags.size) {
177177 .one, .c => unreachable,
178 .many => try writer.print("[*:{}]", .{Value.fromInterned(info.sentinel).fmtValue(pt)}),
179 .slice => try writer.print("[:{}]", .{Value.fromInterned(info.sentinel).fmtValue(pt)}),
178 .many => try writer.print("[*:{f}]", .{Value.fromInterned(info.sentinel).fmtValue(pt)}),
179 .slice => try writer.print("[:{f}]", .{Value.fromInterned(info.sentinel).fmtValue(pt)}),
180180 } else switch (info.flags.size) {
181181 .one => try writer.writeAll("*"),
182182 .many => try writer.writeAll("[*]"),
......@@ -220,7 +220,7 @@ pub fn print(ty: Type, writer: *std.io.Writer, pt: Zcu.PerThread) std.io.Writer.
220220 try writer.print("[{d}]", .{array_type.len});
221221 try print(Type.fromInterned(array_type.child), writer, pt);
222222 } else {
223 try writer.print("[{d}:{}]", .{
223 try writer.print("[{d}:{f}]", .{
224224 array_type.len,
225225 Value.fromInterned(array_type.sentinel).fmtValue(pt),
226226 });
......@@ -250,7 +250,7 @@ pub fn print(ty: Type, writer: *std.io.Writer, pt: Zcu.PerThread) std.io.Writer.
250250 },
251251 .inferred_error_set_type => |func_index| {
252252 const func_nav = ip.getNav(zcu.funcInfo(func_index).owner_nav);
253 try writer.print("@typeInfo(@typeInfo(@TypeOf({})).@\"fn\".return_type.?).error_union.error_set", .{
253 try writer.print("@typeInfo(@typeInfo(@TypeOf({f})).@\"fn\".return_type.?).error_union.error_set", .{
254254 func_nav.fqn.fmt(ip),
255255 });
256256 },
......@@ -259,7 +259,7 @@ pub fn print(ty: Type, writer: *std.io.Writer, pt: Zcu.PerThread) std.io.Writer.
259259 try writer.writeAll("error{");
260260 for (names.get(ip), 0..) |name, i| {
261261 if (i != 0) try writer.writeByte(',');
262 try writer.print("{}", .{name.fmt(ip)});
262 try writer.print("{f}", .{name.fmt(ip)});
263263 }
264264 try writer.writeAll("}");
265265 },
......@@ -302,7 +302,7 @@ pub fn print(ty: Type, writer: *std.io.Writer, pt: Zcu.PerThread) std.io.Writer.
302302 },
303303 .struct_type => {
304304 const name = ip.loadStructType(ty.toIntern()).name;
305 try writer.print("{}", .{name.fmt(ip)});
305 try writer.print("{f}", .{name.fmt(ip)});
306306 },
307307 .tuple_type => |tuple| {
308308 if (tuple.types.len == 0) {
......@@ -313,22 +313,22 @@ pub fn print(ty: Type, writer: *std.io.Writer, pt: Zcu.PerThread) std.io.Writer.
313313 try writer.writeAll(if (i == 0) " " else ", ");
314314 if (val != .none) try writer.writeAll("comptime ");
315315 try print(Type.fromInterned(field_ty), writer, pt);
316 if (val != .none) try writer.print(" = {}", .{Value.fromInterned(val).fmtValue(pt)});
316 if (val != .none) try writer.print(" = {f}", .{Value.fromInterned(val).fmtValue(pt)});
317317 }
318318 try writer.writeAll(" }");
319319 },
320320
321321 .union_type => {
322322 const name = ip.loadUnionType(ty.toIntern()).name;
323 try writer.print("{}", .{name.fmt(ip)});
323 try writer.print("{f}", .{name.fmt(ip)});
324324 },
325325 .opaque_type => {
326326 const name = ip.loadOpaqueType(ty.toIntern()).name;
327 try writer.print("{}", .{name.fmt(ip)});
327 try writer.print("{f}", .{name.fmt(ip)});
328328 },
329329 .enum_type => {
330330 const name = ip.loadEnumType(ty.toIntern()).name;
331 try writer.print("{}", .{name.fmt(ip)});
331 try writer.print("{f}", .{name.fmt(ip)});
332332 },
333333 .func_type => |fn_info| {
334334 if (fn_info.is_noinline) {
src/Zcu.zig+17-17
......@@ -1112,7 +1112,7 @@ pub const File = struct {
11121112 eb: *std.zig.ErrorBundle.Wip,
11131113 ) !std.zig.ErrorBundle.SourceLocationIndex {
11141114 return eb.addSourceLocation(.{
1115 .src_path = try eb.printString("{}", .{file.path.fmt(zcu.comp)}),
1115 .src_path = try eb.printString("{f}", .{file.path.fmt(zcu.comp)}),
11161116 .span_start = 0,
11171117 .span_main = 0,
11181118 .span_end = 0,
......@@ -1133,7 +1133,7 @@ pub const File = struct {
11331133 const end = start + tree.tokenSlice(tok).len;
11341134 const loc = std.zig.findLineColumn(source.bytes, start);
11351135 return eb.addSourceLocation(.{
1136 .src_path = try eb.printString("{}", .{file.path.fmt(zcu.comp)}),
1136 .src_path = try eb.printString("{f}", .{file.path.fmt(zcu.comp)}),
11371137 .span_start = start,
11381138 .span_main = start,
11391139 .span_end = @intCast(end),
......@@ -4238,17 +4238,17 @@ fn formatAnalUnit(data: FormatAnalUnit, writer: *std.io.Writer) std.io.Writer.Er
42384238 const cu = ip.getComptimeUnit(cu_id);
42394239 if (cu.zir_index.resolveFull(ip)) |resolved| {
42404240 const file_path = zcu.fileByIndex(resolved.file).path;
4241 return writer.print("comptime(inst=('{}', %{}) [{}])", .{ file_path.fmt(zcu.comp), @intFromEnum(resolved.inst), @intFromEnum(cu_id) });
4241 return writer.print("comptime(inst=('{f}', %{}) [{}])", .{ file_path.fmt(zcu.comp), @intFromEnum(resolved.inst), @intFromEnum(cu_id) });
42424242 } else {
42434243 return writer.print("comptime(inst=<lost> [{}])", .{@intFromEnum(cu_id)});
42444244 }
42454245 },
4246 .nav_val => |nav| return writer.print("nav_val('{}' [{}])", .{ ip.getNav(nav).fqn.fmt(ip), @intFromEnum(nav) }),
4247 .nav_ty => |nav| return writer.print("nav_ty('{}' [{}])", .{ ip.getNav(nav).fqn.fmt(ip), @intFromEnum(nav) }),
4248 .type => |ty| return writer.print("ty('{}' [{}])", .{ Type.fromInterned(ty).containerTypeName(ip).fmt(ip), @intFromEnum(ty) }),
4246 .nav_val => |nav| return writer.print("nav_val('{f}' [{}])", .{ ip.getNav(nav).fqn.fmt(ip), @intFromEnum(nav) }),
4247 .nav_ty => |nav| return writer.print("nav_ty('{f}' [{}])", .{ ip.getNav(nav).fqn.fmt(ip), @intFromEnum(nav) }),
4248 .type => |ty| return writer.print("ty('{f}' [{}])", .{ Type.fromInterned(ty).containerTypeName(ip).fmt(ip), @intFromEnum(ty) }),
42494249 .func => |func| {
42504250 const nav = zcu.funcInfo(func).owner_nav;
4251 return writer.print("func('{}' [{}])", .{ ip.getNav(nav).fqn.fmt(ip), @intFromEnum(func) });
4251 return writer.print("func('{f}' [{}])", .{ ip.getNav(nav).fqn.fmt(ip), @intFromEnum(func) });
42524252 },
42534253 .memoized_state => return writer.writeAll("memoized_state"),
42544254 }
......@@ -4265,42 +4265,42 @@ fn formatDependee(data: FormatDependee, writer: *std.io.Writer) std.io.Writer.Er
42654265 return writer.writeAll("inst(<lost>)");
42664266 };
42674267 const file_path = zcu.fileByIndex(info.file).path;
4268 return writer.print("inst('{}', %{d})", .{ file_path.fmt(zcu.comp), @intFromEnum(info.inst) });
4268 return writer.print("inst('{f}', %{d})", .{ file_path.fmt(zcu.comp), @intFromEnum(info.inst) });
42694269 },
42704270 .nav_val => |nav| {
42714271 const fqn = ip.getNav(nav).fqn;
4272 return writer.print("nav_val('{}')", .{fqn.fmt(ip)});
4272 return writer.print("nav_val('{f}')", .{fqn.fmt(ip)});
42734273 },
42744274 .nav_ty => |nav| {
42754275 const fqn = ip.getNav(nav).fqn;
4276 return writer.print("nav_ty('{}')", .{fqn.fmt(ip)});
4276 return writer.print("nav_ty('{f}')", .{fqn.fmt(ip)});
42774277 },
42784278 .interned => |ip_index| switch (ip.indexToKey(ip_index)) {
4279 .struct_type, .union_type, .enum_type => return writer.print("type('{}')", .{Type.fromInterned(ip_index).containerTypeName(ip).fmt(ip)}),
4280 .func => |f| return writer.print("ies('{}')", .{ip.getNav(f.owner_nav).fqn.fmt(ip)}),
4279 .struct_type, .union_type, .enum_type => return writer.print("type('{f}')", .{Type.fromInterned(ip_index).containerTypeName(ip).fmt(ip)}),
4280 .func => |f| return writer.print("ies('{f}')", .{ip.getNav(f.owner_nav).fqn.fmt(ip)}),
42814281 else => unreachable,
42824282 },
42834283 .zon_file => |file| {
42844284 const file_path = zcu.fileByIndex(file).path;
4285 return writer.print("zon_file('{}')", .{file_path.fmt(zcu.comp)});
4285 return writer.print("zon_file('{f}')", .{file_path.fmt(zcu.comp)});
42864286 },
42874287 .embed_file => |ef_idx| {
42884288 const ef = ef_idx.get(zcu);
4289 return writer.print("embed_file('{}')", .{ef.path.fmt(zcu.comp)});
4289 return writer.print("embed_file('{f}')", .{ef.path.fmt(zcu.comp)});
42904290 },
42914291 .namespace => |ti| {
42924292 const info = ti.resolveFull(ip) orelse {
42934293 return writer.writeAll("namespace(<lost>)");
42944294 };
42954295 const file_path = zcu.fileByIndex(info.file).path;
4296 return writer.print("namespace('{}', %{d})", .{ file_path.fmt(zcu.comp), @intFromEnum(info.inst) });
4296 return writer.print("namespace('{f}', %{d})", .{ file_path.fmt(zcu.comp), @intFromEnum(info.inst) });
42974297 },
42984298 .namespace_name => |k| {
42994299 const info = k.namespace.resolveFull(ip) orelse {
4300 return writer.print("namespace(<lost>, '{}')", .{k.name.fmt(ip)});
4300 return writer.print("namespace(<lost>, '{f}')", .{k.name.fmt(ip)});
43014301 };
43024302 const file_path = zcu.fileByIndex(info.file).path;
4303 return writer.print("namespace('{}', %{d}, '{}')", .{ file_path.fmt(zcu.comp), @intFromEnum(info.inst), k.name.fmt(ip) });
4303 return writer.print("namespace('{f}', %{d}, '{f}')", .{ file_path.fmt(zcu.comp), @intFromEnum(info.inst), k.name.fmt(ip) });
43044304 },
43054305 .memoized_state => return writer.writeAll("memoized_state"),
43064306 }
src/Zcu/PerThread.zig+9-9
......@@ -53,7 +53,7 @@ fn deinitFile(pt: Zcu.PerThread, file_index: Zcu.File.Index) void {
5353 const zcu = pt.zcu;
5454 const gpa = zcu.gpa;
5555 const file = zcu.fileByIndex(file_index);
56 log.debug("deinit File {}", .{file.path.fmt(zcu.comp)});
56 log.debug("deinit File {f}", .{file.path.fmt(zcu.comp)});
5757 file.path.deinit(gpa);
5858 file.unload(gpa);
5959 if (file.prev_zir) |prev_zir| {
......@@ -117,7 +117,7 @@ pub fn updateFile(
117117 var lock: std.fs.File.Lock = switch (file.status) {
118118 .never_loaded, .retryable_failure => lock: {
119119 // First, load the cached ZIR code, if any.
120 log.debug("AstGen checking cache: {} (local={}, digest={s})", .{
120 log.debug("AstGen checking cache: {f} (local={}, digest={s})", .{
121121 file.path.fmt(comp), want_local_cache, &hex_digest,
122122 });
123123
......@@ -130,11 +130,11 @@ pub fn updateFile(
130130 stat.inode == file.stat.inode;
131131
132132 if (unchanged_metadata) {
133 log.debug("unmodified metadata of file: {}", .{file.path.fmt(comp)});
133 log.debug("unmodified metadata of file: {f}", .{file.path.fmt(comp)});
134134 return;
135135 }
136136
137 log.debug("metadata changed: {}", .{file.path.fmt(comp)});
137 log.debug("metadata changed: {f}", .{file.path.fmt(comp)});
138138
139139 break :lock .exclusive;
140140 },
......@@ -221,12 +221,12 @@ pub fn updateFile(
221221 };
222222 switch (result) {
223223 .success => {
224 log.debug("AstGen cached success: {}", .{file.path.fmt(comp)});
224 log.debug("AstGen cached success: {f}", .{file.path.fmt(comp)});
225225 break false;
226226 },
227227 .invalid => {},
228 .truncated => log.warn("unexpected EOF reading cached ZIR for {}", .{file.path.fmt(comp)}),
229 .stale => log.debug("AstGen cache stale: {}", .{file.path.fmt(comp)}),
228 .truncated => log.warn("unexpected EOF reading cached ZIR for {f}", .{file.path.fmt(comp)}),
229 .stale => log.debug("AstGen cache stale: {f}", .{file.path.fmt(comp)}),
230230 }
231231
232232 // If we already have the exclusive lock then it is our job to update.
......@@ -283,7 +283,7 @@ pub fn updateFile(
283283 },
284284 }
285285
286 log.debug("AstGen fresh success: {}", .{file.path.fmt(comp)});
286 log.debug("AstGen fresh success: {f}", .{file.path.fmt(comp)});
287287 }
288288
289289 file.stat = .{
......@@ -2303,7 +2303,7 @@ pub fn updateBuiltinModule(pt: Zcu.PerThread, opts: Builtin) Allocator.Error!voi
23032303
23042304 Builtin.updateFileOnDisk(file, comp) catch |err| comp.setMiscFailure(
23052305 .write_builtin_zig,
2306 "unable to write '{}': {s}",
2306 "unable to write '{f}': {s}",
23072307 .{ file.path.fmt(comp), @errorName(err) },
23082308 );
23092309}
src/arch/riscv64/CodeGen.zig+10-14
......@@ -566,13 +566,9 @@ const InstTracking = struct {
566566 }
567567 }
568568
569 pub fn format(
570 inst_tracking: InstTracking,
571 comptime _: []const u8,
572 _: std.fmt.FormatOptions,
573 writer: anytype,
574 ) @TypeOf(writer).Error!void {
575 if (!std.meta.eql(inst_tracking.long, inst_tracking.short)) try writer.print("|{f}| ", .{inst_tracking.long});
569 pub fn format(inst_tracking: InstTracking, writer: *std.io.Writer, comptime f: []const u8) std.io.Writer.Error!void {
570 comptime assert(f.len == 0);
571 if (!std.meta.eql(inst_tracking.long, inst_tracking.short)) try writer.print("|{}| ", .{inst_tracking.long});
576572 try writer.print("{}", .{inst_tracking.short});
577573 }
578574};
......@@ -973,7 +969,7 @@ fn formatWipMir(data: FormatWipMirData, writer: *std.io.Writer) std.io.Writer.Er
973969 else => |e| return e,
974970 }).insts) |lowered_inst| {
975971 if (!first) try writer.writeAll("\ndebug(wip_mir): ");
976 try writer.print(" | {f}", .{lowered_inst});
972 try writer.print(" | {}", .{lowered_inst});
977973 first = false;
978974 }
979975}
......@@ -1156,7 +1152,7 @@ fn gen(func: *Func) !void {
11561152 func.ret_mcv.long.address().offset(-func.ret_mcv.short.indirect.off),
11571153 );
11581154 func.ret_mcv.long = .{ .load_frame = .{ .index = frame_index } };
1159 tracking_log.debug("spill {f} to {f}", .{ func.ret_mcv.long, frame_index });
1155 tracking_log.debug("spill {} to {f}", .{ func.ret_mcv.long, frame_index });
11601156 },
11611157 else => unreachable,
11621158 }
......@@ -1656,7 +1652,7 @@ fn genBody(func: *Func, body: []const Air.Inst.Index) InnerError!void {
16561652
16571653 if (std.debug.runtime_safety) {
16581654 if (func.air_bookkeeping < old_air_bookkeeping + 1) {
1659 std.debug.panic("in codegen.zig, handling of AIR instruction %{d} ('{f}') did not do proper bookkeeping. Look for a missing call to finishAir.", .{ inst, air_tags[@intFromEnum(inst)] });
1655 std.debug.panic("in codegen.zig, handling of AIR instruction %{d} ('{}') did not do proper bookkeeping. Look for a missing call to finishAir.", .{ inst, air_tags[@intFromEnum(inst)] });
16601656 }
16611657
16621658 { // check consistency of tracked registers
......@@ -1668,7 +1664,7 @@ fn genBody(func: *Func, body: []const Air.Inst.Index) InnerError!void {
16681664 for (tracking.getRegs()) |reg| {
16691665 if (RegisterManager.indexOfRegIntoTracked(reg).? == index) break;
16701666 } else return std.debug.panic(
1671 \\%{} takes up these regs: {any}, however this regs {any}, don't use it
1667 \\%{f} takes up these regs: {any}, however this regs {any}, don't use it
16721668 , .{ tracked_inst, tracking.getRegs(), RegisterManager.regAtTrackedIndex(@intCast(index)) });
16731669 }
16741670 }
......@@ -1726,7 +1722,7 @@ fn finishAirResult(func: *Func, inst: Air.Inst.Index, result: MCValue) void {
17261722 else => {},
17271723 }
17281724
1729 tracking_log.debug("%{d} => {f} (birth)", .{ inst, result });
1725 tracking_log.debug("%{d} => {} (birth)", .{ inst, result });
17301726 func.inst_tracking.putAssumeCapacityNoClobber(inst, InstTracking.init(result));
17311727 // In some cases, an operand may be reused as the result.
17321728 // If that operand died and was a register, it was freed by
......@@ -1827,7 +1823,7 @@ fn computeFrameLayout(func: *Func) !FrameLayout {
18271823 total_alloc_size + 64 + args_frame_size + spill_frame_size + call_frame_size,
18281824 @intCast(frame_align[@intFromEnum(FrameIndex.base_ptr)].toByteUnits().?),
18291825 );
1830 log.debug("frame size: {f}", .{acc_frame_size});
1826 log.debug("frame size: {d}", .{acc_frame_size});
18311827
18321828 // store the ra at total_size - 8, so it's the very first thing in the stack
18331829 // relative to the fp
......@@ -1888,7 +1884,7 @@ fn splitType(func: *Func, ty: Type) ![2]Type {
18881884 },
18891885 else => unreachable,
18901886 },
1891 else => return func.fail("TODO: splitType class {f}", .{class}),
1887 else => return func.fail("TODO: splitType class {}", .{class}),
18921888 };
18931889 } else if (parts[0].abiSize(zcu) + parts[1].abiSize(zcu) == ty.abiSize(zcu)) return parts;
18941890 return func.fail("TODO implement splitType for {f}", .{ty.fmt(func.pt)});
src/arch/riscv64/Mir.zig+1-6
......@@ -92,12 +92,7 @@ pub const Inst = struct {
9292 },
9393 };
9494
95 pub fn format(
96 inst: Inst,
97 comptime fmt: []const u8,
98 _: std.fmt.FormatOptions,
99 writer: anytype,
100 ) !void {
95 pub fn format(inst: Inst, writer: *std.io.Writer, comptime fmt: []const u8) std.io.Writer.Error!void {
10196 assert(fmt.len == 0);
10297 try writer.print("Tag: {s}, Data: {s}", .{ @tagName(inst.tag), @tagName(inst.data) });
10398 }
src/arch/riscv64/bits.zig+2-7
......@@ -256,19 +256,14 @@ pub const FrameIndex = enum(u32) {
256256 return @intFromEnum(fi) < named_count;
257257 }
258258
259 pub fn format(
260 fi: FrameIndex,
261 comptime fmt: []const u8,
262 options: std.fmt.FormatOptions,
263 writer: anytype,
264 ) @TypeOf(writer).Error!void {
259 pub fn format(fi: FrameIndex, writer: *std.io.Writer, comptime fmt: []const u8) std.io.Writer.Error!void {
265260 try writer.writeAll("FrameIndex");
266261 if (fi.isNamed()) {
267262 try writer.writeByte('.');
268263 try writer.writeAll(@tagName(fi));
269264 } else {
270265 try writer.writeByte('(');
271 try std.fmt.formatType(@intFromEnum(fi), fmt, options, writer, 0);
266 try writer.printInt(fmt, .{}, @intFromEnum(fi));
272267 try writer.writeByte(')');
273268 }
274269 }
src/arch/sparc64/CodeGen.zig+6-6
......@@ -723,7 +723,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
723723
724724 if (std.debug.runtime_safety) {
725725 if (self.air_bookkeeping < old_air_bookkeeping + 1) {
726 std.debug.panic("in codegen.zig, handling of AIR instruction %{d} ('{}') did not do proper bookkeeping. Look for a missing call to finishAir.", .{ inst, air_tags[@intFromEnum(inst)] });
726 std.debug.panic("in codegen.zig, handling of AIR instruction %{d} ('{s}') did not do proper bookkeeping. Look for a missing call to finishAir.", .{ inst, air_tags[@intFromEnum(inst)] });
727727 }
728728 }
729729 }
......@@ -1001,7 +1001,7 @@ fn airArg(self: *Self, inst: Air.Inst.Index) InnerError!void {
10011001 switch (self.args[arg_index]) {
10021002 .stack_offset => |off| {
10031003 const abi_size = math.cast(u32, ty.abiSize(zcu)) orelse {
1004 return self.fail("type '{}' too big to fit into stack frame", .{ty.fmt(pt)});
1004 return self.fail("type '{f}' too big to fit into stack frame", .{ty.fmt(pt)});
10051005 };
10061006 const offset = off + abi_size;
10071007 break :blk .{ .stack_offset = offset };
......@@ -2748,7 +2748,7 @@ fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !u32 {
27482748 }
27492749
27502750 const abi_size = math.cast(u32, elem_ty.abiSize(zcu)) orelse {
2751 return self.fail("type '{}' too big to fit into stack frame", .{elem_ty.fmt(pt)});
2751 return self.fail("type '{f}' too big to fit into stack frame", .{elem_ty.fmt(pt)});
27522752 };
27532753 // TODO swap this for inst.ty.ptrAlign
27542754 const abi_align = elem_ty.abiAlignment(zcu);
......@@ -2760,7 +2760,7 @@ fn allocRegOrMem(self: *Self, inst: Air.Inst.Index, reg_ok: bool) !MCValue {
27602760 const zcu = pt.zcu;
27612761 const elem_ty = self.typeOfIndex(inst);
27622762 const abi_size = math.cast(u32, elem_ty.abiSize(zcu)) orelse {
2763 return self.fail("type '{}' too big to fit into stack frame", .{elem_ty.fmt(pt)});
2763 return self.fail("type '{f}' too big to fit into stack frame", .{elem_ty.fmt(pt)});
27642764 };
27652765 const abi_align = elem_ty.abiAlignment(zcu);
27662766 self.stack_align = self.stack_align.max(abi_align);
......@@ -4111,7 +4111,7 @@ fn getResolvedInstValue(self: *Self, inst: Air.Inst.Index) MCValue {
41114111 while (true) {
41124112 i -= 1;
41134113 if (self.branch_stack.items[i].inst_table.get(inst)) |mcv| {
4114 log.debug("getResolvedInstValue %{} => {}", .{ inst, mcv });
4114 log.debug("getResolvedInstValue %{f} => {}", .{ inst, mcv });
41154115 assert(mcv != .dead);
41164116 return mcv;
41174117 }
......@@ -4382,7 +4382,7 @@ fn processDeath(self: *Self, inst: Air.Inst.Index) void {
43824382 const prev_value = self.getResolvedInstValue(inst);
43834383 const branch = &self.branch_stack.items[self.branch_stack.items.len - 1];
43844384 branch.inst_table.putAssumeCapacity(inst, .dead);
4385 log.debug("%{} death: {} -> .dead", .{ inst, prev_value });
4385 log.debug("%{f} death: {} -> .dead", .{ inst, prev_value });
43864386 switch (prev_value) {
43874387 .register => |reg| {
43884388 self.register_manager.freeReg(reg);
src/arch/wasm/CodeGen.zig+18-24
......@@ -1463,7 +1463,7 @@ fn allocStack(cg: *CodeGen, ty: Type) !WValue {
14631463 }
14641464
14651465 const abi_size = std.math.cast(u32, ty.abiSize(zcu)) orelse {
1466 return cg.fail("Type {} with ABI size of {d} exceeds stack frame size", .{
1466 return cg.fail("Type {f} with ABI size of {d} exceeds stack frame size", .{
14671467 ty.fmt(pt), ty.abiSize(zcu),
14681468 });
14691469 };
......@@ -1497,7 +1497,7 @@ fn allocStackPtr(cg: *CodeGen, inst: Air.Inst.Index) !WValue {
14971497
14981498 const abi_alignment = ptr_ty.ptrAlignment(zcu);
14991499 const abi_size = std.math.cast(u32, pointee_ty.abiSize(zcu)) orelse {
1500 return cg.fail("Type {} with ABI size of {d} exceeds stack frame size", .{
1500 return cg.fail("Type {f} with ABI size of {d} exceeds stack frame size", .{
15011501 pointee_ty.fmt(pt), pointee_ty.abiSize(zcu),
15021502 });
15031503 };
......@@ -2046,7 +2046,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
20462046 try cg.genInst(inst);
20472047
20482048 if (std.debug.runtime_safety and cg.air_bookkeeping < old_bookkeeping_value + 1) {
2049 std.debug.panic("Missing call to `finishAir` in AIR instruction %{d} ('{}')", .{
2049 std.debug.panic("Missing call to `finishAir` in AIR instruction %{d} ('{s}')", .{
20502050 inst,
20512051 cg.air.instructions.items(.tag)[@intFromEnum(inst)],
20522052 });
......@@ -2404,10 +2404,7 @@ fn store(cg: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, offset: u32) InnerErr
24042404 try cg.memcpy(lhs, rhs, .{ .imm32 = @as(u32, @intCast(ty.abiSize(zcu))) });
24052405 },
24062406 else => if (abi_size > 8) {
2407 return cg.fail("TODO: `store` for type `{}` with abisize `{d}`", .{
2408 ty.fmt(pt),
2409 abi_size,
2410 });
2407 return cg.fail("TODO: `store` for type `{f}` with abisize `{d}`", .{ ty.fmt(pt), abi_size });
24112408 },
24122409 }
24132410 try cg.emitWValue(lhs);
......@@ -2596,10 +2593,7 @@ fn binOp(cg: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: Op) InnerError!WV
25962593 if (ty.zigTypeTag(zcu) == .int) {
25972594 return cg.binOpBigInt(lhs, rhs, ty, op);
25982595 } else {
2599 return cg.fail(
2600 "TODO: Implement binary operation for type: {}",
2601 .{ty.fmt(pt)},
2602 );
2596 return cg.fail("TODO: Implement binary operation for type: {f}", .{ty.fmt(pt)});
26032597 }
26042598 }
26052599
......@@ -2817,7 +2811,7 @@ fn airAbs(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
28172811
28182812 switch (scalar_ty.zigTypeTag(zcu)) {
28192813 .int => if (ty.zigTypeTag(zcu) == .vector) {
2820 return cg.fail("TODO implement airAbs for {}", .{ty.fmt(pt)});
2814 return cg.fail("TODO implement airAbs for {f}", .{ty.fmt(pt)});
28212815 } else {
28222816 const int_bits = ty.intInfo(zcu).bits;
28232817 const wasm_bits = toWasmBits(int_bits) orelse {
......@@ -3244,7 +3238,7 @@ fn lowerConstant(cg: *CodeGen, val: Value, ty: Type) InnerError!WValue {
32443238 return .{ .imm32 = @intFromBool(!val.isNull(zcu)) };
32453239 },
32463240 .aggregate => switch (ip.indexToKey(ty.ip_index)) {
3247 .array_type => return cg.fail("Wasm TODO: LowerConstant for {}", .{ty.fmt(pt)}),
3241 .array_type => return cg.fail("Wasm TODO: LowerConstant for {f}", .{ty.fmt(pt)}),
32483242 .vector_type => {
32493243 assert(determineSimdStoreStrategy(ty, zcu, cg.target) == .direct);
32503244 var buf: [16]u8 = undefined;
......@@ -3332,7 +3326,7 @@ fn emitUndefined(cg: *CodeGen, ty: Type) InnerError!WValue {
33323326 },
33333327 else => unreachable,
33343328 },
3335 else => return cg.fail("Wasm TODO: emitUndefined for type: {}\n", .{ty.zigTypeTag(zcu)}),
3329 else => return cg.fail("Wasm TODO: emitUndefined for type: {s}\n", .{ty.zigTypeTag(zcu)}),
33363330 }
33373331}
33383332
......@@ -3608,7 +3602,7 @@ fn airNot(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
36083602 } else {
36093603 const int_info = operand_ty.intInfo(zcu);
36103604 const wasm_bits = toWasmBits(int_info.bits) orelse {
3611 return cg.fail("TODO: Implement binary NOT for {}", .{operand_ty.fmt(pt)});
3605 return cg.fail("TODO: Implement binary NOT for {f}", .{operand_ty.fmt(pt)});
36123606 };
36133607
36143608 switch (wasm_bits) {
......@@ -3874,7 +3868,7 @@ fn airStructFieldVal(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
38743868 },
38753869 else => result: {
38763870 const offset = std.math.cast(u32, struct_ty.structFieldOffset(field_index, zcu)) orelse {
3877 return cg.fail("Field type '{}' too big to fit into stack frame", .{field_ty.fmt(pt)});
3871 return cg.fail("Field type '{f}' too big to fit into stack frame", .{field_ty.fmt(pt)});
38783872 };
38793873 if (isByRef(field_ty, zcu, cg.target)) {
38803874 switch (operand) {
......@@ -4360,7 +4354,7 @@ fn isNull(cg: *CodeGen, operand: WValue, optional_ty: Type, opcode: std.wasm.Opc
43604354 // a pointer to the stack value
43614355 if (payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) {
43624356 const offset = std.math.cast(u32, payload_ty.abiSize(zcu)) orelse {
4363 return cg.fail("Optional type {} too big to fit into stack frame", .{optional_ty.fmt(pt)});
4357 return cg.fail("Optional type {f} too big to fit into stack frame", .{optional_ty.fmt(pt)});
43644358 };
43654359 try cg.addMemArg(.i32_load8_u, .{ .offset = operand.offset() + offset, .alignment = 1 });
43664360 }
......@@ -4430,7 +4424,7 @@ fn airOptionalPayloadPtrSet(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void
44304424 }
44314425
44324426 const offset = std.math.cast(u32, payload_ty.abiSize(zcu)) orelse {
4433 return cg.fail("Optional type {} too big to fit into stack frame", .{opt_ty.fmt(pt)});
4427 return cg.fail("Optional type {f} too big to fit into stack frame", .{opt_ty.fmt(pt)});
44344428 };
44354429
44364430 try cg.emitWValue(operand);
......@@ -4462,7 +4456,7 @@ fn airWrapOptional(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
44624456 break :result cg.reuseOperand(ty_op.operand, operand);
44634457 }
44644458 const offset = std.math.cast(u32, payload_ty.abiSize(zcu)) orelse {
4465 return cg.fail("Optional type {} too big to fit into stack frame", .{op_ty.fmt(pt)});
4459 return cg.fail("Optional type {f} too big to fit into stack frame", .{op_ty.fmt(pt)});
44664460 };
44674461
44684462 // Create optional type, set the non-null bit, and store the operand inside the optional type
......@@ -6196,7 +6190,7 @@ fn airMulWithOverflow(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
61966190 _ = try cg.load(overflow_ret, Type.i32, 0);
61976191 try cg.addLocal(.local_set, overflow_bit.local.value);
61986192 break :blk res;
6199 } else return cg.fail("TODO: @mulWithOverflow for {}", .{ty.fmt(pt)});
6193 } else return cg.fail("TODO: @mulWithOverflow for {f}", .{ty.fmt(pt)});
62006194 var bin_op_local = try mul.toLocal(cg, ty);
62016195 defer bin_op_local.free(cg);
62026196
......@@ -6749,7 +6743,7 @@ fn airMod(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
67496743 const add = try cg.binOp(rem, rhs, ty, .add);
67506744 break :result try cg.binOp(add, rhs, ty, .rem);
67516745 }
6752 return cg.fail("TODO: @mod for {}", .{ty.fmt(pt)});
6746 return cg.fail("TODO: @mod for {f}", .{ty.fmt(pt)});
67536747 };
67546748
67556749 return cg.finishAir(inst, result, &.{ bin_op.lhs, bin_op.rhs });
......@@ -6767,7 +6761,7 @@ fn airSatMul(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
67676761 const lhs = try cg.resolveInst(bin_op.lhs);
67686762 const rhs = try cg.resolveInst(bin_op.rhs);
67696763 const wasm_bits = toWasmBits(int_info.bits) orelse {
6770 return cg.fail("TODO: mul_sat for {}", .{ty.fmt(pt)});
6764 return cg.fail("TODO: mul_sat for {f}", .{ty.fmt(pt)});
67716765 };
67726766
67736767 switch (wasm_bits) {
......@@ -6804,7 +6798,7 @@ fn airSatMul(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
68046798 },
68056799 64 => {
68066800 if (!(int_info.bits == 64 and int_info.signedness == .signed)) {
6807 return cg.fail("TODO: mul_sat for {}", .{ty.fmt(pt)});
6801 return cg.fail("TODO: mul_sat for {f}", .{ty.fmt(pt)});
68086802 }
68096803 const overflow_ret = try cg.allocStack(Type.i32);
68106804 _ = try cg.callIntrinsic(
......@@ -6822,7 +6816,7 @@ fn airSatMul(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
68226816 },
68236817 128 => {
68246818 if (!(int_info.bits == 128 and int_info.signedness == .signed)) {
6825 return cg.fail("TODO: mul_sat for {}", .{ty.fmt(pt)});
6819 return cg.fail("TODO: mul_sat for {f}", .{ty.fmt(pt)});
68266820 }
68276821 const overflow_ret = try cg.allocStack(Type.i32);
68286822 const ret = try cg.callIntrinsic(
src/arch/x86_64/Encoding.zig+2-9
......@@ -158,15 +158,8 @@ pub fn modRmExt(encoding: Encoding) u3 {
158158 };
159159}
160160
161pub fn format(
162 encoding: Encoding,
163 comptime fmt: []const u8,
164 options: std.fmt.FormatOptions,
165 writer: anytype,
166) !void {
167 _ = options;
168 _ = fmt;
169
161pub fn format(encoding: Encoding, writer: *std.io.Writer, comptime fmt: []const u8) std.io.Writer.Error!void {
162 comptime assert(fmt.len == 0);
170163 var opc = encoding.opcode();
171164 if (encoding.data.mode.isVex()) {
172165 try writer.writeAll("VEX.");
src/arch/x86_64/bits.zig+6-19
......@@ -728,19 +728,14 @@ pub const FrameIndex = enum(u32) {
728728 return @intFromEnum(fi) < named_count;
729729 }
730730
731 pub fn format(
732 fi: FrameIndex,
733 comptime fmt: []const u8,
734 options: std.fmt.FormatOptions,
735 writer: anytype,
736 ) @TypeOf(writer).Error!void {
731 pub fn format(fi: FrameIndex, writer: *std.io.Writer, comptime fmt: []const u8) std.io.Writer.Error!void {
737732 try writer.writeAll("FrameIndex");
738733 if (fi.isNamed()) {
739734 try writer.writeByte('.');
740735 try writer.writeAll(@tagName(fi));
741736 } else {
742737 try writer.writeByte('(');
743 try std.fmt.formatType(@intFromEnum(fi), fmt, options, writer, 0);
738 try writer.printInt(fmt, .{}, @intFromEnum(fi));
744739 try writer.writeByte(')');
745740 }
746741 }
......@@ -844,12 +839,8 @@ pub const Memory = struct {
844839 };
845840 }
846841
847 pub fn format(
848 s: Size,
849 comptime _: []const u8,
850 _: std.fmt.FormatOptions,
851 writer: anytype,
852 ) @TypeOf(writer).Error!void {
842 pub fn format(s: Size, writer: *std.io.Writer, comptime f: []const u8) std.io.Writer.Error!void {
843 comptime assert(f.len == 0);
853844 if (s == .none) return;
854845 try writer.writeAll(@tagName(s));
855846 switch (s) {
......@@ -914,12 +905,8 @@ pub const Immediate = union(enum) {
914905 return .{ .signed = x };
915906 }
916907
917 pub fn format(
918 imm: Immediate,
919 comptime _: []const u8,
920 _: std.fmt.FormatOptions,
921 writer: anytype,
922 ) @TypeOf(writer).Error!void {
908 pub fn format(imm: Immediate, writer: *std.io.Writer, comptime f: []const u8) std.io.Writer.Error!void {
909 comptime assert(f.len == 0);
923910 switch (imm) {
924911 inline else => |int| try writer.print("{d}", .{int}),
925912 .nav => |nav_off| try writer.print("Nav({d}) + {d}", .{ @intFromEnum(nav_off.nav), nav_off.off }),
src/codegen.zig+6-6
......@@ -237,7 +237,7 @@ pub fn generateLazySymbol(
237237 const target = &comp.root_mod.resolved_target.result;
238238 const endian = target.cpu.arch.endian();
239239
240 log.debug("generateLazySymbol: kind = {s}, ty = {}", .{
240 log.debug("generateLazySymbol: kind = {s}, ty = {f}", .{
241241 @tagName(lazy_sym.kind),
242242 Type.fromInterned(lazy_sym.ty).fmt(pt),
243243 });
......@@ -277,7 +277,7 @@ pub fn generateLazySymbol(
277277 code.appendAssumeCapacity(0);
278278 }
279279 } else {
280 return zcu.codegenFailType(lazy_sym.ty, "TODO implement generateLazySymbol for {s} {}", .{
280 return zcu.codegenFailType(lazy_sym.ty, "TODO implement generateLazySymbol for {s} {f}", .{
281281 @tagName(lazy_sym.kind), Type.fromInterned(lazy_sym.ty).fmt(pt),
282282 });
283283 }
......@@ -310,7 +310,7 @@ pub fn generateSymbol(
310310 const target = zcu.getTarget();
311311 const endian = target.cpu.arch.endian();
312312
313 log.debug("generateSymbol: val = {}", .{val.fmtValue(pt)});
313 log.debug("generateSymbol: val = {f}", .{val.fmtValue(pt)});
314314
315315 if (val.isUndefDeep(zcu)) {
316316 const abi_size = math.cast(usize, ty.abiSize(zcu)) orelse return error.Overflow;
......@@ -767,7 +767,7 @@ fn lowerUavRef(
767767 const uav_ty = Type.fromInterned(ip.typeOf(uav_val));
768768 const is_fn_body = uav_ty.zigTypeTag(zcu) == .@"fn";
769769
770 log.debug("lowerUavRef: ty = {}", .{uav_ty.fmt(pt)});
770 log.debug("lowerUavRef: ty = {f}", .{uav_ty.fmt(pt)});
771771 try code.ensureUnusedCapacity(gpa, ptr_width_bytes);
772772
773773 if (!is_fn_body and !uav_ty.hasRuntimeBits(zcu)) {
......@@ -913,7 +913,7 @@ pub fn genNavRef(
913913 const zcu = pt.zcu;
914914 const ip = &zcu.intern_pool;
915915 const nav = ip.getNav(nav_index);
916 log.debug("genNavRef({})", .{nav.fqn.fmt(ip)});
916 log.debug("genNavRef({f})", .{nav.fqn.fmt(ip)});
917917
918918 const lib_name, const linkage, const is_threadlocal = if (nav.getExtern(ip)) |e|
919919 .{ e.lib_name, e.linkage, e.is_threadlocal and zcu.comp.config.any_non_single_threaded }
......@@ -1065,7 +1065,7 @@ pub fn lowerValue(pt: Zcu.PerThread, val: Value, target: *const std.Target) Allo
10651065 const ip = &zcu.intern_pool;
10661066 const ty = val.typeOf(zcu);
10671067
1068 log.debug("lowerValue(@as({}, {}))", .{ ty.fmt(pt), val.fmtValue(pt) });
1068 log.debug("lowerValue(@as({f}, {f}))", .{ ty.fmt(pt), val.fmtValue(pt) });
10691069
10701070 if (val.isUndef(zcu)) return .undef;
10711071
src/codegen/c.zig+2-10
......@@ -388,7 +388,7 @@ fn formatCTypePoolString(data: CTypePoolStringFormatData, w: *std.io.Writer) std
388388 if (data.ctype_pool_string.toSlice(data.ctype_pool)) |slice|
389389 try formatIdentOptions(slice, w, data.solo)
390390 else
391 try w.print("{}", .{data.ctype_pool_string.fmt(data.ctype_pool)});
391 try w.print("{f}", .{data.ctype_pool_string.fmt(data.ctype_pool)});
392392}
393393pub fn fmtCTypePoolString(
394394 ctype_pool_string: CType.Pool.String,
......@@ -2471,15 +2471,7 @@ const RenderCTypeTrailing = enum {
24712471 no_space,
24722472 maybe_space,
24732473
2474 pub fn format(
2475 self: @This(),
2476 comptime fmt: []const u8,
2477 _: std.fmt.FormatOptions,
2478 w: *Writer,
2479 ) @TypeOf(w).Error!void {
2480 if (fmt.len != 0)
2481 @compileError("invalid format string '" ++ fmt ++ "' for type '" ++
2482 @typeName(@This()) ++ "'");
2474 pub fn format(self: @This(), w: *Writer, comptime fmt: []const u8) Writer.Error!void {
24832475 comptime assert(fmt.len == 0);
24842476 switch (self) {
24852477 .no_space => {},
src/codegen/spirv.zig+4-4
......@@ -817,7 +817,7 @@ const NavGen = struct {
817817 const result_ty_id = try self.resolveType(ty, repr);
818818 const ip = &zcu.intern_pool;
819819
820 log.debug("lowering constant: ty = {}, val = {}, key = {s}", .{ ty.fmt(pt), val.fmtValue(pt), @tagName(ip.indexToKey(val.toIntern())) });
820 log.debug("lowering constant: ty = {f}, val = {f}, key = {s}", .{ ty.fmt(pt), val.fmtValue(pt), @tagName(ip.indexToKey(val.toIntern())) });
821821 if (val.isUndefDeep(zcu)) {
822822 return self.spv.constUndef(result_ty_id);
823823 }
......@@ -1147,7 +1147,7 @@ const NavGen = struct {
11471147 return result_ptr_id;
11481148 }
11491149
1150 return self.fail("cannot perform pointer cast: '{}' to '{}'", .{
1150 return self.fail("cannot perform pointer cast: '{f}' to '{f}'", .{
11511151 parent_ptr_ty.fmt(pt),
11521152 oac.new_ptr_ty.fmt(pt),
11531153 });
......@@ -1464,7 +1464,7 @@ const NavGen = struct {
14641464 const pt = self.pt;
14651465 const zcu = pt.zcu;
14661466 const ip = &zcu.intern_pool;
1467 log.debug("resolveType: ty = {}", .{ty.fmt(pt)});
1467 log.debug("resolveType: ty = {f}", .{ty.fmt(pt)});
14681468 const target = self.spv.target;
14691469
14701470 const section = &self.spv.sections.types_globals_constants;
......@@ -3070,7 +3070,7 @@ const NavGen = struct {
30703070 try self.func.body.emit(self.spv.gpa, .OpFunctionEnd, {});
30713071 try self.spv.addFunction(spv_decl_index, self.func);
30723072
3073 try self.spv.debugNameFmt(initializer_id, "initializer of {}", .{nav.fqn.fmt(ip)});
3073 try self.spv.debugNameFmt(initializer_id, "initializer of {f}", .{nav.fqn.fmt(ip)});
30743074
30753075 try self.spv.sections.types_globals_constants.emit(self.spv.gpa, .OpExtInst, .{
30763076 .id_result_type = ptr_ty_id,
src/codegen/spirv/spec.zig+4-7
......@@ -1,6 +1,7 @@
11//! This file is auto-generated by tools/gen_spirv_spec.zig.
22
33const std = @import("std");
4const assert = std.debug.assert;
45
56pub const Version = packed struct(Word) {
67 padding: u8 = 0,
......@@ -18,15 +19,11 @@ pub const IdResult = enum(Word) {
1819 none,
1920 _,
2021
21 pub fn format(
22 self: IdResult,
23 comptime _: []const u8,
24 _: std.fmt.FormatOptions,
25 writer: anytype,
26 ) @TypeOf(writer).Error!void {
22 pub fn format(self: IdResult, writer: *std.io.Writer, comptime f: []const u8) std.io.Writer.Error!void {
23 comptime assert(f.len == 0);
2724 switch (self) {
2825 .none => try writer.writeAll("(none)"),
29 else => try writer.print("%{}", .{@intFromEnum(self)}),
26 else => try writer.print("%{d}", .{@intFromEnum(self)}),
3027 }
3128 }
3229};
src/link.zig+16-16
......@@ -323,7 +323,7 @@ pub const Diags = struct {
323323 const main_msg = try m;
324324 errdefer gpa.free(main_msg);
325325 try diags.msgs.ensureUnusedCapacity(gpa, 1);
326 const note = try std.fmt.allocPrint(gpa, "while parsing {}", .{path});
326 const note = try std.fmt.allocPrint(gpa, "while parsing {f}", .{path});
327327 errdefer gpa.free(note);
328328 const notes = try gpa.create([1]Msg);
329329 errdefer gpa.destroy(notes);
......@@ -1351,7 +1351,7 @@ pub fn doPrelinkTask(comp: *Compilation, task: PrelinkTask) void {
13511351 .search_strategy = .paths_first,
13521352 }) catch |archive_err| switch (archive_err) {
13531353 error.LinkFailure => return, // error reported via diags
1354 else => |e| diags.addParseError(dso_path, "failed to parse archive {}: {s}", .{ archive_path, @errorName(e) }),
1354 else => |e| diags.addParseError(dso_path, "failed to parse archive {f}: {s}", .{ archive_path, @errorName(e) }),
13551355 };
13561356 },
13571357 error.LinkFailure => return, // error reported via diags
......@@ -1874,7 +1874,7 @@ pub fn resolveInputs(
18741874 )) |lib_result| {
18751875 switch (lib_result) {
18761876 .ok => {},
1877 .no_match => fatal("{}: file not found", .{pq.path}),
1877 .no_match => fatal("{f}: file not found", .{pq.path}),
18781878 }
18791879 }
18801880 continue;
......@@ -1928,10 +1928,10 @@ fn resolveLibInput(
19281928 .root_dir = lib_directory,
19291929 .sub_path = try std.fmt.allocPrint(arena, "lib{s}.tbd", .{lib_name}),
19301930 };
1931 try checked_paths.writer(gpa).print("\n {}", .{test_path});
1931 try checked_paths.writer(gpa).print("\n {f}", .{test_path});
19321932 var file = test_path.root_dir.handle.openFile(test_path.sub_path, .{}) catch |err| switch (err) {
19331933 error.FileNotFound => break :tbd,
1934 else => |e| fatal("unable to search for tbd library '{}': {s}", .{ test_path, @errorName(e) }),
1934 else => |e| fatal("unable to search for tbd library '{f}': {s}", .{ test_path, @errorName(e) }),
19351935 };
19361936 errdefer file.close();
19371937 return finishResolveLibInput(resolved_inputs, test_path, file, link_mode, name_query.query);
......@@ -1947,7 +1947,7 @@ fn resolveLibInput(
19471947 },
19481948 }),
19491949 };
1950 try checked_paths.writer(gpa).print("\n {}", .{test_path});
1950 try checked_paths.writer(gpa).print("\n {f}", .{test_path});
19511951 switch (try resolvePathInputLib(gpa, arena, unresolved_inputs, resolved_inputs, ld_script_bytes, target, .{
19521952 .path = test_path,
19531953 .query = name_query.query,
......@@ -1964,10 +1964,10 @@ fn resolveLibInput(
19641964 .root_dir = lib_directory,
19651965 .sub_path = try std.fmt.allocPrint(arena, "lib{s}.so", .{lib_name}),
19661966 };
1967 try checked_paths.writer(gpa).print("\n {}", .{test_path});
1967 try checked_paths.writer(gpa).print("\n {f}", .{test_path});
19681968 var file = test_path.root_dir.handle.openFile(test_path.sub_path, .{}) catch |err| switch (err) {
19691969 error.FileNotFound => break :so,
1970 else => |e| fatal("unable to search for so library '{}': {s}", .{
1970 else => |e| fatal("unable to search for so library '{f}': {s}", .{
19711971 test_path, @errorName(e),
19721972 }),
19731973 };
......@@ -1982,10 +1982,10 @@ fn resolveLibInput(
19821982 .root_dir = lib_directory,
19831983 .sub_path = try std.fmt.allocPrint(arena, "lib{s}.a", .{lib_name}),
19841984 };
1985 try checked_paths.writer(gpa).print("\n {}", .{test_path});
1985 try checked_paths.writer(gpa).print("\n {f}", .{test_path});
19861986 var file = test_path.root_dir.handle.openFile(test_path.sub_path, .{}) catch |err| switch (err) {
19871987 error.FileNotFound => break :mingw,
1988 else => |e| fatal("unable to search for static library '{}': {s}", .{ test_path, @errorName(e) }),
1988 else => |e| fatal("unable to search for static library '{f}': {s}", .{ test_path, @errorName(e) }),
19891989 };
19901990 errdefer file.close();
19911991 return finishResolveLibInput(resolved_inputs, test_path, file, link_mode, name_query.query);
......@@ -2037,7 +2037,7 @@ fn resolvePathInput(
20372037 .shared_library => return try resolvePathInputLib(gpa, arena, unresolved_inputs, resolved_inputs, ld_script_bytes, target, pq, .dynamic, color),
20382038 .object => {
20392039 var file = pq.path.root_dir.handle.openFile(pq.path.sub_path, .{}) catch |err|
2040 fatal("failed to open object {}: {s}", .{ pq.path, @errorName(err) });
2040 fatal("failed to open object {f}: {s}", .{ pq.path, @errorName(err) });
20412041 errdefer file.close();
20422042 try resolved_inputs.append(gpa, .{ .object = .{
20432043 .path = pq.path,
......@@ -2049,7 +2049,7 @@ fn resolvePathInput(
20492049 },
20502050 .res => {
20512051 var file = pq.path.root_dir.handle.openFile(pq.path.sub_path, .{}) catch |err|
2052 fatal("failed to open windows resource {}: {s}", .{ pq.path, @errorName(err) });
2052 fatal("failed to open windows resource {f}: {s}", .{ pq.path, @errorName(err) });
20532053 errdefer file.close();
20542054 try resolved_inputs.append(gpa, .{ .res = .{
20552055 .path = pq.path,
......@@ -2057,7 +2057,7 @@ fn resolvePathInput(
20572057 } });
20582058 return null;
20592059 },
2060 else => fatal("{}: unrecognized file extension", .{pq.path}),
2060 else => fatal("{f}: unrecognized file extension", .{pq.path}),
20612061 }
20622062}
20632063
......@@ -2192,19 +2192,19 @@ pub fn openDso(path: Path, needed: bool, weak: bool, reexport: bool) !Input.Dso
21922192
21932193pub fn openObjectInput(diags: *Diags, path: Path) error{LinkFailure}!Input {
21942194 return .{ .object = openObject(path, false, false) catch |err| {
2195 return diags.failParse(path, "failed to open {}: {s}", .{ path, @errorName(err) });
2195 return diags.failParse(path, "failed to open {f}: {s}", .{ path, @errorName(err) });
21962196 } };
21972197}
21982198
21992199pub fn openArchiveInput(diags: *Diags, path: Path, must_link: bool, hidden: bool) error{LinkFailure}!Input {
22002200 return .{ .archive = openObject(path, must_link, hidden) catch |err| {
2201 return diags.failParse(path, "failed to open {}: {s}", .{ path, @errorName(err) });
2201 return diags.failParse(path, "failed to open {f}: {s}", .{ path, @errorName(err) });
22022202 } };
22032203}
22042204
22052205pub fn openDsoInput(diags: *Diags, path: Path, needed: bool, weak: bool, reexport: bool) error{LinkFailure}!Input {
22062206 return .{ .dso = openDso(path, needed, weak, reexport) catch |err| {
2207 return diags.failParse(path, "failed to open {}: {s}", .{ path, @errorName(err) });
2207 return diags.failParse(path, "failed to open {f}: {s}", .{ path, @errorName(err) });
22082208 } };
22092209}
22102210
src/link/Coff.zig+8-8
......@@ -1213,7 +1213,7 @@ fn updateLazySymbolAtom(
12131213 var code_buffer: std.ArrayListUnmanaged(u8) = .empty;
12141214 defer code_buffer.deinit(gpa);
12151215
1216 const name = try allocPrint(gpa, "__lazy_{s}_{}", .{
1216 const name = try allocPrint(gpa, "__lazy_{s}_{f}", .{
12171217 @tagName(sym.kind),
12181218 Type.fromInterned(sym.ty).fmt(pt),
12191219 });
......@@ -1333,7 +1333,7 @@ fn updateNavCode(
13331333 const ip = &zcu.intern_pool;
13341334 const nav = ip.getNav(nav_index);
13351335
1336 log.debug("updateNavCode {} 0x{x}", .{ nav.fqn.fmt(ip), nav_index });
1336 log.debug("updateNavCode {f} 0x{x}", .{ nav.fqn.fmt(ip), nav_index });
13371337
13381338 const target = &zcu.navFileScope(nav_index).mod.?.resolved_target.result;
13391339 const required_alignment = switch (pt.navAlignment(nav_index)) {
......@@ -1361,7 +1361,7 @@ fn updateNavCode(
13611361 error.OutOfMemory => return error.OutOfMemory,
13621362 else => |e| return coff.base.cgFail(nav_index, "failed to grow atom: {s}", .{@errorName(e)}),
13631363 };
1364 log.debug("growing {} from 0x{x} to 0x{x}", .{ nav.fqn.fmt(ip), sym.value, vaddr });
1364 log.debug("growing {f} from 0x{x} to 0x{x}", .{ nav.fqn.fmt(ip), sym.value, vaddr });
13651365 log.debug(" (required alignment 0x{x}", .{required_alignment});
13661366
13671367 if (vaddr != sym.value) {
......@@ -1389,7 +1389,7 @@ fn updateNavCode(
13891389 else => |e| return coff.base.cgFail(nav_index, "failed to allocate atom: {s}", .{@errorName(e)}),
13901390 };
13911391 errdefer coff.freeAtom(atom_index);
1392 log.debug("allocated atom for {} at 0x{x}", .{ nav.fqn.fmt(ip), vaddr });
1392 log.debug("allocated atom for {f} at 0x{x}", .{ nav.fqn.fmt(ip), vaddr });
13931393 coff.getAtomPtr(atom_index).size = code_len;
13941394 sym.value = vaddr;
13951395
......@@ -1454,7 +1454,7 @@ pub fn updateExports(
14541454
14551455 for (export_indices) |export_idx| {
14561456 const exp = export_idx.ptr(zcu);
1457 log.debug("adding new export '{}'", .{exp.opts.name.fmt(&zcu.intern_pool)});
1457 log.debug("adding new export '{f}'", .{exp.opts.name.fmt(&zcu.intern_pool)});
14581458
14591459 if (exp.opts.section.toSlice(&zcu.intern_pool)) |section_name| {
14601460 if (!mem.eql(u8, section_name, ".text")) {
......@@ -1530,7 +1530,7 @@ pub fn deleteExport(
15301530 const gpa = coff.base.comp.gpa;
15311531 const sym_loc = SymbolWithLoc{ .sym_index = sym_index.*, .file = null };
15321532 const sym = coff.getSymbolPtr(sym_loc);
1533 log.debug("deleting export '{}'", .{name.fmt(&zcu.intern_pool)});
1533 log.debug("deleting export '{f}'", .{name.fmt(&zcu.intern_pool)});
15341534 assert(sym.storage_class == .EXTERNAL and sym.section_number != .UNDEFINED);
15351535 sym.* = .{
15361536 .name = [_]u8{0} ** 8,
......@@ -1748,7 +1748,7 @@ pub fn getNavVAddr(
17481748 const zcu = pt.zcu;
17491749 const ip = &zcu.intern_pool;
17501750 const nav = ip.getNav(nav_index);
1751 log.debug("getNavVAddr {}({d})", .{ nav.fqn.fmt(ip), nav_index });
1751 log.debug("getNavVAddr {f}({d})", .{ nav.fqn.fmt(ip), nav_index });
17521752 const sym_index = if (nav.getExtern(ip)) |e|
17531753 try coff.getGlobalSymbol(nav.name.toSlice(ip), e.lib_name.toSlice(ip))
17541754 else
......@@ -2605,7 +2605,7 @@ fn logSymtab(coff: *Coff) void {
26052605 }
26062606
26072607 log.debug("GOT entries:", .{});
2608 log.debug("{}", .{coff.got_table});
2608 log.debug("{f}", .{coff.got_table});
26092609}
26102610
26112611fn logSections(coff: *Coff) void {
src/link/Dwarf.zig+12-12
......@@ -973,7 +973,7 @@ const Entry = struct {
973973 else
974974 .main;
975975 if (sec.getUnit(ty_unit) == unit and unit.getEntry(other_entry) == entry)
976 log.err("missing Type({}({d}))", .{
976 log.err("missing Type({f}({d}))", .{
977977 Type.fromInterned(ty).fmt(.{ .tid = .main, .zcu = zcu }),
978978 @intFromEnum(ty),
979979 });
......@@ -981,7 +981,7 @@ const Entry = struct {
981981 for (dwarf.navs.keys(), dwarf.navs.values()) |nav, other_entry| {
982982 const nav_unit = dwarf.getUnit(zcu.fileByIndex(ip.getNav(nav).srcInst(ip).resolveFile(ip)).mod.?) catch unreachable;
983983 if (sec.getUnit(nav_unit) == unit and unit.getEntry(other_entry) == entry)
984 log.err("missing Nav({}({d}))", .{ ip.getNav(nav).fqn.fmt(ip), @intFromEnum(nav) });
984 log.err("missing Nav({f}({d}))", .{ ip.getNav(nav).fqn.fmt(ip), @intFromEnum(nav) });
985985 }
986986 }
987987 @panic("missing dwarf relocation target");
......@@ -1957,7 +1957,7 @@ pub const WipNav = struct {
19571957 .{ .debug_output = .{ .dwarf = wip_nav } },
19581958 );
19591959 if (old_len + bytes != wip_nav.debug_info.items.len) {
1960 std.debug.print("{} [{}]: {} != {}\n", .{ ty.fmt(wip_nav.pt), ty.toIntern(), bytes, wip_nav.debug_info.items.len - old_len });
1960 std.debug.print("{f} [{}]: {} != {}\n", .{ ty.fmt(wip_nav.pt), ty.toIntern(), bytes, wip_nav.debug_info.items.len - old_len });
19611961 unreachable;
19621962 }
19631963 }
......@@ -2427,7 +2427,7 @@ fn initWipNavInner(
24272427 const inst_info = nav.srcInst(ip).resolveFull(ip).?;
24282428 const file = zcu.fileByIndex(inst_info.file);
24292429 const decl = file.zir.?.getDeclaration(inst_info.inst);
2430 log.debug("initWipNav({s}:{d}:{d} %{d} = {})", .{
2430 log.debug("initWipNav({s}:{d}:{d} %{d} = {f})", .{
24312431 file.sub_file_path,
24322432 decl.src_line + 1,
24332433 decl.src_column + 1,
......@@ -2632,7 +2632,7 @@ pub fn finishWipNavFunc(
26322632 const ip = &zcu.intern_pool;
26332633 const nav = ip.getNav(nav_index);
26342634 assert(wip_nav.func != .none);
2635 log.debug("finishWipNavFunc({})", .{nav.fqn.fmt(ip)});
2635 log.debug("finishWipNavFunc({f})", .{nav.fqn.fmt(ip)});
26362636
26372637 {
26382638 const external_relocs = &dwarf.debug_aranges.section.getUnit(wip_nav.unit).getEntry(wip_nav.entry).external_relocs;
......@@ -2733,7 +2733,7 @@ pub fn finishWipNav(
27332733 const zcu = pt.zcu;
27342734 const ip = &zcu.intern_pool;
27352735 const nav = ip.getNav(nav_index);
2736 log.debug("finishWipNav({})", .{nav.fqn.fmt(ip)});
2736 log.debug("finishWipNav({f})", .{nav.fqn.fmt(ip)});
27372737
27382738 try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.items);
27392739 if (wip_nav.debug_line.items.len > 0) {
......@@ -2765,7 +2765,7 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo
27652765 const inst_info = nav.srcInst(ip).resolveFull(ip).?;
27662766 const file = zcu.fileByIndex(inst_info.file);
27672767 const decl = file.zir.?.getDeclaration(inst_info.inst);
2768 log.debug("updateComptimeNav({s}:{d}:{d} %{d} = {})", .{
2768 log.debug("updateComptimeNav({s}:{d}:{d} %{d} = {f})", .{
27692769 file.sub_file_path,
27702770 decl.src_line + 1,
27712771 decl.src_column + 1,
......@@ -3215,7 +3215,7 @@ fn updateLazyType(
32153215 const ty: Type = .fromInterned(type_index);
32163216 switch (type_index) {
32173217 .generic_poison_type => log.debug("updateLazyType({s})", .{"anytype"}),
3218 else => log.debug("updateLazyType({})", .{ty.fmt(pt)}),
3218 else => log.debug("updateLazyType({f})", .{ty.fmt(pt)}),
32193219 }
32203220
32213221 var wip_nav: WipNav = .{
......@@ -3243,7 +3243,7 @@ fn updateLazyType(
32433243 const diw = wip_nav.debug_info.writer(dwarf.gpa);
32443244 const name = switch (type_index) {
32453245 .generic_poison_type => "",
3246 else => try std.fmt.allocPrint(dwarf.gpa, "{}", .{ty.fmt(pt)}),
3246 else => try std.fmt.allocPrint(dwarf.gpa, "{f}", .{ty.fmt(pt)}),
32473247 };
32483248 defer dwarf.gpa.free(name);
32493249
......@@ -3718,7 +3718,7 @@ fn updateLazyValue(
37183718 const zcu = pt.zcu;
37193719 const ip = &zcu.intern_pool;
37203720 assert(ip.typeOf(value_index) != .type_type);
3721 log.debug("updateLazyValue(@as({}, {}))", .{
3721 log.debug("updateLazyValue(@as({f}, {f}))", .{
37223722 Value.fromInterned(value_index).typeOf(zcu).fmt(pt),
37233723 Value.fromInterned(value_index).fmtValue(pt),
37243724 });
......@@ -4110,7 +4110,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
41104110 const ip = &zcu.intern_pool;
41114111 const ty: Type = .fromInterned(type_index);
41124112 const ty_src_loc = ty.srcLoc(zcu);
4113 log.debug("updateContainerType({})", .{ty.fmt(pt)});
4113 log.debug("updateContainerType({f})", .{ty.fmt(pt)});
41144114
41154115 const inst_info = ty.typeDeclInst(zcu).?.resolveFull(ip).?;
41164116 const file = zcu.fileByIndex(inst_info.file);
......@@ -4239,7 +4239,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
42394239 };
42404240 defer wip_nav.deinit();
42414241 const diw = wip_nav.debug_info.writer(dwarf.gpa);
4242 const name = try std.fmt.allocPrint(dwarf.gpa, "{}", .{ty.fmt(pt)});
4242 const name = try std.fmt.allocPrint(dwarf.gpa, "{f}", .{ty.fmt(pt)});
42434243 defer dwarf.gpa.free(name);
42444244
42454245 switch (ip.indexToKey(type_index)) {
src/link/Elf.zig+19-25
......@@ -702,7 +702,7 @@ pub fn allocateChunk(self: *Elf, args: struct {
702702 shdr.sh_addr + res.value,
703703 shdr.sh_offset + res.value,
704704 });
705 log.debug(" placement {}, {s}", .{
705 log.debug(" placement {f}, {s}", .{
706706 res.placement,
707707 if (self.atom(res.placement)) |atom_ptr| atom_ptr.name(self) else "",
708708 });
......@@ -869,7 +869,7 @@ fn flushInner(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id) !void {
869869 // Dump the state for easy debugging.
870870 // State can be dumped via `--debug-log link_state`.
871871 if (build_options.enable_logging) {
872 state_log.debug("{}", .{self.dumpState()});
872 state_log.debug("{f}", .{self.dumpState()});
873873 }
874874
875875 // Beyond this point, everything has been allocated a virtual address and we can resolve
......@@ -3813,12 +3813,12 @@ fn reportDuplicates(self: *Elf, dupes: anytype) error{ HasDuplicates, OutOfMemor
38133813
38143814 var err = try diags.addErrorWithNotes(nnotes + 1);
38153815 try err.addMsg("duplicate symbol definition: {s}", .{sym.name(self)});
3816 err.addNote("defined by {}", .{sym.file(self).?.fmtPath()});
3816 err.addNote("defined by {f}", .{sym.file(self).?.fmtPath()});
38173817
38183818 var inote: usize = 0;
38193819 while (inote < @min(notes.items.len, max_notes)) : (inote += 1) {
38203820 const file_ptr = self.file(notes.items[inote]).?;
3821 err.addNote("defined by {}", .{file_ptr.fmtPath()});
3821 err.addNote("defined by {f}", .{file_ptr.fmtPath()});
38223822 }
38233823
38243824 if (notes.items.len > max_notes) {
......@@ -3847,7 +3847,7 @@ pub fn addFileError(
38473847 const diags = &self.base.comp.link_diags;
38483848 var err = try diags.addErrorWithNotes(1);
38493849 try err.addMsg(format, args);
3850 err.addNote("while parsing {}", .{self.file(file_index).?.fmtPath()});
3850 err.addNote("while parsing {f}", .{self.file(file_index).?.fmtPath()});
38513851}
38523852
38533853pub fn failFile(
......@@ -3874,7 +3874,7 @@ fn fmtShdr(self: *Elf, shdr: elf.Elf64_Shdr) std.fmt.Formatter(FormatShdr, forma
38743874
38753875fn formatShdr(ctx: FormatShdr, writer: *std.io.Writer) std.io.Writer.Error!void {
38763876 const shdr = ctx.shdr;
3877 try writer.print("{s} : @{x} ({x}) : align({x}) : size({x}) : entsize({x}) : flags({})", .{
3877 try writer.print("{s} : @{x} ({x}) : align({x}) : size({x}) : entsize({x}) : flags({f})", .{
38783878 ctx.elf_file.getShString(shdr.sh_name), shdr.sh_offset,
38793879 shdr.sh_addr, shdr.sh_addralign,
38803880 shdr.sh_size, shdr.sh_entsize,
......@@ -3979,7 +3979,7 @@ fn fmtDumpState(self: *Elf, writer: *std.io.Writer) std.io.Writer.Error!void {
39793979
39803980 if (self.zigObjectPtr()) |zig_object| {
39813981 try writer.print("zig_object({d}) : {s}\n", .{ zig_object.index, zig_object.basename });
3982 try writer.print("{}{}", .{
3982 try writer.print("{f}{f}", .{
39833983 zig_object.fmtAtoms(self),
39843984 zig_object.fmtSymtab(self),
39853985 });
......@@ -3988,10 +3988,10 @@ fn fmtDumpState(self: *Elf, writer: *std.io.Writer) std.io.Writer.Error!void {
39883988
39893989 for (self.objects.items) |index| {
39903990 const object = self.file(index).?.object;
3991 try writer.print("object({d}) : {}", .{ index, object.fmtPath() });
3991 try writer.print("object({d}) : {f}", .{ index, object.fmtPath() });
39923992 if (!object.alive) try writer.writeAll(" : [*]");
39933993 try writer.writeByte('\n');
3994 try writer.print("{}{}{}{}{}\n", .{
3994 try writer.print("{f}{f}{f}{f}{f}\n", .{
39953995 object.fmtAtoms(self),
39963996 object.fmtCies(self),
39973997 object.fmtFdes(self),
......@@ -4002,18 +4002,18 @@ fn fmtDumpState(self: *Elf, writer: *std.io.Writer) std.io.Writer.Error!void {
40024002
40034003 for (shared_objects) |index| {
40044004 const shared_object = self.file(index).?.shared_object;
4005 try writer.print("shared_object({d}) : {} : needed({})", .{
4005 try writer.print("shared_object({d}) : {f} : needed({})", .{
40064006 index, shared_object.path, shared_object.needed,
40074007 });
40084008 if (!shared_object.alive) try writer.writeAll(" : [*]");
40094009 try writer.writeByte('\n');
4010 try writer.print("{}\n", .{shared_object.fmtSymtab(self)});
4010 try writer.print("{f}\n", .{shared_object.fmtSymtab(self)});
40114011 }
40124012
40134013 if (self.linker_defined_index) |index| {
40144014 const linker_defined = self.file(index).?.linker_defined;
40154015 try writer.print("linker_defined({d}) : (linker defined)\n", .{index});
4016 try writer.print("{}\n", .{linker_defined.fmtSymtab(self)});
4016 try writer.print("{f}\n", .{linker_defined.fmtSymtab(self)});
40174017 }
40184018
40194019 const slice = self.sections.slice();
......@@ -4036,7 +4036,7 @@ fn fmtDumpState(self: *Elf, writer: *std.io.Writer) std.io.Writer.Error!void {
40364036
40374037 try writer.writeAll("Output groups\n");
40384038 for (self.group_sections.items) |cg| {
4039 try writer.print(" shdr({d}) : GROUP({})\n", .{ cg.shndx, cg.cg_ref });
4039 try writer.print(" shdr({d}) : GROUP({f})\n", .{ cg.shndx, cg.cg_ref });
40404040 }
40414041
40424042 try writer.writeAll("\nOutput merge sections\n");
......@@ -4046,7 +4046,7 @@ fn fmtDumpState(self: *Elf, writer: *std.io.Writer) std.io.Writer.Error!void {
40464046
40474047 try writer.writeAll("\nOutput shdrs\n");
40484048 for (slice.items(.shdr), slice.items(.phndx), 0..) |shdr, phndx, shndx| {
4049 try writer.print(" shdr({d}) : phdr({?d}) : {}\n", .{
4049 try writer.print(" shdr({d}) : phdr({d}) : {f}\n", .{
40504050 shndx,
40514051 phndx,
40524052 self.fmtShdr(shdr),
......@@ -4054,7 +4054,7 @@ fn fmtDumpState(self: *Elf, writer: *std.io.Writer) std.io.Writer.Error!void {
40544054 }
40554055 try writer.writeAll("\nOutput phdrs\n");
40564056 for (self.phdrs.items, 0..) |phdr, phndx| {
4057 try writer.print(" phdr({d}) : {}\n", .{ phndx, self.fmtPhdr(phdr) });
4057 try writer.print(" phdr({d}) : {f}\n", .{ phndx, self.fmtPhdr(phdr) });
40584058 }
40594059}
40604060
......@@ -4192,15 +4192,9 @@ pub const Ref = struct {
41924192 return ref.index == other.index and ref.file == other.file;
41934193 }
41944194
4195 pub fn format(
4196 ref: Ref,
4197 comptime unused_fmt_string: []const u8,
4198 options: std.fmt.FormatOptions,
4199 writer: anytype,
4200 ) !void {
4201 _ = unused_fmt_string;
4202 _ = options;
4203 try writer.print("ref({},{})", .{ ref.index, ref.file });
4195 pub fn format(ref: Ref, writer: *std.io.Writer, comptime f: []const u8) std.io.Writer.Error!void {
4196 comptime assert(f.len == 0);
4197 try writer.print("ref({d},{d})", .{ ref.index, ref.file });
42044198 }
42054199};
42064200
......@@ -4395,7 +4389,7 @@ fn createThunks(elf_file: *Elf, atom_list: *AtomList) !void {
43954389 for (atom_list.atoms.keys()[start..i]) |ref| {
43964390 const atom_ptr = elf_file.atom(ref).?;
43974391 const file_ptr = atom_ptr.file(elf_file).?;
4398 log.debug("atom({}) {s}", .{ ref, atom_ptr.name(elf_file) });
4392 log.debug("atom({f}) {s}", .{ ref, atom_ptr.name(elf_file) });
43994393 for (atom_ptr.relocs(elf_file)) |rel| {
44004394 const is_reachable = switch (cpu_arch) {
44014395 .aarch64 => r: {
src/link/Elf/Archive.zig+4-23
......@@ -83,7 +83,7 @@ pub fn parse(
8383 .alive = false,
8484 };
8585
86 log.debug("extracting object '{}' from archive '{}'", .{
86 log.debug("extracting object '{f}' from archive '{f}'", .{
8787 @as(Path, object.path), @as(Path, path),
8888 });
8989
......@@ -201,19 +201,6 @@ pub const ArSymtab = struct {
201201 }
202202 }
203203
204 pub fn format(
205 ar: ArSymtab,
206 comptime unused_fmt_string: []const u8,
207 options: std.fmt.FormatOptions,
208 writer: anytype,
209 ) !void {
210 _ = ar;
211 _ = unused_fmt_string;
212 _ = options;
213 _ = writer;
214 @compileError("do not format ar symtab directly; use fmt instead");
215 }
216
217204 const Format = struct {
218205 ar: ArSymtab,
219206 elf_file: *Elf,
......@@ -224,7 +211,7 @@ pub const ArSymtab = struct {
224211 for (ar.symtab.items, 0..) |entry, i| {
225212 const name = ar.strtab.getAssumeExists(entry.off);
226213 const file = elf_file.file(entry.file_index).?;
227 try writer.print(" {d}: {s} in file({d})({})\n", .{ i, name, entry.file_index, file.fmtPath() });
214 try writer.print(" {d}: {s} in file({d})({f})\n", .{ i, name, entry.file_index, file.fmtPath() });
228215 }
229216 }
230217 };
......@@ -273,14 +260,8 @@ pub const ArStrtab = struct {
273260 try writer.writeAll(ar.buffer.items);
274261 }
275262
276 pub fn format(
277 ar: ArStrtab,
278 comptime unused_fmt_string: []const u8,
279 options: std.fmt.FormatOptions,
280 writer: anytype,
281 ) !void {
282 _ = unused_fmt_string;
283 _ = options;
263 pub fn format(ar: ArStrtab, writer: *std.io.Writer, comptime fmt: []const u8) std.io.Writer.Error!void {
264 comptime assert(fmt.len == 0);
284265 try writer.print("{f}", .{std.ascii.hexEscape(ar.buffer.items, .lower)});
285266 }
286267};
src/link/Elf/Atom.zig+24-24
......@@ -142,7 +142,7 @@ pub fn freeListEligible(self: Atom, elf_file: *Elf) bool {
142142}
143143
144144pub fn free(self: *Atom, elf_file: *Elf) void {
145 log.debug("freeAtom atom({}) ({s})", .{ self.ref(), self.name(elf_file) });
145 log.debug("freeAtom atom({f}) ({s})", .{ self.ref(), self.name(elf_file) });
146146
147147 const comp = elf_file.base.comp;
148148 const gpa = comp.gpa;
......@@ -316,7 +316,7 @@ pub fn scanRelocs(self: Atom, elf_file: *Elf, code: ?[]const u8, undefs: anytype
316316 };
317317 // Violation of One Definition Rule for COMDATs.
318318 // TODO convert into an error
319 log.debug("{}: {s}: {s} refers to a discarded COMDAT section", .{
319 log.debug("{f}: {s}: {s} refers to a discarded COMDAT section", .{
320320 file_ptr.fmtPath(),
321321 self.name(elf_file),
322322 sym_name,
......@@ -519,11 +519,11 @@ fn dataType(symbol: *const Symbol, elf_file: *Elf) u2 {
519519fn reportUnhandledRelocError(self: Atom, rel: elf.Elf64_Rela, elf_file: *Elf) RelocError!void {
520520 const diags = &elf_file.base.comp.link_diags;
521521 var err = try diags.addErrorWithNotes(1);
522 try err.addMsg("fatal linker error: unhandled relocation type {} at offset 0x{x}", .{
522 try err.addMsg("fatal linker error: unhandled relocation type {f} at offset 0x{x}", .{
523523 relocation.fmtRelocType(rel.r_type(), elf_file.getTarget().cpu.arch),
524524 rel.r_offset,
525525 });
526 err.addNote("in {}:{s}", .{ self.file(elf_file).?.fmtPath(), self.name(elf_file) });
526 err.addNote("in {f}:{s}", .{ self.file(elf_file).?.fmtPath(), self.name(elf_file) });
527527 return error.RelocFailure;
528528}
529529
......@@ -539,7 +539,7 @@ fn reportTextRelocError(
539539 rel.r_offset,
540540 symbol.name(elf_file),
541541 });
542 err.addNote("in {}:{s}", .{ self.file(elf_file).?.fmtPath(), self.name(elf_file) });
542 err.addNote("in {f}:{s}", .{ self.file(elf_file).?.fmtPath(), self.name(elf_file) });
543543 return error.RelocFailure;
544544}
545545
......@@ -555,7 +555,7 @@ fn reportPicError(
555555 rel.r_offset,
556556 symbol.name(elf_file),
557557 });
558 err.addNote("in {}:{s}", .{ self.file(elf_file).?.fmtPath(), self.name(elf_file) });
558 err.addNote("in {f}:{s}", .{ self.file(elf_file).?.fmtPath(), self.name(elf_file) });
559559 err.addNote("recompile with -fPIC", .{});
560560 return error.RelocFailure;
561561}
......@@ -572,7 +572,7 @@ fn reportNoPicError(
572572 rel.r_offset,
573573 symbol.name(elf_file),
574574 });
575 err.addNote("in {}:{s}", .{ self.file(elf_file).?.fmtPath(), self.name(elf_file) });
575 err.addNote("in {f}:{s}", .{ self.file(elf_file).?.fmtPath(), self.name(elf_file) });
576576 err.addNote("recompile with -fno-PIC", .{});
577577 return error.RelocFailure;
578578}
......@@ -823,7 +823,7 @@ pub fn resolveRelocsNonAlloc(self: Atom, elf_file: *Elf, code: []u8, undefs: any
823823 };
824824 // Violation of One Definition Rule for COMDATs.
825825 // TODO convert into an error
826 log.debug("{}: {s}: {s} refers to a discarded COMDAT section", .{
826 log.debug("{f}: {s}: {s} refers to a discarded COMDAT section", .{
827827 file_ptr.fmtPath(),
828828 self.name(elf_file),
829829 sym_name,
......@@ -855,7 +855,7 @@ pub fn resolveRelocsNonAlloc(self: Atom, elf_file: *Elf, code: []u8, undefs: any
855855
856856 const args = ResolveArgs{ P, A, S, GOT, 0, 0, DTP };
857857
858 relocs_log.debug(" {}: {x}: [{x} => {x}] ({s})", .{
858 relocs_log.debug(" {f}: {x}: [{x} => {x}] ({s})", .{
859859 relocation.fmtRelocType(rel.r_type(), cpu_arch),
860860 rel.r_offset,
861861 P,
......@@ -918,7 +918,7 @@ const Format = struct {
918918 fn default(f: Format, w: *std.io.Writer) std.io.Writer.Error!void {
919919 const atom = f.atom;
920920 const elf_file = f.elf_file;
921 try w.print("atom({d}) : {s} : @{x} : shdr({d}) : align({x}) : size({x}) : prev({}) : next({})", .{
921 try w.print("atom({d}) : {s} : @{x} : shdr({d}) : align({x}) : size({x}) : prev({f}) : next({f})", .{
922922 atom.atom_index, atom.name(elf_file), atom.address(elf_file),
923923 atom.output_section_index, atom.alignment.toByteUnits() orelse 0, atom.size,
924924 atom.prev_atom_ref, atom.next_atom_ref,
......@@ -1169,7 +1169,7 @@ const x86_64 = struct {
11691169 x86_64.relaxGotPcTlsDesc(code[r_offset - 3 ..], t) catch {
11701170 var err = try diags.addErrorWithNotes(1);
11711171 try err.addMsg("could not relax {s}", .{@tagName(r_type)});
1172 err.addNote("in {}:{s} at offset 0x{x}", .{
1172 err.addNote("in {f}:{s} at offset 0x{x}", .{
11731173 atom.file(elf_file).?.fmtPath(),
11741174 atom.name(elf_file),
11751175 rel.r_offset,
......@@ -1265,7 +1265,7 @@ const x86_64 = struct {
12651265 }, t),
12661266 else => return error.RelaxFailure,
12671267 };
1268 relocs_log.debug(" relaxing {} => {}", .{ old_inst.encoding, inst.encoding });
1268 relocs_log.debug(" relaxing {f} => {f}", .{ old_inst.encoding, inst.encoding });
12691269 const nop: Instruction = try .new(.none, .nop, &.{}, t);
12701270 try encode(&.{ nop, inst }, code);
12711271 }
......@@ -1276,7 +1276,7 @@ const x86_64 = struct {
12761276 switch (old_inst.encoding.mnemonic) {
12771277 .mov => {
12781278 const inst: Instruction = try .new(old_inst.prefix, .lea, &old_inst.ops, t);
1279 relocs_log.debug(" relaxing {} => {}", .{ old_inst.encoding, inst.encoding });
1279 relocs_log.debug(" relaxing {f} => {f}", .{ old_inst.encoding, inst.encoding });
12801280 try encode(&.{inst}, code);
12811281 },
12821282 else => return error.RelaxFailure,
......@@ -1310,11 +1310,11 @@ const x86_64 = struct {
13101310
13111311 else => {
13121312 var err = try diags.addErrorWithNotes(1);
1313 try err.addMsg("TODO: rewrite {} when followed by {}", .{
1313 try err.addMsg("TODO: rewrite {f} when followed by {f}", .{
13141314 relocation.fmtRelocType(rels[0].r_type(), .x86_64),
13151315 relocation.fmtRelocType(rels[1].r_type(), .x86_64),
13161316 });
1317 err.addNote("in {}:{s} at offset 0x{x}", .{
1317 err.addNote("in {f}:{s} at offset 0x{x}", .{
13181318 self.file(elf_file).?.fmtPath(),
13191319 self.name(elf_file),
13201320 rels[0].r_offset,
......@@ -1366,11 +1366,11 @@ const x86_64 = struct {
13661366
13671367 else => {
13681368 var err = try diags.addErrorWithNotes(1);
1369 try err.addMsg("TODO: rewrite {} when followed by {}", .{
1369 try err.addMsg("TODO: rewrite {f} when followed by {f}", .{
13701370 relocation.fmtRelocType(rels[0].r_type(), .x86_64),
13711371 relocation.fmtRelocType(rels[1].r_type(), .x86_64),
13721372 });
1373 err.addNote("in {}:{s} at offset 0x{x}", .{
1373 err.addNote("in {f}:{s} at offset 0x{x}", .{
13741374 self.file(elf_file).?.fmtPath(),
13751375 self.name(elf_file),
13761376 rels[0].r_offset,
......@@ -1408,7 +1408,7 @@ const x86_64 = struct {
14081408 // TODO: hack to force imm32s in the assembler
14091409 .{ .imm = .s(-129) },
14101410 }, t) catch unreachable;
1411 relocs_log.debug(" relaxing {} => {}", .{ old_inst.encoding, inst.encoding });
1411 relocs_log.debug(" relaxing {f} => {f}", .{ old_inst.encoding, inst.encoding });
14121412 encode(&.{inst}, code) catch unreachable;
14131413 },
14141414 else => unreachable,
......@@ -1425,7 +1425,7 @@ const x86_64 = struct {
14251425 // TODO: hack to force imm32s in the assembler
14261426 .{ .imm = .s(-129) },
14271427 }, target);
1428 relocs_log.debug(" relaxing {} => {}", .{ old_inst.encoding, inst.encoding });
1428 relocs_log.debug(" relaxing {f} => {f}", .{ old_inst.encoding, inst.encoding });
14291429 try encode(&.{inst}, code);
14301430 },
14311431 else => return error.RelaxFailure,
......@@ -1457,7 +1457,7 @@ const x86_64 = struct {
14571457 std.mem.writeInt(i32, insts[12..][0..4], value, .little);
14581458 try stream.seekBy(-4);
14591459 try writer.writeAll(&insts);
1460 relocs_log.debug(" relaxing {} and {}", .{
1460 relocs_log.debug(" relaxing {f} and {f}", .{
14611461 relocation.fmtRelocType(rels[0].r_type(), .x86_64),
14621462 relocation.fmtRelocType(rels[1].r_type(), .x86_64),
14631463 });
......@@ -1465,11 +1465,11 @@ const x86_64 = struct {
14651465
14661466 else => {
14671467 var err = try diags.addErrorWithNotes(1);
1468 try err.addMsg("fatal linker error: rewrite {} when followed by {}", .{
1468 try err.addMsg("fatal linker error: rewrite {f} when followed by {f}", .{
14691469 relocation.fmtRelocType(rels[0].r_type(), .x86_64),
14701470 relocation.fmtRelocType(rels[1].r_type(), .x86_64),
14711471 });
1472 err.addNote("in {}:{s} at offset 0x{x}", .{
1472 err.addNote("in {f}:{s} at offset 0x{x}", .{
14731473 self.file(elf_file).?.fmtPath(),
14741474 self.name(elf_file),
14751475 rels[0].r_offset,
......@@ -1653,7 +1653,7 @@ const aarch64 = struct {
16531653 // TODO: relax
16541654 var err = try diags.addErrorWithNotes(1);
16551655 try err.addMsg("TODO: relax ADR_GOT_PAGE", .{});
1656 err.addNote("in {}:{s} at offset 0x{x}", .{
1656 err.addNote("in {f}:{s} at offset 0x{x}", .{
16571657 atom.file(elf_file).?.fmtPath(),
16581658 atom.name(elf_file),
16591659 r_offset,
......@@ -1943,7 +1943,7 @@ const riscv = struct {
19431943 // TODO: implement searching forward
19441944 var err = try diags.addErrorWithNotes(1);
19451945 try err.addMsg("TODO: find HI20 paired reloc scanning forward", .{});
1946 err.addNote("in {}:{s} at offset 0x{x}", .{
1946 err.addNote("in {f}:{s} at offset 0x{x}", .{
19471947 atom.file(elf_file).?.fmtPath(),
19481948 atom.name(elf_file),
19491949 rel.r_offset,
src/link/Elf/AtomList.zig+10-8
......@@ -108,7 +108,7 @@ pub fn write(list: AtomList, buffer: *std.ArrayList(u8), undefs: anytype, elf_fi
108108 const off = math.cast(usize, atom_ptr.value - list.value) orelse return error.Overflow;
109109 const size = math.cast(usize, atom_ptr.size) orelse return error.Overflow;
110110
111 log.debug(" atom({}) at 0x{x}", .{ ref, list.offset(elf_file) + off });
111 log.debug(" atom({f}) at 0x{x}", .{ ref, list.offset(elf_file) + off });
112112
113113 const object = atom_ptr.file(elf_file).?.object;
114114 const code = try object.codeDecompressAlloc(elf_file, ref.index);
......@@ -144,7 +144,7 @@ pub fn writeRelocatable(list: AtomList, buffer: *std.ArrayList(u8), elf_file: *E
144144 const off = math.cast(usize, atom_ptr.value - list.value) orelse return error.Overflow;
145145 const size = math.cast(usize, atom_ptr.size) orelse return error.Overflow;
146146
147 log.debug(" atom({}) at 0x{x}", .{ ref, list.offset(elf_file) + off });
147 log.debug(" atom({f}) at 0x{x}", .{ ref, list.offset(elf_file) + off });
148148
149149 const object = atom_ptr.file(elf_file).?.object;
150150 const code = try object.codeDecompressAlloc(elf_file, ref.index);
......@@ -172,22 +172,24 @@ const Format = struct {
172172 elf_file: *Elf,
173173
174174 fn default(f: Format, writer: *std.io.Writer) std.io.Writer.Error!void {
175 const list, const elf_file = f;
175 const list = f.atom_list;
176176 try writer.print("list : @{x} : shdr({d}) : align({x}) : size({x})", .{
177 list.address(elf_file), list.output_section_index,
178 list.alignment.toByteUnits() orelse 0, list.size,
177 list.address(f.elf_file),
178 list.output_section_index,
179 list.alignment.toByteUnits() orelse 0,
180 list.size,
179181 });
180182 try writer.writeAll(" : atoms{ ");
181183 for (list.atoms.keys(), 0..) |ref, i| {
182 try writer.print("{}", .{ref});
184 try writer.print("{f}", .{ref});
183185 if (i < list.atoms.keys().len - 1) try writer.writeAll(", ");
184186 }
185187 try writer.writeAll(" }");
186188 }
187189};
188190
189pub fn fmt(list: AtomList, elf_file: *Elf) std.fmt.Formatter(Format, Format.default) {
190 return .{ .data = .{ list, elf_file } };
191pub fn fmt(atom_list: AtomList, elf_file: *Elf) std.fmt.Formatter(Format, Format.default) {
192 return .{ .data = .{ .atom_list = atom_list, .elf_file = elf_file } };
191193}
192194
193195const assert = std.debug.assert;
src/link/Elf/Object.zig+7-7
......@@ -281,7 +281,7 @@ fn initAtoms(
281281 elf.SHT_GROUP => {
282282 if (shdr.sh_info >= self.symtab.items.len) {
283283 // TODO convert into an error
284 log.debug("{}: invalid symbol index in sh_info", .{self.fmtPath()});
284 log.debug("{f}: invalid symbol index in sh_info", .{self.fmtPath()});
285285 continue;
286286 }
287287 const group_info_sym = self.symtab.items[shdr.sh_info];
......@@ -793,7 +793,7 @@ pub fn initInputMergeSections(self: *Object, elf_file: *Elf) !void {
793793 if (!isNull(data[end .. end + sh_entsize])) {
794794 var err = try diags.addErrorWithNotes(1);
795795 try err.addMsg("string not null terminated", .{});
796 err.addNote("in {}:{s}", .{ self.fmtPath(), atom_ptr.name(elf_file) });
796 err.addNote("in {f}:{s}", .{ self.fmtPath(), atom_ptr.name(elf_file) });
797797 return error.LinkFailure;
798798 }
799799 end += sh_entsize;
......@@ -808,7 +808,7 @@ pub fn initInputMergeSections(self: *Object, elf_file: *Elf) !void {
808808 if (shdr.sh_size % sh_entsize != 0) {
809809 var err = try diags.addErrorWithNotes(1);
810810 try err.addMsg("size not a multiple of sh_entsize", .{});
811 err.addNote("in {}:{s}", .{ self.fmtPath(), atom_ptr.name(elf_file) });
811 err.addNote("in {f}:{s}", .{ self.fmtPath(), atom_ptr.name(elf_file) });
812812 return error.LinkFailure;
813813 }
814814
......@@ -886,7 +886,7 @@ pub fn resolveMergeSubsections(self: *Object, elf_file: *Elf) error{
886886 var err = try diags.addErrorWithNotes(2);
887887 try err.addMsg("invalid symbol value: {x}", .{esym.st_value});
888888 err.addNote("for symbol {s}", .{sym.name(elf_file)});
889 err.addNote("in {}", .{self.fmtPath()});
889 err.addNote("in {f}", .{self.fmtPath()});
890890 return error.LinkFailure;
891891 };
892892
......@@ -911,7 +911,7 @@ pub fn resolveMergeSubsections(self: *Object, elf_file: *Elf) error{
911911 const res = imsec.findSubsection(@intCast(@as(i64, @intCast(esym.st_value)) + rel.r_addend)) orelse {
912912 var err = try diags.addErrorWithNotes(1);
913913 try err.addMsg("invalid relocation at offset 0x{x}", .{rel.r_offset});
914 err.addNote("in {}:{s}", .{ self.fmtPath(), atom_ptr.name(elf_file) });
914 err.addNote("in {f}:{s}", .{ self.fmtPath(), atom_ptr.name(elf_file) });
915915 return error.LinkFailure;
916916 };
917917
......@@ -1536,9 +1536,9 @@ pub fn fmtPath(self: Object) std.fmt.Formatter(Object, formatPath) {
15361536
15371537fn formatPath(object: Object, writer: *std.io.Writer) std.io.Writer.Error!void {
15381538 if (object.archive) |ar| {
1539 try writer.print("{}({})", .{ ar.path, object.path });
1539 try writer.print("{f}({f})", .{ ar.path, object.path });
15401540 } else {
1541 try writer.print("{}", .{object.path});
1541 try writer.print("{f}", .{object.path});
15421542 }
15431543}
15441544
src/link/Elf/SharedObject.zig+12-12
......@@ -519,21 +519,21 @@ pub fn fmtSymtab(self: SharedObject, elf_file: *Elf) std.fmt.Formatter(Format, F
519519const Format = struct {
520520 shared: SharedObject,
521521 elf_file: *Elf,
522};
523522
524fn formatSymtab(f: Format, writer: *std.io.Writer) std.io.Writer.Error!void {
525 const shared = f.shared;
526 const elf_file = f.elf_file;
527 try writer.writeAll(" globals\n");
528 for (shared.symbols.items, 0..) |sym, i| {
529 const ref = shared.resolveSymbol(@intCast(i), elf_file);
530 if (elf_file.symbol(ref)) |ref_sym| {
531 try writer.print(" {}\n", .{ref_sym.fmt(elf_file)});
532 } else {
533 try writer.print(" {s} : unclaimed\n", .{sym.name(elf_file)});
523 fn symtab(f: Format, writer: *std.io.Writer) std.io.Writer.Error!void {
524 const shared = f.shared;
525 const elf_file = f.elf_file;
526 try writer.writeAll(" globals\n");
527 for (shared.symbols.items, 0..) |sym, i| {
528 const ref = shared.resolveSymbol(@intCast(i), elf_file);
529 if (elf_file.symbol(ref)) |ref_sym| {
530 try writer.print(" {f}\n", .{ref_sym.fmt(elf_file)});
531 } else {
532 try writer.print(" {s} : unclaimed\n", .{sym.name(elf_file)});
533 }
534534 }
535535 }
536}
536};
537537
538538const SharedObject = @This();
539539
src/link/Elf/Symbol.zig+1-1
......@@ -338,7 +338,7 @@ const Format = struct {
338338 fn default(f: Format, writer: *std.io.Writer) std.io.Writer.Error!void {
339339 const symbol = f.symbol;
340340 const elf_file = f.elf_file;
341 try writer.print("%{d} : {s} : @{x}", .{
341 try writer.print("%{d} : {f} : @{x}", .{
342342 symbol.esym_index,
343343 symbol.fmtName(elf_file),
344344 symbol.address(.{ .plt = false, .trampoline = false }, elf_file),
src/link/Elf/Thunk.zig+1-1
......@@ -82,7 +82,7 @@ const Format = struct {
8282 try writer.print("@{x} : size({x})\n", .{ thunk.value, thunk.size(elf_file) });
8383 for (thunk.symbols.keys()) |ref| {
8484 const sym = elf_file.symbol(ref).?;
85 try writer.print(" {} : {s} : @{x}\n", .{ ref, sym.name(elf_file), sym.value });
85 try writer.print(" {f} : {s} : @{x}\n", .{ ref, sym.name(elf_file), sym.value });
8686 }
8787 }
8888};
src/link/Elf/ZigObject.zig+2-2
......@@ -2199,7 +2199,7 @@ const Format = struct {
21992199 self: *ZigObject,
22002200 elf_file: *Elf,
22012201
2202 fn symtab(f: Format, writer: *std.io.Writer.Error) std.io.Writer.Error!void {
2202 fn symtab(f: Format, writer: *std.io.Writer) std.io.Writer.Error!void {
22032203 const self = f.self;
22042204 const elf_file = f.elf_file;
22052205 try writer.writeAll(" locals\n");
......@@ -2214,7 +2214,7 @@ const Format = struct {
22142214 }
22152215 }
22162216
2217 fn atoms(f: Format, writer: *std.io.Writer.Error) std.io.Writer.Error!void {
2217 fn atoms(f: Format, writer: *std.io.Writer) std.io.Writer.Error!void {
22182218 try writer.writeAll(" atoms\n");
22192219 for (f.self.atoms_indexes.items) |atom_index| {
22202220 const atom_ptr = f.self.atom(atom_index) orelse continue;
src/link/Elf/eh_frame.zig+3-3
......@@ -141,7 +141,7 @@ pub const Cie = struct {
141141 cie: Cie,
142142 elf_file: *Elf,
143143
144 fn format2(f: Format, writer: *std.io.Writer) std.io.Writer.Error!void {
144 fn default(f: Format, writer: *std.io.Writer) std.io.Writer.Error!void {
145145 const cie = f.cie;
146146 const elf_file = f.elf_file;
147147 const base_addr = cie.address(elf_file);
......@@ -567,11 +567,11 @@ const riscv = struct {
567567fn reportInvalidReloc(rec: anytype, elf_file: *Elf, rel: elf.Elf64_Rela) !void {
568568 const diags = &elf_file.base.comp.link_diags;
569569 var err = try diags.addErrorWithNotes(1);
570 try err.addMsg("invalid relocation type {} at offset 0x{x}", .{
570 try err.addMsg("invalid relocation type {f} at offset 0x{x}", .{
571571 relocation.fmtRelocType(rel.r_type(), elf_file.getTarget().cpu.arch),
572572 rel.r_offset,
573573 });
574 err.addNote("in {}:.eh_frame", .{elf_file.file(rec.file_index).?.fmtPath()});
574 err.addNote("in {f}:.eh_frame", .{elf_file.file(rec.file_index).?.fmtPath()});
575575 return error.RelocFailure;
576576}
577577
src/link/Elf/gc.zig+6-12
......@@ -111,7 +111,7 @@ fn markLive(atom: *Atom, elf_file: *Elf) void {
111111 const target_sym = elf_file.symbol(ref) orelse continue;
112112 const target_atom = target_sym.atom(elf_file) orelse continue;
113113 target_atom.alive = true;
114 gc_track_live_log.debug("{}marking live atom({d})", .{ track_live_level, target_atom.atom_index });
114 gc_track_live_log.debug("{f}marking live atom({d})", .{ track_live_level, target_atom.atom_index });
115115 if (markAtom(target_atom)) markLive(target_atom, elf_file);
116116 }
117117 }
......@@ -128,7 +128,7 @@ fn markLive(atom: *Atom, elf_file: *Elf) void {
128128 }
129129 const target_atom = target_sym.atom(elf_file) orelse continue;
130130 target_atom.alive = true;
131 gc_track_live_log.debug("{}marking live atom({d})", .{ track_live_level, target_atom.atom_index });
131 gc_track_live_log.debug("{f}marking live atom({d})", .{ track_live_level, target_atom.atom_index });
132132 if (markAtom(target_atom)) markLive(target_atom, elf_file);
133133 }
134134}
......@@ -170,7 +170,7 @@ pub fn dumpPrunedAtoms(elf_file: *Elf) !void {
170170 const atom = file.atom(atom_index) orelse continue;
171171 if (!atom.alive)
172172 // TODO should we simply print to stderr?
173 try stderr.print("link: removing unused section '{s}' in file '{}'\n", .{
173 try stderr.print("link: removing unused section '{s}' in file '{f}'\n", .{
174174 atom.name(elf_file),
175175 atom.file(elf_file).?.fmtPath(),
176176 });
......@@ -185,15 +185,9 @@ const Level = struct {
185185 self.value += 1;
186186 }
187187
188 pub fn format(
189 self: *const @This(),
190 comptime unused_fmt_string: []const u8,
191 options: std.fmt.FormatOptions,
192 writer: anytype,
193 ) !void {
194 _ = unused_fmt_string;
195 _ = options;
196 try writer.writeByteNTimes(' ', self.value);
188 pub fn format(self: *const @This(), w: *std.io.Writer, comptime fmt: []const u8) std.io.Writer.Error!void {
189 comptime assert(fmt.len == 0);
190 try w.splatByteAll(' ', self.value);
197191 }
198192};
199193
src/link/Elf/relocatable.zig+4-4
......@@ -31,7 +31,7 @@ pub fn flushStaticLib(elf_file: *Elf, comp: *Compilation) !void {
3131 try elf_file.allocateNonAllocSections();
3232
3333 if (build_options.enable_logging) {
34 state_log.debug("{}", .{elf_file.dumpState()});
34 state_log.debug("{f}", .{elf_file.dumpState()});
3535 }
3636
3737 try elf_file.writeMergeSections();
......@@ -96,8 +96,8 @@ pub fn flushStaticLib(elf_file: *Elf, comp: *Compilation) !void {
9696 };
9797
9898 if (build_options.enable_logging) {
99 state_log.debug("ar_symtab\n{}\n", .{ar_symtab.fmt(elf_file)});
100 state_log.debug("ar_strtab\n{}\n", .{ar_strtab});
99 state_log.debug("ar_symtab\n{f}\n", .{ar_symtab.fmt(elf_file)});
100 state_log.debug("ar_strtab\n{f}\n", .{ar_strtab});
101101 }
102102
103103 var buffer = std.ArrayList(u8).init(gpa);
......@@ -170,7 +170,7 @@ pub fn flushObject(elf_file: *Elf, comp: *Compilation) !void {
170170 try elf_file.allocateNonAllocSections();
171171
172172 if (build_options.enable_logging) {
173 state_log.debug("{}", .{elf_file.dumpState()});
173 state_log.debug("{f}", .{elf_file.dumpState()});
174174 }
175175
176176 try writeAtoms(elf_file);
src/link/Elf/synthetic_sections.zig+2-2
......@@ -616,7 +616,7 @@ pub const GotSection = struct {
616616 try writer.writeAll("GOT\n");
617617 for (got.entries.items) |entry| {
618618 const symbol = elf_file.symbol(entry.ref).?;
619 try writer.print(" {d}@0x{x} => {}@0x{x} ({s})\n", .{
619 try writer.print(" {d}@0x{x} => {f}@0x{x} ({s})\n", .{
620620 entry.cell_index,
621621 entry.address(elf_file),
622622 entry.ref,
......@@ -752,7 +752,7 @@ pub const PltSection = struct {
752752 try writer.writeAll("PLT\n");
753753 for (plt.symbols.items, 0..) |ref, i| {
754754 const symbol = elf_file.symbol(ref).?;
755 try writer.print(" {d}@0x{x} => {}@0x{x} ({s})\n", .{
755 try writer.print(" {d}@0x{x} => {f}@0x{x} ({s})\n", .{
756756 i,
757757 symbol.pltAddress(elf_file),
758758 ref,
src/link/Lld.zig+6-6
......@@ -437,7 +437,7 @@ fn coffLink(lld: *Lld, arena: Allocator) !void {
437437 try argv.append(try allocPrint(arena, "-PDBALTPATH:{s}", .{out_pdb_basename}));
438438 }
439439 if (comp.version) |version| {
440 try argv.append(try allocPrint(arena, "-VERSION:{}.{}", .{ version.major, version.minor }));
440 try argv.append(try allocPrint(arena, "-VERSION:{f}.{f}", .{ version.major, version.minor }));
441441 }
442442
443443 if (target_util.llvmMachineAbi(target)) |mabi| {
......@@ -507,7 +507,7 @@ fn coffLink(lld: *Lld, arena: Allocator) !void {
507507
508508 if (comp.emit_implib) |raw_emit_path| {
509509 const path = try comp.resolveEmitPathFlush(arena, .temp, raw_emit_path);
510 try argv.append(try allocPrint(arena, "-IMPLIB:{}", .{path}));
510 try argv.append(try allocPrint(arena, "-IMPLIB:{f}", .{path}));
511511 }
512512
513513 if (comp.config.link_libc) {
......@@ -533,7 +533,7 @@ fn coffLink(lld: *Lld, arena: Allocator) !void {
533533 },
534534 .object, .archive => |obj| {
535535 if (obj.must_link) {
536 argv.appendAssumeCapacity(try allocPrint(arena, "-WHOLEARCHIVE:{}", .{@as(Cache.Path, obj.path)}));
536 argv.appendAssumeCapacity(try allocPrint(arena, "-WHOLEARCHIVE:{f}", .{@as(Cache.Path, obj.path)}));
537537 } else {
538538 argv.appendAssumeCapacity(try obj.path.toString(arena));
539539 }
......@@ -1216,7 +1216,7 @@ fn elfLink(lld: *Lld, arena: Allocator) !void {
12161216 if (target.os.versionRange().gnuLibCVersion().?.order(rem_in) != .lt) continue;
12171217 }
12181218
1219 const lib_path = try std.fmt.allocPrint(arena, "{}{c}lib{s}.so.{d}", .{
1219 const lib_path = try std.fmt.allocPrint(arena, "{f}{c}lib{s}.so.{d}", .{
12201220 comp.glibc_so_files.?.dir_path, fs.path.sep, lib.name, lib.sover,
12211221 });
12221222 try argv.append(lib_path);
......@@ -1229,14 +1229,14 @@ fn elfLink(lld: *Lld, arena: Allocator) !void {
12291229 }));
12301230 } else if (target.isFreeBSDLibC()) {
12311231 for (freebsd.libs) |lib| {
1232 const lib_path = try std.fmt.allocPrint(arena, "{}{c}lib{s}.so.{d}", .{
1232 const lib_path = try std.fmt.allocPrint(arena, "{f}{c}lib{s}.so.{d}", .{
12331233 comp.freebsd_so_files.?.dir_path, fs.path.sep, lib.name, lib.sover,
12341234 });
12351235 try argv.append(lib_path);
12361236 }
12371237 } else if (target.isNetBSDLibC()) {
12381238 for (netbsd.libs) |lib| {
1239 const lib_path = try std.fmt.allocPrint(arena, "{}{c}lib{s}.so.{d}", .{
1239 const lib_path = try std.fmt.allocPrint(arena, "{f}{c}lib{s}.so.{d}", .{
12401240 comp.netbsd_so_files.?.dir_path, fs.path.sep, lib.name, lib.sover,
12411241 });
12421242 try argv.append(lib_path);
src/link/MachO.zig+1-1
......@@ -4271,7 +4271,7 @@ pub const Platform = struct {
42714271 pub fn allocPrintTarget(plat: Platform, gpa: Allocator, cpu_arch: std.Target.Cpu.Arch) error{OutOfMemory}![]u8 {
42724272 var buffer = std.ArrayList(u8).init(gpa);
42734273 defer buffer.deinit();
4274 try buffer.writer().print("{}", .{plat.fmtTarget(cpu_arch)});
4274 try buffer.writer().print("{f}", .{plat.fmtTarget(cpu_arch)});
42754275 return buffer.toOwnedSlice();
42764276 }
42774277
src/link/MachO/Archive.zig+1-1
......@@ -71,7 +71,7 @@ pub fn unpack(self: *Archive, macho_file: *MachO, path: Path, handle_index: File
7171 .mtime = hdr.date() catch 0,
7272 };
7373
74 log.debug("extracting object '{}' from archive '{}'", .{ object.path, path });
74 log.debug("extracting object '{f}' from archive '{f}'", .{ object.path, path });
7575
7676 try self.objects.append(gpa, object);
7777 }
src/link/MachO/Atom.zig+1-1
......@@ -602,7 +602,7 @@ pub fn resolveRelocs(self: Atom, macho_file: *MachO, buffer: []u8) !void {
602602 };
603603 try macho_file.reportParseError2(
604604 file.getIndex(),
605 "{s}: 0x{x}: 0x{x}: failed to relax relocation: type {}, target {s}",
605 "{s}: 0x{x}: 0x{x}: failed to relax relocation: type {f}, target {s}",
606606 .{
607607 name,
608608 self.getAddress(macho_file),
src/link/Plan9.zig+6-6
......@@ -445,7 +445,7 @@ pub fn updateNav(self: *Plan9, pt: Zcu.PerThread, nav_index: InternPool.Nav.Inde
445445 .func => return,
446446 .variable => |variable| Value.fromInterned(variable.init),
447447 .@"extern" => {
448 log.debug("found extern decl: {}", .{nav.name.fmt(ip)});
448 log.debug("found extern decl: {f}", .{nav.name.fmt(ip)});
449449 return;
450450 },
451451 else => nav_val,
......@@ -675,7 +675,7 @@ pub fn flush(
675675 const off = self.getAddr(text_i, .t);
676676 text_i += out.code.len;
677677 atom.offset = off;
678 log.debug("write text nav 0x{x} ({}), lines {d} to {d}.;__GOT+0x{x} vaddr: 0x{x}", .{ nav_index, nav.name.fmt(&pt.zcu.intern_pool), out.start_line + 1, out.end_line, atom.got_index.? * 8, off });
678 log.debug("write text nav 0x{x} ({f}), lines {d} to {d}.;__GOT+0x{x} vaddr: 0x{x}", .{ nav_index, nav.name.fmt(&pt.zcu.intern_pool), out.start_line + 1, out.end_line, atom.got_index.? * 8, off });
679679 if (!self.sixtyfour_bit) {
680680 mem.writeInt(u32, got_table[atom.got_index.? * 4 ..][0..4], @intCast(off), target.cpu.arch.endian());
681681 } else {
......@@ -974,11 +974,11 @@ pub fn seeNav(self: *Plan9, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index)
974974 self.etext_edata_end_atom_indices[2] = atom_idx;
975975 }
976976 try self.updateFinish(pt, nav_index);
977 log.debug("seeNav(extern) for {} (got_addr=0x{x})", .{
977 log.debug("seeNav(extern) for {f} (got_addr=0x{x})", .{
978978 nav.name.fmt(ip),
979979 self.getAtom(atom_idx).getOffsetTableAddress(self),
980980 });
981 } else log.debug("seeNav for {}", .{nav.name.fmt(ip)});
981 } else log.debug("seeNav for {f}", .{nav.name.fmt(ip)});
982982 return atom_idx;
983983}
984984
......@@ -1043,7 +1043,7 @@ fn updateLazySymbolAtom(
10431043 defer code_buffer.deinit(gpa);
10441044
10451045 // create the symbol for the name
1046 const name = try std.fmt.allocPrint(gpa, "__lazy_{s}_{}", .{
1046 const name = try std.fmt.allocPrint(gpa, "__lazy_{s}_{f}", .{
10471047 @tagName(sym.kind),
10481048 Type.fromInterned(sym.ty).fmt(pt),
10491049 });
......@@ -1314,7 +1314,7 @@ pub fn getNavVAddr(
13141314) !u64 {
13151315 const ip = &pt.zcu.intern_pool;
13161316 const nav = ip.getNav(nav_index);
1317 log.debug("getDeclVAddr for {}", .{nav.name.fmt(ip)});
1317 log.debug("getDeclVAddr for {f}", .{nav.name.fmt(ip)});
13181318 if (nav.getExtern(ip) != null) {
13191319 if (nav.name.eqlSlice("etext", ip)) {
13201320 try self.addReloc(reloc_info.parent.atom_index, .{
src/link/Wasm.zig+12-19
......@@ -547,7 +547,7 @@ pub const SourceLocation = enum(u32) {
547547 switch (sl.unpack(wasm)) {
548548 .none => unreachable,
549549 .zig_object_nofile => diags.addError("zig compilation unit: " ++ f, args),
550 .object_index => |i| diags.addError("{}: " ++ f, .{i.ptr(wasm).path} ++ args),
550 .object_index => |i| diags.addError("{f}: " ++ f, .{i.ptr(wasm).path} ++ args),
551551 .source_location_index => @panic("TODO"),
552552 }
553553 }
......@@ -579,9 +579,9 @@ pub const SourceLocation = enum(u32) {
579579 .object_index => |i| {
580580 const obj = i.ptr(wasm);
581581 return if (obj.archive_member_name.slice(wasm)) |obj_name|
582 try bundle.printString("{} ({s}): {s}", .{ obj.path, std.fs.path.basename(obj_name), msg })
582 try bundle.printString("{f} ({s}): {s}", .{ obj.path, std.fs.path.basename(obj_name), msg })
583583 else
584 try bundle.printString("{}: {s}", .{ obj.path, msg });
584 try bundle.printString("{f}: {s}", .{ obj.path, msg });
585585 },
586586 .source_location_index => @panic("TODO"),
587587 };
......@@ -2126,14 +2126,8 @@ pub const FunctionType = extern struct {
21262126 wasm: *const Wasm,
21272127 ft: FunctionType,
21282128
2129 pub fn format(
2130 self: Formatter,
2131 comptime format_string: []const u8,
2132 options: std.fmt.FormatOptions,
2133 writer: anytype,
2134 ) !void {
2135 if (format_string.len != 0) std.fmt.invalidFmtError(format_string, self);
2136 _ = options;
2129 pub fn format(self: Formatter, writer: *std.io.Writer, comptime f: []const u8) std.io.Writer.Error!void {
2130 comptime assert(f.len == 0);
21372131 const params = self.ft.params.slice(self.wasm);
21382132 const returns = self.ft.returns.slice(self.wasm);
21392133
......@@ -2912,9 +2906,8 @@ pub const Feature = packed struct(u8) {
29122906 @"=",
29132907 };
29142908
2915 pub fn format(feature: Feature, comptime fmt: []const u8, opt: std.fmt.FormatOptions, writer: anytype) !void {
2916 _ = opt;
2917 _ = fmt;
2909 pub fn format(feature: Feature, writer: *std.io.Writer, comptime fmt: []const u8) std.io.Writer.Error!void {
2910 comptime assert(fmt.len == 0);
29182911 try writer.print("{s} {s}", .{ @tagName(feature.prefix), @tagName(feature.tag) });
29192912 }
29202913
......@@ -3036,7 +3029,7 @@ fn openParseObjectReportingFailure(wasm: *Wasm, path: Path) void {
30363029}
30373030
30383031fn parseObject(wasm: *Wasm, obj: link.Input.Object) !void {
3039 log.debug("parseObject {}", .{obj.path});
3032 log.debug("parseObject {f}", .{obj.path});
30403033 const gpa = wasm.base.comp.gpa;
30413034 const gc_sections = wasm.base.gc_sections;
30423035
......@@ -3060,7 +3053,7 @@ fn parseObject(wasm: *Wasm, obj: link.Input.Object) !void {
30603053}
30613054
30623055fn parseArchive(wasm: *Wasm, obj: link.Input.Object) !void {
3063 log.debug("parseArchive {}", .{obj.path});
3056 log.debug("parseArchive {f}", .{obj.path});
30643057 const gpa = wasm.base.comp.gpa;
30653058 const gc_sections = wasm.base.gc_sections;
30663059
......@@ -3196,7 +3189,7 @@ pub fn updateFunc(
31963189 const is_obj = zcu.comp.config.output_mode == .Obj;
31973190 const target = &zcu.comp.root_mod.resolved_target.result;
31983191 const owner_nav = zcu.funcInfo(func_index).owner_nav;
3199 log.debug("updateFunc {}", .{ip.getNav(owner_nav).fqn.fmt(ip)});
3192 log.debug("updateFunc {f}", .{ip.getNav(owner_nav).fqn.fmt(ip)});
32003193
32013194 // For Wasm, we do not lower the MIR to code just yet. That lowering happens during `flush`,
32023195 // after garbage collection, which can affect function and global indexes, which affects the
......@@ -3307,7 +3300,7 @@ pub fn updateNav(wasm: *Wasm, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index
33073300 .variable => |variable| .{ variable.init, variable.owner_nav },
33083301 else => .{ nav.status.fully_resolved.val, nav_index },
33093302 };
3310 //log.debug("updateNav {} {d}", .{ nav.fqn.fmt(ip), chased_nav_index });
3303 //log.debug("updateNav {f} {d}", .{ nav.fqn.fmt(ip), chased_nav_index });
33113304 assert(!wasm.imports.contains(chased_nav_index));
33123305
33133306 if (nav_init != .none and !Value.fromInterned(nav_init).typeOf(zcu).hasRuntimeBits(zcu)) {
......@@ -4347,7 +4340,7 @@ fn resolveFunctionSynthetic(
43474340 });
43484341 if (import.type != correct_func_type) {
43494342 const diags = &wasm.base.comp.link_diags;
4350 return import.source_location.fail(diags, "synthetic function {s} {} imported with incorrect signature {}", .{
4343 return import.source_location.fail(diags, "synthetic function {s} {f} imported with incorrect signature {f}", .{
43514344 @tagName(res), correct_func_type.fmt(wasm), import.type.fmt(wasm),
43524345 });
43534346 }
src/link/table_section.zig+2-8
......@@ -39,14 +39,8 @@ pub fn TableSection(comptime Entry: type) type {
3939 return self.entries.items.len;
4040 }
4141
42 pub fn format(
43 self: Self,
44 comptime unused_format_string: []const u8,
45 options: std.fmt.FormatOptions,
46 writer: anytype,
47 ) !void {
48 _ = options;
49 comptime assert(unused_format_string.len == 0);
42 pub fn format(self: Self, writer: *std.io.Writer, comptime f: []const u8) std.io.Writer.Error!void {
43 comptime assert(f.len == 0);
5044 try writer.writeAll("TableSection:\n");
5145 for (self.entries.items, 0..) |entry, i| {
5246 try writer.print(" {d} => {}\n", .{ i, entry });
src/main.zig+1-1
......@@ -5296,7 +5296,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
52965296 const s = fs.path.sep_str;
52975297 const tmp_sub_path = "tmp" ++ s ++ results_tmp_file_nonce;
52985298 const stdout = dirs.local_cache.handle.readFileAlloc(arena, tmp_sub_path, 50 * 1024 * 1024) catch |err| {
5299 fatal("unable to read results of configure phase from '{}{s}': {s}", .{
5299 fatal("unable to read results of configure phase from '{f}{s}': {s}", .{
53005300 dirs.local_cache, tmp_sub_path, @errorName(err),
53015301 });
53025302 };
src/print_targets.zig+1-1
......@@ -64,7 +64,7 @@ pub fn cmdTargets(
6464 {
6565 var glibc_obj = try root_obj.beginTupleField("glibc", .{});
6666 for (glibc_abi.all_versions) |ver| {
67 const tmp = try std.fmt.allocPrint(allocator, "{}", .{ver});
67 const tmp = try std.fmt.allocPrint(allocator, "{f}", .{ver});
6868 defer allocator.free(tmp);
6969 try glibc_obj.field(tmp, .{});
7070 }
src/print_value.zig+4-3
......@@ -76,14 +76,15 @@ pub fn print(
7676 .@"extern" => |e| try writer.print("(extern '{f}')", .{e.name.fmt(ip)}),
7777 .func => |func| try writer.print("(function '{f}')", .{ip.getNav(func.owner_nav).name.fmt(ip)}),
7878 .int => |int| switch (int.storage) {
79 inline .u64, .i64, .big_int => |x| try writer.print("{}", .{x}),
79 inline .u64, .i64 => |x| try writer.print("{d}", .{x}),
80 .big_int => |x| try writer.print("{fd}", .{x}),
8081 .lazy_align => |ty| if (opt_sema != null) {
8182 const a = try Type.fromInterned(ty).abiAlignmentSema(pt);
82 try writer.print("{}", .{a.toByteUnits() orelse 0});
83 try writer.print("{d}", .{a.toByteUnits() orelse 0});
8384 } else try writer.print("@alignOf({f})", .{Type.fromInterned(ty).fmt(pt)}),
8485 .lazy_size => |ty| if (opt_sema != null) {
8586 const s = try Type.fromInterned(ty).abiSizeSema(pt);
86 try writer.print("{}", .{s});
87 try writer.print("{d}", .{s});
8788 } else try writer.print("@sizeOf({f})", .{Type.fromInterned(ty).fmt(pt)}),
8889 },
8990 .err => |err| try writer.print("error.{f}", .{
src/print_zir.zig+9-9
......@@ -1212,8 +1212,8 @@ const Writer = struct {
12121212
12131213 const name = self.code.nullTerminatedString(output.data.name);
12141214 const constraint = self.code.nullTerminatedString(output.data.constraint);
1215 try stream.print("output({fp}, \"{f}\", ", .{
1216 std.zig.fmtId(name), std.zig.fmtString(constraint),
1215 try stream.print("output({f}, \"{f}\", ", .{
1216 std.zig.fmtIdP(name), std.zig.fmtString(constraint),
12171217 });
12181218 try self.writeFlag(stream, "->", is_type);
12191219 try self.writeInstRef(stream, output.data.operand);
......@@ -1231,8 +1231,8 @@ const Writer = struct {
12311231
12321232 const name = self.code.nullTerminatedString(input.data.name);
12331233 const constraint = self.code.nullTerminatedString(input.data.constraint);
1234 try stream.print("input({fp}, \"{f}\", ", .{
1235 std.zig.fmtId(name), std.zig.fmtString(constraint),
1234 try stream.print("input({f}, \"{f}\", ", .{
1235 std.zig.fmtIdP(name), std.zig.fmtString(constraint),
12361236 });
12371237 try self.writeInstRef(stream, input.data.operand);
12381238 try stream.writeAll(")");
......@@ -1247,7 +1247,7 @@ const Writer = struct {
12471247 const str_index = self.code.extra[extra_i];
12481248 extra_i += 1;
12491249 const clobber = self.code.nullTerminatedString(@enumFromInt(str_index));
1250 try stream.print("{fp}", .{std.zig.fmtId(clobber)});
1250 try stream.print("{f}", .{std.zig.fmtIdP(clobber)});
12511251 if (i + 1 < clobbers_len) {
12521252 try stream.writeAll(", ");
12531253 }
......@@ -1511,7 +1511,7 @@ const Writer = struct {
15111511 try self.writeFlag(stream, "comptime ", field.is_comptime);
15121512 if (field.name != .empty) {
15131513 const field_name = self.code.nullTerminatedString(field.name);
1514 try stream.print("{fp}: ", .{std.zig.fmtId(field_name)});
1514 try stream.print("{f}: ", .{std.zig.fmtIdP(field_name)});
15151515 } else {
15161516 try stream.print("@\"{d}\": ", .{i});
15171517 }
......@@ -1674,7 +1674,7 @@ const Writer = struct {
16741674 extra_index += 1;
16751675
16761676 try stream.splatByteAll(' ', self.indent);
1677 try stream.print("{fp}", .{std.zig.fmtId(field_name)});
1677 try stream.print("{f}", .{std.zig.fmtIdP(field_name)});
16781678
16791679 if (has_type) {
16801680 const field_type = @as(Zir.Inst.Ref, @enumFromInt(self.code.extra[extra_index]));
......@@ -1808,7 +1808,7 @@ const Writer = struct {
18081808 extra_index += 1;
18091809
18101810 try stream.splatByteAll(' ', self.indent);
1811 try stream.print("{fp}", .{std.zig.fmtId(field_name)});
1811 try stream.print("{f}", .{std.zig.fmtIdP(field_name)});
18121812
18131813 if (has_tag_value) {
18141814 const tag_value_ref = @as(Zir.Inst.Ref, @enumFromInt(self.code.extra[extra_index]));
......@@ -1913,7 +1913,7 @@ const Writer = struct {
19131913 const name_index: Zir.NullTerminatedString = @enumFromInt(self.code.extra[extra_index]);
19141914 const name = self.code.nullTerminatedString(name_index);
19151915 try stream.splatByteAll(' ', self.indent);
1916 try stream.print("{fp},\n", .{std.zig.fmtId(name)});
1916 try stream.print("{f},\n", .{std.zig.fmtIdP(name)});
19171917 }
19181918
19191919 self.indent -= 2;
src/register_manager.zig+8-8
......@@ -149,7 +149,7 @@ pub fn RegisterManager(
149149 /// Only the owner of the `RegisterLock` can unlock the
150150 /// register later.
151151 pub fn lockRegIndex(self: *Self, tracked_index: TrackedIndex) ?RegisterLock {
152 log.debug("locking {f}", .{regAtTrackedIndex(tracked_index)});
152 log.debug("locking {}", .{regAtTrackedIndex(tracked_index)});
153153 if (self.isRegIndexLocked(tracked_index)) {
154154 log.debug(" register already locked", .{});
155155 return null;
......@@ -164,7 +164,7 @@ pub fn RegisterManager(
164164 /// Like `lockReg` but asserts the register was unused always
165165 /// returning a valid lock.
166166 pub fn lockRegIndexAssumeUnused(self: *Self, tracked_index: TrackedIndex) RegisterLock {
167 log.debug("locking asserting free {f}", .{regAtTrackedIndex(tracked_index)});
167 log.debug("locking asserting free {}", .{regAtTrackedIndex(tracked_index)});
168168 assert(!self.isRegIndexLocked(tracked_index));
169169 self.locked_registers.set(tracked_index);
170170 return RegisterLock{ .tracked_index = tracked_index };
......@@ -202,7 +202,7 @@ pub fn RegisterManager(
202202 /// Requires `RegisterLock` to unlock a register.
203203 /// Call `lockReg` to obtain the lock first.
204204 pub fn unlockReg(self: *Self, lock: RegisterLock) void {
205 log.debug("unlocking {f}", .{regAtTrackedIndex(lock.tracked_index)});
205 log.debug("unlocking {}", .{regAtTrackedIndex(lock.tracked_index)});
206206 self.locked_registers.unset(lock.tracked_index);
207207 }
208208
......@@ -238,7 +238,7 @@ pub fn RegisterManager(
238238 if (i < count) return null;
239239
240240 for (regs, insts) |reg, inst| {
241 log.debug("tryAllocReg {f} for inst {f}", .{ reg, inst });
241 log.debug("tryAllocReg {} for inst {f}", .{ reg, inst });
242242 self.markRegAllocated(reg);
243243
244244 if (inst) |tracked_inst| {
......@@ -317,7 +317,7 @@ pub fn RegisterManager(
317317 tracked_index: TrackedIndex,
318318 inst: ?Air.Inst.Index,
319319 ) AllocationError!void {
320 log.debug("getReg {f} for inst {f}", .{ regAtTrackedIndex(tracked_index), inst });
320 log.debug("getReg {} for inst {f}", .{ regAtTrackedIndex(tracked_index), inst });
321321 if (!self.isRegIndexFree(tracked_index)) {
322322 // Move the instruction that was previously there to a
323323 // stack allocation.
......@@ -330,7 +330,7 @@ pub fn RegisterManager(
330330 self.getRegIndexAssumeFree(tracked_index, inst);
331331 }
332332 pub fn getReg(self: *Self, reg: Register, inst: ?Air.Inst.Index) AllocationError!void {
333 log.debug("getting reg: {f}", .{reg});
333 log.debug("getting reg: {}", .{reg});
334334 return self.getRegIndex(indexOfRegIntoTracked(reg) orelse return, inst);
335335 }
336336 pub fn getKnownReg(
......@@ -349,7 +349,7 @@ pub fn RegisterManager(
349349 tracked_index: TrackedIndex,
350350 inst: ?Air.Inst.Index,
351351 ) void {
352 log.debug("getRegAssumeFree {f} for inst {f}", .{ regAtTrackedIndex(tracked_index), inst });
352 log.debug("getRegAssumeFree {} for inst {f}", .{ regAtTrackedIndex(tracked_index), inst });
353353 self.markRegIndexAllocated(tracked_index);
354354
355355 assert(self.isRegIndexFree(tracked_index));
......@@ -364,7 +364,7 @@ pub fn RegisterManager(
364364
365365 /// Marks the specified register as free
366366 pub fn freeRegIndex(self: *Self, tracked_index: TrackedIndex) void {
367 log.debug("freeing register {f}", .{regAtTrackedIndex(tracked_index)});
367 log.debug("freeing register {}", .{regAtTrackedIndex(tracked_index)});
368368 self.registers[tracked_index] = undefined;
369369 self.markRegIndexFree(tracked_index);
370370 }
src/translate_c.zig+4-4
......@@ -3327,7 +3327,7 @@ fn transConstantExpr(c: *Context, scope: *Scope, expr: *const clang.Expr, used:
33273327 return maybeSuppressResult(c, used, as_node);
33283328 },
33293329 else => |kind| {
3330 return fail(c, error.UnsupportedTranslation, expr.getBeginLoc(), "unsupported constant expression kind '{}'", .{kind});
3330 return fail(c, error.UnsupportedTranslation, expr.getBeginLoc(), "unsupported constant expression kind '{f}'", .{kind});
33313331 },
33323332 }
33333333}
......@@ -5832,7 +5832,7 @@ fn zigifyEscapeSequences(ctx: *Context, m: *MacroCtx) ![]const u8 {
58325832 num += c - 'A' + 10;
58335833 },
58345834 else => {
5835 i += std.fmt.printInt(bytes[i..], num, 16, .lower, std.fmt.FormatOptions{ .fill = '0', .width = 2 });
5835 i += std.fmt.printInt(bytes[i..], num, 16, .lower, .{ .fill = '0', .width = 2 });
58365836 num = 0;
58375837 if (c == '\\')
58385838 state = .escape
......@@ -5858,7 +5858,7 @@ fn zigifyEscapeSequences(ctx: *Context, m: *MacroCtx) ![]const u8 {
58585858 };
58595859 num += c - '0';
58605860 } else {
5861 i += std.fmt.printInt(bytes[i..], num, 16, .lower, std.fmt.FormatOptions{ .fill = '0', .width = 2 });
5861 i += std.fmt.printInt(bytes[i..], num, 16, .lower, .{ .fill = '0', .width = 2 });
58625862 num = 0;
58635863 count = 0;
58645864 if (c == '\\')
......@@ -5872,7 +5872,7 @@ fn zigifyEscapeSequences(ctx: *Context, m: *MacroCtx) ![]const u8 {
58725872 }
58735873 }
58745874 if (state == .hex or state == .octal)
5875 i += std.fmt.printInt(bytes[i..], num, 16, .lower, std.fmt.FormatOptions{ .fill = '0', .width = 2 });
5875 i += std.fmt.printInt(bytes[i..], num, 16, .lower, .{ .fill = '0', .width = 2 });
58765876 return bytes[0..i];
58775877}
58785878