authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-07-02 14:05:28-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-07-07 22:43:52-07:00
logd5c97fded5d31114f8fc684938a2de22af929949
treeb54ce623de1c4a43165db4cff8a9e5f7e921ac47
parent3afc6fbac63b31fd250b6cbc4451758e50f85b24

compiler: fix a bunch of format strings


22 files changed, 127 insertions(+), 151 deletions(-)

lib/compiler/aro/aro/Diagnostics.zig+5-6
......@@ -328,8 +328,8 @@ pub fn render(comp: *Compilation, config: std.io.tty.Config) void {
328328 defer m.deinit();
329329 renderMessages(comp, &m);
330330}
331pub fn defaultMsgWriter(config: std.io.tty.Config) MsgWriter {
332 return MsgWriter.init(config);
331pub fn defaultMsgWriter(config: std.io.tty.Config, buffer: []u8) MsgWriter {
332 return MsgWriter.init(config, buffer);
333333}
334334
335335pub fn renderMessages(comp: *Compilation, m: anytype) void {
......@@ -529,16 +529,15 @@ const MsgWriter = struct {
529529 config: std.io.tty.Config,
530530
531531 fn init(config: std.io.tty.Config, buffer: []u8) MsgWriter {
532 std.debug.lockStdErr();
533532 return .{
534 .w = std.fs.stderr().writer(buffer),
533 .w = std.debug.lockStderrWriter(buffer),
535534 .config = config,
536535 };
537536 }
538537
539538 pub fn deinit(m: *MsgWriter) void {
540 m.w.flush() catch {};
541 std.debug.unlockStdErr();
539 std.debug.unlockStderrWriter();
540 m.* = undefined;
542541 }
543542
544543 pub fn print(m: *MsgWriter, comptime fmt: []const u8, args: anytype) void {
lib/compiler/aro/aro/Value.zig+1-1
......@@ -961,7 +961,7 @@ 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("{d}", .{x}),
964 inline else => |x| return w.print("{fd}", .{x}),
965965 },
966966 .float => |repr| switch (repr) {
967967 .f16 => |x| return w.print("{d}", .{@round(@as(f64, @floatCast(x)) * 1000) / 1000}),
lib/std/io/Writer.zig+9-24
......@@ -1981,21 +1981,15 @@ pub fn Hashed(comptime Hasher: type) type {
19811981 .hasher = hasher,
19821982 .writer = .{
19831983 .buffer = buffer,
1984 .vtable = &.{@This().drain},
1984 .vtable = &.{ .drain = @This().drain },
19851985 },
19861986 };
19871987 }
19881988
19891989 fn drain(w: *Writer, data: []const []const u8, splat: usize) Error!usize {
19901990 const this: *@This() = @alignCast(@fieldParentPtr("writer", w));
1991 if (data.len == 0) {
1992 const buf = w.buffered();
1993 try this.out.writeAll(buf);
1994 this.hasher.update(buf);
1995 w.end = 0;
1996 return buf.len;
1997 }
1998 const aux_n = try this.out.writeSplatAux(w.buffered(), data, splat);
1991 const aux = w.buffered();
1992 const aux_n = try this.out.writeSplatHeader(aux, data, splat);
19991993 if (aux_n < w.end) {
20001994 this.hasher.update(w.buffer[0..aux_n]);
20011995 const remaining = w.buffer[aux_n..w.end];
......@@ -2003,29 +1997,20 @@ pub fn Hashed(comptime Hasher: type) type {
20031997 w.end = remaining.len;
20041998 return 0;
20051999 }
2006 this.hasher.update(w.buffered());
2000 this.hasher.update(aux);
20072001 const n = aux_n - w.end;
20082002 w.end = 0;
20092003 var remaining: usize = n;
2010 const short_data = data[0 .. data.len - @intFromBool(splat == 0)];
2011 for (short_data) |slice| {
2012 if (remaining < slice.len) {
2004 for (data[0 .. data.len - 1]) |slice| {
2005 if (remaining <= slice.len) {
20132006 this.hasher.update(slice[0..remaining]);
20142007 return n;
2015 } else {
2016 remaining -= slice.len;
2017 this.hasher.update(slice);
20182008 }
2009 remaining -= slice.len;
2010 this.hasher.update(slice);
20192011 }
2020 const remaining_splat = switch (splat) {
2021 0, 1 => {
2022 assert(remaining == 0);
2023 return n;
2024 },
2025 else => splat - 1,
2026 };
20272012 const pattern = data[data.len - 1];
2028 assert(remaining == remaining_splat * pattern.len);
2013 assert(remaining == splat * pattern.len);
20292014 switch (pattern.len) {
20302015 0 => {
20312016 assert(remaining == 0);
lib/std/zig/llvm/Builder.zig+1-1
......@@ -1262,7 +1262,7 @@ pub const Attribute = union(Kind) {
12621262 try w.writeByte(')');
12631263 },
12641264 .alignstack => |alignment| {
1265 try w.print(" {s}", .{attribute});
1265 try w.print(" {f}", .{attribute});
12661266 const alignment_bytes = alignment.toByteUnits() orelse return;
12671267 switch (data.mode) {
12681268 .pound => try w.print("({d})", .{alignment_bytes}),
src/Builtin.zig+1-1
......@@ -317,7 +317,7 @@ pub fn updateFileOnDisk(file: *File, comp: *Compilation) !void {
317317 if (root_dir.statFile(sub_path)) |stat| {
318318 if (stat.size != file.source.?.len) {
319319 std.log.warn(
320 "the cached file '{f}{s}' had the wrong size. Expected {d}, found {d}. " ++
320 "the cached file '{f}' had the wrong size. Expected {d}, found {d}. " ++
321321 "Overwriting with correct file contents now",
322322 .{ file.path.fmt(comp), file.source.?.len, stat.size },
323323 );
src/Compilation.zig+4-3
......@@ -399,9 +399,8 @@ pub const Path = struct {
399399 const Formatter = struct {
400400 p: Path,
401401 comp: *Compilation,
402 pub fn format(f: Formatter, comptime unused_fmt: []const u8, options: std.fmt.FormatOptions, w: anytype) !void {
402 pub fn format(f: Formatter, w: *std.io.Writer, comptime unused_fmt: []const u8) std.io.Writer.Error!void {
403403 comptime assert(unused_fmt.len == 0);
404 _ = options;
405404 const root_path: []const u8 = switch (f.p.root) {
406405 .zig_lib => f.comp.dirs.zig_lib.path orelse ".",
407406 .global_cache => f.comp.dirs.global_cache.path orelse ".",
......@@ -6034,7 +6033,9 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
60346033 // 24 is RT_MANIFEST
60356034 const resource_type = 24;
60366035
6037 const input = try std.fmt.allocPrint(arena, "{} {} \"{s}\"", .{ resource_id, resource_type, fmtRcEscape(src_path) });
6036 const input = try std.fmt.allocPrint(arena, "{} {} \"{f}\"", .{
6037 resource_id, resource_type, fmtRcEscape(src_path),
6038 });
60386039
60396040 try o_dir.writeFile(.{ .sub_path = rc_basename, .data = input });
60406041
src/Package/Fetch.zig+2-2
......@@ -1079,13 +1079,13 @@ fn initResource(f: *Fetch, uri: std.Uri, server_header_buffer: []u8) RunError!Re
10791079 });
10801080 const notes_start = try eb.reserveNotes(notes_len);
10811081 eb.extra.items[notes_start] = @intFromEnum(try eb.addErrorMessage(.{
1082 .msg = try eb.printString("try .url = \"{;+/}#{}\",", .{ uri, want_oid }),
1082 .msg = try eb.printString("try .url = \"{f;+/}#{f}\",", .{ uri, want_oid }),
10831083 }));
10841084 return error.FetchFailed;
10851085 }
10861086
10871087 var want_oid_buf: [git.Oid.max_formatted_length]u8 = undefined;
1088 _ = std.fmt.bufPrint(&want_oid_buf, "{}", .{want_oid}) catch unreachable;
1088 _ = std.fmt.bufPrint(&want_oid_buf, "{f}", .{want_oid}) catch unreachable;
10891089 var fetch_stream = session.fetch(&.{&want_oid_buf}, server_header_buffer) catch |err| {
10901090 return f.fail(f.location_tok, try eb.printString(
10911091 "unable to create fetch stream: {s}",
src/Package/Fetch/git.zig+10-16
......@@ -119,14 +119,8 @@ pub const Oid = union(Format) {
119119 } else error.InvalidOid;
120120 }
121121
122 pub fn format(
123 oid: Oid,
124 comptime fmt: []const u8,
125 options: std.fmt.FormatOptions,
126 writer: anytype,
127 ) @TypeOf(writer).Error!void {
128 _ = fmt;
129 _ = options;
122 pub fn format(oid: Oid, writer: *std.io.Writer, comptime fmt: []const u8) std.io.Writer.Error!void {
123 comptime assert(fmt.len == 0);
130124 try writer.print("{x}", .{oid.slice()});
131125 }
132126
......@@ -669,13 +663,13 @@ pub const Session = struct {
669663 fn init(allocator: Allocator, uri: std.Uri) !Location {
670664 const scheme = try allocator.dupe(u8, uri.scheme);
671665 errdefer allocator.free(scheme);
672 const user = if (uri.user) |user| try std.fmt.allocPrint(allocator, "{user}", .{user}) else null;
666 const user = if (uri.user) |user| try std.fmt.allocPrint(allocator, "{fuser}", .{user}) else null;
673667 errdefer if (user) |s| allocator.free(s);
674 const password = if (uri.password) |password| try std.fmt.allocPrint(allocator, "{password}", .{password}) else null;
668 const password = if (uri.password) |password| try std.fmt.allocPrint(allocator, "{fpassword}", .{password}) else null;
675669 errdefer if (password) |s| allocator.free(s);
676 const host = if (uri.host) |host| try std.fmt.allocPrint(allocator, "{host}", .{host}) else null;
670 const host = if (uri.host) |host| try std.fmt.allocPrint(allocator, "{fhost}", .{host}) else null;
677671 errdefer if (host) |s| allocator.free(s);
678 const path = try std.fmt.allocPrint(allocator, "{path}", .{uri.path});
672 const path = try std.fmt.allocPrint(allocator, "{fpath}", .{uri.path});
679673 errdefer allocator.free(path);
680674 // The query and fragment are not used as part of the base server URI.
681675 return .{
......@@ -706,7 +700,7 @@ pub const Session = struct {
706700 fn getCapabilities(session: *Session, http_headers_buffer: []u8) !CapabilityIterator {
707701 var info_refs_uri = session.location.uri;
708702 {
709 const session_uri_path = try std.fmt.allocPrint(session.allocator, "{path}", .{session.location.uri.path});
703 const session_uri_path = try std.fmt.allocPrint(session.allocator, "{fpath}", .{session.location.uri.path});
710704 defer session.allocator.free(session_uri_path);
711705 info_refs_uri.path = .{ .percent_encoded = try std.fs.path.resolvePosix(session.allocator, &.{ "/", session_uri_path, "info/refs" }) };
712706 }
......@@ -730,7 +724,7 @@ pub const Session = struct {
730724 if (request.response.status != .ok) return error.ProtocolError;
731725 const any_redirects_occurred = request.redirect_behavior.remaining() < max_redirects;
732726 if (any_redirects_occurred) {
733 const request_uri_path = try std.fmt.allocPrint(session.allocator, "{path}", .{request.uri.path});
727 const request_uri_path = try std.fmt.allocPrint(session.allocator, "{fpath}", .{request.uri.path});
734728 defer session.allocator.free(request_uri_path);
735729 if (!mem.endsWith(u8, request_uri_path, "/info/refs")) return error.UnparseableRedirect;
736730 var new_uri = request.uri;
......@@ -817,7 +811,7 @@ pub const Session = struct {
817811 pub fn listRefs(session: Session, options: ListRefsOptions) !RefIterator {
818812 var upload_pack_uri = session.location.uri;
819813 {
820 const session_uri_path = try std.fmt.allocPrint(session.allocator, "{path}", .{session.location.uri.path});
814 const session_uri_path = try std.fmt.allocPrint(session.allocator, "{fpath}", .{session.location.uri.path});
821815 defer session.allocator.free(session_uri_path);
822816 upload_pack_uri.path = .{ .percent_encoded = try std.fs.path.resolvePosix(session.allocator, &.{ "/", session_uri_path, "git-upload-pack" }) };
823817 }
......@@ -932,7 +926,7 @@ pub const Session = struct {
932926 ) !FetchStream {
933927 var upload_pack_uri = session.location.uri;
934928 {
935 const session_uri_path = try std.fmt.allocPrint(session.allocator, "{path}", .{session.location.uri.path});
929 const session_uri_path = try std.fmt.allocPrint(session.allocator, "{fpath}", .{session.location.uri.path});
936930 defer session.allocator.free(session_uri_path);
937931 upload_pack_uri.path = .{ .percent_encoded = try std.fs.path.resolvePosix(session.allocator, &.{ "/", session_uri_path, "git-upload-pack" }) };
938932 }
src/codegen/c.zig+26-26
......@@ -1563,7 +1563,7 @@ pub const DeclGen = struct {
15631563 .payload => {
15641564 try writer.writeByte('{');
15651565 if (field_ty.hasRuntimeBits(zcu)) {
1566 try writer.print(" .{ } = ", .{fmtIdentSolo(field_name.toSlice(ip))});
1566 try writer.print(" .{f} = ", .{fmtIdentSolo(field_name.toSlice(ip))});
15671567 try dg.renderValue(
15681568 writer,
15691569 Value.fromInterned(un.val),
......@@ -1667,7 +1667,7 @@ pub const DeclGen = struct {
16671667 try writer.writeAll("{(");
16681668 const ptr_ty = ty.slicePtrFieldType(zcu);
16691669 try dg.renderType(writer, ptr_ty);
1670 return writer.print("){f}, {0x}}}", .{
1670 return writer.print("){f}, {0fx}}}", .{
16711671 try dg.fmtIntLiteralHex(.undef_usize, .Other),
16721672 });
16731673 },
......@@ -1972,17 +1972,17 @@ pub const DeclGen = struct {
19721972 const is_mangled = isMangledIdent(extern_name, true);
19731973 const is_export = @"export".extern_name != @"export".main_name;
19741974 if (is_mangled and is_export) {
1975 try w.print(" zig_mangled_export({ }, {s}, {s})", .{
1975 try w.print(" zig_mangled_export({f}, {f}, {f})", .{
19761976 fmtIdentSolo(extern_name),
19771977 fmtStringLiteral(extern_name, null),
19781978 fmtStringLiteral(@"export".main_name.toSlice(ip), null),
19791979 });
19801980 } else if (is_mangled) {
1981 try w.print(" zig_mangled({ }, {s})", .{
1981 try w.print(" zig_mangled({f}, {f})", .{
19821982 fmtIdentSolo(extern_name), fmtStringLiteral(extern_name, null),
19831983 });
19841984 } else if (is_export) {
1985 try w.print(" zig_export({s}, {s})", .{
1985 try w.print(" zig_export({f}, {f})", .{
19861986 fmtStringLiteral(@"export".main_name.toSlice(ip), null),
19871987 fmtStringLiteral(extern_name, null),
19881988 });
......@@ -2210,7 +2210,7 @@ pub const DeclGen = struct {
22102210 .new_local, .local => |i| try w.print("t{d}", .{i}),
22112211 .constant => |uav| try renderUavName(w, uav),
22122212 .nav => |nav| try dg.renderNavName(w, nav),
2213 .identifier => |ident| try w.print("{ }", .{fmtIdentSolo(ident)}),
2213 .identifier => |ident| try w.print("{f}", .{fmtIdentSolo(ident)}),
22142214 else => unreachable,
22152215 }
22162216 }
......@@ -2227,8 +2227,8 @@ pub const DeclGen = struct {
22272227 try dg.renderNavName(w, nav);
22282228 },
22292229 .undef => |ty| try dg.renderUndefValue(w, ty, .Other),
2230 .identifier => |ident| try w.print("{ }", .{fmtIdentSolo(ident)}),
2231 .payload_identifier => |ident| try w.print("{ }.{ }", .{
2230 .identifier => |ident| try w.print("{f}", .{fmtIdentSolo(ident)}),
2231 .payload_identifier => |ident| try w.print("{f}.{f}", .{
22322232 fmtIdentSolo("payload"),
22332233 fmtIdentSolo(ident),
22342234 }),
......@@ -2257,8 +2257,8 @@ pub const DeclGen = struct {
22572257 },
22582258 .nav_ref => |nav| try dg.renderNavName(w, nav),
22592259 .undef => unreachable,
2260 .identifier => |ident| try w.print("(*{ })", .{fmtIdentSolo(ident)}),
2261 .payload_identifier => |ident| try w.print("(*{ }.{ })", .{
2260 .identifier => |ident| try w.print("(*{f})", .{fmtIdentSolo(ident)}),
2261 .payload_identifier => |ident| try w.print("(*{f}.{f})", .{
22622262 fmtIdentSolo("payload"),
22632263 fmtIdentSolo(ident),
22642264 }),
......@@ -2345,7 +2345,7 @@ pub const DeclGen = struct {
23452345 const ip = &zcu.intern_pool;
23462346 const nav = ip.getNav(nav_index);
23472347 if (nav.getExtern(ip)) |@"extern"| {
2348 try writer.print("{ }", .{
2348 try writer.print("{f}", .{
23492349 fmtIdentSolo(ip.getNav(@"extern".owner_nav).name.toSlice(ip)),
23502350 });
23512351 } else {
......@@ -2790,7 +2790,7 @@ pub fn genTypeDecl(
27902790
27912791pub fn genGlobalAsm(zcu: *Zcu, writer: anytype) !void {
27922792 for (zcu.global_assembly.values()) |asm_source| {
2793 try writer.print("__asm({s});\n", .{fmtStringLiteral(asm_source, null)});
2793 try writer.print("__asm({f});\n", .{fmtStringLiteral(asm_source, null)});
27942794 }
27952795}
27962796
......@@ -3063,7 +3063,7 @@ fn genFunc(f: *Function) !void {
30633063 try fwd.writeAll(";\n");
30643064
30653065 if (nav.status.fully_resolved.@"linksection".toSlice(ip)) |s|
3066 try o.writer().print("zig_linksection_fn({s}) ", .{fmtStringLiteral(s, null)});
3066 try o.writer().print("zig_linksection_fn({f}) ", .{fmtStringLiteral(s, null)});
30673067 try o.dg.renderFunctionSignature(
30683068 o.writer(),
30693069 nav_val,
......@@ -3176,7 +3176,7 @@ pub fn genDecl(o: *Object) !void {
31763176 const w = o.writer();
31773177 if (variable.is_threadlocal and !o.dg.mod.single_threaded) try w.writeAll("zig_threadlocal ");
31783178 if (nav.status.fully_resolved.@"linksection".toSlice(&zcu.intern_pool)) |s|
3179 try w.print("zig_linksection({s}) ", .{fmtStringLiteral(s, null)});
3179 try w.print("zig_linksection({f}) ", .{fmtStringLiteral(s, null)});
31803180 try o.dg.renderTypeAndName(
31813181 w,
31823182 nav_ty,
......@@ -3217,7 +3217,7 @@ pub fn genDeclValue(
32173217
32183218 const w = o.writer();
32193219 if (@"linksection".toSlice(&zcu.intern_pool)) |s|
3220 try w.print("zig_linksection({s}) ", .{fmtStringLiteral(s, null)});
3220 try w.print("zig_linksection({f}) ", .{fmtStringLiteral(s, null)});
32213221 try o.dg.renderTypeAndName(w, ty, decl_c_value, Const, alignment, .complete);
32223222 try w.writeAll(" = ");
32233223 try o.dg.renderValue(w, val, .StaticInitializer);
......@@ -3236,7 +3236,7 @@ pub fn genExports(dg: *DeclGen, exported: Zcu.Exported, export_indices: []const
32363236 .uav => |uav| try DeclGen.renderUavName(fwd, Value.fromInterned(uav)),
32373237 }
32383238 try fwd.writeByte(' ');
3239 try fwd.print("{ }", .{fmtIdentSolo(main_name.toSlice(ip))});
3239 try fwd.print("{f}", .{fmtIdentSolo(main_name.toSlice(ip))});
32403240 try fwd.writeByte('\n');
32413241
32423242 const exported_val = exported.getValue(zcu);
......@@ -3266,7 +3266,7 @@ pub fn genExports(dg: *DeclGen, exported: Zcu.Exported, export_indices: []const
32663266 const @"export" = export_index.ptr(zcu);
32673267 try fwd.writeAll("zig_extern ");
32683268 if (@"export".opts.linkage == .weak) try fwd.writeAll("zig_weak_linkage ");
3269 if (@"export".opts.section.toSlice(ip)) |s| try fwd.print("zig_linksection({s}) ", .{
3269 if (@"export".opts.section.toSlice(ip)) |s| try fwd.print("zig_linksection({f}) ", .{
32703270 fmtStringLiteral(s, null),
32713271 });
32723272 const extern_name = @"export".opts.name.toSlice(ip);
......@@ -3281,17 +3281,17 @@ pub fn genExports(dg: *DeclGen, exported: Zcu.Exported, export_indices: []const
32813281 .complete,
32823282 );
32833283 if (is_mangled and is_export) {
3284 try fwd.print(" zig_mangled_export({ }, {s}, {s})", .{
3284 try fwd.print(" zig_mangled_export({f}, {f}, {f})", .{
32853285 fmtIdentSolo(extern_name),
32863286 fmtStringLiteral(extern_name, null),
32873287 fmtStringLiteral(main_name.toSlice(ip), null),
32883288 });
32893289 } else if (is_mangled) {
3290 try fwd.print(" zig_mangled({ }, {s})", .{
3290 try fwd.print(" zig_mangled({f}, {f})", .{
32913291 fmtIdentSolo(extern_name), fmtStringLiteral(extern_name, null),
32923292 });
32933293 } else if (is_export) {
3294 try fwd.print(" zig_export({s}, {s})", .{
3294 try fwd.print(" zig_export({f}, {f})", .{
32953295 fmtStringLiteral(main_name.toSlice(ip), null),
32963296 fmtStringLiteral(extern_name, null),
32973297 });
......@@ -4570,7 +4570,7 @@ fn airCmpLtErrorsLen(f: *Function, inst: Air.Inst.Index) !CValue {
45704570 try f.writeCValue(writer, local, .Other);
45714571 try writer.writeAll(" = ");
45724572 try f.writeCValue(writer, operand, .Other);
4573 try writer.print(" < sizeof({ }) / sizeof(*{0 });\n", .{fmtIdentSolo("zig_errorName")});
4573 try writer.print(" < sizeof({f}) / sizeof(*{0f});\n", .{fmtIdentSolo("zig_errorName")});
45744574 return local;
45754575}
45764576
......@@ -5644,7 +5644,7 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue {
56445644
56455645 try writer.writeAll("__asm");
56465646 if (is_volatile) try writer.writeAll(" volatile");
5647 try writer.print("({s}", .{fmtStringLiteral(fixed_asm_source[0..dst_i], null)});
5647 try writer.print("({f}", .{fmtStringLiteral(fixed_asm_source[0..dst_i], null)});
56485648 }
56495649
56505650 extra_i = constraints_extra_begin;
......@@ -5662,7 +5662,7 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue {
56625662 try writer.writeByte(' ');
56635663 if (!mem.eql(u8, name, "_")) try writer.print("[{s}]", .{name});
56645664 const is_reg = constraint[1] == '{';
5665 try writer.print("{s}(", .{fmtStringLiteral(if (is_reg) "=r" else constraint, null)});
5665 try writer.print("{f}(", .{fmtStringLiteral(if (is_reg) "=r" else constraint, null)});
56665666 if (is_reg) {
56675667 try f.writeCValue(writer, .{ .local = locals_index }, .Other);
56685668 locals_index += 1;
......@@ -5688,7 +5688,7 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue {
56885688
56895689 const is_reg = constraint[0] == '{';
56905690 const input_val = try f.resolveInst(input);
5691 try writer.print("{s}(", .{fmtStringLiteral(if (is_reg) "r" else constraint, null)});
5691 try writer.print("{f}(", .{fmtStringLiteral(if (is_reg) "r" else constraint, null)});
56925692 try f.writeCValue(writer, if (asmInputNeedsLocal(f, constraint, input_val)) local: {
56935693 const input_local_idx = locals_index;
56945694 locals_index += 1;
......@@ -5706,7 +5706,7 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue {
57065706 if (clobber.len == 0) continue;
57075707
57085708 if (clobber_i > 0) try writer.writeByte(',');
5709 try writer.print(" {s}", .{fmtStringLiteral(clobber, null)});
5709 try writer.print(" {f}", .{fmtStringLiteral(clobber, null)});
57105710 }
57115711 try writer.writeAll(");\n");
57125712
......@@ -8160,7 +8160,7 @@ fn StringLiteral(comptime WriterType: type) type {
81608160 cur_len: u64 = 0,
81618161 counting_writer: std.io.CountingWriter(WriterType),
81628162
8163 pub const Error = WriterType.Error;
8163 pub const Error = if (WriterType == *std.io.Writer) error{WriteFailed} else WriterType.Error;
81648164
81658165 const Self = @This();
81668166
src/link.zig+9-9
......@@ -838,7 +838,7 @@ pub const File = struct {
838838 const cached_pp_file_path = the_key.status.success.object_path;
839839 cached_pp_file_path.root_dir.handle.copyFile(cached_pp_file_path.sub_path, emit.root_dir.handle, emit.sub_path, .{}) catch |err| {
840840 const diags = &base.comp.link_diags;
841 return diags.fail("failed to copy '{'}' to '{'}': {s}", .{
841 return diags.fail("failed to copy '{f'}' to '{f'}': {s}", .{
842842 @as(Path, cached_pp_file_path), @as(Path, emit), @errorName(err),
843843 });
844844 };
......@@ -2086,13 +2086,13 @@ fn resolvePathInputLib(
20862086 }) {
20872087 var file = test_path.root_dir.handle.openFile(test_path.sub_path, .{}) catch |err| switch (err) {
20882088 error.FileNotFound => return .no_match,
2089 else => |e| fatal("unable to search for {s} library '{'}': {s}", .{
2089 else => |e| fatal("unable to search for {s} library '{f'}': {s}", .{
20902090 @tagName(link_mode), test_path, @errorName(e),
20912091 }),
20922092 };
20932093 errdefer file.close();
20942094 try ld_script_bytes.resize(gpa, @max(std.elf.MAGIC.len, std.elf.ARMAG.len));
2095 const n = file.preadAll(ld_script_bytes.items, 0) catch |err| fatal("failed to read '{'}': {s}", .{
2095 const n = file.preadAll(ld_script_bytes.items, 0) catch |err| fatal("failed to read '{f'}': {s}", .{
20962096 test_path, @errorName(err),
20972097 });
20982098 const buf = ld_script_bytes.items[0..n];
......@@ -2101,14 +2101,14 @@ fn resolvePathInputLib(
21012101 return finishResolveLibInput(resolved_inputs, test_path, file, link_mode, pq.query);
21022102 }
21032103 const stat = file.stat() catch |err|
2104 fatal("failed to stat {}: {s}", .{ test_path, @errorName(err) });
2104 fatal("failed to stat {f}: {s}", .{ test_path, @errorName(err) });
21052105 const size = std.math.cast(u32, stat.size) orelse
2106 fatal("{}: linker script too big", .{test_path});
2106 fatal("{f}: linker script too big", .{test_path});
21072107 try ld_script_bytes.resize(gpa, size);
21082108 const buf2 = ld_script_bytes.items[n..];
21092109 const n2 = file.preadAll(buf2, n) catch |err|
2110 fatal("failed to read {}: {s}", .{ test_path, @errorName(err) });
2111 if (n2 != buf2.len) fatal("failed to read {}: unexpected end of file", .{test_path});
2110 fatal("failed to read {f}: {s}", .{ test_path, @errorName(err) });
2111 if (n2 != buf2.len) fatal("failed to read {f}: unexpected end of file", .{test_path});
21122112 var diags = Diags.init(gpa);
21132113 defer diags.deinit();
21142114 const ld_script_result = LdScript.parse(gpa, &diags, test_path, ld_script_bytes.items);
......@@ -2128,7 +2128,7 @@ fn resolvePathInputLib(
21282128 }
21292129
21302130 var ld_script = ld_script_result catch |err|
2131 fatal("{}: failed to parse linker script: {s}", .{ test_path, @errorName(err) });
2131 fatal("{f}: failed to parse linker script: {s}", .{ test_path, @errorName(err) });
21322132 defer ld_script.deinit(gpa);
21332133
21342134 try unresolved_inputs.ensureUnusedCapacity(gpa, ld_script.args.len);
......@@ -2159,7 +2159,7 @@ fn resolvePathInputLib(
21592159
21602160 var file = test_path.root_dir.handle.openFile(test_path.sub_path, .{}) catch |err| switch (err) {
21612161 error.FileNotFound => return .no_match,
2162 else => |e| fatal("unable to search for {s} library {}: {s}", .{
2162 else => |e| fatal("unable to search for {s} library {f}: {s}", .{
21632163 @tagName(link_mode), test_path, @errorName(e),
21642164 }),
21652165 };
src/link/C.zig+1-1
......@@ -493,7 +493,7 @@ pub fn flush(self: *C, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: std.P
493493
494494 const file = self.base.file.?;
495495 file.setEndPos(f.file_size) catch |err| return diags.fail("failed to allocate file: {s}", .{@errorName(err)});
496 file.pwritevAll(f.all_buffers.items, 0) catch |err| return diags.fail("failed to write to '{'}': {s}", .{
496 file.pwritevAll(f.all_buffers.items, 0) catch |err| return diags.fail("failed to write to '{f'}': {s}", .{
497497 self.base.emit, @errorName(err),
498498 });
499499}
src/link/Coff.zig+1-1
......@@ -2588,7 +2588,7 @@ fn logSymtab(coff: *Coff) void {
25882588 .DEBUG => unreachable, // TODO
25892589 else => @intFromEnum(sym.section_number),
25902590 };
2591 log.debug(" %{d}: {?s} @{x} in {s}({d}), {s}", .{
2591 log.debug(" %{d}: {s} @{x} in {s}({d}), {s}", .{
25922592 sym_id,
25932593 coff.getSymbolName(.{ .sym_index = @as(u32, @intCast(sym_id)), .file = null }),
25942594 sym.value,
src/link/Elf.zig+8-8
......@@ -3544,7 +3544,7 @@ pub fn addRelaDyn(self: *Elf, opts: RelaDyn) !void {
35443544}
35453545
35463546pub fn addRelaDynAssumeCapacity(self: *Elf, opts: RelaDyn) void {
3547 relocs_log.debug(" {s}: [{x} => {d}({s})] + {x}", .{
3547 relocs_log.debug(" {f}: [{x} => {d}({s})] + {x}", .{
35483548 relocation.fmtRelocType(opts.type, self.getTarget().cpu.arch),
35493549 opts.offset,
35503550 opts.sym,
......@@ -3791,7 +3791,7 @@ fn reportUndefinedSymbols(self: *Elf, undefs: anytype) !void {
37913791 for (refs.items[0..nrefs]) |ref| {
37923792 const atom_ptr = self.atom(ref).?;
37933793 const file_ptr = atom_ptr.file(self).?;
3794 err.addNote("referenced by {s}:{s}", .{ file_ptr.fmtPath(), atom_ptr.name(self) });
3794 err.addNote("referenced by {f}:{s}", .{ file_ptr.fmtPath(), atom_ptr.name(self) });
37953795 }
37963796
37973797 if (refs.items.len > max_notes) {
......@@ -4020,19 +4020,19 @@ fn fmtDumpState(self: *Elf, writer: *std.io.Writer) std.io.Writer.Error!void {
40204020 {
40214021 try writer.writeAll("atom lists\n");
40224022 for (slice.items(.shdr), slice.items(.atom_list_2), 0..) |shdr, atom_list, shndx| {
4023 try writer.print("shdr({d}) : {s} : {}\n", .{ shndx, self.getShString(shdr.sh_name), atom_list.fmt(self) });
4023 try writer.print("shdr({d}) : {s} : {f}\n", .{ shndx, self.getShString(shdr.sh_name), atom_list.fmt(self) });
40244024 }
40254025 }
40264026
40274027 if (self.requiresThunks()) {
40284028 try writer.writeAll("thunks\n");
40294029 for (self.thunks.items, 0..) |th, index| {
4030 try writer.print("thunk({d}) : {}\n", .{ index, th.fmt(self) });
4030 try writer.print("thunk({d}) : {f}\n", .{ index, th.fmt(self) });
40314031 }
40324032 }
40334033
4034 try writer.print("{}\n", .{self.got.fmt(self)});
4035 try writer.print("{}\n", .{self.plt.fmt(self)});
4034 try writer.print("{f}\n", .{self.got.fmt(self)});
4035 try writer.print("{f}\n", .{self.plt.fmt(self)});
40364036
40374037 try writer.writeAll("Output groups\n");
40384038 for (self.group_sections.items) |cg| {
......@@ -4041,7 +4041,7 @@ fn fmtDumpState(self: *Elf, writer: *std.io.Writer) std.io.Writer.Error!void {
40414041
40424042 try writer.writeAll("\nOutput merge sections\n");
40434043 for (self.merge_sections.items) |msec| {
4044 try writer.print(" shdr({d}) : {}\n", .{ msec.output_section_index, msec.fmt(self) });
4044 try writer.print(" shdr({d}) : {f}\n", .{ msec.output_section_index, msec.fmt(self) });
40454045 }
40464046
40474047 try writer.writeAll("\nOutput shdrs\n");
......@@ -4424,7 +4424,7 @@ fn createThunks(elf_file: *Elf, atom_list: *AtomList) !void {
44244424
44254425 thunk_ptr.value = try advance(atom_list, thunk_ptr.size(elf_file), Atom.Alignment.fromNonzeroByteUnits(2));
44264426
4427 log.debug("thunk({d}) : {}", .{ thunk_index, thunk_ptr.fmt(elf_file) });
4427 log.debug("thunk({d}) : {f}", .{ thunk_index, thunk_ptr.fmt(elf_file) });
44284428 }
44294429}
44304430
src/link/Elf/Atom.zig+2-2
......@@ -243,7 +243,7 @@ pub fn writeRelocs(self: Atom, elf_file: *Elf, out_relocs: *std.ArrayList(elf.El
243243 },
244244 }
245245
246 relocs_log.debug(" {s}: [{x} => {d}({s})] + {x}", .{
246 relocs_log.debug(" {f}: [{x} => {d}({s})] + {x}", .{
247247 relocation.fmtRelocType(rel.r_type(), cpu_arch),
248248 r_offset,
249249 r_sym,
......@@ -652,7 +652,7 @@ pub fn resolveRelocsAlloc(self: Atom, elf_file: *Elf, code: []u8) RelocError!voi
652652 // Address of the dynamic thread pointer.
653653 const DTP = elf_file.dtpAddress();
654654
655 relocs_log.debug(" {s}: {x}: [{x} => {x}] GOT({x}) ({s})", .{
655 relocs_log.debug(" {f}: {x}: [{x} => {x}] GOT({x}) ({s})", .{
656656 relocation.fmtRelocType(rel.r_type(), cpu_arch),
657657 r_offset,
658658 P,
src/link/Elf/Object.zig+7-10
......@@ -488,10 +488,7 @@ fn parseEhFrame(
488488 if (cie.offset == cie_ptr) break @as(u32, @intCast(cie_index));
489489 } else {
490490 // TODO convert into an error
491 log.debug("{s}: no matching CIE found for FDE at offset {x}", .{
492 self.fmtPath(),
493 fde.offset,
494 });
491 log.debug("{f}: no matching CIE found for FDE at offset {x}", .{ self.fmtPath(), fde.offset });
495492 continue;
496493 };
497494 fde.cie_index = cie_index;
......@@ -582,7 +579,7 @@ pub fn scanRelocs(self: *Object, elf_file: *Elf, undefs: anytype) !void {
582579 if (sym.flags.import) {
583580 if (sym.type(elf_file) != elf.STT_FUNC)
584581 // TODO convert into an error
585 log.debug("{s}: {s}: CIE referencing external data reference", .{
582 log.debug("{f}: {s}: CIE referencing external data reference", .{
586583 self.fmtPath(), sym.name(elf_file),
587584 });
588585 sym.flags.needs_plt = true;
......@@ -1448,14 +1445,14 @@ const Format = struct {
14481445 const elf_file = f.elf_file;
14491446 try writer.writeAll(" locals\n");
14501447 for (object.locals()) |sym| {
1451 try writer.print(" {}\n", .{sym.fmt(elf_file)});
1448 try writer.print(" {f}\n", .{sym.fmt(elf_file)});
14521449 }
14531450 try writer.writeAll(" globals\n");
14541451 for (object.globals(), 0..) |sym, i| {
14551452 const first_global = object.first_global.?;
14561453 const ref = object.resolveSymbol(@intCast(i + first_global), elf_file);
14571454 if (elf_file.symbol(ref)) |ref_sym| {
1458 try writer.print(" {}\n", .{ref_sym.fmt(elf_file)});
1455 try writer.print(" {f}\n", .{ref_sym.fmt(elf_file)});
14591456 } else {
14601457 try writer.print(" {s} : unclaimed\n", .{sym.name(elf_file)});
14611458 }
......@@ -1467,7 +1464,7 @@ const Format = struct {
14671464 try writer.writeAll(" atoms\n");
14681465 for (object.atoms_indexes.items) |atom_index| {
14691466 const atom_ptr = object.atom(atom_index) orelse continue;
1470 try writer.print(" {}\n", .{atom_ptr.fmt(f.elf_file)});
1467 try writer.print(" {f}\n", .{atom_ptr.fmt(f.elf_file)});
14711468 }
14721469 }
14731470
......@@ -1475,7 +1472,7 @@ const Format = struct {
14751472 const object = f.object;
14761473 try writer.writeAll(" cies\n");
14771474 for (object.cies.items, 0..) |cie, i| {
1478 try writer.print(" cie({d}) : {}\n", .{ i, cie.fmt(f.elf_file) });
1475 try writer.print(" cie({d}) : {f}\n", .{ i, cie.fmt(f.elf_file) });
14791476 }
14801477 }
14811478
......@@ -1483,7 +1480,7 @@ const Format = struct {
14831480 const object = f.object;
14841481 try writer.writeAll(" fdes\n");
14851482 for (object.fdes.items, 0..) |fde, i| {
1486 try writer.print(" fde({d}) : {}\n", .{ i, fde.fmt(f.elf_file) });
1483 try writer.print(" fde({d}) : {f}\n", .{ i, fde.fmt(f.elf_file) });
14871484 }
14881485 }
14891486
src/link/Elf/ZigObject.zig+14-14
......@@ -925,7 +925,7 @@ pub fn getNavVAddr(
925925 const zcu = pt.zcu;
926926 const ip = &zcu.intern_pool;
927927 const nav = ip.getNav(nav_index);
928 log.debug("getNavVAddr {}({d})", .{ nav.fqn.fmt(ip), nav_index });
928 log.debug("getNavVAddr {f}({d})", .{ nav.fqn.fmt(ip), nav_index });
929929 const this_sym_index = if (nav.getExtern(ip)) |@"extern"| try self.getGlobalSymbol(
930930 elf_file,
931931 nav.name.toSlice(ip),
......@@ -1268,7 +1268,7 @@ fn updateNavCode(
12681268 const ip = &zcu.intern_pool;
12691269 const nav = ip.getNav(nav_index);
12701270
1271 log.debug("updateNavCode {}({d})", .{ nav.fqn.fmt(ip), nav_index });
1271 log.debug("updateNavCode {f}({d})", .{ nav.fqn.fmt(ip), nav_index });
12721272
12731273 const target = &zcu.navFileScope(nav_index).mod.?.resolved_target.result;
12741274 const required_alignment = switch (pt.navAlignment(nav_index)) {
......@@ -1302,7 +1302,7 @@ fn updateNavCode(
13021302 self.allocateAtom(atom_ptr, true, elf_file) catch |err|
13031303 return elf_file.base.cgFail(nav_index, "failed to allocate atom: {s}", .{@errorName(err)});
13041304
1305 log.debug("growing {} from 0x{x} to 0x{x}", .{ nav.fqn.fmt(ip), old_vaddr, atom_ptr.value });
1305 log.debug("growing {f} from 0x{x} to 0x{x}", .{ nav.fqn.fmt(ip), old_vaddr, atom_ptr.value });
13061306 if (old_vaddr != atom_ptr.value) {
13071307 sym.value = 0;
13081308 esym.st_value = 0;
......@@ -1347,7 +1347,7 @@ fn updateNavCode(
13471347 const file_offset = atom_ptr.offset(elf_file);
13481348 elf_file.base.file.?.pwriteAll(code, file_offset) catch |err|
13491349 return elf_file.base.cgFail(nav_index, "failed to write to output file: {s}", .{@errorName(err)});
1350 log.debug("writing {} from 0x{x} to 0x{x}", .{ nav.fqn.fmt(ip), file_offset, file_offset + code.len });
1350 log.debug("writing {f} from 0x{x} to 0x{x}", .{ nav.fqn.fmt(ip), file_offset, file_offset + code.len });
13511351 }
13521352}
13531353
......@@ -1365,7 +1365,7 @@ fn updateTlv(
13651365 const gpa = zcu.gpa;
13661366 const nav = ip.getNav(nav_index);
13671367
1368 log.debug("updateTlv {}({d})", .{ nav.fqn.fmt(ip), nav_index });
1368 log.debug("updateTlv {f}({d})", .{ nav.fqn.fmt(ip), nav_index });
13691369
13701370 const required_alignment = pt.navAlignment(nav_index);
13711371
......@@ -1424,7 +1424,7 @@ pub fn updateFunc(
14241424 const gpa = elf_file.base.comp.gpa;
14251425 const func = zcu.funcInfo(func_index);
14261426
1427 log.debug("updateFunc {}({d})", .{ ip.getNav(func.owner_nav).fqn.fmt(ip), func.owner_nav });
1427 log.debug("updateFunc {f}({d})", .{ ip.getNav(func.owner_nav).fqn.fmt(ip), func.owner_nav });
14281428
14291429 const sym_index = try self.getOrCreateMetadataForNav(zcu, func.owner_nav);
14301430 self.atom(self.symbol(sym_index).ref.index).?.freeRelocs(self);
......@@ -1447,7 +1447,7 @@ pub fn updateFunc(
14471447 const code = code_buffer.items;
14481448
14491449 const shndx = try self.getNavShdrIndex(elf_file, zcu, func.owner_nav, sym_index, code);
1450 log.debug("setting shdr({x},{s}) for {}", .{
1450 log.debug("setting shdr({x},{s}) for {f}", .{
14511451 shndx,
14521452 elf_file.getShString(elf_file.sections.items(.shdr)[shndx].sh_name),
14531453 ip.getNav(func.owner_nav).fqn.fmt(ip),
......@@ -1529,7 +1529,7 @@ pub fn updateNav(
15291529 const ip = &zcu.intern_pool;
15301530 const nav = ip.getNav(nav_index);
15311531
1532 log.debug("updateNav {}({d})", .{ nav.fqn.fmt(ip), nav_index });
1532 log.debug("updateNav {f}({d})", .{ nav.fqn.fmt(ip), nav_index });
15331533
15341534 const nav_init = switch (ip.indexToKey(nav.status.fully_resolved.val)) {
15351535 .func => .none,
......@@ -1576,7 +1576,7 @@ pub fn updateNav(
15761576 const code = code_buffer.items;
15771577
15781578 const shndx = try self.getNavShdrIndex(elf_file, zcu, nav_index, sym_index, code);
1579 log.debug("setting shdr({x},{s}) for {}", .{
1579 log.debug("setting shdr({x},{s}) for {f}", .{
15801580 shndx,
15811581 elf_file.getShString(elf_file.sections.items(.shdr)[shndx].sh_name),
15821582 nav.fqn.fmt(ip),
......@@ -1622,7 +1622,7 @@ fn updateLazySymbol(
16221622 defer code_buffer.deinit(gpa);
16231623
16241624 const name_str_index = blk: {
1625 const name = try std.fmt.allocPrint(gpa, "__lazy_{s}_{}", .{
1625 const name = try std.fmt.allocPrint(gpa, "__lazy_{s}_{f}", .{
16261626 @tagName(sym.kind),
16271627 Type.fromInterned(sym.ty).fmt(pt),
16281628 });
......@@ -1941,7 +1941,7 @@ pub fn allocateAtom(self: *ZigObject, atom_ptr: *Atom, requires_padding: bool, e
19411941 .requires_padding = requires_padding,
19421942 });
19431943 atom_ptr.value = @intCast(alloc_res.value);
1944 log.debug("allocated {s} at {x}\n placement {?}", .{
1944 log.debug("allocated {s} at {x}\n placement {f}", .{
19451945 atom_ptr.name(elf_file),
19461946 atom_ptr.offset(elf_file),
19471947 alloc_res.placement,
......@@ -1986,7 +1986,7 @@ pub fn allocateAtom(self: *ZigObject, atom_ptr: *Atom, requires_padding: bool, e
19861986 atom_ptr.next_atom_ref = .{ .index = 0, .file = 0 };
19871987 }
19881988
1989 log.debug(" prev {?}, next {?}", .{ atom_ptr.prev_atom_ref, atom_ptr.next_atom_ref });
1989 log.debug(" prev {f}, next {f}", .{ atom_ptr.prev_atom_ref, atom_ptr.next_atom_ref });
19901990}
19911991
19921992pub fn resetShdrIndexes(self: *ZigObject, backlinks: []const u32) void {
......@@ -2271,7 +2271,7 @@ fn checkNavAllocated(pt: Zcu.PerThread, index: InternPool.Nav.Index, meta: AvMet
22712271 const zcu = pt.zcu;
22722272 const ip = &zcu.intern_pool;
22732273 const nav = ip.getNav(index);
2274 log.err("NAV {}({d}) assigned symbol {d} but not allocated!", .{
2274 log.err("NAV {f}({d}) assigned symbol {d} but not allocated!", .{
22752275 nav.fqn.fmt(ip),
22762276 index,
22772277 meta.symbol_index,
......@@ -2284,7 +2284,7 @@ fn checkUavAllocated(pt: Zcu.PerThread, index: InternPool.Index, meta: AvMetadat
22842284 const zcu = pt.zcu;
22852285 const uav = Value.fromInterned(index);
22862286 const ty = uav.typeOf(zcu);
2287 log.err("UAV {}({d}) assigned symbol {d} but not allocated!", .{
2287 log.err("UAV {f}({d}) assigned symbol {d} but not allocated!", .{
22882288 ty.fmt(pt),
22892289 index,
22902290 meta.symbol_index,
src/link/Elf/eh_frame.zig+2-2
......@@ -276,7 +276,7 @@ fn resolveReloc(rec: anytype, sym: *const Symbol, rel: elf.Elf64_Rela, elf_file:
276276 const S = math.cast(i64, sym.address(.{}, elf_file)) orelse return error.Overflow;
277277 const A = rel.r_addend;
278278
279 relocs_log.debug(" {s}: {x}: [{x} => {x}] ({s})", .{
279 relocs_log.debug(" {f}: {x}: [{x} => {x}] ({s})", .{
280280 relocation.fmtRelocType(rel.r_type(), cpu_arch),
281281 offset,
282282 P,
......@@ -398,7 +398,7 @@ fn emitReloc(elf_file: *Elf, r_offset: u64, sym: *const Symbol, rel: elf.Elf64_R
398398 },
399399 }
400400
401 relocs_log.debug(" {s}: [{x} => {d}({s})] + {x}", .{
401 relocs_log.debug(" {f}: [{x} => {d}({s})] + {x}", .{
402402 relocation.fmtRelocType(r_type, cpu_arch),
403403 r_offset,
404404 r_sym,
src/link/Elf/synthetic_sections.zig+1-1
......@@ -696,7 +696,7 @@ pub const PltSection = struct {
696696 const r_sym: u64 = extra.dynamic;
697697 const r_type = relocation.encode(.jump_slot, cpu_arch);
698698
699 relocs_log.debug(" {s}: [{x} => {d}({s})] + 0", .{
699 relocs_log.debug(" {f}: [{x} => {d}({s})] + 0", .{
700700 relocation.fmtRelocType(r_type, cpu_arch),
701701 r_offset,
702702 r_sym,
src/link/MachO/Atom.zig+1-1
......@@ -653,7 +653,7 @@ fn resolveRelocInner(
653653 const divExact = struct {
654654 fn divExact(atom: Atom, r: Relocation, num: u12, den: u12, ctx: *MachO) !u12 {
655655 return math.divExact(u12, num, den) catch {
656 try ctx.reportParseError2(atom.getFile(ctx).getIndex(), "{s}: unexpected remainder when resolving {s} at offset 0x{x}", .{
656 try ctx.reportParseError2(atom.getFile(ctx).getIndex(), "{s}: unexpected remainder when resolving {f} at offset 0x{x}", .{
657657 atom.getName(ctx),
658658 r.fmtPretty(ctx.getTarget().cpu.arch),
659659 r.offset,
src/link/MachO/dyld_info/bind.zig+2-2
......@@ -205,7 +205,7 @@ pub const Bind = struct {
205205 }
206206 }
207207
208 log.debug("{x}, {d}, {x}, {?x}, {s}", .{ offset, count, skip, addend, @tagName(state) });
208 log.debug("{x}, {d}, {x}, {x}, {s}", .{ offset, count, skip, addend, @tagName(state) });
209209 log.debug(" => {x}", .{current.offset});
210210 switch (state) {
211211 .start => {
......@@ -447,7 +447,7 @@ pub const WeakBind = struct {
447447 }
448448 }
449449
450 log.debug("{x}, {d}, {x}, {?x}, {s}", .{ offset, count, skip, addend, @tagName(state) });
450 log.debug("{x}, {d}, {x}, {x}, {s}", .{ offset, count, skip, addend, @tagName(state) });
451451 log.debug(" => {x}", .{current.offset});
452452 switch (state) {
453453 .start => {
src/link/Wasm/Flush.zig+1-1
......@@ -534,7 +534,7 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void {
534534 wasm.memories.limits.max = @intCast(max_memory / page_size);
535535 wasm.memories.limits.flags.has_max = true;
536536 if (shared_memory) wasm.memories.limits.flags.is_shared = true;
537 log.debug("maximum memory pages: {?d}", .{wasm.memories.limits.max});
537 log.debug("maximum memory pages: {d}", .{wasm.memories.limits.max});
538538 }
539539 f.memory_layout_finished = true;
540540
src/print_value.zig+19-19
......@@ -73,35 +73,35 @@ pub fn print(
7373 else => try writer.writeAll(@tagName(simple_value)),
7474 },
7575 .variable => try writer.writeAll("(variable)"),
76 .@"extern" => |e| try writer.print("(extern '{}')", .{e.name.fmt(ip)}),
77 .func => |func| try writer.print("(function '{}')", .{ip.getNav(func.owner_nav).name.fmt(ip)}),
76 .@"extern" => |e| try writer.print("(extern '{f}')", .{e.name.fmt(ip)}),
77 .func => |func| try writer.print("(function '{f}')", .{ip.getNav(func.owner_nav).name.fmt(ip)}),
7878 .int => |int| switch (int.storage) {
7979 inline .u64, .i64, .big_int => |x| try writer.print("{}", .{x}),
8080 .lazy_align => |ty| if (opt_sema != null) {
8181 const a = try Type.fromInterned(ty).abiAlignmentSema(pt);
8282 try writer.print("{}", .{a.toByteUnits() orelse 0});
83 } else try writer.print("@alignOf({})", .{Type.fromInterned(ty).fmt(pt)}),
83 } else try writer.print("@alignOf({f})", .{Type.fromInterned(ty).fmt(pt)}),
8484 .lazy_size => |ty| if (opt_sema != null) {
8585 const s = try Type.fromInterned(ty).abiSizeSema(pt);
8686 try writer.print("{}", .{s});
87 } else try writer.print("@sizeOf({})", .{Type.fromInterned(ty).fmt(pt)}),
87 } else try writer.print("@sizeOf({f})", .{Type.fromInterned(ty).fmt(pt)}),
8888 },
89 .err => |err| try writer.print("error.{}", .{
89 .err => |err| try writer.print("error.{f}", .{
9090 err.name.fmt(ip),
9191 }),
9292 .error_union => |error_union| switch (error_union.val) {
93 .err_name => |err_name| try writer.print("error.{}", .{
93 .err_name => |err_name| try writer.print("error.{f}", .{
9494 err_name.fmt(ip),
9595 }),
9696 .payload => |payload| try print(Value.fromInterned(payload), writer, level, pt, opt_sema),
9797 },
98 .enum_literal => |enum_literal| try writer.print(".{}", .{
98 .enum_literal => |enum_literal| try writer.print(".{f}", .{
9999 enum_literal.fmt(ip),
100100 }),
101101 .enum_tag => |enum_tag| {
102102 const enum_type = ip.loadEnumType(val.typeOf(zcu).toIntern());
103103 if (enum_type.tagValueIndex(ip, val.toIntern())) |tag_index| {
104 return writer.print(".{i}", .{enum_type.names.get(ip)[tag_index].fmt(ip)});
104 return writer.print(".{fi}", .{enum_type.names.get(ip)[tag_index].fmt(ip)});
105105 }
106106 if (level == 0) {
107107 return writer.writeAll("@enumFromInt(...)");
......@@ -164,7 +164,7 @@ pub fn print(
164164 }
165165 if (un.tag == .none) {
166166 const backing_ty = try val.typeOf(zcu).unionBackingType(pt);
167 try writer.print("@bitCast(@as({}, ", .{backing_ty.fmt(pt)});
167 try writer.print("@bitCast(@as({f}, ", .{backing_ty.fmt(pt)});
168168 try print(Value.fromInterned(un.val), writer, level - 1, pt, opt_sema);
169169 try writer.writeAll("))");
170170 } else {
......@@ -206,7 +206,7 @@ fn printAggregate(
206206 for (0..max_len) |i| {
207207 if (i != 0) try writer.writeAll(", ");
208208 const field_name = ty.structFieldName(@intCast(i), zcu).unwrap().?;
209 try writer.print(".{i} = ", .{field_name.fmt(ip)});
209 try writer.print(".{fi} = ", .{field_name.fmt(ip)});
210210 try print(try val.fieldValue(pt, i), writer, level - 1, pt, opt_sema);
211211 }
212212 try writer.writeAll(" }");
......@@ -391,14 +391,14 @@ pub fn printPtrDerivation(
391391 const agg_ty = (try field.parent.ptrType(pt)).childType(zcu);
392392 switch (agg_ty.zigTypeTag(zcu)) {
393393 .@"struct" => if (agg_ty.structFieldName(field.field_idx, zcu).unwrap()) |field_name| {
394 try writer.print(".{i}", .{field_name.fmt(ip)});
394 try writer.print(".{fi}", .{field_name.fmt(ip)});
395395 } else {
396396 try writer.print("[{d}]", .{field.field_idx});
397397 },
398398 .@"union" => {
399399 const tag_ty = agg_ty.unionTagTypeHypothetical(zcu);
400400 const field_name = tag_ty.enumFieldName(field.field_idx, zcu);
401 try writer.print(".{i}", .{field_name.fmt(ip)});
401 try writer.print(".{fi}", .{field_name.fmt(ip)});
402402 },
403403 .pointer => switch (field.field_idx) {
404404 Value.slice_ptr_index => try writer.writeAll(".ptr"),
......@@ -416,12 +416,12 @@ pub fn printPtrDerivation(
416416 },
417417
418418 .offset_and_cast => |oac| if (oac.byte_offset == 0) root: {
419 try writer.print("@as({}, @ptrCast(", .{oac.new_ptr_ty.fmt(pt)});
419 try writer.print("@as({f}, @ptrCast(", .{oac.new_ptr_ty.fmt(pt)});
420420 const root = try printPtrDerivation(oac.parent.*, writer, pt, .rvalue, root_strat, ptr_depth - 1);
421421 try writer.writeAll("))");
422422 break :root root;
423423 } else root: {
424 try writer.print("@as({}, @ptrFromInt(@intFromPtr(", .{oac.new_ptr_ty.fmt(pt)});
424 try writer.print("@as({f}, @ptrFromInt(@intFromPtr(", .{oac.new_ptr_ty.fmt(pt)});
425425 const root = try printPtrDerivation(oac.parent.*, writer, pt, .rvalue, root_strat, ptr_depth - 1);
426426 try writer.print(") + {d}))", .{oac.byte_offset});
427427 break :root root;
......@@ -433,22 +433,22 @@ pub fn printPtrDerivation(
433433 if (root_or_null == null) switch (root_strat) {
434434 .str => |x| try writer.writeAll(x),
435435 .print_val => |x| switch (derivation) {
436 .int => |int| try writer.print("@as({}, @ptrFromInt(0x{x}))", .{ int.ptr_ty.fmt(pt), int.addr }),
437 .nav_ptr => |nav| try writer.print("{}", .{ip.getNav(nav).fqn.fmt(ip)}),
436 .int => |int| try writer.print("@as({f}, @ptrFromInt(0x{x}))", .{ int.ptr_ty.fmt(pt), int.addr }),
437 .nav_ptr => |nav| try writer.print("{f}", .{ip.getNav(nav).fqn.fmt(ip)}),
438438 .uav_ptr => |uav| {
439439 const ty = Value.fromInterned(uav.val).typeOf(zcu);
440 try writer.print("@as({}, ", .{ty.fmt(pt)});
440 try writer.print("@as({f}, ", .{ty.fmt(pt)});
441441 try print(Value.fromInterned(uav.val), writer, x.level - 1, pt, x.opt_sema);
442442 try writer.writeByte(')');
443443 },
444444 .comptime_alloc_ptr => |info| {
445 try writer.print("@as({}, ", .{info.val.typeOf(zcu).fmt(pt)});
445 try writer.print("@as({f}, ", .{info.val.typeOf(zcu).fmt(pt)});
446446 try print(info.val, writer, x.level - 1, pt, x.opt_sema);
447447 try writer.writeByte(')');
448448 },
449449 .comptime_field_ptr => |val| {
450450 const ty = val.typeOf(zcu);
451 try writer.print("@as({}, ", .{ty.fmt(pt)});
451 try writer.print("@as({f}, ", .{ty.fmt(pt)});
452452 try print(val, writer, x.level - 1, pt, x.opt_sema);
453453 try writer.writeByte(')');
454454 },