Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/compiler/aro/aro/Diagnostics.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler/resinator/errors.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler/resinator/res.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}
};
Expand Down
2 changes: 1 addition & 1 deletion lib/docs/wasm/markdown/renderer.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}

Expand Down
4 changes: 2 additions & 2 deletions lib/std/Build/Cache/Path.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}

Expand All @@ -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 };
}

Expand Down
6 changes: 3 additions & 3 deletions lib/std/Build/Step/CheckObject.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 };
}

Expand Down Expand Up @@ -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 };
}

Expand Down
2 changes: 1 addition & 1 deletion lib/std/Build/Step/Run.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}

Expand Down
2 changes: 1 addition & 1 deletion lib/std/Uri.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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 } };
}

Expand Down
2 changes: 1 addition & 1 deletion lib/std/ascii.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/std/debug.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 2 additions & 16 deletions lib/std/fmt.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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 };
}

Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/std/fs/path.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}

Expand Down
4 changes: 2 additions & 2 deletions lib/std/unicode.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}

Expand Down Expand Up @@ -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 };
}

Expand Down
4 changes: 2 additions & 2 deletions lib/std/zig.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}

Expand Down
32 changes: 16 additions & 16 deletions lib/std/zig/llvm/Builder.zig
Original file line number Diff line number Diff line change
Expand Up @@ -111,23 +111,23 @@ 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,
.quote_behavior = .quote_unless_valid_identifier,
} };
}

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,
.quote_behavior = .always_quote,
} };
}

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,
Expand Down Expand Up @@ -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 } };
}

Expand Down Expand Up @@ -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 } };
}

Expand Down Expand Up @@ -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 } };
}
};
Expand Down Expand Up @@ -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 };
}
};
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 } };
}

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 } };
}
};
Expand Down Expand Up @@ -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 } };
}
};
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/std/zig/string_literal.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/Compilation.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/InternPool.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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 } };
}

Expand Down
Loading
Loading