Merge pull request #25088 from ziglang/delete-deprecated-fmt

std.fmt: delete deprecated APIs
This commit is contained in:
Andrew Kelley 2025-08-31 19:28:21 -07:00 committed by GitHub
commit 4c01a6553a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
58 changed files with 128 additions and 176 deletions

View File

@ -470,7 +470,7 @@ pub fn renderMessage(comp: *Compilation, m: anytype, msg: Message) void {
}
}.f;
printRt(m, prop.msg, .{"{f}"}, .{
std.fmt.Formatter([]const u8, f){ .data = msg.extra.normalized },
std.fmt.Alt([]const u8, f){ .data = msg.extra.normalized },
});
},
.none, .offset => m.write(prop.msg),

View File

@ -433,7 +433,7 @@ pub const ErrorDetails = struct {
code_page: SupportedCodePage,
};
fn fmtToken(self: ErrorDetails, source: []const u8) std.fmt.Formatter(TokenFormatContext, formatToken) {
fn fmtToken(self: ErrorDetails, source: []const u8) std.fmt.Alt(TokenFormatContext, formatToken) {
return .{ .data = .{
.token = self.token,
.code_page = self.code_page,

View File

@ -465,7 +465,7 @@ pub const NameOrOrdinal = union(enum) {
}
}
pub fn fmtResourceType(type_value: NameOrOrdinal) std.fmt.Formatter(NameOrOrdinal, formatResourceType) {
pub fn fmtResourceType(type_value: NameOrOrdinal) std.fmt.Alt(NameOrOrdinal, formatResourceType) {
return .{ .data = type_value };
}
};

View File

@ -231,7 +231,7 @@ pub fn renderInlineNodeText(
}
}
pub fn fmtHtml(bytes: []const u8) std.fmt.Formatter([]const u8, formatHtml) {
pub fn fmtHtml(bytes: []const u8) std.fmt.Alt([]const u8, formatHtml) {
return .{ .data = bytes };
}

View File

@ -147,7 +147,7 @@ pub fn toStringZ(p: Path, allocator: Allocator) Allocator.Error![:0]u8 {
return std.fmt.allocPrintSentinel(allocator, "{f}", .{p}, 0);
}
pub fn fmtEscapeString(path: Path) std.fmt.Formatter(Path, formatEscapeString) {
pub fn fmtEscapeString(path: Path) std.fmt.Alt(Path, formatEscapeString) {
return .{ .data = path };
}
@ -162,7 +162,7 @@ pub fn formatEscapeString(path: Path, writer: *std.Io.Writer) std.Io.Writer.Erro
}
/// Deprecated, use double quoted escape to print paths.
pub fn fmtEscapeChar(path: Path) std.fmt.Formatter(Path, formatEscapeChar) {
pub fn fmtEscapeChar(path: Path) std.fmt.Alt(Path, formatEscapeChar) {
return .{ .data = path };
}

View File

@ -595,7 +595,7 @@ fn make(step: *Step, make_options: Step.MakeOptions) !void {
// we either format message string with escaped codes, or not to aid debugging
// the failed test.
const fmtMessageString = struct {
fn fmtMessageString(kind: Check.Kind, msg: []const u8) std.fmt.Formatter(Ctx, formatMessageString) {
fn fmtMessageString(kind: Check.Kind, msg: []const u8) std.fmt.Alt(Ctx, formatMessageString) {
return .{ .data = .{
.kind = kind,
.msg = msg,
@ -2281,7 +2281,7 @@ const ElfDumper = struct {
return mem.sliceTo(@as([*:0]const u8, @ptrCast(strtab.ptr + off)), 0);
}
fn fmtShType(sh_type: u32) std.fmt.Formatter(u32, formatShType) {
fn fmtShType(sh_type: u32) std.fmt.Alt(u32, formatShType) {
return .{ .data = sh_type };
}
@ -2321,7 +2321,7 @@ const ElfDumper = struct {
try writer.writeAll(name);
}
fn fmtPhType(ph_type: u32) std.fmt.Formatter(u32, formatPhType) {
fn fmtPhType(ph_type: u32) std.fmt.Alt(u32, formatPhType) {
return .{ .data = ph_type };
}

View File

@ -1025,7 +1025,7 @@ fn formatTerm(term: ?std.process.Child.Term, w: *std.Io.Writer) std.Io.Writer.Er
try w.writeAll("exited with any code");
}
}
fn fmtTerm(term: ?std.process.Child.Term) std.fmt.Formatter(?std.process.Child.Term, formatTerm) {
fn fmtTerm(term: ?std.process.Child.Term) std.fmt.Alt(?std.process.Child.Term, formatTerm) {
return .{ .data = term };
}

View File

@ -359,7 +359,7 @@ pub const Format = struct {
}
};
pub fn fmt(uri: *const Uri, flags: Format.Flags) std.fmt.Formatter(Format, Format.default) {
pub fn fmt(uri: *const Uri, flags: Format.Flags) std.fmt.Alt(Format, Format.default) {
return .{ .data = .{ .uri = uri, .flags = flags } };
}

View File

@ -464,7 +464,7 @@ pub const HexEscape = struct {
};
/// Replaces non-ASCII bytes with hex escapes.
pub fn hexEscape(bytes: []const u8, case: std.fmt.Case) std.fmt.Formatter(HexEscape, HexEscape.format) {
pub fn hexEscape(bytes: []const u8, case: std.fmt.Case) std.fmt.Alt(HexEscape, HexEscape.format) {
return .{ .data = .{ .bytes = bytes, .charset = switch (case) {
.lower => HexEscape.lower_charset,
.upper => HexEscape.upper_charset,

View File

@ -1697,7 +1697,7 @@ pub fn ConfigurableTrace(comptime size: usize, comptime stack_frame_count: usize
pub fn format(
t: @This(),
comptime fmt: []const u8,
options: std.fmt.FormatOptions,
options: std.fmt.Options,
writer: *Writer,
) !void {
if (fmt.len != 0) std.fmt.invalidFmtError(fmt, t);

View File

@ -28,9 +28,6 @@ pub const Case = enum { lower, upper };
const default_alignment = .right;
const default_fill_char = ' ';
/// Deprecated in favor of `Options`.
pub const FormatOptions = Options;
pub const Options = struct {
precision: ?usize = null,
width: ?usize = null,
@ -77,14 +74,6 @@ pub const Number = struct {
};
};
/// Deprecated in favor of `Writer.print`.
pub fn format(writer: anytype, comptime fmt: []const u8, args: anytype) !void {
var adapter = writer.adaptToNewApi(&.{});
return adapter.new_interface.print(fmt, args) catch |err| switch (err) {
error.WriteFailed => return adapter.err.?,
};
}
pub const Placeholder = struct {
specifier_arg: []const u8,
fill: u8,
@ -274,9 +263,6 @@ pub fn digits2(value: u8) [2]u8 {
}
}
/// Deprecated in favor of `Alt`.
pub const Formatter = Alt;
/// Creates a type suitable for instantiating and passing to a "{f}" placeholder.
pub fn Alt(
comptime Data: type,
@ -294,7 +280,7 @@ pub fn Alt(
pub fn alt(
context: anytype,
comptime func_name: @TypeOf(.enum_literal),
) Formatter(@TypeOf(context), @field(@TypeOf(context), @tagName(func_name))) {
) Alt(@TypeOf(context), @field(@TypeOf(context), @tagName(func_name))) {
return .{ .data = context };
}
@ -607,7 +593,7 @@ pub const BufPrintError = error{
NoSpaceLeft,
};
/// Print a Formatter string into `buf`. Returns a slice of the bytes printed.
/// Print a format string into `buf`. Returns a slice of the bytes printed.
pub fn bufPrint(buf: []u8, comptime fmt: []const u8, args: anytype) BufPrintError![]u8 {
var w: Writer = .fixed(buf);
w.print(fmt, args) catch |err| switch (err) {

View File

@ -146,7 +146,7 @@ pub fn joinZ(allocator: Allocator, paths: []const []const u8) ![:0]u8 {
return out[0 .. out.len - 1 :0];
}
pub fn fmtJoin(paths: []const []const u8) std.fmt.Formatter([]const []const u8, formatJoin) {
pub fn fmtJoin(paths: []const []const u8) std.fmt.Alt([]const []const u8, formatJoin) {
return .{ .data = paths };
}

View File

@ -893,7 +893,7 @@ fn formatUtf8(utf8: []const u8, writer: *std.Io.Writer) std.Io.Writer.Error!void
/// Ill-formed UTF-8 byte sequences are replaced by the replacement character (U+FFFD)
/// according to "U+FFFD Substitution of Maximal Subparts" from Chapter 3 of
/// the Unicode standard, and as specified by https://encoding.spec.whatwg.org/#utf-8-decoder
pub fn fmtUtf8(utf8: []const u8) std.fmt.Formatter([]const u8, formatUtf8) {
pub fn fmtUtf8(utf8: []const u8) std.fmt.Alt([]const u8, formatUtf8) {
return .{ .data = utf8 };
}
@ -1483,7 +1483,7 @@ fn formatUtf16Le(utf16le: []const u16, writer: *std.Io.Writer) std.Io.Writer.Err
/// Return a Formatter for a (potentially ill-formed) UTF-16 LE string,
/// which will be converted to UTF-8 during formatting.
/// Unpaired surrogates are replaced by the replacement character (U+FFFD).
pub fn fmtUtf16Le(utf16le: []const u16) std.fmt.Formatter([]const u16, formatUtf16Le) {
pub fn fmtUtf16Le(utf16le: []const u16) std.fmt.Alt([]const u16, formatUtf16Le) {
return .{ .data = utf16le };
}

View File

@ -462,12 +462,12 @@ pub const FormatId = struct {
};
/// Return a formatter for escaping a double quoted Zig string.
pub fn fmtString(bytes: []const u8) std.fmt.Formatter([]const u8, stringEscape) {
pub fn fmtString(bytes: []const u8) std.fmt.Alt([]const u8, stringEscape) {
return .{ .data = bytes };
}
/// Return a formatter for escaping a single quoted Zig string.
pub fn fmtChar(c: u21) std.fmt.Formatter(u21, charEscape) {
pub fn fmtChar(c: u21) std.fmt.Alt(u21, charEscape) {
return .{ .data = c };
}

View File

@ -111,7 +111,7 @@ pub const String = enum(u32) {
return printEscapedString(string_slice, quote_behavior, w);
}
pub fn fmt(self: String, builder: *const Builder) std.fmt.Formatter(FormatData, format) {
pub fn fmt(self: String, builder: *const Builder) std.fmt.Alt(FormatData, format) {
return .{ .data = .{
.string = self,
.builder = builder,
@ -119,7 +119,7 @@ pub const String = enum(u32) {
} };
}
pub fn fmtQ(self: String, builder: *const Builder) std.fmt.Formatter(FormatData, format) {
pub fn fmtQ(self: String, builder: *const Builder) std.fmt.Alt(FormatData, format) {
return .{ .data = .{
.string = self,
.builder = builder,
@ -127,7 +127,7 @@ pub const String = enum(u32) {
} };
}
pub fn fmtRaw(self: String, builder: *const Builder) std.fmt.Formatter(FormatData, format) {
pub fn fmtRaw(self: String, builder: *const Builder) std.fmt.Alt(FormatData, format) {
return .{ .data = .{
.string = self,
.builder = builder,
@ -846,7 +846,7 @@ pub const Type = enum(u32) {
},
}
}
pub fn fmt(self: Type, builder: *const Builder, mode: FormatData.Mode) std.fmt.Formatter(FormatData, format) {
pub fn fmt(self: Type, builder: *const Builder, mode: FormatData.Mode) std.fmt.Alt(FormatData, format) {
return .{ .data = .{ .type = self, .builder = builder, .mode = mode } };
}
@ -1325,7 +1325,7 @@ pub const Attribute = union(Kind) {
.none => unreachable,
}
}
pub fn fmt(self: Index, builder: *const Builder, mode: FormatData.mode) std.fmt.Formatter(FormatData, format) {
pub fn fmt(self: Index, builder: *const Builder, mode: FormatData.mode) std.fmt.Alt(FormatData, format) {
return .{ .data = .{ .attribute_index = self, .builder = builder, .mode = mode } };
}
@ -1609,7 +1609,7 @@ pub const Attributes = enum(u32) {
.flags = data.flags,
}, w);
}
pub fn fmt(self: Attributes, builder: *const Builder, flags: FormatData.Flags) std.fmt.Formatter(FormatData, format) {
pub fn fmt(self: Attributes, builder: *const Builder, flags: FormatData.Flags) std.fmt.Alt(FormatData, format) {
return .{ .data = .{ .attributes = self, .builder = builder, .flags = flags } };
}
};
@ -1803,7 +1803,7 @@ pub const Linkage = enum(u4) {
fn formatOptional(data: ?Linkage, w: *Writer) Writer.Error!void {
if (data) |linkage| try w.print(" {s}", .{@tagName(linkage)});
}
pub fn fmtOptional(self: ?Linkage) std.fmt.Formatter(?Linkage, formatOptional) {
pub fn fmtOptional(self: ?Linkage) std.fmt.Alt(?Linkage, formatOptional) {
return .{ .data = self };
}
};
@ -2208,7 +2208,7 @@ pub const StrtabString = enum(u32) {
self: StrtabString,
builder: *const Builder,
quote_behavior: ?QuoteBehavior,
) std.fmt.Formatter(FormatData, format) {
) std.fmt.Alt(FormatData, format) {
return .{ .data = .{
.string = self,
.builder = builder,
@ -2387,7 +2387,7 @@ pub const Global = struct {
data.global.unwrap(data.builder).name(data.builder).fmt(data.builder, .quote_unless_valid_identifier),
});
}
pub fn fmt(self: Index, builder: *const Builder) std.fmt.Formatter(FormatData, format) {
pub fn fmt(self: Index, builder: *const Builder) std.fmt.Alt(FormatData, format) {
return .{ .data = .{ .global = self, .builder = builder } };
}
@ -4852,7 +4852,7 @@ pub const Function = struct {
function: Function.Index,
builder: *Builder,
flags: FormatFlags,
) std.fmt.Formatter(FormatData, format) {
) std.fmt.Alt(FormatData, format) {
return .{ .data = .{
.instruction = self,
.function = function,
@ -7790,7 +7790,7 @@ pub const Constant = enum(u32) {
.global => |global| try w.print("{f}", .{global.fmt(data.builder)}),
}
}
pub fn fmt(self: Constant, builder: *Builder, flags: FormatFlags) std.fmt.Formatter(FormatData, format) {
pub fn fmt(self: Constant, builder: *Builder, flags: FormatFlags) std.fmt.Alt(FormatData, format) {
return .{ .data = .{
.constant = self,
.builder = builder,
@ -7868,7 +7868,7 @@ pub const Value = enum(u32) {
.metadata => unreachable,
}
}
pub fn fmt(self: Value, function: Function.Index, builder: *Builder, flags: FormatFlags) std.fmt.Formatter(FormatData, format) {
pub fn fmt(self: Value, function: Function.Index, builder: *Builder, flags: FormatFlags) std.fmt.Alt(FormatData, format) {
return .{ .data = .{ .value = self, .function = function, .builder = builder, .flags = flags } };
}
};
@ -7902,7 +7902,7 @@ pub const MetadataString = enum(u32) {
fn format(data: FormatData, w: *Writer) Writer.Error!void {
try printEscapedString(data.metadata_string.slice(data.builder), .always_quote, w);
}
fn fmt(self: MetadataString, builder: *const Builder) std.fmt.Formatter(FormatData, format) {
fn fmt(self: MetadataString, builder: *const Builder) std.fmt.Alt(FormatData, format) {
return .{ .data = .{ .metadata_string = self, .builder = builder } };
}
};
@ -8411,7 +8411,7 @@ pub const Metadata = enum(u32) {
inline fn fmt(formatter: *Formatter, prefix: []const u8, node: anytype, special: ?FormatFlags) switch (@TypeOf(node)) {
Metadata => Allocator.Error,
else => error{},
}!std.fmt.Formatter(FormatData, format) {
}!std.fmt.Alt(FormatData, format) {
const Node = @TypeOf(node);
const MaybeNode = switch (@typeInfo(Node)) {
.optional => Node,
@ -8456,7 +8456,7 @@ pub const Metadata = enum(u32) {
prefix: []const u8,
value: Value,
function: Function.Index,
) Allocator.Error!std.fmt.Formatter(FormatData, format) {
) Allocator.Error!std.fmt.Alt(FormatData, format) {
return .{ .data = .{
.formatter = formatter,
.prefix = prefix,
@ -8539,7 +8539,7 @@ pub const Metadata = enum(u32) {
fmt_str = fmt_str ++ "(";
inline for (fields[2..], names) |*field, name| {
fmt_str = fmt_str ++ "{[" ++ name ++ "]f}";
const T = std.fmt.Formatter(FormatData, format);
const T = std.fmt.Alt(FormatData, format);
field.* = .{
.name = name,
.type = T,

View File

@ -87,7 +87,7 @@ pub const Error = union(enum) {
}
}
pub fn fmt(self: @This(), raw_string: []const u8) std.fmt.Formatter(FormatMessage, formatMessage) {
pub fn fmt(self: @This(), raw_string: []const u8) std.fmt.Alt(FormatMessage, formatMessage) {
return .{ .data = .{
.err = self,
.raw_string = raw_string,

View File

@ -6465,7 +6465,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
};
}
pub fn fmtRcEscape(bytes: []const u8) std.fmt.Formatter([]const u8, formatRcEscape) {
pub fn fmtRcEscape(bytes: []const u8) std.fmt.Alt([]const u8, formatRcEscape) {
return .{ .data = bytes };
}
}.fmtRcEscape;

View File

@ -1904,11 +1904,11 @@ pub const NullTerminatedString = enum(u32) {
}
}
pub fn fmt(string: NullTerminatedString, ip: *const InternPool) std.fmt.Formatter(FormatData, format) {
pub fn fmt(string: NullTerminatedString, ip: *const InternPool) std.fmt.Alt(FormatData, format) {
return .{ .data = .{ .string = string, .ip = ip, .id = false } };
}
pub fn fmtId(string: NullTerminatedString, ip: *const InternPool) std.fmt.Formatter(FormatData, format) {
pub fn fmtId(string: NullTerminatedString, ip: *const InternPool) std.fmt.Alt(FormatData, format) {
return .{ .data = .{ .string = string, .ip = ip, .id = true } };
}

View File

@ -127,7 +127,7 @@ pub fn format(ty: Type, writer: *std.Io.Writer) !void {
@compileError("do not format types directly; use either ty.fmtDebug() or ty.fmt()");
}
pub const Formatter = std.fmt.Formatter(Format, Format.default);
pub const Formatter = std.fmt.Alt(Format, Format.default);
pub fn fmt(ty: Type, pt: Zcu.PerThread) Formatter {
return .{ .data = .{
@ -145,7 +145,7 @@ const Format = struct {
}
};
pub fn fmtDebug(ty: Type) std.fmt.Formatter(Type, dump) {
pub fn fmtDebug(ty: Type) std.fmt.Alt(Type, dump) {
return .{ .data = ty };
}

View File

@ -27,11 +27,11 @@ pub fn dump(start_val: Value, w: std.Io.Writer) std.Io.Writer.Error!void {
try w.print("(interned: {})", .{start_val.toIntern()});
}
pub fn fmtDebug(val: Value) std.fmt.Formatter(Value, dump) {
pub fn fmtDebug(val: Value) std.fmt.Alt(Value, dump) {
return .{ .data = val };
}
pub fn fmtValue(val: Value, pt: Zcu.PerThread) std.fmt.Formatter(print_value.FormatContext, print_value.format) {
pub fn fmtValue(val: Value, pt: Zcu.PerThread) std.fmt.Alt(print_value.FormatContext, print_value.format) {
return .{ .data = .{
.val = val,
.pt = pt,
@ -40,7 +40,7 @@ pub fn fmtValue(val: Value, pt: Zcu.PerThread) std.fmt.Formatter(print_value.For
} };
}
pub fn fmtValueSema(val: Value, pt: Zcu.PerThread, sema: *Sema) std.fmt.Formatter(print_value.FormatContext, print_value.formatSema) {
pub fn fmtValueSema(val: Value, pt: Zcu.PerThread, sema: *Sema) std.fmt.Alt(print_value.FormatContext, print_value.formatSema) {
return .{ .data = .{
.val = val,
.pt = pt,
@ -49,7 +49,7 @@ pub fn fmtValueSema(val: Value, pt: Zcu.PerThread, sema: *Sema) std.fmt.Formatte
} };
}
pub fn fmtValueSemaFull(ctx: print_value.FormatContext) std.fmt.Formatter(print_value.FormatContext, print_value.formatSema) {
pub fn fmtValueSemaFull(ctx: print_value.FormatContext) std.fmt.Alt(print_value.FormatContext, print_value.formatSema) {
return .{ .data = ctx };
}

View File

@ -4306,10 +4306,10 @@ pub fn navFileScope(zcu: *Zcu, nav: InternPool.Nav.Index) *File {
return zcu.fileByIndex(zcu.navFileScopeIndex(nav));
}
pub fn fmtAnalUnit(zcu: *Zcu, unit: AnalUnit) std.fmt.Formatter(FormatAnalUnit, formatAnalUnit) {
pub fn fmtAnalUnit(zcu: *Zcu, unit: AnalUnit) std.fmt.Alt(FormatAnalUnit, formatAnalUnit) {
return .{ .data = .{ .unit = unit, .zcu = zcu } };
}
pub fn fmtDependee(zcu: *Zcu, d: InternPool.Dependee) std.fmt.Formatter(FormatDependee, formatDependee) {
pub fn fmtDependee(zcu: *Zcu, d: InternPool.Dependee) std.fmt.Alt(FormatDependee, formatDependee) {
return .{ .data = .{ .dependee = d, .zcu = zcu } };
}

View File

@ -972,7 +972,7 @@ fn formatWipMir(data: FormatWipMirData, writer: *std.Io.Writer) std.Io.Writer.Er
first = false;
}
}
fn fmtWipMir(func: *Func, inst: Mir.Inst.Index) std.fmt.Formatter(FormatWipMirData, formatWipMir) {
fn fmtWipMir(func: *Func, inst: Mir.Inst.Index) std.fmt.Alt(FormatWipMirData, formatWipMir) {
return .{ .data = .{ .func = func, .inst = inst } };
}
@ -983,7 +983,7 @@ const FormatNavData = struct {
fn formatNav(data: FormatNavData, writer: *std.Io.Writer) std.Io.Writer.Error!void {
try writer.print("{f}", .{data.ip.getNav(data.nav_index).fqn.fmt(data.ip)});
}
fn fmtNav(nav_index: InternPool.Nav.Index, ip: *const InternPool) std.fmt.Formatter(FormatNavData, formatNav) {
fn fmtNav(nav_index: InternPool.Nav.Index, ip: *const InternPool) std.fmt.Alt(FormatNavData, formatNav) {
return .{ .data = .{
.ip = ip,
.nav_index = nav_index,
@ -1001,7 +1001,7 @@ fn formatAir(data: FormatAirData, writer: *std.Io.Writer) std.Io.Writer.Error!vo
_ = writer;
@panic("unimplemented");
}
fn fmtAir(func: *Func, inst: Air.Inst.Index) std.fmt.Formatter(FormatAirData, formatAir) {
fn fmtAir(func: *Func, inst: Air.Inst.Index) std.fmt.Alt(FormatAirData, formatAir) {
return .{ .data = .{ .func = func, .inst = inst } };
}
@ -1012,7 +1012,7 @@ fn formatTracking(data: FormatTrackingData, writer: *std.Io.Writer) std.Io.Write
var it = data.func.inst_tracking.iterator();
while (it.next()) |entry| try writer.print("\n%{d} = {f}", .{ entry.key_ptr.*, entry.value_ptr.* });
}
fn fmtTracking(func: *Func) std.fmt.Formatter(FormatTrackingData, formatTracking) {
fn fmtTracking(func: *Func) std.fmt.Alt(FormatTrackingData, formatTracking) {
return .{ .data = .{ .func = func } };
}

View File

@ -1091,7 +1091,7 @@ const FormatNavData = struct {
fn formatNav(data: FormatNavData, w: *Writer) Writer.Error!void {
try w.print("{f}", .{data.ip.getNav(data.nav_index).fqn.fmt(data.ip)});
}
fn fmtNav(nav_index: InternPool.Nav.Index, ip: *const InternPool) std.fmt.Formatter(FormatNavData, formatNav) {
fn fmtNav(nav_index: InternPool.Nav.Index, ip: *const InternPool) std.fmt.Alt(FormatNavData, formatNav) {
return .{ .data = .{
.ip = ip,
.nav_index = nav_index,
@ -1105,7 +1105,7 @@ const FormatAirData = struct {
fn formatAir(data: FormatAirData, w: *Writer) Writer.Error!void {
data.self.air.writeInst(w, data.inst, data.self.pt, data.self.liveness);
}
fn fmtAir(self: *CodeGen, inst: Air.Inst.Index) std.fmt.Formatter(FormatAirData, formatAir) {
fn fmtAir(self: *CodeGen, inst: Air.Inst.Index) std.fmt.Alt(FormatAirData, formatAir) {
return .{ .data = .{ .self = self, .inst = inst } };
}
@ -1197,7 +1197,7 @@ fn formatWipMir(data: FormatWipMirData, w: *Writer) Writer.Error!void {
}
}
}
fn fmtWipMir(self: *CodeGen, inst: Mir.Inst.Index) std.fmt.Formatter(FormatWipMirData, formatWipMir) {
fn fmtWipMir(self: *CodeGen, inst: Mir.Inst.Index) std.fmt.Alt(FormatWipMirData, formatWipMir) {
return .{ .data = .{ .self = self, .inst = inst } };
}
@ -1208,7 +1208,7 @@ fn formatTracking(data: FormatTrackingData, w: *Writer) Writer.Error!void {
var it = data.self.inst_tracking.iterator();
while (it.next()) |entry| try w.print("\n{f} = {f}", .{ entry.key_ptr.*, entry.value_ptr.* });
}
fn fmtTracking(self: *CodeGen) std.fmt.Formatter(FormatTrackingData, formatTracking) {
fn fmtTracking(self: *CodeGen) std.fmt.Alt(FormatTrackingData, formatTracking) {
return .{ .data = .{ .self = self } };
}

View File

@ -301,7 +301,7 @@ pub const Instruction = struct {
}
};
pub fn fmt(op: Operand, enc_op: Encoding.Op) std.fmt.Formatter(Format, Format.default) {
pub fn fmt(op: Operand, enc_op: Encoding.Op) std.fmt.Alt(Format, Format.default) {
return .{ .data = .{ .op = op, .enc_op = enc_op } };
}
};

View File

@ -371,11 +371,11 @@ fn formatIdentOptions(ident: []const u8, w: *Writer, solo: bool) Writer.Error!vo
}
}
pub fn fmtIdentSolo(ident: []const u8) std.fmt.Formatter([]const u8, formatIdentSolo) {
pub fn fmtIdentSolo(ident: []const u8) std.fmt.Alt([]const u8, formatIdentSolo) {
return .{ .data = ident };
}
pub fn fmtIdentUnsolo(ident: []const u8) std.fmt.Formatter([]const u8, formatIdentUnsolo) {
pub fn fmtIdentUnsolo(ident: []const u8) std.fmt.Alt([]const u8, formatIdentUnsolo) {
return .{ .data = ident };
}
@ -394,7 +394,7 @@ pub fn fmtCTypePoolString(
ctype_pool_string: CType.Pool.String,
ctype_pool: *const CType.Pool,
solo: bool,
) std.fmt.Formatter(CTypePoolStringFormatData, formatCTypePoolString) {
) std.fmt.Alt(CTypePoolStringFormatData, formatCTypePoolString) {
return .{ .data = .{
.ctype_pool_string = ctype_pool_string,
.ctype_pool = ctype_pool,
@ -610,11 +610,11 @@ pub const Function = struct {
return f.object.dg.renderIntCast(w, dest_ty, .{ .c_value = .{ .f = f, .value = src, .v = v } }, src_ty, location);
}
fn fmtIntLiteralDec(f: *Function, val: Value) !std.fmt.Formatter(FormatIntLiteralContext, formatIntLiteral) {
fn fmtIntLiteralDec(f: *Function, val: Value) !std.fmt.Alt(FormatIntLiteralContext, formatIntLiteral) {
return f.object.dg.fmtIntLiteralDec(val, .Other);
}
fn fmtIntLiteralHex(f: *Function, val: Value) !std.fmt.Formatter(FormatIntLiteralContext, formatIntLiteral) {
fn fmtIntLiteralHex(f: *Function, val: Value) !std.fmt.Alt(FormatIntLiteralContext, formatIntLiteral) {
return f.object.dg.fmtIntLiteralHex(val, .Other);
}
@ -1919,7 +1919,7 @@ pub const DeclGen = struct {
kind: CType.Kind,
name: union(enum) {
nav: InternPool.Nav.Index,
fmt_ctype_pool_string: std.fmt.Formatter(CTypePoolStringFormatData, formatCTypePoolString),
fmt_ctype_pool_string: std.fmt.Alt(CTypePoolStringFormatData, formatCTypePoolString),
@"export": struct {
main_name: InternPool.NullTerminatedString,
extern_name: InternPool.NullTerminatedString,
@ -2439,7 +2439,7 @@ pub const DeclGen = struct {
loc: ValueRenderLocation,
base: u8,
case: std.fmt.Case,
) !std.fmt.Formatter(FormatIntLiteralContext, formatIntLiteral) {
) !std.fmt.Alt(FormatIntLiteralContext, formatIntLiteral) {
const zcu = dg.pt.zcu;
const kind = loc.toCTypeKind();
const ty = val.typeOf(zcu);
@ -2461,7 +2461,7 @@ pub const DeclGen = struct {
dg: *DeclGen,
val: Value,
loc: ValueRenderLocation,
) !std.fmt.Formatter(FormatIntLiteralContext, formatIntLiteral) {
) !std.fmt.Alt(FormatIntLiteralContext, formatIntLiteral) {
return fmtIntLiteral(dg, val, loc, 10, .lower);
}
@ -2469,7 +2469,7 @@ pub const DeclGen = struct {
dg: *DeclGen,
val: Value,
loc: ValueRenderLocation,
) !std.fmt.Formatter(FormatIntLiteralContext, formatIntLiteral) {
) !std.fmt.Alt(FormatIntLiteralContext, formatIntLiteral) {
return fmtIntLiteral(dg, val, loc, 16, .lower);
}
};
@ -8295,7 +8295,7 @@ fn formatStringLiteral(data: FormatStringContext, w: *Writer) Writer.Error!void
try literal.end();
}
fn fmtStringLiteral(str: []const u8, sentinel: ?u8) std.fmt.Formatter(FormatStringContext, formatStringLiteral) {
fn fmtStringLiteral(str: []const u8, sentinel: ?u8) std.fmt.Alt(FormatStringContext, formatStringLiteral) {
return .{ .data = .{ .str = str, .sentinel = sentinel } };
}

View File

@ -989,7 +989,7 @@ pub const Pool = struct {
else
try writer.print("f{d}", .{@intFromEnum(data.string.index)});
}
pub fn fmt(str: String, pool: *const Pool) std.fmt.Formatter(FormatData, format) {
pub fn fmt(str: String, pool: *const Pool) std.fmt.Alt(FormatData, format) {
return .{ .data = .{ .string = str, .pool = pool } };
}

View File

@ -3053,7 +3053,7 @@ const ImportTable = struct {
}
};
fn fmtDebug(itab: ImportTable, ctx: Context) fmt.Formatter(Format, Format.default) {
fn fmtDebug(itab: ImportTable, ctx: Context) fmt.Alt(Format, Format.default) {
return .{ .data = .{ .itab = itab, .ctx = ctx } };
}

View File

@ -3862,7 +3862,7 @@ const FormatShdr = struct {
shdr: elf.Elf64_Shdr,
};
fn fmtShdr(self: *Elf, shdr: elf.Elf64_Shdr) std.fmt.Formatter(FormatShdr, formatShdr) {
fn fmtShdr(self: *Elf, shdr: elf.Elf64_Shdr) std.fmt.Alt(FormatShdr, formatShdr) {
return .{ .data = .{
.shdr = shdr,
.elf_file = self,
@ -3879,7 +3879,7 @@ fn formatShdr(ctx: FormatShdr, writer: *std.Io.Writer) std.Io.Writer.Error!void
});
}
pub fn fmtShdrFlags(sh_flags: u64) std.fmt.Formatter(u64, formatShdrFlags) {
pub fn fmtShdrFlags(sh_flags: u64) std.fmt.Alt(u64, formatShdrFlags) {
return .{ .data = sh_flags };
}
@ -3933,7 +3933,7 @@ const FormatPhdr = struct {
phdr: elf.Elf64_Phdr,
};
fn fmtPhdr(self: *Elf, phdr: elf.Elf64_Phdr) std.fmt.Formatter(FormatPhdr, formatPhdr) {
fn fmtPhdr(self: *Elf, phdr: elf.Elf64_Phdr) std.fmt.Alt(FormatPhdr, formatPhdr) {
return .{ .data = .{
.phdr = phdr,
.elf_file = self,
@ -3967,7 +3967,7 @@ fn formatPhdr(ctx: FormatPhdr, writer: *std.Io.Writer) std.Io.Writer.Error!void
});
}
pub fn dumpState(self: *Elf) std.fmt.Formatter(*Elf, fmtDumpState) {
pub fn dumpState(self: *Elf) std.fmt.Alt(*Elf, fmtDumpState) {
return .{ .data = self };
}

View File

@ -215,7 +215,7 @@ pub const ArSymtab = struct {
}
};
pub fn fmt(ar: ArSymtab, elf_file: *Elf) std.fmt.Formatter(Format, Format.default) {
pub fn fmt(ar: ArSymtab, elf_file: *Elf) std.fmt.Alt(Format, Format.default) {
return .{ .data = .{
.ar = ar,
.elf_file = elf_file,

View File

@ -894,7 +894,7 @@ pub fn setExtra(atom: Atom, extras: Extra, elf_file: *Elf) void {
atom.file(elf_file).?.setAtomExtra(atom.extra_index, extras);
}
pub fn fmt(atom: Atom, elf_file: *Elf) std.fmt.Formatter(Format, Format.default) {
pub fn fmt(atom: Atom, elf_file: *Elf) std.fmt.Alt(Format, Format.default) {
return .{ .data = .{
.atom = atom,
.elf_file = elf_file,

View File

@ -187,7 +187,7 @@ const Format = struct {
}
};
pub fn fmt(atom_list: AtomList, elf_file: *Elf) std.fmt.Formatter(Format, Format.default) {
pub fn fmt(atom_list: AtomList, elf_file: *Elf) std.fmt.Alt(Format, Format.default) {
return .{ .data = .{ .atom_list = atom_list, .elf_file = elf_file } };
}

View File

@ -437,7 +437,7 @@ pub fn setSymbolExtra(self: *LinkerDefined, index: u32, extra: Symbol.Extra) voi
}
}
pub fn fmtSymtab(self: *LinkerDefined, elf_file: *Elf) std.fmt.Formatter(Format, Format.symtab) {
pub fn fmtSymtab(self: *LinkerDefined, elf_file: *Elf) std.fmt.Alt(Format, Format.symtab) {
return .{ .data = .{
.self = self,
.elf_file = elf_file,

View File

@ -157,7 +157,7 @@ pub const Section = struct {
}
};
pub fn fmt(msec: Section, elf_file: *Elf) std.fmt.Formatter(Format, Format.default) {
pub fn fmt(msec: Section, elf_file: *Elf) std.fmt.Alt(Format, Format.default) {
return .{ .data = .{
.msec = msec,
.elf_file = elf_file,
@ -211,7 +211,7 @@ pub const Subsection = struct {
return msec.bytes.items[msub.string_index..][0..msub.size];
}
pub fn fmt(msub: Subsection, elf_file: *Elf) std.fmt.Formatter(Format, Format.default) {
pub fn fmt(msub: Subsection, elf_file: *Elf) std.fmt.Alt(Format, Format.default) {
return .{ .data = .{
.msub = msub,
.elf_file = elf_file,

View File

@ -1431,7 +1431,7 @@ pub fn group(self: *Object, index: Elf.Group.Index) *Elf.Group {
return &self.groups.items[index];
}
pub fn fmtSymtab(self: *Object, elf_file: *Elf) std.fmt.Formatter(Format, Format.symtab) {
pub fn fmtSymtab(self: *Object, elf_file: *Elf) std.fmt.Alt(Format, Format.symtab) {
return .{ .data = .{
.object = self,
.elf_file = elf_file,
@ -1504,35 +1504,35 @@ const Format = struct {
}
};
pub fn fmtAtoms(self: *Object, elf_file: *Elf) std.fmt.Formatter(Format, Format.atoms) {
pub fn fmtAtoms(self: *Object, elf_file: *Elf) std.fmt.Alt(Format, Format.atoms) {
return .{ .data = .{
.object = self,
.elf_file = elf_file,
} };
}
pub fn fmtCies(self: *Object, elf_file: *Elf) std.fmt.Formatter(Format, Format.cies) {
pub fn fmtCies(self: *Object, elf_file: *Elf) std.fmt.Alt(Format, Format.cies) {
return .{ .data = .{
.object = self,
.elf_file = elf_file,
} };
}
pub fn fmtFdes(self: *Object, elf_file: *Elf) std.fmt.Formatter(Format, Format.fdes) {
pub fn fmtFdes(self: *Object, elf_file: *Elf) std.fmt.Alt(Format, Format.fdes) {
return .{ .data = .{
.object = self,
.elf_file = elf_file,
} };
}
pub fn fmtGroups(self: *Object, elf_file: *Elf) std.fmt.Formatter(Format, Format.groups) {
pub fn fmtGroups(self: *Object, elf_file: *Elf) std.fmt.Alt(Format, Format.groups) {
return .{ .data = .{
.object = self,
.elf_file = elf_file,
} };
}
pub fn fmtPath(self: Object) std.fmt.Formatter(Object, formatPath) {
pub fn fmtPath(self: Object) std.fmt.Alt(Object, formatPath) {
return .{ .data = self };
}

View File

@ -509,7 +509,7 @@ pub fn setSymbolExtra(self: *SharedObject, index: u32, extra: Symbol.Extra) void
}
}
pub fn fmtSymtab(self: SharedObject, elf_file: *Elf) std.fmt.Formatter(Format, Format.symtab) {
pub fn fmtSymtab(self: SharedObject, elf_file: *Elf) std.fmt.Alt(Format, Format.symtab) {
return .{ .data = .{
.shared = self,
.elf_file = elf_file,

View File

@ -368,14 +368,14 @@ const Format = struct {
}
};
pub fn fmtName(symbol: Symbol, elf_file: *Elf) std.fmt.Formatter(Format, Format.name) {
pub fn fmtName(symbol: Symbol, elf_file: *Elf) std.fmt.Alt(Format, Format.name) {
return .{ .data = .{
.symbol = symbol,
.elf_file = elf_file,
} };
}
pub fn fmt(symbol: Symbol, elf_file: *Elf) std.fmt.Formatter(Format, Format.default) {
pub fn fmt(symbol: Symbol, elf_file: *Elf) std.fmt.Alt(Format, Format.default) {
return .{ .data = .{
.symbol = symbol,
.elf_file = elf_file,

View File

@ -65,7 +65,7 @@ fn trampolineSize(cpu_arch: std.Target.Cpu.Arch) usize {
};
}
pub fn fmt(thunk: Thunk, elf_file: *Elf) std.fmt.Formatter(Format, Format.default) {
pub fn fmt(thunk: Thunk, elf_file: *Elf) std.fmt.Alt(Format, Format.default) {
return .{ .data = .{
.thunk = thunk,
.elf_file = elf_file,

View File

@ -2225,14 +2225,14 @@ const Format = struct {
}
};
pub fn fmtSymtab(self: *ZigObject, elf_file: *Elf) std.fmt.Formatter(Format, Format.symtab) {
pub fn fmtSymtab(self: *ZigObject, elf_file: *Elf) std.fmt.Alt(Format, Format.symtab) {
return .{ .data = .{
.self = self,
.elf_file = elf_file,
} };
}
pub fn fmtAtoms(self: *ZigObject, elf_file: *Elf) std.fmt.Formatter(Format, Format.atoms) {
pub fn fmtAtoms(self: *ZigObject, elf_file: *Elf) std.fmt.Alt(Format, Format.atoms) {
return .{ .data = .{
.self = self,
.elf_file = elf_file,

View File

@ -47,7 +47,7 @@ pub const Fde = struct {
return object.relocs.items[fde.rel_index..][0..fde.rel_num];
}
pub fn fmt(fde: Fde, elf_file: *Elf) std.fmt.Formatter(Format, Format.default) {
pub fn fmt(fde: Fde, elf_file: *Elf) std.fmt.Alt(Format, Format.default) {
return .{ .data = .{
.fde = fde,
.elf_file = elf_file,
@ -130,7 +130,7 @@ pub const Cie = struct {
return true;
}
pub fn fmt(cie: Cie, elf_file: *Elf) std.fmt.Formatter(Format, Format.default) {
pub fn fmt(cie: Cie, elf_file: *Elf) std.fmt.Alt(Format, Format.default) {
return .{ .data = .{
.cie = cie,
.elf_file = elf_file,

View File

@ -10,7 +10,7 @@ pub const File = union(enum) {
};
}
pub fn fmtPath(file: File) std.fmt.Formatter(File, formatPath) {
pub fn fmtPath(file: File) std.fmt.Alt(File, formatPath) {
return .{ .data = file };
}

View File

@ -153,7 +153,7 @@ const FormatRelocTypeCtx = struct {
cpu_arch: std.Target.Cpu.Arch,
};
pub fn fmtRelocType(r_type: u32, cpu_arch: std.Target.Cpu.Arch) std.fmt.Formatter(FormatRelocTypeCtx, formatRelocType) {
pub fn fmtRelocType(r_type: u32, cpu_arch: std.Target.Cpu.Arch) std.fmt.Alt(FormatRelocTypeCtx, formatRelocType) {
return .{ .data = .{
.r_type = r_type,
.cpu_arch = cpu_arch,

View File

@ -622,7 +622,7 @@ pub const GotSection = struct {
}
};
pub fn fmt(got: GotSection, elf_file: *Elf) std.fmt.Formatter(Format, Format.default) {
pub fn fmt(got: GotSection, elf_file: *Elf) std.fmt.Alt(Format, Format.default) {
return .{ .data = .{ .got = got, .elf_file = elf_file } };
}
};
@ -758,7 +758,7 @@ pub const PltSection = struct {
}
};
pub fn fmt(plt: PltSection, elf_file: *Elf) std.fmt.Formatter(Format, Format.default) {
pub fn fmt(plt: PltSection, elf_file: *Elf) std.fmt.Alt(Format, Format.default) {
return .{ .data = .{ .plt = plt, .elf_file = elf_file } };
}

View File

@ -3906,7 +3906,7 @@ pub fn ptraceDetach(self: *MachO, pid: std.posix.pid_t) !void {
self.hot_state.mach_task = null;
}
pub fn dumpState(self: *MachO) std.fmt.Formatter(*MachO, fmtDumpState) {
pub fn dumpState(self: *MachO) std.fmt.Alt(*MachO, fmtDumpState) {
return .{ .data = self };
}
@ -3964,7 +3964,7 @@ fn fmtDumpState(self: *MachO, w: *Writer) Writer.Error!void {
try w.print("segments\n{f}\n", .{self.fmtSegments()});
}
fn fmtSections(self: *MachO) std.fmt.Formatter(*MachO, formatSections) {
fn fmtSections(self: *MachO) std.fmt.Alt(*MachO, formatSections) {
return .{ .data = self };
}
@ -3981,7 +3981,7 @@ fn formatSections(self: *MachO, w: *Writer) Writer.Error!void {
}
}
fn fmtSegments(self: *MachO) std.fmt.Formatter(*MachO, formatSegments) {
fn fmtSegments(self: *MachO) std.fmt.Alt(*MachO, formatSegments) {
return .{ .data = self };
}
@ -3994,7 +3994,7 @@ fn formatSegments(self: *MachO, w: *Writer) Writer.Error!void {
}
}
pub fn fmtSectType(tt: u8) std.fmt.Formatter(u8, formatSectType) {
pub fn fmtSectType(tt: u8) std.fmt.Alt(u8, formatSectType) {
return .{ .data = tt };
}
@ -4257,7 +4257,7 @@ pub const Platform = struct {
return false;
}
pub fn fmtTarget(plat: Platform, cpu_arch: std.Target.Cpu.Arch) std.fmt.Formatter(Format, Format.target) {
pub fn fmtTarget(plat: Platform, cpu_arch: std.Target.Cpu.Arch) std.fmt.Alt(Format, Format.target) {
return .{ .data = .{ .platform = plat, .cpu_arch = cpu_arch } };
}

View File

@ -225,7 +225,7 @@ pub const ArSymtab = struct {
}
};
pub fn fmt(ar: ArSymtab, macho_file: *MachO) std.fmt.Formatter(PrintFormat, PrintFormat.default) {
pub fn fmt(ar: ArSymtab, macho_file: *MachO) std.fmt.Alt(PrintFormat, PrintFormat.default) {
return .{ .data = .{ .ar = ar, .macho_file = macho_file } };
}

View File

@ -1073,7 +1073,7 @@ pub fn writeRelocs(self: Atom, macho_file: *MachO, code: []u8, buffer: []macho.r
assert(i == buffer.len);
}
pub fn fmt(atom: Atom, macho_file: *MachO) std.fmt.Formatter(Format, Format.print) {
pub fn fmt(atom: Atom, macho_file: *MachO) std.fmt.Alt(Format, Format.print) {
return .{ .data = .{
.atom = atom,
.macho_file = macho_file,

View File

@ -667,7 +667,7 @@ pub fn setSymbolExtra(self: *Dylib, index: u32, extra: Symbol.Extra) void {
}
}
pub fn fmtSymtab(self: *Dylib, macho_file: *MachO) std.fmt.Formatter(Format, Format.symtab) {
pub fn fmtSymtab(self: *Dylib, macho_file: *MachO) std.fmt.Alt(Format, Format.symtab) {
return .{ .data = .{
.dylib = self,
.macho_file = macho_file,

View File

@ -864,14 +864,14 @@ const Format = struct {
}
};
pub fn fmtAtoms(self: *InternalObject, macho_file: *MachO) std.fmt.Formatter(Format, Format.atoms) {
pub fn fmtAtoms(self: *InternalObject, macho_file: *MachO) std.fmt.Alt(Format, Format.atoms) {
return .{ .data = .{
.self = self,
.macho_file = macho_file,
} };
}
pub fn fmtSymtab(self: *InternalObject, macho_file: *MachO) std.fmt.Formatter(Format, Format.symtab) {
pub fn fmtSymtab(self: *InternalObject, macho_file: *MachO) std.fmt.Alt(Format, Format.symtab) {
return .{ .data = .{
.self = self,
.macho_file = macho_file,

View File

@ -2578,42 +2578,42 @@ const Format = struct {
}
};
pub fn fmtAtoms(self: *Object, macho_file: *MachO) std.fmt.Formatter(Format, Format.atoms) {
pub fn fmtAtoms(self: *Object, macho_file: *MachO) std.fmt.Alt(Format, Format.atoms) {
return .{ .data = .{
.object = self,
.macho_file = macho_file,
} };
}
pub fn fmtCies(self: *Object, macho_file: *MachO) std.fmt.Formatter(Format, Format.cies) {
pub fn fmtCies(self: *Object, macho_file: *MachO) std.fmt.Alt(Format, Format.cies) {
return .{ .data = .{
.object = self,
.macho_file = macho_file,
} };
}
pub fn fmtFdes(self: *Object, macho_file: *MachO) std.fmt.Formatter(Format, Format.fdes) {
pub fn fmtFdes(self: *Object, macho_file: *MachO) std.fmt.Alt(Format, Format.fdes) {
return .{ .data = .{
.object = self,
.macho_file = macho_file,
} };
}
pub fn fmtUnwindRecords(self: *Object, macho_file: *MachO) std.fmt.Formatter(Format, Format.unwindRecords) {
pub fn fmtUnwindRecords(self: *Object, macho_file: *MachO) std.fmt.Alt(Format, Format.unwindRecords) {
return .{ .data = .{
.object = self,
.macho_file = macho_file,
} };
}
pub fn fmtSymtab(self: *Object, macho_file: *MachO) std.fmt.Formatter(Format, Format.symtab) {
pub fn fmtSymtab(self: *Object, macho_file: *MachO) std.fmt.Alt(Format, Format.symtab) {
return .{ .data = .{
.object = self,
.macho_file = macho_file,
} };
}
pub fn fmtPath(self: Object) std.fmt.Formatter(Object, formatPath) {
pub fn fmtPath(self: Object) std.fmt.Alt(Object, formatPath) {
return .{ .data = self };
}
@ -2694,7 +2694,7 @@ const StabFile = struct {
}
};
pub fn fmt(stab: Stab, object: Object) std.fmt.Formatter(Stab.Format, Stab.Format.default) {
pub fn fmt(stab: Stab, object: Object) std.fmt.Alt(Stab.Format, Stab.Format.default) {
return .{ .data = .{ .stab = stab, .object = object } };
}
};

View File

@ -70,7 +70,7 @@ pub fn lessThan(ctx: void, lhs: Relocation, rhs: Relocation) bool {
return lhs.offset < rhs.offset;
}
pub fn fmtPretty(rel: Relocation, cpu_arch: std.Target.Cpu.Arch) std.fmt.Formatter(Format, Format.pretty) {
pub fn fmtPretty(rel: Relocation, cpu_arch: std.Target.Cpu.Arch) std.fmt.Alt(Format, Format.pretty) {
return .{ .data = .{ .relocation = rel, .arch = cpu_arch } };
}

View File

@ -286,7 +286,7 @@ pub fn setOutputSym(symbol: Symbol, macho_file: *MachO, out: *macho.nlist_64) vo
}
}
pub fn fmt(symbol: Symbol, macho_file: *MachO) std.fmt.Formatter(Format, Format.default) {
pub fn fmt(symbol: Symbol, macho_file: *MachO) std.fmt.Alt(Format, Format.default) {
return .{ .data = .{
.symbol = symbol,
.macho_file = macho_file,

View File

@ -63,7 +63,7 @@ pub fn writeSymtab(thunk: Thunk, macho_file: *MachO, ctx: anytype) void {
}
}
pub fn fmt(thunk: Thunk, macho_file: *MachO) std.fmt.Formatter(Format, Format.default) {
pub fn fmt(thunk: Thunk, macho_file: *MachO) std.fmt.Alt(Format, Format.default) {
return .{ .data = .{
.thunk = thunk,
.macho_file = macho_file,

View File

@ -509,7 +509,7 @@ pub const Record = struct {
return lsda.getAddress(macho_file) + rec.lsda_offset;
}
pub fn fmt(rec: Record, macho_file: *MachO) std.fmt.Formatter(Format, Format.default) {
pub fn fmt(rec: Record, macho_file: *MachO) std.fmt.Alt(Format, Format.default) {
return .{ .data = .{
.rec = rec,
.macho_file = macho_file,
@ -603,7 +603,7 @@ const Page = struct {
}
};
fn fmt(page: Page, info: UnwindInfo) std.fmt.Formatter(Format, Format.default) {
fn fmt(page: Page, info: UnwindInfo) std.fmt.Alt(Format, Format.default) {
return .{ .data = .{
.page = page,
.info = info,

View File

@ -1680,7 +1680,7 @@ pub fn asFile(self: *ZigObject) File {
return .{ .zig_object = self };
}
pub fn fmtSymtab(self: *ZigObject, macho_file: *MachO) std.fmt.Formatter(Format, Format.symtab) {
pub fn fmtSymtab(self: *ZigObject, macho_file: *MachO) std.fmt.Alt(Format, Format.symtab) {
return .{ .data = .{
.self = self,
.macho_file = macho_file,
@ -1717,7 +1717,7 @@ const Format = struct {
}
};
pub fn fmtAtoms(self: *ZigObject, macho_file: *MachO) std.fmt.Formatter(Format, Format.atoms) {
pub fn fmtAtoms(self: *ZigObject, macho_file: *MachO) std.fmt.Alt(Format, Format.atoms) {
return .{ .data = .{
.self = self,
.macho_file = macho_file,

View File

@ -79,7 +79,7 @@ pub const Cie = struct {
return true;
}
pub fn fmt(cie: Cie, macho_file: *MachO) std.fmt.Formatter(Format, Format.default) {
pub fn fmt(cie: Cie, macho_file: *MachO) std.fmt.Alt(Format, Format.default) {
return .{ .data = .{
.cie = cie,
.macho_file = macho_file,
@ -208,7 +208,7 @@ pub const Fde = struct {
return fde.getObject(macho_file).getAtom(fde.lsda);
}
pub fn fmt(fde: Fde, macho_file: *MachO) std.fmt.Formatter(Format, Format.default) {
pub fn fmt(fde: Fde, macho_file: *MachO) std.fmt.Alt(Format, Format.default) {
return .{ .data = .{
.fde = fde,
.macho_file = macho_file,

View File

@ -10,7 +10,7 @@ pub const File = union(enum) {
};
}
pub fn fmtPath(file: File) std.fmt.Formatter(File, formatPath) {
pub fn fmtPath(file: File) std.fmt.Alt(File, formatPath) {
return .{ .data = file };
}

View File

@ -55,7 +55,7 @@ pub const GotSection = struct {
}
};
pub fn fmt(got: GotSection, macho_file: *MachO) std.fmt.Formatter(Format, Format.print) {
pub fn fmt(got: GotSection, macho_file: *MachO) std.fmt.Alt(Format, Format.print) {
return .{ .data = .{ .got = got, .macho_file = macho_file } };
}
};
@ -120,7 +120,7 @@ pub const StubsSection = struct {
}
}
pub fn fmt(stubs: StubsSection, macho_file: *MachO) std.fmt.Formatter(Format, Format.print) {
pub fn fmt(stubs: StubsSection, macho_file: *MachO) std.fmt.Alt(Format, Format.print) {
return .{ .data = .{ .stubs = stubs, .macho_file = macho_file } };
}
@ -337,7 +337,7 @@ pub const TlvPtrSection = struct {
}
}
pub fn fmt(tlv: TlvPtrSection, macho_file: *MachO) std.fmt.Formatter(Format, Format.print) {
pub fn fmt(tlv: TlvPtrSection, macho_file: *MachO) std.fmt.Alt(Format, Format.print) {
return .{ .data = .{ .tlv = tlv, .macho_file = macho_file } };
}
@ -452,7 +452,7 @@ pub const ObjcStubsSection = struct {
}
}
pub fn fmt(objc: ObjcStubsSection, macho_file: *MachO) std.fmt.Formatter(Format, Format.print) {
pub fn fmt(objc: ObjcStubsSection, macho_file: *MachO) std.fmt.Alt(Format, Format.print) {
return .{ .data = .{ .objc = objc, .macho_file = macho_file } };
}

View File

@ -100,7 +100,6 @@ test {
_ = @import("behavior/undefined.zig");
_ = @import("behavior/underscore.zig");
_ = @import("behavior/union.zig");
_ = @import("behavior/union_with_members.zig");
_ = @import("behavior/var_args.zig");
_ = @import("behavior/vector.zig");
_ = @import("behavior/void.zig");

View File

@ -1,33 +0,0 @@
const builtin = @import("builtin");
const std = @import("std");
const expect = std.testing.expect;
const mem = std.mem;
const fmt = std.fmt;
const ET = union(enum) {
SINT: i32,
UINT: u32,
pub fn print(a: *const ET, buf: []u8) anyerror!usize {
return switch (a.*) {
ET.SINT => |x| fmt.printInt(buf, x, 10, .lower, fmt.FormatOptions{}),
ET.UINT => |x| fmt.printInt(buf, x, 10, .lower, fmt.FormatOptions{}),
};
}
};
test "enum with members" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
const a = ET{ .SINT = -42 };
const b = ET{ .UINT = 42 };
var buf: [20]u8 = undefined;
try expect((a.print(buf[0..]) catch unreachable) == 3);
try expect(mem.eql(u8, buf[0..3], "-42"));
try expect((b.print(buf[0..]) catch unreachable) == 2);
try expect(mem.eql(u8, buf[0..2], "42"));
}