aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2024-08-28 02:35:53 +0100
committermlugg <mlugg@mlugg.co.uk>2024-08-28 08:39:59 +0100
commit0fe3fd01ddc2cd49c6a2b939577d16b9d2c65ea9 (patch)
tree2c07fddf2b6230360fe618c4de192bc2d24eeaf7 /lib/std
parent1a178d499537b922ff05c5d0186ed5a00dbb1a9b (diff)
downloadzig-0fe3fd01ddc2cd49c6a2b939577d16b9d2c65ea9.tar.gz
zig-0fe3fd01ddc2cd49c6a2b939577d16b9d2c65ea9.zip
std: update `std.builtin.Type` fields to follow naming conventions
The compiler actually doesn't need any functional changes for this: Sema does reification based on the tag indices of `std.builtin.Type` already! So, no zig1.wasm update is necessary. This change is necessary to disallow name clashes between fields and decls on a type, which is a prerequisite of #9938.
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/Build.zig46
-rw-r--r--lib/std/Build/Cache.zig6
-rw-r--r--lib/std/Build/Cache/Path.zig4
-rw-r--r--lib/std/Build/Step/ConfigHeader.zig22
-rw-r--r--lib/std/Build/Step/Options.zig34
-rw-r--r--lib/std/Build/Step/Run.zig2
-rw-r--r--lib/std/Progress.zig18
-rw-r--r--lib/std/Random.zig40
-rw-r--r--lib/std/Target.zig4
-rw-r--r--lib/std/Target/Query.zig4
-rw-r--r--lib/std/Target/aarch64.zig4
-rw-r--r--lib/std/Target/amdgpu.zig4
-rw-r--r--lib/std/Target/arc.zig4
-rw-r--r--lib/std/Target/arm.zig4
-rw-r--r--lib/std/Target/avr.zig4
-rw-r--r--lib/std/Target/bpf.zig4
-rw-r--r--lib/std/Target/csky.zig4
-rw-r--r--lib/std/Target/hexagon.zig4
-rw-r--r--lib/std/Target/loongarch.zig4
-rw-r--r--lib/std/Target/m68k.zig4
-rw-r--r--lib/std/Target/mips.zig4
-rw-r--r--lib/std/Target/msp430.zig4
-rw-r--r--lib/std/Target/nvptx.zig4
-rw-r--r--lib/std/Target/powerpc.zig4
-rw-r--r--lib/std/Target/riscv.zig4
-rw-r--r--lib/std/Target/s390x.zig4
-rw-r--r--lib/std/Target/sparc.zig4
-rw-r--r--lib/std/Target/spirv.zig4
-rw-r--r--lib/std/Target/ve.zig4
-rw-r--r--lib/std/Target/wasm.zig4
-rw-r--r--lib/std/Target/x86.zig4
-rw-r--r--lib/std/Target/xtensa.zig4
-rw-r--r--lib/std/Thread.zig18
-rw-r--r--lib/std/array_hash_map.zig22
-rw-r--r--lib/std/bit_set.zig4
-rw-r--r--lib/std/builtin.zig48
-rw-r--r--lib/std/c/darwin.zig2
-rw-r--r--lib/std/compress/flate/huffman_encoder.zig2
-rw-r--r--lib/std/crypto/cmac.zig2
-rw-r--r--lib/std/crypto/ff.zig4
-rw-r--r--lib/std/crypto/phc_encoding.zig16
-rw-r--r--lib/std/crypto/timing_safe.zig14
-rw-r--r--lib/std/crypto/tls.zig4
-rw-r--r--lib/std/debug.zig2
-rw-r--r--lib/std/debug/Dwarf.zig2
-rw-r--r--lib/std/debug/Dwarf/expression.zig6
-rw-r--r--lib/std/debug/FixedBufferReader.zig2
-rw-r--r--lib/std/debug/Pdb.zig2
-rw-r--r--lib/std/debug/SelfInfo.zig10
-rw-r--r--lib/std/enums.zig62
-rw-r--r--lib/std/fmt.zig76
-rw-r--r--lib/std/fmt/format_float.zig12
-rw-r--r--lib/std/fmt/parse_float.zig4
-rw-r--r--lib/std/hash/auto_hash.zig56
-rw-r--r--lib/std/hash/verify.zig10
-rw-r--r--lib/std/hash_map.zig22
-rw-r--r--lib/std/heap/logging_allocator.zig2
-rw-r--r--lib/std/io.zig8
-rw-r--r--lib/std/io/Reader.zig6
-rw-r--r--lib/std/io/Writer.zig4
-rw-r--r--lib/std/io/bit_writer.zig2
-rw-r--r--lib/std/io/fixed_buffer_stream.zig6
-rw-r--r--lib/std/io/multi_writer.zig2
-rw-r--r--lib/std/io/tty.zig2
-rw-r--r--lib/std/json/static.zig46
-rw-r--r--lib/std/json/stringify.zig32
-rw-r--r--lib/std/leb128.zig38
-rw-r--r--lib/std/log.zig12
-rw-r--r--lib/std/math.zig196
-rw-r--r--lib/std/math/big.zig2
-rw-r--r--lib/std/math/big/int.zig24
-rw-r--r--lib/std/math/big/int_test.zig26
-rw-r--r--lib/std/math/big/rational.zig14
-rw-r--r--lib/std/math/copysign.zig2
-rw-r--r--lib/std/math/float.zig20
-rw-r--r--lib/std/math/frexp.zig2
-rw-r--r--lib/std/math/gcd.zig4
-rw-r--r--lib/std/math/hypot.zig4
-rw-r--r--lib/std/math/ilogb.zig2
-rw-r--r--lib/std/math/isfinite.zig2
-rw-r--r--lib/std/math/isinf.zig2
-rw-r--r--lib/std/math/isnormal.zig2
-rw-r--r--lib/std/math/iszero.zig4
-rw-r--r--lib/std/math/ldexp.zig2
-rw-r--r--lib/std/math/log.zig10
-rw-r--r--lib/std/math/log10.zig12
-rw-r--r--lib/std/math/log2.zig8
-rw-r--r--lib/std/math/log_int.zig8
-rw-r--r--lib/std/math/nextafter.zig12
-rw-r--r--lib/std/math/pow.zig6
-rw-r--r--lib/std/math/powi.zig2
-rw-r--r--lib/std/math/signbit.zig2
-rw-r--r--lib/std/math/sqrt.zig12
-rw-r--r--lib/std/mem.zig178
-rw-r--r--lib/std/mem/Allocator.zig20
-rw-r--r--lib/std/meta.zig190
-rw-r--r--lib/std/meta/trailer_flags.zig16
-rw-r--r--lib/std/multi_array_list.zig21
-rw-r--r--lib/std/os/emscripten.zig2
-rw-r--r--lib/std/os/linux.zig14
-rw-r--r--lib/std/os/linux/bpf.zig2
-rw-r--r--lib/std/os/uefi/protocol/device_path.zig4
-rw-r--r--lib/std/os/uefi/status.zig4
-rw-r--r--lib/std/posix.zig4
-rw-r--r--lib/std/posix/test.zig2
-rw-r--r--lib/std/process/Child.zig2
-rw-r--r--lib/std/segmented_list.zig2
-rw-r--r--lib/std/simd.zig14
-rw-r--r--lib/std/start.zig12
-rw-r--r--lib/std/testing.zig132
-rw-r--r--lib/std/zig.zig4
-rw-r--r--lib/std/zig/AstGen.zig78
-rw-r--r--lib/std/zig/ErrorBundle.zig12
-rw-r--r--lib/std/zig/Server.zig6
-rw-r--r--lib/std/zig/Zir.zig16
-rw-r--r--lib/std/zig/c_translation.zig118
-rw-r--r--lib/std/zig/parser_test.zig2
-rw-r--r--lib/std/zig/system/windows.zig4
118 files changed, 1033 insertions, 1036 deletions
diff --git a/lib/std/Build.zig b/lib/std/Build.zig
index f8ab20cac1..109ebc8be2 100644
--- a/lib/std/Build.zig
+++ b/lib/std/Build.zig
@@ -408,7 +408,7 @@ fn createChildOnly(
fn userInputOptionsFromArgs(allocator: Allocator, args: anytype) UserInputOptionsMap {
var user_input_options = UserInputOptionsMap.init(allocator);
- inline for (@typeInfo(@TypeOf(args)).Struct.fields) |field| {
+ inline for (@typeInfo(@TypeOf(args)).@"struct".fields) |field| {
const v = @field(args, field.name);
const T = @TypeOf(v);
switch (T) {
@@ -454,28 +454,28 @@ fn userInputOptionsFromArgs(allocator: Allocator, args: anytype) UserInputOption
}) catch @panic("OOM");
},
else => switch (@typeInfo(T)) {
- .Bool => {
+ .bool => {
user_input_options.put(field.name, .{
.name = field.name,
.value = .{ .scalar = if (v) "true" else "false" },
.used = false,
}) catch @panic("OOM");
},
- .Enum, .EnumLiteral => {
+ .@"enum", .enum_literal => {
user_input_options.put(field.name, .{
.name = field.name,
.value = .{ .scalar = @tagName(v) },
.used = false,
}) catch @panic("OOM");
},
- .ComptimeInt, .Int => {
+ .comptime_int, .int => {
user_input_options.put(field.name, .{
.name = field.name,
.value = .{ .scalar = std.fmt.allocPrint(allocator, "{d}", .{v}) catch @panic("OOM") },
.used = false,
}) catch @panic("OOM");
},
- .ComptimeFloat, .Float => {
+ .comptime_float, .float => {
user_input_options.put(field.name, .{
.name = field.name,
.value = .{ .scalar = std.fmt.allocPrint(allocator, "{e}", .{v}) catch @panic("OOM") },
@@ -1111,7 +1111,7 @@ pub fn option(b: *Build, comptime T: type, name_raw: []const u8, description_raw
const description = b.dupe(description_raw);
const type_id = comptime typeToEnum(T);
const enum_options = if (type_id == .@"enum" or type_id == .enum_list) blk: {
- const EnumType = if (type_id == .enum_list) @typeInfo(T).Pointer.child else T;
+ const EnumType = if (type_id == .enum_list) @typeInfo(T).pointer.child else T;
const fields = comptime std.meta.fields(EnumType);
var options = ArrayList([]const u8).initCapacity(b.allocator, fields.len) catch @panic("OOM");
@@ -1265,7 +1265,7 @@ pub fn option(b: *Build, comptime T: type, name_raw: []const u8, description_raw
return null;
},
.scalar => |s| {
- const Child = @typeInfo(T).Pointer.child;
+ const Child = @typeInfo(T).pointer.child;
const value = std.meta.stringToEnum(Child, s) orelse {
log.err("Expected -D{s} to be of type {s}.", .{ name, @typeName(Child) });
b.markInvalidUserInput();
@@ -1274,7 +1274,7 @@ pub fn option(b: *Build, comptime T: type, name_raw: []const u8, description_raw
return b.allocator.dupe(Child, &[_]Child{value}) catch @panic("OOM");
},
.list => |lst| {
- const Child = @typeInfo(T).Pointer.child;
+ const Child = @typeInfo(T).pointer.child;
var new_list = b.allocator.alloc(Child, lst.items.len) catch @panic("OOM");
for (lst.items, 0..) |str, i| {
const value = std.meta.stringToEnum(Child, str) orelse {
@@ -1542,15 +1542,15 @@ fn typeToEnum(comptime T: type) TypeId {
return switch (T) {
std.zig.BuildId => .build_id,
else => return switch (@typeInfo(T)) {
- .Int => .int,
- .Float => .float,
- .Bool => .bool,
- .Enum => .@"enum",
- .Pointer => |pointer| switch (pointer.child) {
+ .int => .int,
+ .float => .float,
+ .bool => .bool,
+ .@"enum" => .@"enum",
+ .pointer => |pointer| switch (pointer.child) {
u8 => .string,
[]const u8 => .list,
else => switch (@typeInfo(pointer.child)) {
- .Enum => .enum_list,
+ .@"enum" => .enum_list,
else => @compileError("Unsupported type: " ++ @typeName(T)),
},
},
@@ -1726,7 +1726,7 @@ pub fn fmt(b: *Build, comptime format: []const u8, args: anytype) []u8 {
}
fn supportedWindowsProgramExtension(ext: []const u8) bool {
- inline for (@typeInfo(std.process.Child.WindowsExtension).Enum.fields) |field| {
+ inline for (@typeInfo(std.process.Child.WindowsExtension).@"enum".fields) |field| {
if (std.ascii.eqlIgnoreCase(ext, "." ++ field.name)) return true;
}
return false;
@@ -1925,7 +1925,7 @@ inline fn findImportPkgHashOrFatal(b: *Build, comptime asking_build_zig: type, c
const build_runner = @import("root");
const deps = build_runner.dependencies;
- const b_pkg_hash, const b_pkg_deps = comptime for (@typeInfo(deps.packages).Struct.decls) |decl| {
+ const b_pkg_hash, const b_pkg_deps = comptime for (@typeInfo(deps.packages).@"struct".decls) |decl| {
const pkg_hash = decl.name;
const pkg = @field(deps.packages, pkg_hash);
if (@hasDecl(pkg, "build_zig") and pkg.build_zig == asking_build_zig) break .{ pkg_hash, pkg.deps };
@@ -1963,7 +1963,7 @@ pub fn lazyDependency(b: *Build, name: []const u8, args: anytype) ?*Dependency {
const deps = build_runner.dependencies;
const pkg_hash = findPkgHashOrFatal(b, name);
- inline for (@typeInfo(deps.packages).Struct.decls) |decl| {
+ inline for (@typeInfo(deps.packages).@"struct".decls) |decl| {
if (mem.eql(u8, decl.name, pkg_hash)) {
const pkg = @field(deps.packages, decl.name);
const available = !@hasDecl(pkg, "available") or pkg.available;
@@ -1983,7 +1983,7 @@ pub fn dependency(b: *Build, name: []const u8, args: anytype) *Dependency {
const deps = build_runner.dependencies;
const pkg_hash = findPkgHashOrFatal(b, name);
- inline for (@typeInfo(deps.packages).Struct.decls) |decl| {
+ inline for (@typeInfo(deps.packages).@"struct".decls) |decl| {
if (mem.eql(u8, decl.name, pkg_hash)) {
const pkg = @field(deps.packages, decl.name);
if (@hasDecl(pkg, "available")) {
@@ -2013,7 +2013,7 @@ pub inline fn lazyImport(
const deps = build_runner.dependencies;
const pkg_hash = findImportPkgHashOrFatal(b, asking_build_zig, dep_name);
- inline for (@typeInfo(deps.packages).Struct.decls) |decl| {
+ inline for (@typeInfo(deps.packages).@"struct".decls) |decl| {
if (comptime mem.eql(u8, decl.name, pkg_hash)) {
const pkg = @field(deps.packages, decl.name);
const available = !@hasDecl(pkg, "available") or pkg.available;
@@ -2042,7 +2042,7 @@ pub fn dependencyFromBuildZig(
const deps = build_runner.dependencies;
find_dep: {
- const pkg, const pkg_hash = inline for (@typeInfo(deps.packages).Struct.decls) |decl| {
+ const pkg, const pkg_hash = inline for (@typeInfo(deps.packages).@"struct".decls) |decl| {
const pkg_hash = decl.name;
const pkg = @field(deps.packages, pkg_hash);
if (@hasDecl(pkg, "build_zig") and pkg.build_zig == build_zig) break .{ pkg, pkg_hash };
@@ -2150,9 +2150,9 @@ fn dependencyInner(
}
pub fn runBuild(b: *Build, build_zig: anytype) anyerror!void {
- switch (@typeInfo(@typeInfo(@TypeOf(build_zig.build)).Fn.return_type.?)) {
- .Void => build_zig.build(b),
- .ErrorUnion => try build_zig.build(b),
+ switch (@typeInfo(@typeInfo(@TypeOf(build_zig.build)).@"fn".return_type.?)) {
+ .void => build_zig.build(b),
+ .error_union => try build_zig.build(b),
else => @compileError("expected return type of build to be 'void' or '!void'"),
}
}
diff --git a/lib/std/Build/Cache.zig b/lib/std/Build/Cache.zig
index 1eabdd54e6..93908807eb 100644
--- a/lib/std/Build/Cache.zig
+++ b/lib/std/Build/Cache.zig
@@ -222,7 +222,7 @@ pub const HashHelper = struct {
.hexstring => |hex_string| hh.addBytes(hex_string.toSlice()),
},
else => switch (@typeInfo(@TypeOf(x))) {
- .Bool, .Int, .Enum, .Array => hh.addBytes(mem.asBytes(&x)),
+ .bool, .int, .@"enum", .array => hh.addBytes(mem.asBytes(&x)),
else => @compileError("unable to hash type " ++ @typeName(@TypeOf(x))),
},
}
@@ -1014,7 +1014,7 @@ pub const Manifest = struct {
}
pub fn populateFileSystemInputs(man: *Manifest, buf: *std.ArrayListUnmanaged(u8)) Allocator.Error!void {
- assert(@typeInfo(std.zig.Server.Message.PathPrefix).Enum.fields.len == man.cache.prefixes_len);
+ assert(@typeInfo(std.zig.Server.Message.PathPrefix).@"enum".fields.len == man.cache.prefixes_len);
buf.clearRetainingCapacity();
const gpa = man.cache.gpa;
const files = man.files.keys();
@@ -1032,7 +1032,7 @@ pub const Manifest = struct {
pub fn populateOtherManifest(man: *Manifest, other: *Manifest, prefix_map: [4]u8) Allocator.Error!void {
const gpa = other.cache.gpa;
- assert(@typeInfo(std.zig.Server.Message.PathPrefix).Enum.fields.len == man.cache.prefixes_len);
+ assert(@typeInfo(std.zig.Server.Message.PathPrefix).@"enum".fields.len == man.cache.prefixes_len);
assert(man.cache.prefixes_len == 4);
for (man.files.keys()) |file| {
const prefixed_path: PrefixedPath = .{
diff --git a/lib/std/Build/Cache/Path.zig b/lib/std/Build/Cache/Path.zig
index 65c6f6a9bc..ee0666b70a 100644
--- a/lib/std/Build/Cache/Path.zig
+++ b/lib/std/Build/Cache/Path.zig
@@ -189,8 +189,8 @@ pub const TableAdapter = struct {
pub fn hash(self: TableAdapter, a: Cache.Path) u32 {
_ = self;
const seed = switch (@typeInfo(@TypeOf(a.root_dir.handle.fd))) {
- .Pointer => @intFromPtr(a.root_dir.handle.fd),
- .Int => @as(u32, @bitCast(a.root_dir.handle.fd)),
+ .pointer => @intFromPtr(a.root_dir.handle.fd),
+ .int => @as(u32, @bitCast(a.root_dir.handle.fd)),
else => @compileError("unimplemented hash function"),
};
return @truncate(Hash.hash(seed, a.sub_path));
diff --git a/lib/std/Build/Step/ConfigHeader.zig b/lib/std/Build/Step/ConfigHeader.zig
index 512460a532..895f50f5d0 100644
--- a/lib/std/Build/Step/ConfigHeader.zig
+++ b/lib/std/Build/Step/ConfigHeader.zig
@@ -109,47 +109,47 @@ pub fn getOutput(config_header: *ConfigHeader) std.Build.LazyPath {
}
fn addValuesInner(config_header: *ConfigHeader, values: anytype) !void {
- inline for (@typeInfo(@TypeOf(values)).Struct.fields) |field| {
+ inline for (@typeInfo(@TypeOf(values)).@"struct".fields) |field| {
try putValue(config_header, field.name, field.type, @field(values, field.name));
}
}
fn putValue(config_header: *ConfigHeader, field_name: []const u8, comptime T: type, v: T) !void {
switch (@typeInfo(T)) {
- .Null => {
+ .null => {
try config_header.values.put(field_name, .undef);
},
- .Void => {
+ .void => {
try config_header.values.put(field_name, .defined);
},
- .Bool => {
+ .bool => {
try config_header.values.put(field_name, .{ .boolean = v });
},
- .Int => {
+ .int => {
try config_header.values.put(field_name, .{ .int = v });
},
- .ComptimeInt => {
+ .comptime_int => {
try config_header.values.put(field_name, .{ .int = v });
},
- .EnumLiteral => {
+ .enum_literal => {
try config_header.values.put(field_name, .{ .ident = @tagName(v) });
},
- .Optional => {
+ .optional => {
if (v) |x| {
return putValue(config_header, field_name, @TypeOf(x), x);
} else {
try config_header.values.put(field_name, .undef);
}
},
- .Pointer => |ptr| {
+ .pointer => |ptr| {
switch (@typeInfo(ptr.child)) {
- .Array => |array| {
+ .array => |array| {
if (ptr.size == .One and array.child == u8) {
try config_header.values.put(field_name, .{ .string = v });
return;
}
},
- .Int => {
+ .int => {
if (ptr.size == .Slice and ptr.child == u8) {
try config_header.values.put(field_name, .{ .string = v });
return;
diff --git a/lib/std/Build/Step/Options.zig b/lib/std/Build/Step/Options.zig
index 6131912b1b..41739dba47 100644
--- a/lib/std/Build/Step/Options.zig
+++ b/lib/std/Build/Step/Options.zig
@@ -151,7 +151,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent
}
switch (@typeInfo(T)) {
- .Array => {
+ .array => {
if (name) |some| {
try out.print("pub const {}: {s} = ", .{ std.zig.fmtId(some), @typeName(T) });
}
@@ -171,7 +171,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent
}
return;
},
- .Pointer => |p| {
+ .pointer => |p| {
if (p.size != .Slice) {
@compileError("Non-slice pointers are not yet supported in build options");
}
@@ -195,7 +195,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent
}
return;
},
- .Optional => {
+ .optional => {
if (name) |some| {
try out.print("pub const {}: {s} = ", .{ std.zig.fmtId(some), @typeName(T) });
}
@@ -216,12 +216,12 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent
}
return;
},
- .Void,
- .Bool,
- .Int,
- .ComptimeInt,
- .Float,
- .Null,
+ .void,
+ .bool,
+ .int,
+ .comptime_int,
+ .float,
+ .null,
=> {
if (name) |some| {
try out.print("pub const {}: {s} = {any};\n", .{ std.zig.fmtId(some), @typeName(T), value });
@@ -230,7 +230,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent
}
return;
},
- .Enum => |info| {
+ .@"enum" => |info| {
try printEnum(options, out, T, info, indent);
if (name) |some| {
@@ -242,7 +242,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent
}
return;
},
- .Struct => |info| {
+ .@"struct" => |info| {
try printStruct(options, out, T, info, indent);
if (name) |some| {
@@ -260,10 +260,10 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent
fn printUserDefinedType(options: *Options, out: anytype, comptime T: type, indent: u8) !void {
switch (@typeInfo(T)) {
- .Enum => |info| {
+ .@"enum" => |info| {
return try printEnum(options, out, T, info, indent);
},
- .Struct => |info| {
+ .@"struct" => |info| {
return try printStruct(options, out, T, info, indent);
},
else => {},
@@ -323,8 +323,8 @@ fn printStruct(options: *Options, out: anytype, comptime T: type, comptime val:
try out.writeAll(" = ");
switch (@typeInfo(@TypeOf(default_value))) {
- .Enum => try out.print(".{s},\n", .{@tagName(default_value)}),
- .Struct => |info| {
+ .@"enum" => try out.print(".{s},\n", .{@tagName(default_value)}),
+ .@"struct" => |info| {
try printStructValue(options, out, info, default_value, indent + 4);
},
else => try printType(options, out, @TypeOf(default_value), default_value, indent, null),
@@ -359,8 +359,8 @@ fn printStructValue(options: *Options, out: anytype, comptime struct_val: std.bu
const field_name = @field(val, field.name);
switch (@typeInfo(@TypeOf(field_name))) {
- .Enum => try out.print(".{s},\n", .{@tagName(field_name)}),
- .Struct => |struct_info| {
+ .@"enum" => try out.print(".{s},\n", .{@tagName(field_name)}),
+ .@"struct" => |struct_info| {
try printStructValue(options, out, struct_info, field_name, indent + 4);
},
else => try printType(options, out, @TypeOf(field_name), field_name, indent, null),
diff --git a/lib/std/Build/Step/Run.zig b/lib/std/Build/Step/Run.zig
index 0c011e25ed..e37b97ddb3 100644
--- a/lib/std/Build/Step/Run.zig
+++ b/lib/std/Build/Step/Run.zig
@@ -614,7 +614,7 @@ fn checksContainStderr(checks: []const StdIo.Check) bool {
const IndexedOutput = struct {
index: usize,
- tag: @typeInfo(Arg).Union.tag_type.?,
+ tag: @typeInfo(Arg).@"union".tag_type.?,
output: *Output,
};
fn make(step: *Step, options: Step.MakeOptions) !void {
diff --git a/lib/std/Progress.zig b/lib/std/Progress.zig
index 9c34cbbec9..7e24f25c73 100644
--- a/lib/std/Progress.zig
+++ b/lib/std/Progress.zig
@@ -95,8 +95,8 @@ pub const Node = struct {
/// Not thread-safe.
fn getIpcFd(s: Storage) ?posix.fd_t {
return if (s.estimated_total_count == std.math.maxInt(u32)) switch (@typeInfo(posix.fd_t)) {
- .Int => @bitCast(s.completed_count),
- .Pointer => @ptrFromInt(s.completed_count),
+ .int => @bitCast(s.completed_count),
+ .pointer => @ptrFromInt(s.completed_count),
else => @compileError("unsupported fd_t of " ++ @typeName(posix.fd_t)),
} else null;
}
@@ -104,8 +104,8 @@ pub const Node = struct {
/// Thread-safe.
fn setIpcFd(s: *Storage, fd: posix.fd_t) void {
const integer: u32 = switch (@typeInfo(posix.fd_t)) {
- .Int => @bitCast(fd),
- .Pointer => @intFromPtr(fd),
+ .int => @bitCast(fd),
+ .pointer => @intFromPtr(fd),
else => @compileError("unsupported fd_t of " ++ @typeName(posix.fd_t)),
};
// `estimated_total_count` max int indicates the special state that
@@ -276,8 +276,8 @@ pub const Node = struct {
const storage = storageByIndex(index);
const int = @atomicLoad(u32, &storage.completed_count, .monotonic);
return switch (@typeInfo(posix.fd_t)) {
- .Int => @bitCast(int),
- .Pointer => @ptrFromInt(int),
+ .int => @bitCast(int),
+ .pointer => @ptrFromInt(int),
else => @compileError("unsupported fd_t of " ++ @typeName(posix.fd_t)),
};
}
@@ -381,8 +381,8 @@ pub fn start(options: Options) Node {
if (std.process.parseEnvVarInt("ZIG_PROGRESS", u31, 10)) |ipc_fd| {
global_progress.update_thread = std.Thread.spawn(.{}, ipcThreadRun, .{
@as(posix.fd_t, switch (@typeInfo(posix.fd_t)) {
- .Int => ipc_fd,
- .Pointer => @ptrFromInt(ipc_fd),
+ .int => ipc_fd,
+ .pointer => @ptrFromInt(ipc_fd),
else => @compileError("unsupported fd_t of " ++ @typeName(posix.fd_t)),
}),
}) catch |err| {
@@ -633,7 +633,7 @@ const TreeSymbol = enum {
fn maxByteLen(symbol: TreeSymbol) usize {
var max: usize = 0;
- inline for (@typeInfo(Encoding).Enum.fields) |field| {
+ inline for (@typeInfo(Encoding).@"enum".fields) |field| {
const len = symbol.bytes(@field(Encoding, field.name)).len;
max = @max(max, len);
}
diff --git a/lib/std/Random.zig b/lib/std/Random.zig
index 0ba048eb0c..3de754c6de 100644
--- a/lib/std/Random.zig
+++ b/lib/std/Random.zig
@@ -34,9 +34,9 @@ fillFn: *const fn (ptr: *anyopaque, buf: []u8) void,
pub fn init(pointer: anytype, comptime fillFn: fn (ptr: @TypeOf(pointer), buf: []u8) void) Random {
const Ptr = @TypeOf(pointer);
- assert(@typeInfo(Ptr) == .Pointer); // Must be a pointer
- assert(@typeInfo(Ptr).Pointer.size == .One); // Must be a single-item pointer
- assert(@typeInfo(@typeInfo(Ptr).Pointer.child) == .Struct); // Must point to a struct
+ assert(@typeInfo(Ptr) == .pointer); // Must be a pointer
+ assert(@typeInfo(Ptr).pointer.size == .One); // Must be a single-item pointer
+ assert(@typeInfo(@typeInfo(Ptr).pointer.child) == .@"struct"); // Must point to a struct
const gen = struct {
fn fill(ptr: *anyopaque, buf: []u8) void {
const self: Ptr = @ptrCast(@alignCast(ptr));
@@ -79,7 +79,7 @@ pub inline fn enumValue(r: Random, comptime EnumType: type) EnumType {
/// See `uintLessThan`, which this function uses in most cases,
/// for commentary on the runtime of this function.
pub fn enumValueWithIndex(r: Random, comptime EnumType: type, comptime Index: type) EnumType {
- comptime assert(@typeInfo(EnumType) == .Enum);
+ comptime assert(@typeInfo(EnumType) == .@"enum");
// We won't use int -> enum casting because enum elements can have
// arbitrary values. Instead we'll randomly pick one of the type's values.
@@ -100,7 +100,7 @@ pub fn enumValueWithIndex(r: Random, comptime EnumType: type, comptime Index: ty
/// Returns a random int `i` such that `minInt(T) <= i <= maxInt(T)`.
/// `i` is evenly distributed.
pub fn int(r: Random, comptime T: type) T {
- const bits = @typeInfo(T).Int.bits;
+ const bits = @typeInfo(T).int.bits;
const UnsignedT = std.meta.Int(.unsigned, bits);
const ceil_bytes = comptime std.math.divCeil(u16, bits, 8) catch unreachable;
const ByteAlignedT = std.meta.Int(.unsigned, ceil_bytes * 8);
@@ -119,7 +119,7 @@ pub fn int(r: Random, comptime T: type) T {
/// Constant-time implementation off `uintLessThan`.
/// The results of this function may be biased.
pub fn uintLessThanBiased(r: Random, comptime T: type, less_than: T) T {
- comptime assert(@typeInfo(T).Int.signedness == .unsigned);
+ comptime assert(@typeInfo(T).int.signedness == .unsigned);
assert(0 < less_than);
return limitRangeBiased(T, r.int(T), less_than);
}
@@ -133,8 +133,8 @@ pub fn uintLessThanBiased(r: Random, comptime T: type, less_than: T) T {
/// this function is guaranteed to return.
/// If you need deterministic runtime bounds, use `uintLessThanBiased`.
pub fn uintLessThan(r: Random, comptime T: type, less_than: T) T {
- comptime assert(@typeInfo(T).Int.signedness == .unsigned);
- const bits = @typeInfo(T).Int.bits;
+ comptime assert(@typeInfo(T).int.signedness == .unsigned);
+ const bits = @typeInfo(T).int.bits;
assert(0 < less_than);
// adapted from:
@@ -164,7 +164,7 @@ pub fn uintLessThan(r: Random, comptime T: type, less_than: T) T {
/// Constant-time implementation off `uintAtMost`.
/// The results of this function may be biased.
pub fn uintAtMostBiased(r: Random, comptime T: type, at_most: T) T {
- assert(@typeInfo(T).Int.signedness == .unsigned);
+ assert(@typeInfo(T).int.signedness == .unsigned);
if (at_most == maxInt(T)) {
// have the full range
return r.int(T);
@@ -176,7 +176,7 @@ pub fn uintAtMostBiased(r: Random, comptime T: type, at_most: T) T {
/// See `uintLessThan`, which this function uses in most cases,
/// for commentary on the runtime of this function.
pub fn uintAtMost(r: Random, comptime T: type, at_most: T) T {
- assert(@typeInfo(T).Int.signedness == .unsigned);
+ assert(@typeInfo(T).int.signedness == .unsigned);
if (at_most == maxInt(T)) {
// have the full range
return r.int(T);
@@ -188,7 +188,7 @@ pub fn uintAtMost(r: Random, comptime T: type, at_most: T) T {
/// The results of this function may be biased.
pub fn intRangeLessThanBiased(r: Random, comptime T: type, at_least: T, less_than: T) T {
assert(at_least < less_than);
- const info = @typeInfo(T).Int;
+ const info = @typeInfo(T).int;
if (info.signedness == .signed) {
// Two's complement makes this math pretty easy.
const UnsignedT = std.meta.Int(.unsigned, info.bits);
@@ -207,7 +207,7 @@ pub fn intRangeLessThanBiased(r: Random, comptime T: type, at_least: T, less_tha
/// for commentary on the runtime of this function.
pub fn intRangeLessThan(r: Random, comptime T: type, at_least: T, less_than: T) T {
assert(at_least < less_than);
- const info = @typeInfo(T).Int;
+ const info = @typeInfo(T).int;
if (info.signedness == .signed) {
// Two's complement makes this math pretty easy.
const UnsignedT = std.meta.Int(.unsigned, info.bits);
@@ -225,7 +225,7 @@ pub fn intRangeLessThan(r: Random, comptime T: type, at_least: T, less_than: T)
/// The results of this function may be biased.
pub fn intRangeAtMostBiased(r: Random, comptime T: type, at_least: T, at_most: T) T {
assert(at_least <= at_most);
- const info = @typeInfo(T).Int;
+ const info = @typeInfo(T).int;
if (info.signedness == .signed) {
// Two's complement makes this math pretty easy.
const UnsignedT = std.meta.Int(.unsigned, info.bits);
@@ -244,7 +244,7 @@ pub fn intRangeAtMostBiased(r: Random, comptime T: type, at_least: T, at_most: T
/// for commentary on the runtime of this function.
pub fn intRangeAtMost(r: Random, comptime T: type, at_least: T, at_most: T) T {
assert(at_least <= at_most);
- const info = @typeInfo(T).Int;
+ const info = @typeInfo(T).int;
if (info.signedness == .signed) {
// Two's complement makes this math pretty easy.
const UnsignedT = std.meta.Int(.unsigned, info.bits);
@@ -392,12 +392,12 @@ pub fn weightedIndex(r: Random, comptime T: type, proportions: []const T) usize
};
const point = switch (@typeInfo(T)) {
- .Int => |int_info| switch (int_info.signedness) {
+ .int => |int_info| switch (int_info.signedness) {
.signed => r.intRangeLessThan(T, 0, sum),
.unsigned => r.uintLessThan(T, sum),
},
// take care that imprecision doesn't lead to a value slightly greater than sum
- .Float => @min(r.float(T) * sum, sum - std.math.floatEps(T)),
+ .float => @min(r.float(T) * sum, sum - std.math.floatEps(T)),
else => @compileError("weightedIndex does not support proportions of type " ++
@typeName(T)),
};
@@ -415,8 +415,8 @@ pub fn weightedIndex(r: Random, comptime T: type, proportions: []const T) usize
/// into an integer 0 <= result < less_than.
/// This function introduces a minor bias.
pub fn limitRangeBiased(comptime T: type, random_int: T, less_than: T) T {
- comptime assert(@typeInfo(T).Int.signedness == .unsigned);
- const bits = @typeInfo(T).Int.bits;
+ comptime assert(@typeInfo(T).int.signedness == .unsigned);
+ const bits = @typeInfo(T).int.bits;
// adapted from:
// http://www.pcg-random.org/posts/bounded-rands.html
@@ -427,9 +427,9 @@ pub fn limitRangeBiased(comptime T: type, random_int: T, less_than: T) T {
/// Returns the smallest of `Index` and `usize`.
fn MinArrayIndex(comptime Index: type) type {
- const index_info = @typeInfo(Index).Int;
+ const index_info = @typeInfo(Index).int;
assert(index_info.signedness == .unsigned);
- return if (index_info.bits >= @typeInfo(usize).Int.bits) usize else Index;
+ return if (index_info.bits >= @typeInfo(usize).int.bits) usize else Index;
}
test {
diff --git a/lib/std/Target.zig b/lib/std/Target.zig
index a231892e6e..3580813aec 100644
--- a/lib/std/Target.zig
+++ b/lib/std/Target.zig
@@ -154,7 +154,7 @@ pub const Os = struct {
};
}
- pub inline fn getVersionRangeTag(tag: Tag) @typeInfo(TaggedVersionRange).Union.tag_type.? {
+ pub inline fn getVersionRangeTag(tag: Tag) @typeInfo(TaggedVersionRange).@"union".tag_type.? {
return switch (tag) {
.freestanding,
.fuchsia,
@@ -1458,7 +1458,7 @@ pub const Cpu = struct {
fn allCpusFromDecls(comptime cpus: type) []const *const Cpu.Model {
@setEvalBranchQuota(2000);
- const decls = @typeInfo(cpus).Struct.decls;
+ const decls = @typeInfo(cpus).@"struct".decls;
var array: [decls.len]*const Cpu.Model = undefined;
for (decls, 0..) |decl, i| {
array[i] = &@field(cpus, decl.name);
diff --git a/lib/std/Target/Query.zig b/lib/std/Target/Query.zig
index 4241e425ad..f18d211853 100644
--- a/lib/std/Target/Query.zig
+++ b/lib/std/Target/Query.zig
@@ -53,7 +53,7 @@ pub const CpuModel = union(enum) {
explicit: *const Target.Cpu.Model,
pub fn eql(a: CpuModel, b: CpuModel) bool {
- const Tag = @typeInfo(CpuModel).Union.tag_type.?;
+ const Tag = @typeInfo(CpuModel).@"union".tag_type.?;
const a_tag: Tag = a;
const b_tag: Tag = b;
if (a_tag != b_tag) return false;
@@ -70,7 +70,7 @@ pub const OsVersion = union(enum) {
windows: Target.Os.WindowsVersion,
pub fn eql(a: OsVersion, b: OsVersion) bool {
- const Tag = @typeInfo(OsVersion).Union.tag_type.?;
+ const Tag = @typeInfo(OsVersion).@"union".tag_type.?;
const a_tag: Tag = a;
const b_tag: Tag = b;
if (a_tag != b_tag) return false;
diff --git a/lib/std/Target/aarch64.zig b/lib/std/Target/aarch64.zig
index 7755f7959a..b0b895cfeb 100644
--- a/lib/std/Target/aarch64.zig
+++ b/lib/std/Target/aarch64.zig
@@ -242,7 +242,7 @@ pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
pub const all_features = blk: {
@setEvalBranchQuota(2000);
- const len = @typeInfo(Feature).Enum.fields.len;
+ const len = @typeInfo(Feature).@"enum".fields.len;
std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
var result: [len]CpuFeature = undefined;
result[@intFromEnum(Feature.a510)] = .{
@@ -1660,7 +1660,7 @@ pub const all_features = blk: {
const ti = @typeInfo(Feature);
for (&result, 0..) |*elem, i| {
elem.index = i;
- elem.name = ti.Enum.fields[i].name;
+ elem.name = ti.@"enum".fields[i].name;
}
break :blk result;
};
diff --git a/lib/std/Target/amdgpu.zig b/lib/std/Target/amdgpu.zig
index 9fe574bd85..0cc7eafe89 100644
--- a/lib/std/Target/amdgpu.zig
+++ b/lib/std/Target/amdgpu.zig
@@ -183,7 +183,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
pub const all_features = blk: {
- const len = @typeInfo(Feature).Enum.fields.len;
+ const len = @typeInfo(Feature).@"enum".fields.len;
std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
var result: [len]CpuFeature = undefined;
result[@intFromEnum(Feature.@"16_bit_insts")] = .{
@@ -1284,7 +1284,7 @@ pub const all_features = blk: {
const ti = @typeInfo(Feature);
for (&result, 0..) |*elem, i| {
elem.index = i;
- elem.name = ti.Enum.fields[i].name;
+ elem.name = ti.@"enum".fields[i].name;
}
break :blk result;
};
diff --git a/lib/std/Target/arc.zig b/lib/std/Target/arc.zig
index 37fc2243c3..4642a085aa 100644
--- a/lib/std/Target/arc.zig
+++ b/lib/std/Target/arc.zig
@@ -14,7 +14,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
pub const all_features = blk: {
- const len = @typeInfo(Feature).Enum.fields.len;
+ const len = @typeInfo(Feature).@"enum".fields.len;
std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
var result: [len]CpuFeature = undefined;
result[@intFromEnum(Feature.norm)] = .{
@@ -25,7 +25,7 @@ pub const all_features = blk: {
const ti = @typeInfo(Feature);
for (&result, 0..) |*elem, i| {
elem.index = i;
- elem.name = ti.Enum.fields[i].name;
+ elem.name = ti.@"enum".fields[i].name;
}
break :blk result;
};
diff --git a/lib/std/Target/arm.zig b/lib/std/Target/arm.zig
index d8b3216a12..7bb2d6b600 100644
--- a/lib/std/Target/arm.zig
+++ b/lib/std/Target/arm.zig
@@ -215,7 +215,7 @@ pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
pub const all_features = blk: {
@setEvalBranchQuota(10000);
- const len = @typeInfo(Feature).Enum.fields.len;
+ const len = @typeInfo(Feature).@"enum".fields.len;
std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
var result: [len]CpuFeature = undefined;
result[@intFromEnum(Feature.@"32bit")] = .{
@@ -1735,7 +1735,7 @@ pub const all_features = blk: {
const ti = @typeInfo(Feature);
for (&result, 0..) |*elem, i| {
elem.index = i;
- elem.name = ti.Enum.fields[i].name;
+ elem.name = ti.@"enum".fields[i].name;
}
break :blk result;
};
diff --git a/lib/std/Target/avr.zig b/lib/std/Target/avr.zig
index 0512bd8718..3183aa4f4d 100644
--- a/lib/std/Target/avr.zig
+++ b/lib/std/Target/avr.zig
@@ -49,7 +49,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
pub const all_features = blk: {
- const len = @typeInfo(Feature).Enum.fields.len;
+ const len = @typeInfo(Feature).@"enum".fields.len;
std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
var result: [len]CpuFeature = undefined;
result[@intFromEnum(Feature.addsubiw)] = .{
@@ -340,7 +340,7 @@ pub const all_features = blk: {
const ti = @typeInfo(Feature);
for (&result, 0..) |*elem, i| {
elem.index = i;
- elem.name = ti.Enum.fields[i].name;
+ elem.name = ti.@"enum".fields[i].name;
}
break :blk result;
};
diff --git a/lib/std/Target/bpf.zig b/lib/std/Target/bpf.zig
index 2d17805fbc..5f314a5455 100644
--- a/lib/std/Target/bpf.zig
+++ b/lib/std/Target/bpf.zig
@@ -16,7 +16,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
pub const all_features = blk: {
- const len = @typeInfo(Feature).Enum.fields.len;
+ const len = @typeInfo(Feature).@"enum".fields.len;
std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
var result: [len]CpuFeature = undefined;
result[@intFromEnum(Feature.alu32)] = .{
@@ -37,7 +37,7 @@ pub const all_features = blk: {
const ti = @typeInfo(Feature);
for (&result, 0..) |*elem, i| {
elem.index = i;
- elem.name = ti.Enum.fields[i].name;
+ elem.name = ti.@"enum".fields[i].name;
}
break :blk result;
};
diff --git a/lib/std/Target/csky.zig b/lib/std/Target/csky.zig
index bdb8637709..9ea4c3f41e 100644
--- a/lib/std/Target/csky.zig
+++ b/lib/std/Target/csky.zig
@@ -76,7 +76,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
pub const all_features = blk: {
- const len = @typeInfo(Feature).Enum.fields.len;
+ const len = @typeInfo(Feature).@"enum".fields.len;
std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
var result: [len]CpuFeature = undefined;
result[@intFromEnum(Feature.@"10e60")] = .{
@@ -418,7 +418,7 @@ pub const all_features = blk: {
const ti = @typeInfo(Feature);
for (&result, 0..) |*elem, i| {
elem.index = i;
- elem.name = ti.Enum.fields[i].name;
+ elem.name = ti.@"enum".fields[i].name;
}
break :blk result;
};
diff --git a/lib/std/Target/hexagon.zig b/lib/std/Target/hexagon.zig
index c1cfc777e5..7b1d619e87 100644
--- a/lib/std/Target/hexagon.zig
+++ b/lib/std/Target/hexagon.zig
@@ -55,7 +55,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
pub const all_features = blk: {
- const len = @typeInfo(Feature).Enum.fields.len;
+ const len = @typeInfo(Feature).@"enum".fields.len;
std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
var result: [len]CpuFeature = undefined;
result[@intFromEnum(Feature.audio)] = .{
@@ -298,7 +298,7 @@ pub const all_features = blk: {
const ti = @typeInfo(Feature);
for (&result, 0..) |*elem, i| {
elem.index = i;
- elem.name = ti.Enum.fields[i].name;
+ elem.name = ti.@"enum".fields[i].name;
}
break :blk result;
};
diff --git a/lib/std/Target/loongarch.zig b/lib/std/Target/loongarch.zig
index 999c33f9c2..c5a905dc11 100644
--- a/lib/std/Target/loongarch.zig
+++ b/lib/std/Target/loongarch.zig
@@ -28,7 +28,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
pub const all_features = blk: {
- const len = @typeInfo(Feature).Enum.fields.len;
+ const len = @typeInfo(Feature).@"enum".fields.len;
std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
var result: [len]CpuFeature = undefined;
result[@intFromEnum(Feature.@"32bit")] = .{
@@ -115,7 +115,7 @@ pub const all_features = blk: {
const ti = @typeInfo(Feature);
for (&result, 0..) |*elem, i| {
elem.index = i;
- elem.name = ti.Enum.fields[i].name;
+ elem.name = ti.@"enum".fields[i].name;
}
break :blk result;
};
diff --git a/lib/std/Target/m68k.zig b/lib/std/Target/m68k.zig
index 549ecd4668..a9fcf9e231 100644
--- a/lib/std/Target/m68k.zig
+++ b/lib/std/Target/m68k.zig
@@ -36,7 +36,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
pub const all_features = blk: {
- const len = @typeInfo(Feature).Enum.fields.len;
+ const len = @typeInfo(Feature).@"enum".fields.len;
std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
var result: [len]CpuFeature = undefined;
result[@intFromEnum(Feature.isa_68000)] = .{
@@ -170,7 +170,7 @@ pub const all_features = blk: {
const ti = @typeInfo(Feature);
for (&result, 0..) |*elem, i| {
elem.index = i;
- elem.name = ti.Enum.fields[i].name;
+ elem.name = ti.@"enum".fields[i].name;
}
break :blk result;
};
diff --git a/lib/std/Target/mips.zig b/lib/std/Target/mips.zig
index 0d3f587683..9638cb3907 100644
--- a/lib/std/Target/mips.zig
+++ b/lib/std/Target/mips.zig
@@ -65,7 +65,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
pub const all_features = blk: {
- const len = @typeInfo(Feature).Enum.fields.len;
+ const len = @typeInfo(Feature).@"enum".fields.len;
std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
var result: [len]CpuFeature = undefined;
result[@intFromEnum(Feature.abs2008)] = .{
@@ -389,7 +389,7 @@ pub const all_features = blk: {
const ti = @typeInfo(Feature);
for (&result, 0..) |*elem, i| {
elem.index = i;
- elem.name = ti.Enum.fields[i].name;
+ elem.name = ti.@"enum".fields[i].name;
}
break :blk result;
};
diff --git a/lib/std/Target/msp430.zig b/lib/std/Target/msp430.zig
index 1fb473420d..9ee76ca894 100644
--- a/lib/std/Target/msp430.zig
+++ b/lib/std/Target/msp430.zig
@@ -17,7 +17,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
pub const all_features = blk: {
- const len = @typeInfo(Feature).Enum.fields.len;
+ const len = @typeInfo(Feature).@"enum".fields.len;
std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
var result: [len]CpuFeature = undefined;
result[@intFromEnum(Feature.ext)] = .{
@@ -43,7 +43,7 @@ pub const all_features = blk: {
const ti = @typeInfo(Feature);
for (&result, 0..) |*elem, i| {
elem.index = i;
- elem.name = ti.Enum.fields[i].name;
+ elem.name = ti.@"enum".fields[i].name;
}
break :blk result;
};
diff --git a/lib/std/Target/nvptx.zig b/lib/std/Target/nvptx.zig
index a97994a0d1..bcdf91027b 100644
--- a/lib/std/Target/nvptx.zig
+++ b/lib/std/Target/nvptx.zig
@@ -58,7 +58,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
pub const all_features = blk: {
- const len = @typeInfo(Feature).Enum.fields.len;
+ const len = @typeInfo(Feature).@"enum".fields.len;
std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
var result: [len]CpuFeature = undefined;
result[@intFromEnum(Feature.ptx32)] = .{
@@ -289,7 +289,7 @@ pub const all_features = blk: {
const ti = @typeInfo(Feature);
for (&result, 0..) |*elem, i| {
elem.index = i;
- elem.name = ti.Enum.fields[i].name;
+ elem.name = ti.@"enum".fields[i].name;
}
break :blk result;
};
diff --git a/lib/std/Target/powerpc.zig b/lib/std/Target/powerpc.zig
index 3397446bd1..19c8735bb3 100644
--- a/lib/std/Target/powerpc.zig
+++ b/lib/std/Target/powerpc.zig
@@ -95,7 +95,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
pub const all_features = blk: {
- const len = @typeInfo(Feature).Enum.fields.len;
+ const len = @typeInfo(Feature).@"enum".fields.len;
std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
var result: [len]CpuFeature = undefined;
result[@intFromEnum(Feature.@"64bit")] = .{
@@ -606,7 +606,7 @@ pub const all_features = blk: {
const ti = @typeInfo(Feature);
for (&result, 0..) |*elem, i| {
elem.index = i;
- elem.name = ti.Enum.fields[i].name;
+ elem.name = ti.@"enum".fields[i].name;
}
break :blk result;
};
diff --git a/lib/std/Target/riscv.zig b/lib/std/Target/riscv.zig
index ac31070980..9ee2ea9114 100644
--- a/lib/std/Target/riscv.zig
+++ b/lib/std/Target/riscv.zig
@@ -201,7 +201,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
pub const all_features = blk: {
- const len = @typeInfo(Feature).Enum.fields.len;
+ const len = @typeInfo(Feature).@"enum".fields.len;
std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
var result: [len]CpuFeature = undefined;
result[@intFromEnum(Feature.@"32bit")] = .{
@@ -1298,7 +1298,7 @@ pub const all_features = blk: {
const ti = @typeInfo(Feature);
for (&result, 0..) |*elem, i| {
elem.index = i;
- elem.name = ti.Enum.fields[i].name;
+ elem.name = ti.@"enum".fields[i].name;
}
break :blk result;
};
diff --git a/lib/std/Target/s390x.zig b/lib/std/Target/s390x.zig
index c9516be074..2e7dda40f4 100644
--- a/lib/std/Target/s390x.zig
+++ b/lib/std/Target/s390x.zig
@@ -55,7 +55,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
pub const all_features = blk: {
- const len = @typeInfo(Feature).Enum.fields.len;
+ const len = @typeInfo(Feature).@"enum".fields.len;
std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
var result: [len]CpuFeature = undefined;
result[@intFromEnum(Feature.backchain)] = .{
@@ -271,7 +271,7 @@ pub const all_features = blk: {
const ti = @typeInfo(Feature);
for (&result, 0..) |*elem, i| {
elem.index = i;
- elem.name = ti.Enum.fields[i].name;
+ elem.name = ti.@"enum".fields[i].name;
}
break :blk result;
};
diff --git a/lib/std/Target/sparc.zig b/lib/std/Target/sparc.zig
index 7b550fd2c5..b08d5420b9 100644
--- a/lib/std/Target/sparc.zig
+++ b/lib/std/Target/sparc.zig
@@ -60,7 +60,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
pub const all_features = blk: {
- const len = @typeInfo(Feature).Enum.fields.len;
+ const len = @typeInfo(Feature).@"enum".fields.len;
std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
var result: [len]CpuFeature = undefined;
result[@intFromEnum(Feature.deprecated_v8)] = .{
@@ -303,7 +303,7 @@ pub const all_features = blk: {
const ti = @typeInfo(Feature);
for (&result, 0..) |*elem, i| {
elem.index = i;
- elem.name = ti.Enum.fields[i].name;
+ elem.name = ti.@"enum".fields[i].name;
}
break :blk result;
};
diff --git a/lib/std/Target/spirv.zig b/lib/std/Target/spirv.zig
index 8bc81e189d..6c58fd48eb 100644
--- a/lib/std/Target/spirv.zig
+++ b/lib/std/Target/spirv.zig
@@ -301,7 +301,7 @@ pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
pub const all_features = blk: {
@setEvalBranchQuota(2000);
- const len = @typeInfo(Feature).Enum.fields.len;
+ const len = @typeInfo(Feature).@"enum".fields.len;
std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
var result: [len]CpuFeature = undefined;
result[@intFromEnum(Feature.v1_1)] = .{
@@ -2077,7 +2077,7 @@ pub const all_features = blk: {
const ti = @typeInfo(Feature);
for (&result, 0..) |*elem, i| {
elem.index = i;
- elem.name = ti.Enum.fields[i].name;
+ elem.name = ti.@"enum".fields[i].name;
}
break :blk result;
};
diff --git a/lib/std/Target/ve.zig b/lib/std/Target/ve.zig
index cfd6576ff7..6c0d93d1cb 100644
--- a/lib/std/Target/ve.zig
+++ b/lib/std/Target/ve.zig
@@ -14,7 +14,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
pub const all_features = blk: {
- const len = @typeInfo(Feature).Enum.fields.len;
+ const len = @typeInfo(Feature).@"enum".fields.len;
std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
var result: [len]CpuFeature = undefined;
result[@intFromEnum(Feature.vpu)] = .{
@@ -25,7 +25,7 @@ pub const all_features = blk: {
const ti = @typeInfo(Feature);
for (&result, 0..) |*elem, i| {
elem.index = i;
- elem.name = ti.Enum.fields[i].name;
+ elem.name = ti.@"enum".fields[i].name;
}
break :blk result;
};
diff --git a/lib/std/Target/wasm.zig b/lib/std/Target/wasm.zig
index 7f0ae49a78..172c3ecf79 100644
--- a/lib/std/Target/wasm.zig
+++ b/lib/std/Target/wasm.zig
@@ -26,7 +26,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
pub const all_features = blk: {
- const len = @typeInfo(Feature).Enum.fields.len;
+ const len = @typeInfo(Feature).@"enum".fields.len;
std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
var result: [len]CpuFeature = undefined;
result[@intFromEnum(Feature.atomics)] = .{
@@ -97,7 +97,7 @@ pub const all_features = blk: {
const ti = @typeInfo(Feature);
for (&result, 0..) |*elem, i| {
elem.index = i;
- elem.name = ti.Enum.fields[i].name;
+ elem.name = ti.@"enum".fields[i].name;
}
break :blk result;
};
diff --git a/lib/std/Target/x86.zig b/lib/std/Target/x86.zig
index 09ce8cd33e..50d8d48593 100644
--- a/lib/std/Target/x86.zig
+++ b/lib/std/Target/x86.zig
@@ -199,7 +199,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
pub const all_features = blk: {
- const len = @typeInfo(Feature).Enum.fields.len;
+ const len = @typeInfo(Feature).@"enum".fields.len;
std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
var result: [len]CpuFeature = undefined;
result[@intFromEnum(Feature.@"16bit_mode")] = .{
@@ -1272,7 +1272,7 @@ pub const all_features = blk: {
const ti = @typeInfo(Feature);
for (&result, 0..) |*elem, i| {
elem.index = i;
- elem.name = ti.Enum.fields[i].name;
+ elem.name = ti.@"enum".fields[i].name;
}
break :blk result;
};
diff --git a/lib/std/Target/xtensa.zig b/lib/std/Target/xtensa.zig
index 40143512c0..4b27e8e12f 100644
--- a/lib/std/Target/xtensa.zig
+++ b/lib/std/Target/xtensa.zig
@@ -14,7 +14,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
pub const all_features = blk: {
- const len = @typeInfo(Feature).Enum.fields.len;
+ const len = @typeInfo(Feature).@"enum".fields.len;
std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
var result: [len]CpuFeature = undefined;
result[@intFromEnum(Feature.density)] = .{
@@ -25,7 +25,7 @@ pub const all_features = blk: {
const ti = @typeInfo(Feature);
for (&result, 0..) |*elem, i| {
elem.index = i;
- elem.name = ti.Enum.fields[i].name;
+ elem.name = ti.@"enum".fields[i].name;
}
break :blk result;
};
diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig
index 87a4eec921..60021346e4 100644
--- a/lib/std/Thread.zig
+++ b/lib/std/Thread.zig
@@ -401,15 +401,15 @@ fn callFn(comptime f: anytype, args: anytype) switch (Impl) {
const default_value = if (Impl == PosixThreadImpl) null else 0;
const bad_fn_ret = "expected return type of startFn to be 'u8', 'noreturn', '!noreturn', 'void', or '!void'";
- switch (@typeInfo(@typeInfo(@TypeOf(f)).Fn.return_type.?)) {
- .NoReturn => {
+ switch (@typeInfo(@typeInfo(@TypeOf(f)).@"fn".return_type.?)) {
+ .noreturn => {
@call(.auto, f, args);
},
- .Void => {
+ .void => {
@call(.auto, f, args);
return default_value;
},
- .Int => |info| {
+ .int => |info| {
if (info.bits != 8) {
@compileError(bad_fn_ret);
}
@@ -422,7 +422,7 @@ fn callFn(comptime f: anytype, args: anytype) switch (Impl) {
// pthreads don't support exit status, ignore value
return default_value;
},
- .ErrorUnion => |info| {
+ .error_union => |info| {
switch (info.payload) {
void, noreturn => {
@call(.auto, f, args) catch |err| {
@@ -850,17 +850,17 @@ const WasiThreadImpl = struct {
fn entry(ptr: usize) void {
const w: *@This() = @ptrFromInt(ptr);
const bad_fn_ret = "expected return type of startFn to be 'u8', 'noreturn', 'void', or '!void'";
- switch (@typeInfo(@typeInfo(@TypeOf(f)).Fn.return_type.?)) {
- .NoReturn, .Void => {
+ switch (@typeInfo(@typeInfo(@TypeOf(f)).@"fn".return_type.?)) {
+ .noreturn, .void => {
@call(.auto, f, w.args);
},
- .Int => |info| {
+ .int => |info| {
if (info.bits != 8) {
@compileError(bad_fn_ret);
}
_ = @call(.auto, f, w.args); // WASI threads don't support exit status, ignore value
},
- .ErrorUnion => |info| {
+ .error_union => |info| {
if (info.payload != void) {
@compileError(bad_fn_ret);
}
diff --git a/lib/std/array_hash_map.zig b/lib/std/array_hash_map.zig
index 62e875ff0a..eb31d1cae3 100644
--- a/lib/std/array_hash_map.zig
+++ b/lib/std/array_hash_map.zig
@@ -2584,17 +2584,17 @@ pub fn getAutoEqlFn(comptime K: type, comptime Context: type) (fn (Context, K, K
pub fn autoEqlIsCheap(comptime K: type) bool {
return switch (@typeInfo(K)) {
- .Bool,
- .Int,
- .Float,
- .Pointer,
- .ComptimeFloat,
- .ComptimeInt,
- .Enum,
- .Fn,
- .ErrorSet,
- .AnyFrame,
- .EnumLiteral,
+ .bool,
+ .int,
+ .float,
+ .pointer,
+ .comptime_float,
+ .comptime_int,
+ .@"enum",
+ .@"fn",
+ .error_set,
+ .@"anyframe",
+ .enum_literal,
=> true,
else => false,
};
diff --git a/lib/std/bit_set.zig b/lib/std/bit_set.zig
index d70f425e61..1e2a0179ef 100644
--- a/lib/std/bit_set.zig
+++ b/lib/std/bit_set.zig
@@ -319,10 +319,10 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
const mask_info: std.builtin.Type = @typeInfo(MaskIntType);
// Make sure the mask int is indeed an int
- if (mask_info != .Int) @compileError("ArrayBitSet can only operate on integer masks, but was passed " ++ @typeName(MaskIntType));
+ if (mask_info != .int) @compileError("ArrayBitSet can only operate on integer masks, but was passed " ++ @typeName(MaskIntType));
// It must also be unsigned.
- if (mask_info.Int.signedness != .unsigned) @compileError("ArrayBitSet requires an unsigned integer mask type, but was passed " ++ @typeName(MaskIntType));
+ if (mask_info.int.signedness != .unsigned) @compileError("ArrayBitSet requires an unsigned integer mask type, but was passed " ++ @typeName(MaskIntType));
// And it must not be empty.
if (MaskIntType == u0)
diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig
index 6028db83a0..d585bcb94d 100644
--- a/lib/std/builtin.zig
+++ b/lib/std/builtin.zig
@@ -257,30 +257,30 @@ pub const TypeId = std.meta.Tag(Type);
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Type = union(enum) {
- Type: void,
- Void: void,
- Bool: void,
- NoReturn: void,
- Int: Int,
- Float: Float,
- Pointer: Pointer,
- Array: Array,
- Struct: Struct,
- ComptimeFloat: void,
- ComptimeInt: void,
- Undefined: void,
- Null: void,
- Optional: Optional,
- ErrorUnion: ErrorUnion,
- ErrorSet: ErrorSet,
- Enum: Enum,
- Union: Union,
- Fn: Fn,
- Opaque: Opaque,
- Frame: Frame,
- AnyFrame: AnyFrame,
- Vector: Vector,
- EnumLiteral: void,
+ type: void,
+ void: void,
+ bool: void,
+ noreturn: void,
+ int: Int,
+ float: Float,
+ pointer: Pointer,
+ array: Array,
+ @"struct": Struct,
+ comptime_float: void,
+ comptime_int: void,
+ undefined: void,
+ null: void,
+ optional: Optional,
+ error_union: ErrorUnion,
+ error_set: ErrorSet,
+ @"enum": Enum,
+ @"union": Union,
+ @"fn": Fn,
+ @"opaque": Opaque,
+ frame: Frame,
+ @"anyframe": AnyFrame,
+ vector: Vector,
+ enum_literal: void,
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
diff --git a/lib/std/c/darwin.zig b/lib/std/c/darwin.zig
index 3e2cf53b60..60a349868e 100644
--- a/lib/std/c/darwin.zig
+++ b/lib/std/c/darwin.zig
@@ -54,7 +54,7 @@ pub const EXC = enum(exception_type_t) {
/// Abnormal process exited to corpse state
CORPSE_NOTIFY = 13,
- pub const TYPES_COUNT = @typeInfo(EXC).Enum.fields.len;
+ pub const TYPES_COUNT = @typeInfo(EXC).@"enum".fields.len;
pub const SOFT_SIGNAL = 0x10003;
pub const MASK = packed struct(u32) {
diff --git a/lib/std/compress/flate/huffman_encoder.zig b/lib/std/compress/flate/huffman_encoder.zig
index 42cf9a20c2..3e92e55a63 100644
--- a/lib/std/compress/flate/huffman_encoder.zig
+++ b/lib/std/compress/flate/huffman_encoder.zig
@@ -455,7 +455,7 @@ test "generate a Huffman code for the 30 possible relative distances (LZ77 dista
// Reverse bit-by-bit a N-bit code.
fn bitReverse(comptime T: type, value: T, n: usize) T {
const r = @bitReverse(value);
- return r >> @as(math.Log2Int(T), @intCast(@typeInfo(T).Int.bits - n));
+ return r >> @as(math.Log2Int(T), @intCast(@typeInfo(T).int.bits - n));
}
test bitReverse {
diff --git a/lib/std/crypto/cmac.zig b/lib/std/crypto/cmac.zig
index 902bac591c..c026850ea6 100644
--- a/lib/std/crypto/cmac.zig
+++ b/lib/std/crypto/cmac.zig
@@ -8,7 +8,7 @@ pub const CmacAes128 = Cmac(crypto.core.aes.Aes128);
/// NIST Special Publication 800-38B - The CMAC Mode for Authentication
/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38b.pdf
pub fn Cmac(comptime BlockCipher: type) type {
- const BlockCipherCtx = @typeInfo(@TypeOf(BlockCipher.initEnc)).Fn.return_type.?;
+ const BlockCipherCtx = @typeInfo(@TypeOf(BlockCipher.initEnc)).@"fn".return_type.?;
const Block = [BlockCipher.block.block_length]u8;
return struct {
diff --git a/lib/std/crypto/ff.zig b/lib/std/crypto/ff.zig
index ba37a428ad..ff018b3c9b 100644
--- a/lib/std/crypto/ff.zig
+++ b/lib/std/crypto/ff.zig
@@ -848,7 +848,7 @@ const ct_protected = struct {
// Multiplies two limbs and returns the result as a wide limb.
fn mulWide(x: Limb, y: Limb) WideLimb {
- const half_bits = @typeInfo(Limb).Int.bits / 2;
+ const half_bits = @typeInfo(Limb).int.bits / 2;
const Half = meta.Int(.unsigned, half_bits);
const x0 = @as(Half, @truncate(x));
const x1 = @as(Half, @truncate(x >> half_bits));
@@ -901,7 +901,7 @@ const ct_unprotected = struct {
fn mulWide(x: Limb, y: Limb) WideLimb {
const wide = math.mulWide(Limb, x, y);
return .{
- .hi = @as(Limb, @truncate(wide >> @typeInfo(Limb).Int.bits)),
+ .hi = @as(Limb, @truncate(wide >> @typeInfo(Limb).int.bits)),
.lo = @as(Limb, @truncate(wide)),
};
}
diff --git a/lib/std/crypto/phc_encoding.zig b/lib/std/crypto/phc_encoding.zig
index fecd7f1239..3442073632 100644
--- a/lib/std/crypto/phc_encoding.zig
+++ b/lib/std/crypto/phc_encoding.zig
@@ -91,7 +91,7 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult
if (mem.eql(u8, opt_version.key, version_param_name)) {
if (@hasField(HashResult, "alg_version")) {
const value_type_info = switch (@typeInfo(@TypeOf(out.alg_version))) {
- .Optional => |opt| comptime @typeInfo(opt.child),
+ .optional => |opt| @typeInfo(opt.child),
else => |t| t,
};
out.alg_version = fmt.parseUnsigned(
@@ -114,16 +114,16 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult
inline for (comptime meta.fields(HashResult)) |p| {
if (mem.eql(u8, p.name, param.key)) {
switch (@typeInfo(p.type)) {
- .Int => @field(out, p.name) = fmt.parseUnsigned(
+ .int => @field(out, p.name) = fmt.parseUnsigned(
p.type,
param.value,
10,
) catch return Error.InvalidEncoding,
- .Pointer => |ptr| {
+ .pointer => |ptr| {
if (!ptr.is_const) @compileError("Value slice must be constant");
@field(out, p.name) = param.value;
},
- .Struct => try @field(out, p.name).fromB64(param.value),
+ .@"struct" => try @field(out, p.name).fromB64(param.value),
else => std.debug.panic(
"Value for [{s}] must be an integer, a constant slice or a BinValue",
.{p.name},
@@ -164,7 +164,7 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult
// with default values
var expected_fields: usize = 0;
inline for (comptime meta.fields(HashResult)) |p| {
- if (@typeInfo(p.type) != .Optional and p.default_value == null) {
+ if (@typeInfo(p.type) != .optional and p.default_value == null) {
expected_fields += 1;
}
}
@@ -202,7 +202,7 @@ fn serializeTo(params: anytype, out: anytype) !void {
try out.writeAll(params.alg_id);
if (@hasField(HashResult, "alg_version")) {
- if (@typeInfo(@TypeOf(params.alg_version)) == .Optional) {
+ if (@typeInfo(@TypeOf(params.alg_version)) == .optional) {
if (params.alg_version) |alg_version| {
try out.print(
"{s}{s}{s}{}",
@@ -226,12 +226,12 @@ fn serializeTo(params: anytype, out: anytype) !void {
{
const value = @field(params, p.name);
try out.writeAll(if (has_params) params_delimiter else fields_delimiter);
- if (@typeInfo(p.type) == .Struct) {
+ if (@typeInfo(p.type) == .@"struct") {
var buf: [@TypeOf(value).max_encoded_length]u8 = undefined;
try out.print("{s}{s}{s}", .{ p.name, kv_delimiter, try value.toB64(&buf) });
} else {
try out.print(
- if (@typeInfo(@TypeOf(value)) == .Pointer) "{s}{s}{s}" else "{s}{s}{}",
+ if (@typeInfo(@TypeOf(value)) == .pointer) "{s}{s}{s}" else "{s}{s}{}",
.{ p.name, kv_delimiter, value },
);
}
diff --git a/lib/std/crypto/timing_safe.zig b/lib/std/crypto/timing_safe.zig
index 4adeb9cf69..72543340c3 100644
--- a/lib/std/crypto/timing_safe.zig
+++ b/lib/std/crypto/timing_safe.zig
@@ -11,27 +11,27 @@ const Order = std.math.Order;
/// For all other applications, use mem.eql() instead.
pub fn eql(comptime T: type, a: T, b: T) bool {
switch (@typeInfo(T)) {
- .Array => |info| {
+ .array => |info| {
const C = info.child;
- if (@typeInfo(C) != .Int) {
+ if (@typeInfo(C) != .int) {
@compileError("Elements to be compared must be integers");
}
var acc = @as(C, 0);
for (a, 0..) |x, i| {
acc |= x ^ b[i];
}
- const s = @typeInfo(C).Int.bits;
+ const s = @typeInfo(C).int.bits;
const Cu = std.meta.Int(.unsigned, s);
const Cext = std.meta.Int(.unsigned, s + 1);
return @as(bool, @bitCast(@as(u1, @truncate((@as(Cext, @as(Cu, @bitCast(acc))) -% 1) >> s))));
},
- .Vector => |info| {
+ .vector => |info| {
const C = info.child;
- if (@typeInfo(C) != .Int) {
+ if (@typeInfo(C) != .int) {
@compileError("Elements to be compared must be integers");
}
const acc = @reduce(.Or, a ^ b);
- const s = @typeInfo(C).Int.bits;
+ const s = @typeInfo(C).int.bits;
const Cu = std.meta.Int(.unsigned, s);
const Cext = std.meta.Int(.unsigned, s + 1);
return @as(bool, @bitCast(@as(u1, @truncate((@as(Cext, @as(Cu, @bitCast(acc))) -% 1) >> s))));
@@ -47,7 +47,7 @@ pub fn eql(comptime T: type, a: T, b: T) bool {
pub fn compare(comptime T: type, a: []const T, b: []const T, endian: Endian) Order {
assert(a.len == b.len);
const bits = switch (@typeInfo(T)) {
- .Int => |cinfo| if (cinfo.signedness != .unsigned) @compileError("Elements to be compared must be unsigned") else cinfo.bits,
+ .int => |cinfo| if (cinfo.signedness != .unsigned) @compileError("Elements to be compared must be unsigned") else cinfo.bits,
else => @compileError("Elements to be compared must be integers"),
};
const Cext = std.meta.Int(.unsigned, bits + 1);
diff --git a/lib/std/crypto/tls.zig b/lib/std/crypto/tls.zig
index fbb41a3fd7..b3d0dcb59f 100644
--- a/lib/std/crypto/tls.zig
+++ b/lib/std/crypto/tls.zig
@@ -491,7 +491,7 @@ pub const Decoder = struct {
/// Use this function to increase `idx`.
pub fn decode(d: *Decoder, comptime T: type) T {
switch (@typeInfo(T)) {
- .Int => |info| switch (info.bits) {
+ .int => |info| switch (info.bits) {
8 => {
skip(d, 1);
return d.buf[d.idx - 1];
@@ -511,7 +511,7 @@ pub const Decoder = struct {
},
else => @compileError("unsupported int type: " ++ @typeName(T)),
},
- .Enum => |info| {
+ .@"enum" => |info| {
const int = d.decode(info.tag_type);
if (info.is_exhaustive) @compileError("exhaustive enum cannot be used");
return @as(T, @enumFromInt(int));
diff --git a/lib/std/debug.zig b/lib/std/debug.zig
index 4672f7ac06..4424bb1af1 100644
--- a/lib/std/debug.zig
+++ b/lib/std/debug.zig
@@ -547,7 +547,7 @@ pub fn writeStackTrace(
}
pub const UnwindError = if (have_ucontext)
- @typeInfo(@typeInfo(@TypeOf(StackIterator.next_unwind)).Fn.return_type.?).ErrorUnion.error_set
+ @typeInfo(@typeInfo(@TypeOf(StackIterator.next_unwind)).@"fn".return_type.?).error_union.error_set
else
void;
diff --git a/lib/std/debug/Dwarf.zig b/lib/std/debug/Dwarf.zig
index 7cce30df38..c311dc4cf6 100644
--- a/lib/std/debug/Dwarf.zig
+++ b/lib/std/debug/Dwarf.zig
@@ -2216,7 +2216,7 @@ pub const ElfModule = struct {
}
var section_index: ?usize = null;
- inline for (@typeInfo(Dwarf.Section.Id).Enum.fields, 0..) |sect, i| {
+ inline for (@typeInfo(Dwarf.Section.Id).@"enum".fields, 0..) |sect, i| {
if (mem.eql(u8, "." ++ sect.name, name)) section_index = i;
}
if (section_index == null) continue;
diff --git a/lib/std/debug/Dwarf/expression.zig b/lib/std/debug/Dwarf/expression.zig
index 5fab56de6e..f71a4e02c1 100644
--- a/lib/std/debug/Dwarf/expression.zig
+++ b/lib/std/debug/Dwarf/expression.zig
@@ -164,7 +164,7 @@ pub fn StackMachine(comptime options: Options) type {
}
fn generic(value: anytype) Operand {
- const int_info = @typeInfo(@TypeOf(value)).Int;
+ const int_info = @typeInfo(@TypeOf(value)).int;
if (@sizeOf(@TypeOf(value)) > options.addr_size) {
return .{ .generic = switch (int_info.signedness) {
.signed => @bitCast(@as(addr_type_signed, @truncate(value))),
@@ -843,7 +843,7 @@ pub fn Builder(comptime options: Options) type {
}
pub fn writeConst(writer: anytype, comptime T: type, value: T) !void {
- if (@typeInfo(T) != .Int) @compileError("Constants must be integers");
+ if (@typeInfo(T) != .int) @compileError("Constants must be integers");
switch (T) {
u8, i8, u16, i16, u32, i32, u64, i64 => {
@@ -861,7 +861,7 @@ pub fn Builder(comptime options: Options) type {
try writer.writeInt(T, value, options.endian);
},
- else => switch (@typeInfo(T).Int.signedness) {
+ else => switch (@typeInfo(T).int.signedness) {
.unsigned => {
try writer.writeByte(OP.constu);
try leb.writeUleb128(writer, value);
diff --git a/lib/std/debug/FixedBufferReader.zig b/lib/std/debug/FixedBufferReader.zig
index 494245a9e9..e4aec1a9c6 100644
--- a/lib/std/debug/FixedBufferReader.zig
+++ b/lib/std/debug/FixedBufferReader.zig
@@ -32,7 +32,7 @@ pub fn readByteSigned(fbr: *FixedBufferReader) Error!i8 {
}
pub fn readInt(fbr: *FixedBufferReader, comptime T: type) Error!T {
- const size = @divExact(@typeInfo(T).Int.bits, 8);
+ const size = @divExact(@typeInfo(T).int.bits, 8);
if (fbr.buf.len - fbr.pos < size) return error.EndOfBuffer;
defer fbr.pos += size;
return std.mem.readInt(T, fbr.buf[fbr.pos..][0..size], fbr.endian);
diff --git a/lib/std/debug/Pdb.zig b/lib/std/debug/Pdb.zig
index bdcc108c1d..2b2f37e7b6 100644
--- a/lib/std/debug/Pdb.zig
+++ b/lib/std/debug/Pdb.zig
@@ -495,7 +495,7 @@ const MsfStream = struct {
blocks: []u32 = undefined,
block_size: u32 = undefined,
- pub const Error = @typeInfo(@typeInfo(@TypeOf(read)).Fn.return_type.?).ErrorUnion.error_set;
+ pub const Error = @typeInfo(@typeInfo(@TypeOf(read)).@"fn".return_type.?).error_union.error_set;
fn init(block_size: u32, file: File, blocks: []u32) MsfStream {
const stream = MsfStream{
diff --git a/lib/std/debug/SelfInfo.zig b/lib/std/debug/SelfInfo.zig
index 5d2dca960b..19adebf711 100644
--- a/lib/std/debug/SelfInfo.zig
+++ b/lib/std/debug/SelfInfo.zig
@@ -37,7 +37,7 @@ modules: if (native_os == .windows) std.ArrayListUnmanaged(WindowsModule) else v
pub const OpenError = error{
MissingDebugInfo,
UnsupportedOperatingSystem,
-} || @typeInfo(@typeInfo(@TypeOf(SelfInfo.init)).Fn.return_type.?).ErrorUnion.error_set;
+} || @typeInfo(@typeInfo(@TypeOf(SelfInfo.init)).@"fn".return_type.?).error_union.error_set;
pub fn open(allocator: Allocator) OpenError!SelfInfo {
nosuspend {
@@ -582,7 +582,7 @@ pub const Module = switch (native_os) {
if (!std.mem.eql(u8, "__DWARF", sect.segName())) continue;
var section_index: ?usize = null;
- inline for (@typeInfo(Dwarf.Section.Id).Enum.fields, 0..) |section, i| {
+ inline for (@typeInfo(Dwarf.Section.Id).@"enum".fields, 0..) |section, i| {
if (mem.eql(u8, "__" ++ section.name, sect.sectName())) section_index = i;
}
if (section_index == null) continue;
@@ -981,7 +981,7 @@ fn readCoffDebugInfo(allocator: Allocator, coff_obj: *coff.Coff) !Module {
var sections: Dwarf.SectionArray = Dwarf.null_section_array;
errdefer for (sections) |section| if (section) |s| if (s.owned) allocator.free(s.data);
- inline for (@typeInfo(Dwarf.Section.Id).Enum.fields, 0..) |section, i| {
+ inline for (@typeInfo(Dwarf.Section.Id).@"enum".fields, 0..) |section, i| {
sections[i] = if (coff_obj.getSectionByName("." ++ section.name)) |section_header| blk: {
break :blk .{
.data = try coff_obj.getSectionDataAlloc(section_header, allocator),
@@ -1443,7 +1443,7 @@ pub fn unwindFrameMachO(
if (ma.load(usize, new_sp) == null or ma.load(usize, min_reg_addr) == null) return error.InvalidUnwindInfo;
var reg_addr = fp - @sizeOf(usize);
- inline for (@typeInfo(@TypeOf(encoding.value.arm64.frame.x_reg_pairs)).Struct.fields, 0..) |field, i| {
+ inline for (@typeInfo(@TypeOf(encoding.value.arm64.frame.x_reg_pairs)).@"struct".fields, 0..) |field, i| {
if (@field(encoding.value.arm64.frame.x_reg_pairs, field.name) != 0) {
(try regValueNative(context.thread_context, 19 + i, reg_context)).* = @as(*const usize, @ptrFromInt(reg_addr)).*;
reg_addr += @sizeOf(usize);
@@ -1452,7 +1452,7 @@ pub fn unwindFrameMachO(
}
}
- inline for (@typeInfo(@TypeOf(encoding.value.arm64.frame.d_reg_pairs)).Struct.fields, 0..) |field, i| {
+ inline for (@typeInfo(@TypeOf(encoding.value.arm64.frame.d_reg_pairs)).@"struct".fields, 0..) |field, i| {
if (@field(encoding.value.arm64.frame.d_reg_pairs, field.name) != 0) {
// Only the lower half of the 128-bit V registers are restored during unwinding
@memcpy(
diff --git a/lib/std/enums.zig b/lib/std/enums.zig
index 1cc7bde8d2..a051d96112 100644
--- a/lib/std/enums.zig
+++ b/lib/std/enums.zig
@@ -13,9 +13,9 @@ const eval_branch_quota_cushion = 10;
/// the first name is used. Each field is of type Data and has the provided
/// default, which may be undefined.
pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_default: ?Data) type {
- @setEvalBranchQuota(@typeInfo(E).Enum.fields.len + eval_branch_quota_cushion);
- var struct_fields: [@typeInfo(E).Enum.fields.len]std.builtin.Type.StructField = undefined;
- for (&struct_fields, @typeInfo(E).Enum.fields) |*struct_field, enum_field| {
+ @setEvalBranchQuota(@typeInfo(E).@"enum".fields.len + eval_branch_quota_cushion);
+ var struct_fields: [@typeInfo(E).@"enum".fields.len]std.builtin.Type.StructField = undefined;
+ for (&struct_fields, @typeInfo(E).@"enum".fields) |*struct_field, enum_field| {
struct_field.* = .{
.name = enum_field.name ++ "",
.type = Data,
@@ -24,7 +24,7 @@ pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_def
.alignment = if (@sizeOf(Data) > 0) @alignOf(Data) else 0,
};
}
- return @Type(.{ .Struct = .{
+ return @Type(.{ .@"struct" = .{
.layout = .auto,
.fields = &struct_fields,
.decls = &.{},
@@ -49,14 +49,14 @@ pub inline fn valuesFromFields(comptime E: type, comptime fields: []const EnumFi
/// Returns the set of all named values in the given enum, in
/// declaration order.
pub fn values(comptime E: type) []const E {
- return comptime valuesFromFields(E, @typeInfo(E).Enum.fields);
+ return comptime valuesFromFields(E, @typeInfo(E).@"enum".fields);
}
/// A safe alternative to @tagName() for non-exhaustive enums that doesn't
/// panic when `e` has no tagged value.
/// Returns the tag name for `e` or null if no tag exists.
pub fn tagName(comptime E: type, e: E) ?[]const u8 {
- return inline for (@typeInfo(E).Enum.fields) |f| {
+ return inline for (@typeInfo(E).@"enum".fields) |f| {
if (@intFromEnum(e) == f.value) break f.name;
} else null;
}
@@ -80,7 +80,7 @@ test tagName {
pub fn directEnumArrayLen(comptime E: type, comptime max_unused_slots: comptime_int) comptime_int {
var max_value: comptime_int = -1;
const max_usize: comptime_int = ~@as(usize, 0);
- const fields = @typeInfo(E).Enum.fields;
+ const fields = @typeInfo(E).@"enum".fields;
for (fields) |f| {
if (f.value < 0) {
@compileError("Cannot create a direct enum array for " ++ @typeName(E) ++ ", field ." ++ f.name ++ " has a negative value.");
@@ -159,7 +159,7 @@ pub fn directEnumArrayDefault(
) [directEnumArrayLen(E, max_unused_slots)]Data {
const len = comptime directEnumArrayLen(E, max_unused_slots);
var result: [len]Data = if (default) |d| [_]Data{d} ** len else undefined;
- inline for (@typeInfo(@TypeOf(init_values)).Struct.fields) |f| {
+ inline for (@typeInfo(@TypeOf(init_values)).@"struct".fields) |f| {
const enum_value = @field(E, f.name);
const index = @as(usize, @intCast(@intFromEnum(enum_value)));
result[index] = @field(init_values, f.name);
@@ -204,8 +204,8 @@ pub fn nameCast(comptime E: type, comptime value: anytype) E {
const V = @TypeOf(value);
if (V == E) break :blk value;
const name: ?[]const u8 = switch (@typeInfo(V)) {
- .EnumLiteral, .Enum => @tagName(value),
- .Pointer => value,
+ .enum_literal, .@"enum" => @tagName(value),
+ .pointer => value,
else => null,
};
if (name) |n| {
@@ -262,9 +262,9 @@ pub fn EnumSet(comptime E: type) type {
/// Initializes the set using a struct of bools
pub fn init(init_values: EnumFieldStruct(E, bool, false)) Self {
- @setEvalBranchQuota(2 * @typeInfo(E).Enum.fields.len);
+ @setEvalBranchQuota(2 * @typeInfo(E).@"enum".fields.len);
var result: Self = .{};
- if (@typeInfo(E).Enum.is_exhaustive) {
+ if (@typeInfo(E).@"enum".is_exhaustive) {
inline for (0..Self.len) |i| {
const key = comptime Indexer.keyForIndex(i);
const tag = @tagName(key);
@@ -453,9 +453,9 @@ pub fn EnumMap(comptime E: type, comptime V: type) type {
/// Initializes the map using a sparse struct of optionals
pub fn init(init_values: EnumFieldStruct(E, ?Value, @as(?Value, null))) Self {
- @setEvalBranchQuota(2 * @typeInfo(E).Enum.fields.len);
+ @setEvalBranchQuota(2 * @typeInfo(E).@"enum".fields.len);
var result: Self = .{};
- if (@typeInfo(E).Enum.is_exhaustive) {
+ if (@typeInfo(E).@"enum".is_exhaustive) {
inline for (0..Self.len) |i| {
const key = comptime Indexer.keyForIndex(i);
const tag = @tagName(key);
@@ -497,7 +497,7 @@ pub fn EnumMap(comptime E: type, comptime V: type) type {
/// Initializes a full mapping with a provided default.
/// Consider using EnumArray instead if the map will remain full.
pub fn initFullWithDefault(comptime default: ?Value, init_values: EnumFieldStruct(E, Value, default)) Self {
- @setEvalBranchQuota(2 * @typeInfo(E).Enum.fields.len);
+ @setEvalBranchQuota(2 * @typeInfo(E).@"enum".fields.len);
var result: Self = .{
.bits = Self.BitSet.initFull(),
.values = undefined,
@@ -683,9 +683,9 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {
/// Initializes the multiset using a struct of counts.
pub fn init(init_counts: EnumFieldStruct(E, CountSize, 0)) Self {
- @setEvalBranchQuota(2 * @typeInfo(E).Enum.fields.len);
+ @setEvalBranchQuota(2 * @typeInfo(E).@"enum".fields.len);
var self = initWithCount(0);
- inline for (@typeInfo(E).Enum.fields) |field| {
+ inline for (@typeInfo(E).@"enum".fields) |field| {
const c = @field(init_counts, field.name);
const key = @as(E, @enumFromInt(field.value));
self.counts.set(key, c);
@@ -757,7 +757,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {
/// Increases the all key counts by given multiset. Caller
/// asserts operation will not overflow any key.
pub fn addSetAssertSafe(self: *Self, other: Self) void {
- inline for (@typeInfo(E).Enum.fields) |field| {
+ inline for (@typeInfo(E).@"enum".fields) |field| {
const key = @as(E, @enumFromInt(field.value));
self.addAssertSafe(key, other.getCount(key));
}
@@ -765,7 +765,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {
/// Increases the all key counts by given multiset.
pub fn addSet(self: *Self, other: Self) error{Overflow}!void {
- inline for (@typeInfo(E).Enum.fields) |field| {
+ inline for (@typeInfo(E).@"enum".fields) |field| {
const key = @as(E, @enumFromInt(field.value));
try self.add(key, other.getCount(key));
}
@@ -775,7 +775,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {
/// the given multiset has more key counts than this,
/// then that key will have a key count of zero.
pub fn removeSet(self: *Self, other: Self) void {
- inline for (@typeInfo(E).Enum.fields) |field| {
+ inline for (@typeInfo(E).@"enum".fields) |field| {
const key = @as(E, @enumFromInt(field.value));
self.remove(key, other.getCount(key));
}
@@ -784,7 +784,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {
/// Returns true iff all key counts are the same as
/// given multiset.
pub fn eql(self: Self, other: Self) bool {
- inline for (@typeInfo(E).Enum.fields) |field| {
+ inline for (@typeInfo(E).@"enum".fields) |field| {
const key = @as(E, @enumFromInt(field.value));
if (self.getCount(key) != other.getCount(key)) {
return false;
@@ -796,7 +796,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {
/// Returns true iff all key counts less than or
/// equal to the given multiset.
pub fn subsetOf(self: Self, other: Self) bool {
- inline for (@typeInfo(E).Enum.fields) |field| {
+ inline for (@typeInfo(E).@"enum".fields) |field| {
const key = @as(E, @enumFromInt(field.value));
if (self.getCount(key) > other.getCount(key)) {
return false;
@@ -808,7 +808,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {
/// Returns true iff all key counts greater than or
/// equal to the given multiset.
pub fn supersetOf(self: Self, other: Self) bool {
- inline for (@typeInfo(E).Enum.fields) |field| {
+ inline for (@typeInfo(E).@"enum".fields) |field| {
const key = @as(E, @enumFromInt(field.value));
if (self.getCount(key) < other.getCount(key)) {
return false;
@@ -1087,7 +1087,7 @@ pub fn EnumArray(comptime E: type, comptime V: type) type {
/// Initializes values in the enum array, with the specified default.
pub fn initDefault(comptime default: ?Value, init_values: EnumFieldStruct(E, Value, default)) Self {
- @setEvalBranchQuota(2 * @typeInfo(E).Enum.fields.len);
+ @setEvalBranchQuota(2 * @typeInfo(E).@"enum".fields.len);
var result: Self = .{ .values = undefined };
inline for (0..Self.len) |i| {
const key = comptime Indexer.keyForIndex(i);
@@ -1277,17 +1277,17 @@ test "EnumSet non-exhaustive" {
pub fn EnumIndexer(comptime E: type) type {
// Assumes that the enum fields are sorted in ascending order (optimistic).
// Unsorted enums may require the user to manually increase the quota.
- @setEvalBranchQuota(3 * @typeInfo(E).Enum.fields.len + eval_branch_quota_cushion);
+ @setEvalBranchQuota(3 * @typeInfo(E).@"enum".fields.len + eval_branch_quota_cushion);
- if (!@typeInfo(E).Enum.is_exhaustive) {
- const BackingInt = @typeInfo(E).Enum.tag_type;
+ if (!@typeInfo(E).@"enum".is_exhaustive) {
+ const BackingInt = @typeInfo(E).@"enum".tag_type;
if (@bitSizeOf(BackingInt) > @bitSizeOf(usize))
@compileError("Cannot create an enum indexer for a given non-exhaustive enum, tag_type is larger than usize.");
return struct {
pub const Key: type = E;
- const backing_int_sign = @typeInfo(BackingInt).Int.signedness;
+ const backing_int_sign = @typeInfo(BackingInt).int.signedness;
const min_value = std.math.minInt(BackingInt);
const max_value = std.math.maxInt(BackingInt);
@@ -1312,7 +1312,7 @@ pub fn EnumIndexer(comptime E: type) type {
};
}
- const const_fields = @typeInfo(E).Enum.fields;
+ const const_fields = @typeInfo(E).@"enum".fields;
var fields = const_fields[0..const_fields.len].*;
const fields_len = fields.len;
@@ -1359,7 +1359,7 @@ pub fn EnumIndexer(comptime E: type) type {
// gives up some safety to avoid artificially limiting
// the range of signed enum values to max_isize.
const enum_value = if (min < 0) @as(isize, @bitCast(i)) +% min else i + min;
- return @as(E, @enumFromInt(@as(@typeInfo(E).Enum.tag_type, @intCast(enum_value))));
+ return @as(E, @enumFromInt(@as(@typeInfo(E).@"enum".tag_type, @intCast(enum_value))));
}
};
}
@@ -1411,7 +1411,7 @@ test "EnumIndexer non-exhaustive" {
const RangedType = std.meta.Int(.unsigned, @bitSizeOf(BackingInt));
const max_index: comptime_int = std.math.maxInt(RangedType);
- const number_zero_tag_index: usize = switch (@typeInfo(BackingInt).Int.signedness) {
+ const number_zero_tag_index: usize = switch (@typeInfo(BackingInt).int.signedness) {
.unsigned => 0,
.signed => std.math.divCeil(comptime_int, max_index, 2) catch unreachable,
};
diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig
index a7136d99bb..7f323248cf 100644
--- a/lib/std/fmt.zig
+++ b/lib/std/fmt.zig
@@ -87,11 +87,11 @@ pub fn format(
) !void {
const ArgsType = @TypeOf(args);
const args_type_info = @typeInfo(ArgsType);
- if (args_type_info != .Struct) {
+ if (args_type_info != .@"struct") {
@compileError("expected tuple or struct argument, found " ++ @typeName(ArgsType));
}
- const fields_info = args_type_info.Struct.fields;
+ const fields_info = args_type_info.@"struct".fields;
if (fields_info.len > max_format_args) {
@compileError("32 arguments max are supported per format call");
}
@@ -397,7 +397,7 @@ pub const Parser = struct {
};
pub const ArgSetType = u32;
-const max_format_args = @typeInfo(ArgSetType).Int.bits;
+const max_format_args = @typeInfo(ArgSetType).int.bits;
pub const ArgState = struct {
next_arg: usize = 0,
@@ -430,7 +430,7 @@ pub fn formatAddress(value: anytype, options: FormatOptions, writer: anytype) @T
const T = @TypeOf(value);
switch (@typeInfo(T)) {
- .Pointer => |info| {
+ .pointer => |info| {
try writer.writeAll(@typeName(info.child) ++ "@");
if (info.size == .Slice)
try formatInt(@intFromPtr(value.ptr), 16, .lower, FormatOptions{}, writer)
@@ -438,8 +438,8 @@ pub fn formatAddress(value: anytype, options: FormatOptions, writer: anytype) @T
try formatInt(@intFromPtr(value), 16, .lower, FormatOptions{}, writer);
return;
},
- .Optional => |info| {
- if (@typeInfo(info.child) == .Pointer) {
+ .optional => |info| {
+ if (@typeInfo(info.child) == .pointer) {
try writer.writeAll(@typeName(info.child) ++ "@");
try formatInt(@intFromPtr(value), 16, .lower, FormatOptions{}, writer);
return;
@@ -456,17 +456,17 @@ const ANY = "any";
pub fn defaultSpec(comptime T: type) [:0]const u8 {
switch (@typeInfo(T)) {
- .Array => |_| return ANY,
- .Pointer => |ptr_info| switch (ptr_info.size) {
+ .array => |_| return ANY,
+ .pointer => |ptr_info| switch (ptr_info.size) {
.One => switch (@typeInfo(ptr_info.child)) {
- .Array => |_| return ANY,
+ .array => |_| return ANY,
else => {},
},
.Many, .C => return "*",
.Slice => return ANY,
},
- .Optional => |info| return "?" ++ defaultSpec(info.child),
- .ErrorUnion => |info| return "!" ++ defaultSpec(info.payload),
+ .optional => |info| return "?" ++ defaultSpec(info.child),
+ .error_union => |info| return "!" ++ defaultSpec(info.payload),
else => {},
}
return "";
@@ -494,7 +494,7 @@ pub fn formatType(
const actual_fmt = comptime if (std.mem.eql(u8, fmt, ANY))
defaultSpec(T)
else if (fmt.len != 0 and (fmt[0] == '?' or fmt[0] == '!')) switch (@typeInfo(T)) {
- .Optional, .ErrorUnion => fmt,
+ .optional, .error_union => fmt,
else => stripOptionalOrErrorUnionSpec(fmt),
} else fmt;
@@ -507,18 +507,18 @@ pub fn formatType(
}
switch (@typeInfo(T)) {
- .ComptimeInt, .Int, .ComptimeFloat, .Float => {
+ .comptime_int, .int, .comptime_float, .float => {
return formatValue(value, actual_fmt, options, writer);
},
- .Void => {
+ .void => {
if (actual_fmt.len != 0) invalidFmtError(fmt, value);
return formatBuf("void", options, writer);
},
- .Bool => {
+ .bool => {
if (actual_fmt.len != 0) invalidFmtError(fmt, value);
return formatBuf(if (value) "true" else "false", options, writer);
},
- .Optional => {
+ .optional => {
if (actual_fmt.len == 0 or actual_fmt[0] != '?')
@compileError("cannot format optional without a specifier (i.e. {?} or {any})");
const remaining_fmt = comptime stripOptionalOrErrorUnionSpec(actual_fmt);
@@ -528,7 +528,7 @@ pub fn formatType(
return formatBuf("null", options, writer);
}
},
- .ErrorUnion => {
+ .error_union => {
if (actual_fmt.len == 0 or actual_fmt[0] != '!')
@compileError("cannot format error union without a specifier (i.e. {!} or {any})");
const remaining_fmt = comptime stripOptionalOrErrorUnionSpec(actual_fmt);
@@ -538,12 +538,12 @@ pub fn formatType(
return formatType(err, "", options, writer, max_depth);
}
},
- .ErrorSet => {
+ .error_set => {
if (actual_fmt.len != 0) invalidFmtError(fmt, value);
try writer.writeAll("error.");
return writer.writeAll(@errorName(value));
},
- .Enum => |enumInfo| {
+ .@"enum" => |enumInfo| {
try writer.writeAll(@typeName(T));
if (enumInfo.is_exhaustive) {
if (actual_fmt.len != 0) invalidFmtError(fmt, value);
@@ -566,7 +566,7 @@ pub fn formatType(
try formatType(@intFromEnum(value), actual_fmt, options, writer, max_depth);
try writer.writeAll(")");
},
- .Union => |info| {
+ .@"union" => |info| {
if (actual_fmt.len != 0) invalidFmtError(fmt, value);
try writer.writeAll(@typeName(T));
if (max_depth == 0) {
@@ -586,7 +586,7 @@ pub fn formatType(
try format(writer, "@{x}", .{@intFromPtr(&value)});
}
},
- .Struct => |info| {
+ .@"struct" => |info| {
if (actual_fmt.len != 0) invalidFmtError(fmt, value);
if (info.is_tuple) {
// Skip the type and field names when formatting tuples.
@@ -621,9 +621,9 @@ pub fn formatType(
}
try writer.writeAll(" }");
},
- .Pointer => |ptr_info| switch (ptr_info.size) {
+ .pointer => |ptr_info| switch (ptr_info.size) {
.One => switch (@typeInfo(ptr_info.child)) {
- .Array, .Enum, .Union, .Struct => {
+ .array, .@"enum", .@"union", .@"struct" => {
return formatType(value.*, actual_fmt, options, writer, max_depth);
},
else => return format(writer, "{s}@{x}", .{ @typeName(ptr_info.child), @intFromPtr(value) }),
@@ -658,7 +658,7 @@ pub fn formatType(
try writer.writeAll(" }");
},
},
- .Array => |info| {
+ .array => |info| {
if (actual_fmt.len == 0)
@compileError("cannot format array without a specifier (i.e. {s} or {any})");
if (max_depth == 0) {
@@ -676,7 +676,7 @@ pub fn formatType(
}
try writer.writeAll(" }");
},
- .Vector => |info| {
+ .vector => |info| {
try writer.writeAll("{ ");
var i: usize = 0;
while (i < info.len) : (i += 1) {
@@ -687,17 +687,17 @@ pub fn formatType(
}
try writer.writeAll(" }");
},
- .Fn => @compileError("unable to format function body type, use '*const " ++ @typeName(T) ++ "' for a function pointer type"),
- .Type => {
+ .@"fn" => @compileError("unable to format function body type, use '*const " ++ @typeName(T) ++ "' for a function pointer type"),
+ .type => {
if (actual_fmt.len != 0) invalidFmtError(fmt, value);
return formatBuf(@typeName(value), options, writer);
},
- .EnumLiteral => {
+ .enum_literal => {
if (actual_fmt.len != 0) invalidFmtError(fmt, value);
const buffer = [_]u8{'.'} ++ @tagName(value);
return formatBuf(buffer, options, writer);
},
- .Null => {
+ .null => {
if (actual_fmt.len != 0) invalidFmtError(fmt, value);
return formatBuf("null", options, writer);
},
@@ -713,9 +713,9 @@ fn formatValue(
) !void {
const T = @TypeOf(value);
switch (@typeInfo(T)) {
- .Float, .ComptimeFloat => return formatFloatValue(value, fmt, options, writer),
- .Int, .ComptimeInt => return formatIntValue(value, fmt, options, writer),
- .Bool => return formatBuf(if (value) "true" else "false", options, writer),
+ .float, .comptime_float => return formatFloatValue(value, fmt, options, writer),
+ .int, .comptime_int => return formatIntValue(value, fmt, options, writer),
+ .bool => return formatBuf(if (value) "true" else "false", options, writer),
else => comptime unreachable,
}
}
@@ -738,13 +738,13 @@ pub fn formatIntValue(
base = 10;
case = .lower;
} else if (comptime std.mem.eql(u8, fmt, "c")) {
- if (@typeInfo(@TypeOf(int_value)).Int.bits <= 8) {
+ if (@typeInfo(@TypeOf(int_value)).int.bits <= 8) {
return formatAsciiChar(@as(u8, int_value), options, writer);
} else {
@compileError("cannot print integer that is larger than 8 bits as an ASCII character");
}
} else if (comptime std.mem.eql(u8, fmt, "u")) {
- if (@typeInfo(@TypeOf(int_value)).Int.bits <= 21) {
+ if (@typeInfo(@TypeOf(int_value)).int.bits <= 21) {
return formatUnicodeCodepoint(@as(u21, int_value), options, writer);
} else {
@compileError("cannot print integer that is larger than 21 bits as an UTF-8 sequence");
@@ -1179,7 +1179,7 @@ pub fn formatInt(
break :blk @as(Int, value);
} else value;
- const value_info = @typeInfo(@TypeOf(int_value)).Int;
+ const value_info = @typeInfo(@TypeOf(int_value)).int;
// The type must have the same size as `base` or be wider in order for the
// division to work
@@ -1480,7 +1480,7 @@ pub const ParseIntError = error{
/// ) !void;
///
pub fn Formatter(comptime format_fn: anytype) type {
- const Data = @typeInfo(@TypeOf(format_fn)).Fn.params[0].type.?;
+ const Data = @typeInfo(@TypeOf(format_fn)).@"fn".params[0].type.?;
return struct {
data: Data,
pub fn format(
@@ -1624,7 +1624,7 @@ fn parseIntWithSign(
// accumulate into Accumulate which is always 8 bits or larger. this prevents
// `buf_base` from overflowing Result.
const info = @typeInfo(Result);
- const Accumulate = std.meta.Int(info.Int.signedness, @max(8, info.Int.bits));
+ const Accumulate = std.meta.Int(info.int.signedness, @max(8, info.int.bits));
var accumulate: Accumulate = 0;
if (buf_start[0] == '_' or buf_start[buf_start.len - 1] == '_') return error.InvalidCharacter;
@@ -2724,7 +2724,7 @@ pub const hex_charset = "0123456789abcdef";
/// Converts an unsigned integer of any multiple of u8 to an array of lowercase
/// hex bytes, little endian.
pub fn hex(x: anytype) [@sizeOf(@TypeOf(x)) * 2]u8 {
- comptime assert(@typeInfo(@TypeOf(x)).Int.signedness == .unsigned);
+ comptime assert(@typeInfo(@TypeOf(x)).int.signedness == .unsigned);
var result: [@sizeOf(@TypeOf(x)) * 2]u8 = undefined;
var i: usize = 0;
while (i < result.len / 2) : (i += 1) {
diff --git a/lib/std/fmt/format_float.zig b/lib/std/fmt/format_float.zig
index b7b08281a7..4c4c1a2922 100644
--- a/lib/std/fmt/format_float.zig
+++ b/lib/std/fmt/format_float.zig
@@ -12,7 +12,7 @@ pub const min_buffer_size = 53;
/// Returns the minimum buffer size needed to print every float of a specific type and format.
pub fn bufferSize(comptime mode: Format, comptime T: type) comptime_int {
- comptime std.debug.assert(@typeInfo(T) == .Float);
+ comptime std.debug.assert(@typeInfo(T) == .float);
return switch (mode) {
.scientific => 53,
// Based on minimum subnormal values.
@@ -60,8 +60,8 @@ pub fn formatFloat(buf: []u8, v_: anytype, options: FormatOptions) FormatError![
};
const T = @TypeOf(v);
- comptime std.debug.assert(@typeInfo(T) == .Float);
- const I = @Type(.{ .Int = .{ .signedness = .unsigned, .bits = @bitSizeOf(T) } });
+ comptime std.debug.assert(@typeInfo(T) == .float);
+ const I = @Type(.{ .int = .{ .signedness = .unsigned, .bits = @bitSizeOf(T) } });
const DT = if (@bitSizeOf(T) <= 64) u64 else u128;
const tables = switch (DT) {
@@ -563,13 +563,13 @@ fn pow5Factor(value_: anytype) u32 {
fn multipleOfPowerOf5(value: anytype, p: u32) bool {
const T = @TypeOf(value);
- std.debug.assert(@typeInfo(T) == .Int);
+ std.debug.assert(@typeInfo(T) == .int);
return pow5Factor(value) >= p;
}
fn multipleOfPowerOf2(value: anytype, p: u32) bool {
const T = @TypeOf(value);
- std.debug.assert(@typeInfo(T) == .Int);
+ std.debug.assert(@typeInfo(T) == .int);
return (value & ((@as(T, 1) << @as(std.math.Log2Int(T), @intCast(p))) - 1)) == 0;
}
@@ -1516,7 +1516,7 @@ const FLOAT128_POW5_INV_ERRORS: [154]u64 = .{
const builtin = @import("builtin");
fn check(comptime T: type, value: T, comptime expected: []const u8) !void {
- const I = @Type(.{ .Int = .{ .signedness = .unsigned, .bits = @bitSizeOf(T) } });
+ const I = @Type(.{ .int = .{ .signedness = .unsigned, .bits = @bitSizeOf(T) } });
var buf: [6000]u8 = undefined;
const value_bits: I = @bitCast(value);
diff --git a/lib/std/fmt/parse_float.zig b/lib/std/fmt/parse_float.zig
index 425286ff07..cb47faee8d 100644
--- a/lib/std/fmt/parse_float.zig
+++ b/lib/std/fmt/parse_float.zig
@@ -17,7 +17,7 @@ pub const ParseFloatError = error{
};
pub fn parseFloat(comptime T: type, s: []const u8) ParseFloatError!T {
- if (@typeInfo(T) != .Float) {
+ if (@typeInfo(T) != .float) {
@compileError("Cannot parse a float into a non-floating point type.");
}
@@ -128,7 +128,7 @@ test parseFloat {
test "nan and inf" {
inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| {
- const Z = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);
+ const Z = std.meta.Int(.unsigned, @typeInfo(T).float.bits);
try expectEqual(@as(Z, @bitCast(try parseFloat(T, "nAn"))), @as(Z, @bitCast(std.math.nan(T))));
try expectEqual(try parseFloat(T, "inF"), std.math.inf(T));
diff --git a/lib/std/hash/auto_hash.zig b/lib/std/hash/auto_hash.zig
index b7321c0b9e..d9d3b1836d 100644
--- a/lib/std/hash/auto_hash.zig
+++ b/lib/std/hash/auto_hash.zig
@@ -22,7 +22,7 @@ pub const HashStrategy = enum {
pub fn hashPointer(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {
const info = @typeInfo(@TypeOf(key));
- switch (info.Pointer.size) {
+ switch (info.pointer.size) {
.One => switch (strat) {
.Shallow => hash(hasher, @intFromPtr(key), .Shallow),
.Deep => hash(hasher, key.*, .Shallow),
@@ -64,7 +64,7 @@ pub fn hashArray(hasher: anytype, key: anytype, comptime strat: HashStrategy) vo
pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {
const Key = @TypeOf(key);
const Hasher = switch (@typeInfo(@TypeOf(hasher))) {
- .Pointer => |ptr| ptr.child,
+ .pointer => |ptr| ptr.child,
else => @TypeOf(hasher),
};
@@ -74,24 +74,24 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {
}
switch (@typeInfo(Key)) {
- .NoReturn,
- .Opaque,
- .Undefined,
- .Null,
- .ComptimeFloat,
- .ComptimeInt,
- .Type,
- .EnumLiteral,
- .Frame,
- .Float,
+ .noreturn,
+ .@"opaque",
+ .undefined,
+ .null,
+ .comptime_float,
+ .comptime_int,
+ .type,
+ .enum_literal,
+ .frame,
+ .float,
=> @compileError("unable to hash type " ++ @typeName(Key)),
- .Void => return,
+ .void => return,
// Help the optimizer see that hashing an int is easy by inlining!
// TODO Check if the situation is better after #561 is resolved.
- .Int => |int| switch (int.signedness) {
- .signed => hash(hasher, @as(@Type(.{ .Int = .{
+ .int => |int| switch (int.signedness) {
+ .signed => hash(hasher, @as(@Type(.{ .int = .{
.bits = int.bits,
.signedness = .unsigned,
} }), @bitCast(key)), strat),
@@ -107,18 +107,18 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {
},
},
- .Bool => hash(hasher, @intFromBool(key), strat),
- .Enum => hash(hasher, @intFromEnum(key), strat),
- .ErrorSet => hash(hasher, @intFromError(key), strat),
- .AnyFrame, .Fn => hash(hasher, @intFromPtr(key), strat),
+ .bool => hash(hasher, @intFromBool(key), strat),
+ .@"enum" => hash(hasher, @intFromEnum(key), strat),
+ .error_set => hash(hasher, @intFromError(key), strat),
+ .@"anyframe", .@"fn" => hash(hasher, @intFromPtr(key), strat),
- .Pointer => @call(.always_inline, hashPointer, .{ hasher, key, strat }),
+ .pointer => @call(.always_inline, hashPointer, .{ hasher, key, strat }),
- .Optional => if (key) |k| hash(hasher, k, strat),
+ .optional => if (key) |k| hash(hasher, k, strat),
- .Array => hashArray(hasher, key, strat),
+ .array => hashArray(hasher, key, strat),
- .Vector => |info| {
+ .vector => |info| {
if (std.meta.hasUniqueRepresentation(Key)) {
hasher.update(mem.asBytes(&key));
} else {
@@ -129,7 +129,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {
}
},
- .Struct => |info| {
+ .@"struct" => |info| {
inline for (info.fields) |field| {
// We reuse the hash of the previous field as the seed for the
// next one so that they're dependant.
@@ -137,7 +137,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {
}
},
- .Union => |info| {
+ .@"union" => |info| {
if (info.tag_type) |tag_type| {
const tag = std.meta.activeTag(key);
hash(hasher, tag, strat);
@@ -155,7 +155,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {
} else @compileError("cannot hash untagged union type: " ++ @typeName(Key) ++ ", provide your own hash function");
},
- .ErrorUnion => blk: {
+ .error_union => blk: {
const payload = key catch |err| {
hash(hasher, err, strat);
break :blk;
@@ -167,9 +167,9 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {
inline fn typeContainsSlice(comptime K: type) bool {
return switch (@typeInfo(K)) {
- .Pointer => |info| info.size == .Slice,
+ .pointer => |info| info.size == .Slice,
- inline .Struct, .Union => |info| {
+ inline .@"struct", .@"union" => |info| {
inline for (info.fields) |field| {
if (typeContainsSlice(field.type)) {
return true;
diff --git a/lib/std/hash/verify.zig b/lib/std/hash/verify.zig
index 485a1fd976..61f501a881 100644
--- a/lib/std/hash/verify.zig
+++ b/lib/std/hash/verify.zig
@@ -1,9 +1,9 @@
const std = @import("std");
-fn hashMaybeSeed(comptime hash_fn: anytype, seed: anytype, buf: []const u8) @typeInfo(@TypeOf(hash_fn)).Fn.return_type.? {
- const HashFn = @typeInfo(@TypeOf(hash_fn)).Fn;
+fn hashMaybeSeed(comptime hash_fn: anytype, seed: anytype, buf: []const u8) @typeInfo(@TypeOf(hash_fn)).@"fn".return_type.? {
+ const HashFn = @typeInfo(@TypeOf(hash_fn)).@"fn";
if (HashFn.params.len > 1) {
- if (@typeInfo(HashFn.params[0].type.?) == .Int) {
+ if (@typeInfo(HashFn.params[0].type.?) == .int) {
return hash_fn(@intCast(seed), buf);
} else {
return hash_fn(buf, @intCast(seed));
@@ -14,7 +14,7 @@ fn hashMaybeSeed(comptime hash_fn: anytype, seed: anytype, buf: []const u8) @typ
}
fn initMaybeSeed(comptime Hash: anytype, seed: anytype) Hash {
- const HashFn = @typeInfo(@TypeOf(Hash.init)).Fn;
+ const HashFn = @typeInfo(@TypeOf(Hash.init)).@"fn";
if (HashFn.params.len == 1) {
return Hash.init(@intCast(seed));
} else {
@@ -27,7 +27,7 @@ fn initMaybeSeed(comptime Hash: anytype, seed: anytype) Hash {
// Hash keys of the form {0}, {0,1}, {0,1,2}... up to N=255, using 256-N as seed.
// First four-bytes of the hash, interpreted as little-endian is the verification code.
pub fn smhasher(comptime hash_fn: anytype) u32 {
- const HashFnTy = @typeInfo(@TypeOf(hash_fn)).Fn;
+ const HashFnTy = @typeInfo(@TypeOf(hash_fn)).@"fn";
const HashResult = HashFnTy.return_type.?;
const hash_size = @sizeOf(HashResult);
diff --git a/lib/std/hash_map.zig b/lib/std/hash_map.zig
index c0ae4596dc..1c8a5d78af 100644
--- a/lib/std/hash_map.zig
+++ b/lib/std/hash_map.zig
@@ -139,10 +139,10 @@ pub fn verifyContext(
var Context = RawContext;
// Make sure the context is a namespace type which may have member functions
switch (@typeInfo(Context)) {
- .Struct, .Union, .Enum => {},
- // Special-case .Opaque for a better error message
- .Opaque => @compileError("Hash context must be a type with hash and eql member functions. Cannot use " ++ @typeName(Context) ++ " because it is opaque. Use a pointer instead."),
- .Pointer => |ptr| {
+ .@"struct", .@"union", .@"enum" => {},
+ // Special-case .@"opaque" for a better error message
+ .@"opaque" => @compileError("Hash context must be a type with hash and eql member functions. Cannot use " ++ @typeName(Context) ++ " because it is opaque. Use a pointer instead."),
+ .pointer => |ptr| {
if (ptr.size != .One) {
@compileError("Hash context must be a type with hash and eql member functions. Cannot use " ++ @typeName(Context) ++ " because it is not a single pointer.");
}
@@ -150,7 +150,7 @@ pub fn verifyContext(
allow_const_ptr = true;
allow_mutable_ptr = !ptr.is_const;
switch (@typeInfo(Context)) {
- .Struct, .Union, .Enum, .Opaque => {},
+ .@"struct", .@"union", .@"enum", .@"opaque" => {},
else => @compileError("Hash context must be a type with hash and eql member functions. Cannot use " ++ @typeName(Context)),
}
},
@@ -179,8 +179,8 @@ pub fn verifyContext(
if (@hasDecl(Context, "hash")) {
const hash = Context.hash;
const info = @typeInfo(@TypeOf(hash));
- if (info == .Fn) {
- const func = info.Fn;
+ if (info == .@"fn") {
+ const func = info.@"fn";
if (func.params.len != 2) {
errors = errors ++ lazy.err_invalid_hash_signature;
} else {
@@ -255,8 +255,8 @@ pub fn verifyContext(
if (@hasDecl(Context, "eql")) {
const eql = Context.eql;
const info = @typeInfo(@TypeOf(eql));
- if (info == .Fn) {
- const func = info.Fn;
+ if (info == .@"fn") {
+ const func = info.@"fn";
const args_len = if (is_array) 4 else 3;
if (func.params.len != args_len) {
errors = errors ++ lazy.err_invalid_eql_signature;
@@ -824,8 +824,8 @@ pub fn HashMapUnmanaged(
}
pub fn takeFingerprint(hash: Hash) FingerPrint {
- const hash_bits = @typeInfo(Hash).Int.bits;
- const fp_bits = @typeInfo(FingerPrint).Int.bits;
+ const hash_bits = @typeInfo(Hash).int.bits;
+ const fp_bits = @typeInfo(FingerPrint).int.bits;
return @as(FingerPrint, @truncate(hash >> (hash_bits - fp_bits)));
}
diff --git a/lib/std/heap/logging_allocator.zig b/lib/std/heap/logging_allocator.zig
index 6924a284e3..706f2ac544 100644
--- a/lib/std/heap/logging_allocator.zig
+++ b/lib/std/heap/logging_allocator.zig
@@ -15,7 +15,7 @@ pub fn LoggingAllocator(
/// with the given scope on every call to the allocator.
/// For logging to a `std.io.Writer` see `std.heap.LogToWriterAllocator`
pub fn ScopedLoggingAllocator(
- comptime scope: @Type(.EnumLiteral),
+ comptime scope: @Type(.enum_literal),
comptime success_log_level: std.log.Level,
comptime failure_log_level: std.log.Level,
) type {
diff --git a/lib/std/io.zig b/lib/std/io.zig
index 1f4cb411b4..6455693d67 100644
--- a/lib/std/io.zig
+++ b/lib/std/io.zig
@@ -434,7 +434,7 @@ pub fn poll(
comptime StreamEnum: type,
files: PollFiles(StreamEnum),
) Poller(StreamEnum) {
- const enum_fields = @typeInfo(StreamEnum).Enum.fields;
+ const enum_fields = @typeInfo(StreamEnum).@"enum".fields;
var result: Poller(StreamEnum) = undefined;
if (is_windows) result.windows = .{
@@ -473,7 +473,7 @@ pub const PollFifo = std.fifo.LinearFifo(u8, .Dynamic);
pub fn Poller(comptime StreamEnum: type) type {
return struct {
- const enum_fields = @typeInfo(StreamEnum).Enum.fields;
+ const enum_fields = @typeInfo(StreamEnum).@"enum".fields;
const PollFd = if (is_windows) void else posix.pollfd;
fifos: [enum_fields.len]PollFifo,
@@ -676,7 +676,7 @@ fn windowsAsyncRead(
/// Given an enum, returns a struct with fields of that enum, each field
/// representing an I/O stream for polling.
pub fn PollFiles(comptime StreamEnum: type) type {
- const enum_fields = @typeInfo(StreamEnum).Enum.fields;
+ const enum_fields = @typeInfo(StreamEnum).@"enum".fields;
var struct_fields: [enum_fields.len]std.builtin.Type.StructField = undefined;
for (&struct_fields, enum_fields) |*struct_field, enum_field| {
struct_field.* = .{
@@ -687,7 +687,7 @@ pub fn PollFiles(comptime StreamEnum: type) type {
.alignment = @alignOf(fs.File),
};
}
- return @Type(.{ .Struct = .{
+ return @Type(.{ .@"struct" = .{
.layout = .auto,
.fields = &struct_fields,
.decls = &.{},
diff --git a/lib/std/io/Reader.zig b/lib/std/io/Reader.zig
index a769fe4c04..33187125b8 100644
--- a/lib/std/io/Reader.zig
+++ b/lib/std/io/Reader.zig
@@ -277,7 +277,7 @@ pub fn readBoundedBytes(self: Self, comptime num_bytes: usize) anyerror!std.Boun
}
pub inline fn readInt(self: Self, comptime T: type, endian: std.builtin.Endian) anyerror!T {
- const bytes = try self.readBytesNoEof(@divExact(@typeInfo(T).Int.bits, 8));
+ const bytes = try self.readBytesNoEof(@divExact(@typeInfo(T).int.bits, 8));
return mem.readInt(T, &bytes, endian);
}
@@ -326,7 +326,7 @@ pub fn isBytes(self: Self, slice: []const u8) anyerror!bool {
pub fn readStruct(self: Self, comptime T: type) anyerror!T {
// Only extern and packed structs have defined in-memory layout.
- comptime assert(@typeInfo(T).Struct.layout != .auto);
+ comptime assert(@typeInfo(T).@"struct".layout != .auto);
var res: [1]T = undefined;
try self.readNoEof(mem.sliceAsBytes(res[0..]));
return res[0];
@@ -348,7 +348,7 @@ pub fn readEnum(self: Self, comptime Enum: type, endian: std.builtin.Endian) any
/// An integer was read, but it did not match any of the tags in the supplied enum.
InvalidValue,
};
- const type_info = @typeInfo(Enum).Enum;
+ const type_info = @typeInfo(Enum).@"enum";
const tag = try self.readInt(type_info.tag_type, endian);
inline for (std.meta.fields(Enum)) |field| {
diff --git a/lib/std/io/Writer.zig b/lib/std/io/Writer.zig
index 0c80393e45..26d4f88def 100644
--- a/lib/std/io/Writer.zig
+++ b/lib/std/io/Writer.zig
@@ -49,14 +49,14 @@ pub fn writeBytesNTimes(self: Self, bytes: []const u8, n: usize) anyerror!void {
}
pub inline fn writeInt(self: Self, comptime T: type, value: T, endian: std.builtin.Endian) anyerror!void {
- var bytes: [@divExact(@typeInfo(T).Int.bits, 8)]u8 = undefined;
+ var bytes: [@divExact(@typeInfo(T).int.bits, 8)]u8 = undefined;
mem.writeInt(std.math.ByteAlignedInt(@TypeOf(value)), &bytes, value, endian);
return self.writeAll(&bytes);
}
pub fn writeStruct(self: Self, value: anytype) anyerror!void {
// Only extern and packed structs have defined in-memory layout.
- comptime assert(@typeInfo(@TypeOf(value)).Struct.layout != .auto);
+ comptime assert(@typeInfo(@TypeOf(value)).@"struct".layout != .auto);
return self.writeAll(mem.asBytes(&value));
}
diff --git a/lib/std/io/bit_writer.zig b/lib/std/io/bit_writer.zig
index 14e7f994ed..b5db45898b 100644
--- a/lib/std/io/bit_writer.zig
+++ b/lib/std/io/bit_writer.zig
@@ -33,7 +33,7 @@ pub fn BitWriter(comptime endian: std.builtin.Endian, comptime WriterType: type)
if (bits == 0) return;
const U = @TypeOf(value);
- comptime assert(@typeInfo(U).Int.signedness == .unsigned);
+ comptime assert(@typeInfo(U).int.signedness == .unsigned);
//by extending the buffer to a minimum of u8 we can cover a number of edge cases
// related to shifting and casting.
diff --git a/lib/std/io/fixed_buffer_stream.zig b/lib/std/io/fixed_buffer_stream.zig
index 14e5e5de43..7750c29fc8 100644
--- a/lib/std/io/fixed_buffer_stream.zig
+++ b/lib/std/io/fixed_buffer_stream.zig
@@ -115,18 +115,18 @@ pub fn fixedBufferStream(buffer: anytype) FixedBufferStream(Slice(@TypeOf(buffer
fn Slice(comptime T: type) type {
switch (@typeInfo(T)) {
- .Pointer => |ptr_info| {
+ .pointer => |ptr_info| {
var new_ptr_info = ptr_info;
switch (ptr_info.size) {
.Slice => {},
.One => switch (@typeInfo(ptr_info.child)) {
- .Array => |info| new_ptr_info.child = info.child,
+ .array => |info| new_ptr_info.child = info.child,
else => @compileError("invalid type given to fixedBufferStream"),
},
else => @compileError("invalid type given to fixedBufferStream"),
}
new_ptr_info.size = .Slice;
- return @Type(.{ .Pointer = new_ptr_info });
+ return @Type(.{ .pointer = new_ptr_info });
},
else => @compileError("invalid type given to fixedBufferStream"),
}
diff --git a/lib/std/io/multi_writer.zig b/lib/std/io/multi_writer.zig
index 9cd4600e63..be109867b7 100644
--- a/lib/std/io/multi_writer.zig
+++ b/lib/std/io/multi_writer.zig
@@ -4,7 +4,7 @@ const io = std.io;
/// Takes a tuple of streams, and constructs a new stream that writes to all of them
pub fn MultiWriter(comptime Writers: type) type {
comptime var ErrSet = error{};
- inline for (@typeInfo(Writers).Struct.fields) |field| {
+ inline for (@typeInfo(Writers).@"struct".fields) |field| {
const StreamType = field.type;
ErrSet = ErrSet || StreamType.Error;
}
diff --git a/lib/std/io/tty.zig b/lib/std/io/tty.zig
index 83206a6a67..013057649e 100644
--- a/lib/std/io/tty.zig
+++ b/lib/std/io/tty.zig
@@ -75,7 +75,7 @@ pub const Config = union(enum) {
conf: Config,
writer: anytype,
color: Color,
- ) (@typeInfo(@TypeOf(writer.writeAll(""))).ErrorUnion.error_set ||
+ ) (@typeInfo(@TypeOf(writer.writeAll(""))).error_union.error_set ||
windows.SetConsoleTextAttributeError)!void {
nosuspend switch (conf) {
.no_color => return,
diff --git a/lib/std/json/static.zig b/lib/std/json/static.zig
index 74901f85a8..15cb5bc75a 100644
--- a/lib/std/json/static.zig
+++ b/lib/std/json/static.zig
@@ -219,14 +219,14 @@ pub fn innerParse(
options: ParseOptions,
) ParseError(@TypeOf(source.*))!T {
switch (@typeInfo(T)) {
- .Bool => {
+ .bool => {
return switch (try source.next()) {
.true => true,
.false => false,
else => error.UnexpectedToken,
};
},
- .Float, .ComptimeFloat => {
+ .float, .comptime_float => {
const token = try source.nextAllocMax(allocator, .alloc_if_needed, options.max_value_len.?);
defer freeAllocated(allocator, token);
const slice = switch (token) {
@@ -235,7 +235,7 @@ pub fn innerParse(
};
return try std.fmt.parseFloat(T, slice);
},
- .Int, .ComptimeInt => {
+ .int, .comptime_int => {
const token = try source.nextAllocMax(allocator, .alloc_if_needed, options.max_value_len.?);
defer freeAllocated(allocator, token);
const slice = switch (token) {
@@ -244,7 +244,7 @@ pub fn innerParse(
};
return sliceToInt(T, slice);
},
- .Optional => |optionalInfo| {
+ .optional => |optionalInfo| {
switch (try source.peekNextTokenType()) {
.null => {
_ = try source.next();
@@ -255,7 +255,7 @@ pub fn innerParse(
},
}
},
- .Enum => {
+ .@"enum" => {
if (std.meta.hasFn(T, "jsonParse")) {
return T.jsonParse(allocator, source, options);
}
@@ -268,7 +268,7 @@ pub fn innerParse(
};
return sliceToEnum(T, slice);
},
- .Union => |unionInfo| {
+ .@"union" => |unionInfo| {
if (std.meta.hasFn(T, "jsonParse")) {
return T.jsonParse(allocator, source, options);
}
@@ -313,7 +313,7 @@ pub fn innerParse(
return result.?;
},
- .Struct => |structInfo| {
+ .@"struct" => |structInfo| {
if (structInfo.is_tuple) {
if (.array_begin != try source.next()) return error.UnexpectedToken;
@@ -385,7 +385,7 @@ pub fn innerParse(
return r;
},
- .Array => |arrayInfo| {
+ .array => |arrayInfo| {
switch (try source.peekNextTokenType()) {
.array_begin => {
// Typical array.
@@ -440,7 +440,7 @@ pub fn innerParse(
}
},
- .Vector => |vecInfo| {
+ .vector => |vecInfo| {
switch (try source.peekNextTokenType()) {
.array_begin => {
return internalParseArray(T, vecInfo.child, vecInfo.len, allocator, source, options);
@@ -449,7 +449,7 @@ pub fn innerParse(
}
},
- .Pointer => |ptrInfo| {
+ .pointer => |ptrInfo| {
switch (ptrInfo.size) {
.One => {
const r: *ptrInfo.child = try allocator.create(ptrInfo.child);
@@ -550,13 +550,13 @@ pub fn innerParseFromValue(
options: ParseOptions,
) ParseFromValueError!T {
switch (@typeInfo(T)) {
- .Bool => {
+ .bool => {
switch (source) {
.bool => |b| return b,
else => return error.UnexpectedToken,
}
},
- .Float, .ComptimeFloat => {
+ .float, .comptime_float => {
switch (source) {
.float => |f| return @as(T, @floatCast(f)),
.integer => |i| return @as(T, @floatFromInt(i)),
@@ -564,7 +564,7 @@ pub fn innerParseFromValue(
else => return error.UnexpectedToken,
}
},
- .Int, .ComptimeInt => {
+ .int, .comptime_int => {
switch (source) {
.float => |f| {
if (@round(f) != f) return error.InvalidNumber;
@@ -583,13 +583,13 @@ pub fn innerParseFromValue(
else => return error.UnexpectedToken,
}
},
- .Optional => |optionalInfo| {
+ .optional => |optionalInfo| {
switch (source) {
.null => return null,
else => return try innerParseFromValue(optionalInfo.child, allocator, source, options),
}
},
- .Enum => {
+ .@"enum" => {
if (std.meta.hasFn(T, "jsonParseFromValue")) {
return T.jsonParseFromValue(allocator, source, options);
}
@@ -601,7 +601,7 @@ pub fn innerParseFromValue(
else => return error.UnexpectedToken,
}
},
- .Union => |unionInfo| {
+ .@"union" => |unionInfo| {
if (std.meta.hasFn(T, "jsonParseFromValue")) {
return T.jsonParseFromValue(allocator, source, options);
}
@@ -631,7 +631,7 @@ pub fn innerParseFromValue(
return error.UnknownField;
},
- .Struct => |structInfo| {
+ .@"struct" => |structInfo| {
if (structInfo.is_tuple) {
if (source != .array) return error.UnexpectedToken;
if (source.array.items.len != structInfo.fields.len) return error.UnexpectedToken;
@@ -674,7 +674,7 @@ pub fn innerParseFromValue(
return r;
},
- .Array => |arrayInfo| {
+ .array => |arrayInfo| {
switch (source) {
.array => |array| {
// Typical array.
@@ -695,7 +695,7 @@ pub fn innerParseFromValue(
}
},
- .Vector => |vecInfo| {
+ .vector => |vecInfo| {
switch (source) {
.array => |array| {
return innerParseArrayFromArrayValue(T, vecInfo.child, vecInfo.len, allocator, array, options);
@@ -704,7 +704,7 @@ pub fn innerParseFromValue(
}
},
- .Pointer => |ptrInfo| {
+ .pointer => |ptrInfo| {
switch (ptrInfo.size) {
.One => {
const r: *ptrInfo.child = try allocator.create(ptrInfo.child);
@@ -780,12 +780,12 @@ fn sliceToEnum(comptime T: type, slice: []const u8) !T {
if (std.meta.stringToEnum(T, slice)) |value| return value;
// Check for a numeric value.
if (!isNumberFormattedLikeAnInteger(slice)) return error.InvalidEnumTag;
- const n = std.fmt.parseInt(@typeInfo(T).Enum.tag_type, slice, 10) catch return error.InvalidEnumTag;
+ const n = std.fmt.parseInt(@typeInfo(T).@"enum".tag_type, slice, 10) catch return error.InvalidEnumTag;
return std.meta.intToEnum(T, n);
}
-fn fillDefaultStructValues(comptime T: type, r: *T, fields_seen: *[@typeInfo(T).Struct.fields.len]bool) !void {
- inline for (@typeInfo(T).Struct.fields, 0..) |field, i| {
+fn fillDefaultStructValues(comptime T: type, r: *T, fields_seen: *[@typeInfo(T).@"struct".fields.len]bool) !void {
+ inline for (@typeInfo(T).@"struct".fields, 0..) |field, i| {
if (!fields_seen[i]) {
if (field.default_value) |default_ptr| {
const default = @as(*align(1) const field.type, @ptrCast(default_ptr)).*;
diff --git a/lib/std/json/stringify.zig b/lib/std/json/stringify.zig
index 965b7c3113..11e1dcf710 100644
--- a/lib/std/json/stringify.zig
+++ b/lib/std/json/stringify.zig
@@ -493,7 +493,7 @@ pub fn WriteStream(
if (build_mode_has_safety) assert(self.raw_streaming_mode == .none);
const T = @TypeOf(value);
switch (@typeInfo(T)) {
- .Int => {
+ .int => {
try self.valueStart();
if (self.options.emit_nonportable_numbers_as_strings and
(value <= -(1 << 53) or value >= (1 << 53)))
@@ -505,10 +505,10 @@ pub fn WriteStream(
self.valueDone();
return;
},
- .ComptimeInt => {
+ .comptime_int => {
return self.write(@as(std.math.IntFittingRange(value, value), value));
},
- .Float, .ComptimeFloat => {
+ .float, .comptime_float => {
if (@as(f64, @floatCast(value)) == value) {
try self.valueStart();
try self.stream.print("{}", .{@as(f64, @floatCast(value))});
@@ -521,38 +521,38 @@ pub fn WriteStream(
return;
},
- .Bool => {
+ .bool => {
try self.valueStart();
try self.stream.writeAll(if (value) "true" else "false");
self.valueDone();
return;
},
- .Null => {
+ .null => {
try self.valueStart();
try self.stream.writeAll("null");
self.valueDone();
return;
},
- .Optional => {
+ .optional => {
if (value) |payload| {
return try self.write(payload);
} else {
return try self.write(null);
}
},
- .Enum, .EnumLiteral => {
+ .@"enum", .enum_literal => {
if (std.meta.hasFn(T, "jsonStringify")) {
return value.jsonStringify(self);
}
return self.stringValue(@tagName(value));
},
- .Union => {
+ .@"union" => {
if (std.meta.hasFn(T, "jsonStringify")) {
return value.jsonStringify(self);
}
- const info = @typeInfo(T).Union;
+ const info = @typeInfo(T).@"union";
if (info.tag_type) |UnionTagType| {
try self.beginObject();
inline for (info.fields) |u_field| {
@@ -576,7 +576,7 @@ pub fn WriteStream(
@compileError("Unable to stringify untagged union '" ++ @typeName(T) ++ "'");
}
},
- .Struct => |S| {
+ .@"struct" => |S| {
if (std.meta.hasFn(T, "jsonStringify")) {
return value.jsonStringify(self);
}
@@ -593,7 +593,7 @@ pub fn WriteStream(
var emit_field = true;
// don't include optional fields that are null when emit_null_optional_fields is set to false
- if (@typeInfo(Field.type) == .Optional) {
+ if (@typeInfo(Field.type) == .optional) {
if (self.options.emit_null_optional_fields == false) {
if (@field(value, Field.name) == null) {
emit_field = false;
@@ -615,10 +615,10 @@ pub fn WriteStream(
}
return;
},
- .ErrorSet => return self.stringValue(@errorName(value)),
- .Pointer => |ptr_info| switch (ptr_info.size) {
+ .error_set => return self.stringValue(@errorName(value)),
+ .pointer => |ptr_info| switch (ptr_info.size) {
.One => switch (@typeInfo(ptr_info.child)) {
- .Array => {
+ .array => {
// Coerce `*[N]T` to `[]const T`.
const Slice = []const std.meta.Elem(ptr_info.child);
return self.write(@as(Slice, value));
@@ -648,11 +648,11 @@ pub fn WriteStream(
},
else => @compileError("Unable to stringify type '" ++ @typeName(T) ++ "'"),
},
- .Array => {
+ .array => {
// Coerce `[N]T` to `*const [N]T` (and then to `[]const T`).
return self.write(&value);
},
- .Vector => |info| {
+ .vector => |info| {
const array: [info.len]info.child = value;
return self.write(&array);
},
diff --git a/lib/std/leb128.zig b/lib/std/leb128.zig
index d9e0556231..2a5d9b20fc 100644
--- a/lib/std/leb128.zig
+++ b/lib/std/leb128.zig
@@ -4,10 +4,10 @@ const testing = std.testing;
/// Read a single unsigned LEB128 value from the given reader as type T,
/// or error.Overflow if the value cannot fit.
pub fn readUleb128(comptime T: type, reader: anytype) !T {
- const U = if (@typeInfo(T).Int.bits < 8) u8 else T;
+ const U = if (@typeInfo(T).int.bits < 8) u8 else T;
const ShiftT = std.math.Log2Int(U);
- const max_group = (@typeInfo(U).Int.bits + 6) / 7;
+ const max_group = (@typeInfo(U).int.bits + 6) / 7;
var value: U = 0;
var group: ShiftT = 0;
@@ -42,7 +42,7 @@ pub fn writeUleb128(writer: anytype, arg: anytype) !void {
comptime_int => std.math.IntFittingRange(arg, arg),
else => Arg,
};
- const Value = if (@typeInfo(Int).Int.bits < 8) u8 else Int;
+ const Value = if (@typeInfo(Int).int.bits < 8) u8 else Int;
var value: Value = arg;
while (true) {
@@ -63,11 +63,11 @@ pub const writeULEB128 = writeUleb128;
/// Read a single signed LEB128 value from the given reader as type T,
/// or error.Overflow if the value cannot fit.
pub fn readIleb128(comptime T: type, reader: anytype) !T {
- const S = if (@typeInfo(T).Int.bits < 8) i8 else T;
- const U = std.meta.Int(.unsigned, @typeInfo(S).Int.bits);
+ const S = if (@typeInfo(T).int.bits < 8) i8 else T;
+ const U = std.meta.Int(.unsigned, @typeInfo(S).int.bits);
const ShiftU = std.math.Log2Int(U);
- const max_group = (@typeInfo(U).Int.bits + 6) / 7;
+ const max_group = (@typeInfo(U).int.bits + 6) / 7;
var value = @as(U, 0);
var group = @as(ShiftU, 0);
@@ -83,14 +83,14 @@ pub fn readIleb128(comptime T: type, reader: anytype) !T {
if (@as(S, @bitCast(ov[0])) >= 0) return error.Overflow;
// and all the overflowed bits are 1
- const remaining_shift = @as(u3, @intCast(@typeInfo(U).Int.bits - @as(u16, shift)));
+ const remaining_shift = @as(u3, @intCast(@typeInfo(U).int.bits - @as(u16, shift)));
const remaining_bits = @as(i8, @bitCast(byte | 0x80)) >> remaining_shift;
if (remaining_bits != -1) return error.Overflow;
} else {
// If we don't overflow and this is the last byte and the number being decoded
// is negative, check that the remaining bits are 1
if ((byte & 0x80 == 0) and (@as(S, @bitCast(ov[0])) < 0)) {
- const remaining_shift = @as(u3, @intCast(@typeInfo(U).Int.bits - @as(u16, shift)));
+ const remaining_shift = @as(u3, @intCast(@typeInfo(U).int.bits - @as(u16, shift)));
const remaining_bits = @as(i8, @bitCast(byte | 0x80)) >> remaining_shift;
if (remaining_bits != -1) return error.Overflow;
}
@@ -128,8 +128,8 @@ pub fn writeIleb128(writer: anytype, arg: anytype) !void {
comptime_int => std.math.IntFittingRange(-@abs(arg), @abs(arg)),
else => Arg,
};
- const Signed = if (@typeInfo(Int).Int.bits < 8) i8 else Int;
- const Unsigned = std.meta.Int(.unsigned, @typeInfo(Signed).Int.bits);
+ const Signed = if (@typeInfo(Int).int.bits < 8) i8 else Int;
+ const Unsigned = std.meta.Int(.unsigned, @typeInfo(Signed).int.bits);
var value: Signed = arg;
while (true) {
@@ -165,7 +165,7 @@ pub fn writeUnsignedExtended(slice: []u8, arg: anytype) void {
comptime_int => std.math.IntFittingRange(arg, arg),
else => Arg,
};
- const Value = if (@typeInfo(Int).Int.bits < 8) u8 else Int;
+ const Value = if (@typeInfo(Int).int.bits < 8) u8 else Int;
var value: Value = arg;
for (slice[0 .. slice.len - 1]) |*byte| {
@@ -210,7 +210,7 @@ test writeUnsignedFixed {
/// different value without shifting all the following code.
pub fn writeSignedFixed(comptime l: usize, ptr: *[l]u8, int: std.meta.Int(.signed, l * 7)) void {
const T = @TypeOf(int);
- const U = if (@typeInfo(T).Int.bits < 8) u8 else T;
+ const U = if (@typeInfo(T).int.bits < 8) u8 else T;
var value: U = @intCast(int);
comptime var i = 0;
@@ -388,7 +388,7 @@ test "deserialize unsigned LEB128" {
fn test_write_leb128(value: anytype) !void {
const T = @TypeOf(value);
- const signedness = @typeInfo(T).Int.signedness;
+ const signedness = @typeInfo(T).int.signedness;
const t_signed = signedness == .signed;
const writeStream = if (t_signed) writeIleb128 else writeUleb128;
@@ -396,19 +396,19 @@ fn test_write_leb128(value: anytype) !void {
// decode to a larger bit size too, to ensure sign extension
// is working as expected
- const larger_type_bits = ((@typeInfo(T).Int.bits + 8) / 8) * 8;
+ const larger_type_bits = ((@typeInfo(T).int.bits + 8) / 8) * 8;
const B = std.meta.Int(signedness, larger_type_bits);
const bytes_needed = bn: {
- if (@typeInfo(T).Int.bits <= 7) break :bn @as(u16, 1);
+ if (@typeInfo(T).int.bits <= 7) break :bn @as(u16, 1);
const unused_bits = if (value < 0) @clz(~value) else @clz(value);
- const used_bits: u16 = (@typeInfo(T).Int.bits - unused_bits) + @intFromBool(t_signed);
+ const used_bits: u16 = (@typeInfo(T).int.bits - unused_bits) + @intFromBool(t_signed);
if (used_bits <= 7) break :bn @as(u16, 1);
break :bn ((used_bits + 6) / 7);
};
- const max_groups = if (@typeInfo(T).Int.bits == 0) 1 else (@typeInfo(T).Int.bits + 6) / 7;
+ const max_groups = if (@typeInfo(T).int.bits == 0) 1 else (@typeInfo(T).int.bits + 6) / 7;
var buf: [max_groups]u8 = undefined;
var fbs = std.io.fixedBufferStream(&buf);
@@ -439,7 +439,7 @@ test "serialize unsigned LEB128" {
const T = std.meta.Int(.unsigned, t);
const min = std.math.minInt(T);
const max = std.math.maxInt(T);
- var i = @as(std.meta.Int(.unsigned, @typeInfo(T).Int.bits + 1), min);
+ var i = @as(std.meta.Int(.unsigned, @typeInfo(T).int.bits + 1), min);
while (i <= max) : (i += 1) try test_write_leb128(@as(T, @intCast(i)));
}
@@ -457,7 +457,7 @@ test "serialize signed LEB128" {
const T = std.meta.Int(.signed, t);
const min = std.math.minInt(T);
const max = std.math.maxInt(T);
- var i = @as(std.meta.Int(.signed, @typeInfo(T).Int.bits + 1), min);
+ var i = @as(std.meta.Int(.signed, @typeInfo(T).int.bits + 1), min);
while (i <= max) : (i += 1) try test_write_leb128(@as(T, @intCast(i)));
}
diff --git a/lib/std/log.zig b/lib/std/log.zig
index 1533161cba..81a0ab0947 100644
--- a/lib/std/log.zig
+++ b/lib/std/log.zig
@@ -28,7 +28,7 @@
//!
//! pub fn myLogFn(
//! comptime level: std.log.Level,
-//! comptime scope: @TypeOf(.EnumLiteral),
+//! comptime scope: @Type(.enum_literal),
//! comptime format: []const u8,
//! args: anytype,
//! ) void {
@@ -108,7 +108,7 @@ pub const default_level: Level = switch (builtin.mode) {
const level = std.options.log_level;
pub const ScopeLevel = struct {
- scope: @Type(.EnumLiteral),
+ scope: @Type(.enum_literal),
level: Level,
};
@@ -116,7 +116,7 @@ const scope_levels = std.options.log_scope_levels;
fn log(
comptime message_level: Level,
- comptime scope: @Type(.EnumLiteral),
+ comptime scope: @Type(.enum_literal),
comptime format: []const u8,
args: anytype,
) void {
@@ -126,7 +126,7 @@ fn log(
}
/// Determine if a specific log message level and scope combination are enabled for logging.
-pub fn logEnabled(comptime message_level: Level, comptime scope: @Type(.EnumLiteral)) bool {
+pub fn logEnabled(comptime message_level: Level, comptime scope: @Type(.enum_literal)) bool {
inline for (scope_levels) |scope_level| {
if (scope_level.scope == scope) return @intFromEnum(message_level) <= @intFromEnum(scope_level.level);
}
@@ -142,7 +142,7 @@ pub fn defaultLogEnabled(comptime message_level: Level) bool {
/// forward log messages to this function.
pub fn defaultLog(
comptime message_level: Level,
- comptime scope: @Type(.EnumLiteral),
+ comptime scope: @Type(.enum_literal),
comptime format: []const u8,
args: anytype,
) void {
@@ -162,7 +162,7 @@ pub fn defaultLog(
/// Returns a scoped logging namespace that logs all messages using the scope
/// provided here.
-pub fn scoped(comptime scope: @Type(.EnumLiteral)) type {
+pub fn scoped(comptime scope: @Type(.enum_literal)) type {
return struct {
/// Log an error message. This log level is intended to be used
/// when something has gone wrong. This might be recoverable or might
diff --git a/lib/std/math.zig b/lib/std/math.zig
index f18739095c..67782bf93b 100644
--- a/lib/std/math.zig
+++ b/lib/std/math.zig
@@ -71,7 +71,7 @@ pub const snan = float.snan;
///
/// NaN values are never considered equal to any value.
pub fn approxEqAbs(comptime T: type, x: T, y: T, tolerance: T) bool {
- assert(@typeInfo(T) == .Float or @typeInfo(T) == .ComptimeFloat);
+ assert(@typeInfo(T) == .float or @typeInfo(T) == .comptime_float);
assert(tolerance >= 0);
// Fast path for equal values (and signed zeros and infinites).
@@ -99,7 +99,7 @@ pub fn approxEqAbs(comptime T: type, x: T, y: T, tolerance: T) bool {
///
/// NaN values are never considered equal to any value.
pub fn approxEqRel(comptime T: type, x: T, y: T, tolerance: T) bool {
- assert(@typeInfo(T) == .Float or @typeInfo(T) == .ComptimeFloat);
+ assert(@typeInfo(T) == .float or @typeInfo(T) == .comptime_float);
assert(tolerance > 0);
// Fast path for equal values (and signed zeros and infinites).
@@ -263,8 +263,8 @@ pub inline fn tan(value: anytype) @TypeOf(value) {
pub fn radiansToDegrees(ang: anytype) if (@TypeOf(ang) == comptime_int) comptime_float else @TypeOf(ang) {
const T = @TypeOf(ang);
switch (@typeInfo(T)) {
- .Float, .ComptimeFloat, .ComptimeInt => return ang * deg_per_rad,
- .Vector => |V| if (@typeInfo(V.child) == .Float) return ang * @as(T, @splat(deg_per_rad)),
+ .float, .comptime_float, .comptime_int => return ang * deg_per_rad,
+ .vector => |V| if (@typeInfo(V.child) == .float) return ang * @as(T, @splat(deg_per_rad)),
else => {},
}
@compileError("Input must be float or a comptime number, or a vector of floats.");
@@ -298,8 +298,8 @@ test radiansToDegrees {
pub fn degreesToRadians(ang: anytype) if (@TypeOf(ang) == comptime_int) comptime_float else @TypeOf(ang) {
const T = @TypeOf(ang);
switch (@typeInfo(T)) {
- .Float, .ComptimeFloat, .ComptimeInt => return ang * rad_per_deg,
- .Vector => |V| if (@typeInfo(V.child) == .Float) return ang * @as(T, @splat(rad_per_deg)),
+ .float, .comptime_float, .comptime_int => return ang * rad_per_deg,
+ .vector => |V| if (@typeInfo(V.child) == .float) return ang * @as(T, @splat(rad_per_deg)),
else => {},
}
@compileError("Input must be float or a comptime number, or a vector of floats.");
@@ -408,8 +408,8 @@ test {
/// full range of the minimum value.
pub fn Min(comptime A: type, comptime B: type) type {
switch (@typeInfo(A)) {
- .Int => |a_info| switch (@typeInfo(B)) {
- .Int => |b_info| if (a_info.signedness == .unsigned and b_info.signedness == .unsigned) {
+ .int => |a_info| switch (@typeInfo(B)) {
+ .int => |b_info| if (a_info.signedness == .unsigned and b_info.signedness == .unsigned) {
if (a_info.bits < b_info.bits) {
return A;
} else {
@@ -437,21 +437,21 @@ pub fn Min(comptime A: type, comptime B: type) type {
pub fn wrap(x: anytype, r: anytype) @TypeOf(x) {
const info_x = @typeInfo(@TypeOf(x));
const info_r = @typeInfo(@TypeOf(r));
- if (info_x == .Int and info_x.Int.signedness != .signed) {
+ if (info_x == .int and info_x.int.signedness != .signed) {
@compileError("x must be floating point, comptime integer, or signed integer.");
}
switch (info_r) {
- .Int => {
+ .int => {
// in the rare usecase of r not being comptime_int or float,
// take the penalty of having an intermediary type conversion,
// otherwise the alternative is to unwind iteratively to avoid overflow
const R = comptime do: {
var info = info_r;
- info.Int.bits += 1;
- info.Int.signedness = .signed;
+ info.int.bits += 1;
+ info.int.signedness = .signed;
break :do @Type(info);
};
- const radius: if (info_r.Int.signedness == .signed) @TypeOf(r) else R = r;
+ const radius: if (info_r.int.signedness == .signed) @TypeOf(r) else R = r;
return @intCast(@mod(x - radius, 2 * @as(R, r)) - r); // provably impossible to overflow
},
else => {
@@ -520,9 +520,9 @@ test wrap {
pub fn clamp(val: anytype, lower: anytype, upper: anytype) @TypeOf(val, lower, upper) {
const T = @TypeOf(val, lower, upper);
switch (@typeInfo(T)) {
- .Int, .Float, .ComptimeInt, .ComptimeFloat => assert(lower <= upper),
- .Vector => |vinfo| switch (@typeInfo(vinfo.child)) {
- .Int, .Float => assert(@reduce(.And, lower <= upper)),
+ .int, .float, .comptime_int, .comptime_float => assert(lower <= upper),
+ .vector => |vinfo| switch (@typeInfo(vinfo.child)) {
+ .int, .float => assert(@reduce(.And, lower <= upper)),
else => @compileError("Expected vector of ints or floats, found " ++ @typeName(T)),
},
else => @compileError("Expected an int, float or vector of one, found " ++ @typeName(T)),
@@ -593,18 +593,18 @@ pub fn shl(comptime T: type, a: T, shift_amt: anytype) T {
const abs_shift_amt = @abs(shift_amt);
const casted_shift_amt = blk: {
- if (@typeInfo(T) == .Vector) {
- const C = @typeInfo(T).Vector.child;
- const len = @typeInfo(T).Vector.len;
- if (abs_shift_amt >= @typeInfo(C).Int.bits) return @splat(0);
+ if (@typeInfo(T) == .vector) {
+ const C = @typeInfo(T).vector.child;
+ const len = @typeInfo(T).vector.len;
+ if (abs_shift_amt >= @typeInfo(C).int.bits) return @splat(0);
break :blk @as(@Vector(len, Log2Int(C)), @splat(@as(Log2Int(C), @intCast(abs_shift_amt))));
} else {
- if (abs_shift_amt >= @typeInfo(T).Int.bits) return 0;
+ if (abs_shift_amt >= @typeInfo(T).int.bits) return 0;
break :blk @as(Log2Int(T), @intCast(abs_shift_amt));
}
};
- if (@TypeOf(shift_amt) == comptime_int or @typeInfo(@TypeOf(shift_amt)).Int.signedness == .signed) {
+ if (@TypeOf(shift_amt) == comptime_int or @typeInfo(@TypeOf(shift_amt)).int.signedness == .signed) {
if (shift_amt < 0) {
return a >> casted_shift_amt;
}
@@ -633,18 +633,18 @@ pub fn shr(comptime T: type, a: T, shift_amt: anytype) T {
const abs_shift_amt = @abs(shift_amt);
const casted_shift_amt = blk: {
- if (@typeInfo(T) == .Vector) {
- const C = @typeInfo(T).Vector.child;
- const len = @typeInfo(T).Vector.len;
- if (abs_shift_amt >= @typeInfo(C).Int.bits) return @splat(0);
+ if (@typeInfo(T) == .vector) {
+ const C = @typeInfo(T).vector.child;
+ const len = @typeInfo(T).vector.len;
+ if (abs_shift_amt >= @typeInfo(C).int.bits) return @splat(0);
break :blk @as(@Vector(len, Log2Int(C)), @splat(@as(Log2Int(C), @intCast(abs_shift_amt))));
} else {
- if (abs_shift_amt >= @typeInfo(T).Int.bits) return 0;
+ if (abs_shift_amt >= @typeInfo(T).int.bits) return 0;
break :blk @as(Log2Int(T), @intCast(abs_shift_amt));
}
};
- if (@TypeOf(shift_amt) == comptime_int or @typeInfo(@TypeOf(shift_amt)).Int.signedness == .signed) {
+ if (@TypeOf(shift_amt) == comptime_int or @typeInfo(@TypeOf(shift_amt)).int.signedness == .signed) {
if (shift_amt < 0) {
return a << casted_shift_amt;
}
@@ -670,26 +670,26 @@ test shr {
/// Rotates right. Only unsigned values can be rotated. Negative shift
/// values result in shift modulo the bit count.
pub fn rotr(comptime T: type, x: T, r: anytype) T {
- if (@typeInfo(T) == .Vector) {
- const C = @typeInfo(T).Vector.child;
+ if (@typeInfo(T) == .vector) {
+ const C = @typeInfo(T).vector.child;
if (C == u0) return 0;
- if (@typeInfo(C).Int.signedness == .signed) {
+ if (@typeInfo(C).int.signedness == .signed) {
@compileError("cannot rotate signed integers");
}
- const ar: Log2Int(C) = @intCast(@mod(r, @typeInfo(C).Int.bits));
+ const ar: Log2Int(C) = @intCast(@mod(r, @typeInfo(C).int.bits));
return (x >> @splat(ar)) | (x << @splat(1 + ~ar));
- } else if (@typeInfo(T).Int.signedness == .signed) {
+ } else if (@typeInfo(T).int.signedness == .signed) {
@compileError("cannot rotate signed integer");
} else {
if (T == u0) return 0;
- if (comptime isPowerOfTwo(@typeInfo(T).Int.bits)) {
- const ar: Log2Int(T) = @intCast(@mod(r, @typeInfo(T).Int.bits));
+ if (comptime isPowerOfTwo(@typeInfo(T).int.bits)) {
+ const ar: Log2Int(T) = @intCast(@mod(r, @typeInfo(T).int.bits));
return x >> ar | x << (1 +% ~ar);
} else {
- const ar = @mod(r, @typeInfo(T).Int.bits);
- return shr(T, x, ar) | shl(T, x, @typeInfo(T).Int.bits - ar);
+ const ar = @mod(r, @typeInfo(T).int.bits);
+ return shr(T, x, ar) | shl(T, x, @typeInfo(T).int.bits - ar);
}
}
}
@@ -711,26 +711,26 @@ test rotr {
/// Rotates left. Only unsigned values can be rotated. Negative shift
/// values result in shift modulo the bit count.
pub fn rotl(comptime T: type, x: T, r: anytype) T {
- if (@typeInfo(T) == .Vector) {
- const C = @typeInfo(T).Vector.child;
+ if (@typeInfo(T) == .vector) {
+ const C = @typeInfo(T).vector.child;
if (C == u0) return 0;
- if (@typeInfo(C).Int.signedness == .signed) {
+ if (@typeInfo(C).int.signedness == .signed) {
@compileError("cannot rotate signed integers");
}
- const ar: Log2Int(C) = @intCast(@mod(r, @typeInfo(C).Int.bits));
+ const ar: Log2Int(C) = @intCast(@mod(r, @typeInfo(C).int.bits));
return (x << @splat(ar)) | (x >> @splat(1 +% ~ar));
- } else if (@typeInfo(T).Int.signedness == .signed) {
+ } else if (@typeInfo(T).int.signedness == .signed) {
@compileError("cannot rotate signed integer");
} else {
if (T == u0) return 0;
- if (comptime isPowerOfTwo(@typeInfo(T).Int.bits)) {
- const ar: Log2Int(T) = @intCast(@mod(r, @typeInfo(T).Int.bits));
+ if (comptime isPowerOfTwo(@typeInfo(T).int.bits)) {
+ const ar: Log2Int(T) = @intCast(@mod(r, @typeInfo(T).int.bits));
return x << ar | x >> 1 +% ~ar;
} else {
- const ar = @mod(r, @typeInfo(T).Int.bits);
- return shl(T, x, ar) | shr(T, x, @typeInfo(T).Int.bits - ar);
+ const ar = @mod(r, @typeInfo(T).int.bits);
+ return shl(T, x, ar) | shr(T, x, @typeInfo(T).int.bits - ar);
}
}
}
@@ -754,7 +754,7 @@ test rotl {
pub fn Log2Int(comptime T: type) type {
// comptime ceil log2
if (T == comptime_int) return comptime_int;
- const bits: u16 = @typeInfo(T).Int.bits;
+ const bits: u16 = @typeInfo(T).int.bits;
const log2_bits = 16 - @clz(bits - 1);
return std.meta.Int(.unsigned, log2_bits);
}
@@ -763,7 +763,7 @@ pub fn Log2Int(comptime T: type) type {
pub fn Log2IntCeil(comptime T: type) type {
// comptime ceil log2
if (T == comptime_int) return comptime_int;
- const bits: u16 = @typeInfo(T).Int.bits;
+ const bits: u16 = @typeInfo(T).int.bits;
const log2_bits = 16 - @clz(bits);
return std.meta.Int(.unsigned, log2_bits);
}
@@ -849,7 +849,7 @@ fn testOverflow() !void {
pub fn divTrunc(comptime T: type, numerator: T, denominator: T) !T {
@setRuntimeSafety(false);
if (denominator == 0) return error.DivisionByZero;
- if (@typeInfo(T) == .Int and @typeInfo(T).Int.signedness == .signed and numerator == minInt(T) and denominator == -1) return error.Overflow;
+ if (@typeInfo(T) == .int and @typeInfo(T).int.signedness == .signed and numerator == minInt(T) and denominator == -1) return error.Overflow;
return @divTrunc(numerator, denominator);
}
@@ -873,7 +873,7 @@ fn testDivTrunc() !void {
pub fn divFloor(comptime T: type, numerator: T, denominator: T) !T {
@setRuntimeSafety(false);
if (denominator == 0) return error.DivisionByZero;
- if (@typeInfo(T) == .Int and @typeInfo(T).Int.signedness == .signed and numerator == minInt(T) and denominator == -1) return error.Overflow;
+ if (@typeInfo(T) == .int and @typeInfo(T).int.signedness == .signed and numerator == minInt(T) and denominator == -1) return error.Overflow;
return @divFloor(numerator, denominator);
}
@@ -899,10 +899,10 @@ pub fn divCeil(comptime T: type, numerator: T, denominator: T) !T {
if (denominator == 0) return error.DivisionByZero;
const info = @typeInfo(T);
switch (info) {
- .ComptimeFloat, .Float => return @ceil(numerator / denominator),
- .ComptimeInt, .Int => {
+ .comptime_float, .float => return @ceil(numerator / denominator),
+ .comptime_int, .int => {
if (numerator < 0 and denominator < 0) {
- if (info == .Int and numerator == minInt(T) and denominator == -1)
+ if (info == .int and numerator == minInt(T) and denominator == -1)
return error.Overflow;
return @divFloor(numerator + 1, denominator) + 1;
}
@@ -952,7 +952,7 @@ fn testDivCeil() !void {
pub fn divExact(comptime T: type, numerator: T, denominator: T) !T {
@setRuntimeSafety(false);
if (denominator == 0) return error.DivisionByZero;
- if (@typeInfo(T) == .Int and @typeInfo(T).Int.signedness == .signed and numerator == minInt(T) and denominator == -1) return error.Overflow;
+ if (@typeInfo(T) == .int and @typeInfo(T).int.signedness == .signed and numerator == minInt(T) and denominator == -1) return error.Overflow;
const result = @divTrunc(numerator, denominator);
if (result * denominator != numerator) return error.UnexpectedRemainder;
return result;
@@ -1029,7 +1029,7 @@ fn testRem() !void {
/// Returns the negation of the integer parameter.
/// Result is a signed integer.
pub fn negateCast(x: anytype) !std.meta.Int(.signed, @bitSizeOf(@TypeOf(x))) {
- if (@typeInfo(@TypeOf(x)).Int.signedness == .signed) return negate(x);
+ if (@typeInfo(@TypeOf(x)).int.signedness == .signed) return negate(x);
const int = std.meta.Int(.signed, @bitSizeOf(@TypeOf(x)));
if (x > -minInt(int)) return error.Overflow;
@@ -1052,9 +1052,9 @@ test negateCast {
/// Cast an integer to a different integer type. If the value doesn't fit,
/// return null.
pub fn cast(comptime T: type, x: anytype) ?T {
- comptime assert(@typeInfo(T) == .Int); // must pass an integer
+ comptime assert(@typeInfo(T) == .int); // must pass an integer
const is_comptime = @TypeOf(x) == comptime_int;
- comptime assert(is_comptime or @typeInfo(@TypeOf(x)) == .Int); // must pass an integer
+ comptime assert(is_comptime or @typeInfo(@TypeOf(x)) == .int); // must pass an integer
if ((is_comptime or maxInt(@TypeOf(x)) > maxInt(T)) and x > maxInt(T)) {
return null;
} else if ((is_comptime or minInt(@TypeOf(x)) < minInt(T)) and x < minInt(T)) {
@@ -1084,7 +1084,7 @@ pub const AlignCastError = error{UnalignedMemory};
fn AlignCastResult(comptime alignment: u29, comptime Ptr: type) type {
var ptr_info = @typeInfo(Ptr);
- ptr_info.Pointer.alignment = alignment;
+ ptr_info.pointer.alignment = alignment;
return @Type(ptr_info);
}
@@ -1117,7 +1117,7 @@ test isPowerOfTwo {
/// Aligns the given integer type bit width to a width divisible by 8.
pub fn ByteAlignedInt(comptime T: type) type {
- const info = @typeInfo(T).Int;
+ const info = @typeInfo(T).int;
const bits = (info.bits + 7) / 8 * 8;
const extended_type = std.meta.Int(info.signedness, bits);
return extended_type;
@@ -1157,7 +1157,7 @@ pub inline fn floor(value: anytype) @TypeOf(value) {
/// Returns the nearest power of two less than or equal to value, or
/// zero if value is less than or equal to zero.
pub fn floorPowerOfTwo(comptime T: type, value: T) T {
- const uT = std.meta.Int(.unsigned, @typeInfo(T).Int.bits);
+ const uT = std.meta.Int(.unsigned, @typeInfo(T).int.bits);
if (value <= 0) return 0;
return @as(T, 1) << log2_int(uT, @as(uT, @intCast(value)));
}
@@ -1192,21 +1192,21 @@ pub inline fn ceil(value: anytype) @TypeOf(value) {
/// Returns the next power of two (if the value is not already a power of two).
/// Only unsigned integers can be used. Zero is not an allowed input.
/// Result is a type with 1 more bit than the input type.
-pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) std.meta.Int(@typeInfo(T).Int.signedness, @typeInfo(T).Int.bits + 1) {
- comptime assert(@typeInfo(T) == .Int);
- comptime assert(@typeInfo(T).Int.signedness == .unsigned);
+pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) std.meta.Int(@typeInfo(T).int.signedness, @typeInfo(T).int.bits + 1) {
+ comptime assert(@typeInfo(T) == .int);
+ comptime assert(@typeInfo(T).int.signedness == .unsigned);
assert(value != 0);
- const PromotedType = std.meta.Int(@typeInfo(T).Int.signedness, @typeInfo(T).Int.bits + 1);
+ const PromotedType = std.meta.Int(@typeInfo(T).int.signedness, @typeInfo(T).int.bits + 1);
const ShiftType = std.math.Log2Int(PromotedType);
- return @as(PromotedType, 1) << @as(ShiftType, @intCast(@typeInfo(T).Int.bits - @clz(value - 1)));
+ return @as(PromotedType, 1) << @as(ShiftType, @intCast(@typeInfo(T).int.bits - @clz(value - 1)));
}
/// Returns the next power of two (if the value is not already a power of two).
/// Only unsigned integers can be used. Zero is not an allowed input.
/// If the value doesn't fit, returns an error.
pub fn ceilPowerOfTwo(comptime T: type, value: T) (error{Overflow}!T) {
- comptime assert(@typeInfo(T) == .Int);
- const info = @typeInfo(T).Int;
+ comptime assert(@typeInfo(T) == .int);
+ const info = @typeInfo(T).int;
comptime assert(info.signedness == .unsigned);
const PromotedType = std.meta.Int(info.signedness, info.bits + 1);
const overflowBit = @as(PromotedType, 1) << info.bits;
@@ -1261,16 +1261,16 @@ fn testCeilPowerOfTwo() !void {
/// Return the log base 2 of integer value x, rounding down to the
/// nearest integer.
pub fn log2_int(comptime T: type, x: T) Log2Int(T) {
- if (@typeInfo(T) != .Int or @typeInfo(T).Int.signedness != .unsigned)
+ if (@typeInfo(T) != .int or @typeInfo(T).int.signedness != .unsigned)
@compileError("log2_int requires an unsigned integer, found " ++ @typeName(T));
assert(x != 0);
- return @as(Log2Int(T), @intCast(@typeInfo(T).Int.bits - 1 - @clz(x)));
+ return @as(Log2Int(T), @intCast(@typeInfo(T).int.bits - 1 - @clz(x)));
}
/// Return the log base 2 of integer value x, rounding up to the
/// nearest integer.
pub fn log2_int_ceil(comptime T: type, x: T) Log2IntCeil(T) {
- if (@typeInfo(T) != .Int or @typeInfo(T).Int.signedness != .unsigned)
+ if (@typeInfo(T) != .int or @typeInfo(T).int.signedness != .unsigned)
@compileError("log2_int_ceil requires an unsigned integer, found " ++ @typeName(T));
assert(x != 0);
if (x == 1) return 0;
@@ -1296,35 +1296,35 @@ test log2_int_ceil {
/// converted to the closest possible representation.
pub fn lossyCast(comptime T: type, value: anytype) T {
switch (@typeInfo(T)) {
- .Float => {
+ .float => {
switch (@typeInfo(@TypeOf(value))) {
- .Int => return @as(T, @floatFromInt(value)),
- .Float => return @as(T, @floatCast(value)),
- .ComptimeInt => return @as(T, value),
- .ComptimeFloat => return @as(T, value),
+ .int => return @floatFromInt(value),
+ .float => return @floatCast(value),
+ .comptime_int => return value,
+ .comptime_float => return value,
else => @compileError("bad type"),
}
},
- .Int => {
+ .int => {
switch (@typeInfo(@TypeOf(value))) {
- .Int, .ComptimeInt => {
+ .int, .comptime_int => {
if (value >= maxInt(T)) {
- return @as(T, maxInt(T));
+ return maxInt(T);
} else if (value <= minInt(T)) {
- return @as(T, minInt(T));
+ return minInt(T);
} else {
- return @as(T, @intCast(value));
+ return @intCast(value);
}
},
- .Float, .ComptimeFloat => {
+ .float, .comptime_float => {
if (isNan(value)) {
return 0;
} else if (value >= maxInt(T)) {
- return @as(T, maxInt(T));
+ return maxInt(T);
} else if (value <= minInt(T)) {
- return @as(T, minInt(T));
+ return minInt(T);
} else {
- return @as(T, @intFromFloat(value));
+ return @intFromFloat(value);
}
},
else => @compileError("bad type"),
@@ -1405,16 +1405,16 @@ test lerp {
/// Returns the maximum value of integer type T.
pub fn maxInt(comptime T: type) comptime_int {
const info = @typeInfo(T);
- const bit_count = info.Int.bits;
+ const bit_count = info.int.bits;
if (bit_count == 0) return 0;
- return (1 << (bit_count - @intFromBool(info.Int.signedness == .signed))) - 1;
+ return (1 << (bit_count - @intFromBool(info.int.signedness == .signed))) - 1;
}
/// Returns the minimum value of integer type T.
pub fn minInt(comptime T: type) comptime_int {
const info = @typeInfo(T);
- const bit_count = info.Int.bits;
- if (info.Int.signedness == .unsigned) return 0;
+ const bit_count = info.int.bits;
+ if (info.int.signedness == .unsigned) return 0;
if (bit_count == 0) return 0;
return -(1 << (bit_count - 1));
}
@@ -1466,12 +1466,12 @@ test "max value type" {
/// Multiply a and b. Return type is wide enough to guarantee no
/// overflow.
pub fn mulWide(comptime T: type, a: T, b: T) std.meta.Int(
- @typeInfo(T).Int.signedness,
- @typeInfo(T).Int.bits * 2,
+ @typeInfo(T).int.signedness,
+ @typeInfo(T).int.bits * 2,
) {
const ResultInt = std.meta.Int(
- @typeInfo(T).Int.signedness,
- @typeInfo(T).Int.bits * 2,
+ @typeInfo(T).int.signedness,
+ @typeInfo(T).int.bits * 2,
);
return @as(ResultInt, a) * @as(ResultInt, b);
}
@@ -1616,7 +1616,7 @@ pub const CompareOperator = enum {
}
test reverse {
- inline for (@typeInfo(CompareOperator).Enum.fields) |op_field| {
+ inline for (@typeInfo(CompareOperator).@"enum".fields) |op_field| {
const op = @as(CompareOperator, @enumFromInt(op_field.value));
try testing.expect(compare(2, op, 3) == compare(3, op.reverse(), 2));
try testing.expect(compare(3, op, 3) == compare(3, op.reverse(), 3));
@@ -1669,7 +1669,7 @@ test order {
/// and a mask of all zeroes if value is false.
/// Compiles to one instruction for register sized integers.
pub inline fn boolMask(comptime MaskInt: type, value: bool) MaskInt {
- if (@typeInfo(MaskInt) != .Int)
+ if (@typeInfo(MaskInt) != .int)
@compileError("boolMask requires an integer mask type.");
if (MaskInt == u0 or MaskInt == i0)
@@ -1742,11 +1742,11 @@ pub fn break_f80(x: f80) F80 {
pub inline fn sign(i: anytype) @TypeOf(i) {
const T = @TypeOf(i);
return switch (@typeInfo(T)) {
- .Int, .ComptimeInt => @as(T, @intFromBool(i > 0)) - @as(T, @intFromBool(i < 0)),
- .Float, .ComptimeFloat => @as(T, @floatFromInt(@intFromBool(i > 0))) - @as(T, @floatFromInt(@intFromBool(i < 0))),
- .Vector => |vinfo| blk: {
+ .int, .comptime_int => @as(T, @intFromBool(i > 0)) - @as(T, @intFromBool(i < 0)),
+ .float, .comptime_float => @as(T, @floatFromInt(@intFromBool(i > 0))) - @as(T, @floatFromInt(@intFromBool(i < 0))),
+ .vector => |vinfo| blk: {
switch (@typeInfo(vinfo.child)) {
- .Int, .Float => {
+ .int, .float => {
const zero: T = @splat(0);
const one: T = @splat(1);
break :blk @select(vinfo.child, i > zero, one, zero) - @select(vinfo.child, i < zero, one, zero);
diff --git a/lib/std/math/big.zig b/lib/std/math/big.zig
index c0d8e74eb2..c201bf1df2 100644
--- a/lib/std/math/big.zig
+++ b/lib/std/math/big.zig
@@ -4,7 +4,7 @@ const assert = std.debug.assert;
pub const Rational = @import("big/rational.zig").Rational;
pub const int = @import("big/int.zig");
pub const Limb = usize;
-const limb_info = @typeInfo(Limb).Int;
+const limb_info = @typeInfo(Limb).int;
pub const SignedLimb = std.meta.Int(.signed, limb_info.bits);
pub const DoubleLimb = std.meta.Int(.unsigned, 2 * limb_info.bits);
pub const HalfLimb = std.meta.Int(.unsigned, limb_info.bits / 2);
diff --git a/lib/std/math/big/int.zig b/lib/std/math/big/int.zig
index f0fd6fca4e..2c656033e9 100644
--- a/lib/std/math/big/int.zig
+++ b/lib/std/math/big/int.zig
@@ -2,9 +2,9 @@ const std = @import("../../std.zig");
const builtin = @import("builtin");
const math = std.math;
const Limb = std.math.big.Limb;
-const limb_bits = @typeInfo(Limb).Int.bits;
+const limb_bits = @typeInfo(Limb).int.bits;
const HalfLimb = std.math.big.HalfLimb;
-const half_limb_bits = @typeInfo(HalfLimb).Int.bits;
+const half_limb_bits = @typeInfo(HalfLimb).int.bits;
const DoubleLimb = std.math.big.DoubleLimb;
const SignedDoubleLimb = std.math.big.SignedDoubleLimb;
const Log2Limb = std.math.big.Log2Limb;
@@ -23,7 +23,7 @@ const debug_safety = false;
/// primitive integer value.
/// Note: A comptime-known upper bound of this value that may be used
/// instead if `scalar` is not already comptime-known is
-/// `calcTwosCompLimbCount(@typeInfo(@TypeOf(scalar)).Int.bits)`
+/// `calcTwosCompLimbCount(@typeInfo(@TypeOf(scalar)).int.bits)`
pub fn calcLimbLen(scalar: anytype) usize {
if (scalar == 0) {
return 1;
@@ -236,7 +236,7 @@ pub const Mutable = struct {
self.positive = value >= 0;
switch (@typeInfo(T)) {
- .Int => |info| {
+ .int => |info| {
var w_value = @abs(value);
if (info.bits <= limb_bits) {
@@ -251,7 +251,7 @@ pub const Mutable = struct {
}
}
},
- .ComptimeInt => {
+ .comptime_int => {
comptime var w_value = @abs(value);
if (w_value <= maxInt(Limb)) {
@@ -405,8 +405,8 @@ pub const Mutable = struct {
// is well worth being able to use the stack and not needing an allocator passed in.
// Note that Mutable.init still sets len to calcLimbLen(scalar) in any case.
const limb_len = comptime switch (@typeInfo(@TypeOf(scalar))) {
- .ComptimeInt => calcLimbLen(scalar),
- .Int => |info| calcTwosCompLimbCount(info.bits),
+ .comptime_int => calcLimbLen(scalar),
+ .int => |info| calcTwosCompLimbCount(info.bits),
else => @compileError("expected scalar to be an int"),
};
var limbs: [limb_len]Limb = undefined;
@@ -2158,7 +2158,7 @@ pub const Const = struct {
/// Returns whether self can fit into an integer of the requested type.
pub fn fits(self: Const, comptime T: type) bool {
- const info = @typeInfo(T).Int;
+ const info = @typeInfo(T).int;
return self.fitsInTwosComp(info.signedness, info.bits);
}
@@ -2181,7 +2181,7 @@ pub const Const = struct {
/// Returns an error if self cannot be narrowed into the requested type without truncation.
pub fn to(self: Const, comptime T: type) ConvertError!T {
switch (@typeInfo(T)) {
- .Int => |info| {
+ .int => |info| {
// Make sure -0 is handled correctly.
if (self.eqlZero()) return 0;
@@ -2495,8 +2495,8 @@ pub const Const = struct {
// is well worth being able to use the stack and not needing an allocator passed in.
// Note that Mutable.init still sets len to calcLimbLen(scalar) in any case.
const limb_len = comptime switch (@typeInfo(@TypeOf(scalar))) {
- .ComptimeInt => calcLimbLen(scalar),
- .Int => |info| calcTwosCompLimbCount(info.bits),
+ .comptime_int => calcLimbLen(scalar),
+ .int => |info| calcTwosCompLimbCount(info.bits),
else => @compileError("expected scalar to be an int"),
};
var limbs: [limb_len]Limb = undefined;
@@ -2555,7 +2555,7 @@ pub const Const = struct {
/// Memory is allocated as needed to ensure operations never overflow. The range
/// is bounded only by available memory.
pub const Managed = struct {
- pub const sign_bit: usize = 1 << (@typeInfo(usize).Int.bits - 1);
+ pub const sign_bit: usize = 1 << (@typeInfo(usize).int.bits - 1);
/// Default number of limbs to allocate on creation of a `Managed`.
pub const default_capacity = 4;
diff --git a/lib/std/math/big/int_test.zig b/lib/std/math/big/int_test.zig
index f06917f0f2..17652179f5 100644
--- a/lib/std/math/big/int_test.zig
+++ b/lib/std/math/big/int_test.zig
@@ -22,13 +22,13 @@ test "comptime_int set" {
var a = try Managed.initSet(testing.allocator, s);
defer a.deinit();
- const s_limb_count = 128 / @typeInfo(Limb).Int.bits;
+ const s_limb_count = 128 / @typeInfo(Limb).int.bits;
comptime var i: usize = 0;
inline while (i < s_limb_count) : (i += 1) {
const result = @as(Limb, s & maxInt(Limb));
- s >>= @typeInfo(Limb).Int.bits / 2;
- s >>= @typeInfo(Limb).Int.bits / 2;
+ s >>= @typeInfo(Limb).int.bits / 2;
+ s >>= @typeInfo(Limb).int.bits / 2;
try testing.expect(a.limbs[i] == result);
}
}
@@ -299,7 +299,7 @@ test "twos complement limit set" {
}
fn testTwosComplementLimit(comptime T: type) !void {
- const int_info = @typeInfo(T).Int;
+ const int_info = @typeInfo(T).int;
var a = try Managed.init(testing.allocator);
defer a.deinit();
@@ -1893,7 +1893,7 @@ test "truncate multi to single signed" {
}
test "truncate multi to multi unsigned" {
- const bits = @typeInfo(SignedDoubleLimb).Int.bits;
+ const bits = @typeInfo(SignedDoubleLimb).int.bits;
const Int = std.meta.Int(.unsigned, bits - 1);
var a = try Managed.initSet(testing.allocator, maxInt(SignedDoubleLimb));
@@ -2239,11 +2239,11 @@ test "bitNotWrap more than two limbs" {
const bits = @bitSizeOf(Limb) * 4 + 2;
try res.bitNotWrap(&a, .unsigned, bits);
- const Unsigned = @Type(.{ .Int = .{ .signedness = .unsigned, .bits = bits } });
+ const Unsigned = @Type(.{ .int = .{ .signedness = .unsigned, .bits = bits } });
try testing.expectEqual((try res.to(Unsigned)), ~@as(Unsigned, maxInt(Limb)));
try res.bitNotWrap(&a, .signed, bits);
- const Signed = @Type(.{ .Int = .{ .signedness = .signed, .bits = bits } });
+ const Signed = @Type(.{ .int = .{ .signedness = .signed, .bits = bits } });
try testing.expectEqual((try res.to(Signed)), ~@as(Signed, maxInt(Limb)));
}
@@ -3037,8 +3037,8 @@ test "big int conversion write twos complement zero" {
}
fn bitReverseTest(comptime T: type, comptime input: comptime_int, comptime expected_output: comptime_int) !void {
- const bit_count = @typeInfo(T).Int.bits;
- const signedness = @typeInfo(T).Int.signedness;
+ const bit_count = @typeInfo(T).int.bits;
+ const signedness = @typeInfo(T).int.signedness;
var a = try Managed.initSet(testing.allocator, input);
defer a.deinit();
@@ -3084,8 +3084,8 @@ test "big int bit reverse" {
}
fn byteSwapTest(comptime T: type, comptime input: comptime_int, comptime expected_output: comptime_int) !void {
- const byte_count = @typeInfo(T).Int.bits / 8;
- const signedness = @typeInfo(T).Int.signedness;
+ const byte_count = @typeInfo(T).int.bits / 8;
+ const signedness = @typeInfo(T).int.signedness;
var a = try Managed.initSet(testing.allocator, input);
defer a.deinit();
@@ -3151,7 +3151,7 @@ test "mul multi-multi alias r with a and b" {
try testing.expect(a.eql(want));
- if (@typeInfo(Limb).Int.bits == 64) {
+ if (@typeInfo(Limb).int.bits == 64) {
try testing.expectEqual(@as(usize, 5), a.limbs.len);
}
}
@@ -3167,7 +3167,7 @@ test "sqr multi alias r with a" {
try testing.expect(a.eql(want));
- if (@typeInfo(Limb).Int.bits == 64) {
+ if (@typeInfo(Limb).int.bits == 64) {
try testing.expectEqual(@as(usize, 5), a.limbs.len);
}
}
diff --git a/lib/std/math/big/rational.zig b/lib/std/math/big/rational.zig
index bbfea9de74..ce93f40a25 100644
--- a/lib/std/math/big/rational.zig
+++ b/lib/std/math/big/rational.zig
@@ -135,9 +135,9 @@ pub const Rational = struct {
/// completely represent the provided float.
pub fn setFloat(self: *Rational, comptime T: type, f: T) !void {
// Translated from golang.go/src/math/big/rat.go.
- debug.assert(@typeInfo(T) == .Float);
+ debug.assert(@typeInfo(T) == .float);
- const UnsignedInt = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);
+ const UnsignedInt = std.meta.Int(.unsigned, @typeInfo(T).float.bits);
const f_bits = @as(UnsignedInt, @bitCast(f));
const exponent_bits = math.floatExponentBits(T);
@@ -193,9 +193,9 @@ pub const Rational = struct {
pub fn toFloat(self: Rational, comptime T: type) !T {
// Translated from golang.go/src/math/big/rat.go.
// TODO: Indicate whether the result is not exact.
- debug.assert(@typeInfo(T) == .Float);
+ debug.assert(@typeInfo(T) == .float);
- const fsize = @typeInfo(T).Float.bits;
+ const fsize = @typeInfo(T).float.bits;
const BitReprType = std.meta.Int(.unsigned, fsize);
const msize = math.floatMantissaBits(T);
@@ -473,10 +473,10 @@ pub const Rational = struct {
};
fn extractLowBits(a: Int, comptime T: type) T {
- debug.assert(@typeInfo(T) == .Int);
+ debug.assert(@typeInfo(T) == .int);
- const t_bits = @typeInfo(T).Int.bits;
- const limb_bits = @typeInfo(Limb).Int.bits;
+ const t_bits = @typeInfo(T).int.bits;
+ const limb_bits = @typeInfo(Limb).int.bits;
if (t_bits <= limb_bits) {
return @as(T, @truncate(a.limbs[0]));
} else {
diff --git a/lib/std/math/copysign.zig b/lib/std/math/copysign.zig
index 63daf59047..65144dfe3f 100644
--- a/lib/std/math/copysign.zig
+++ b/lib/std/math/copysign.zig
@@ -5,7 +5,7 @@ const expect = std.testing.expect;
/// Returns a value with the magnitude of `magnitude` and the sign of `sign`.
pub fn copysign(magnitude: anytype, sign: @TypeOf(magnitude)) @TypeOf(magnitude) {
const T = @TypeOf(magnitude);
- const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);
+ const TBits = std.meta.Int(.unsigned, @typeInfo(T).float.bits);
const sign_bit_mask = @as(TBits, 1) << (@bitSizeOf(T) - 1);
const mag = @as(TBits, @bitCast(magnitude)) & ~sign_bit_mask;
const sgn = @as(TBits, @bitCast(sign)) & sign_bit_mask;
diff --git a/lib/std/math/float.zig b/lib/std/math/float.zig
index 1d19fdc57c..a10332f863 100644
--- a/lib/std/math/float.zig
+++ b/lib/std/math/float.zig
@@ -6,21 +6,21 @@ const expectEqual = std.testing.expectEqual;
/// Creates a raw "1.0" mantissa for floating point type T. Used to dedupe f80 logic.
inline fn mantissaOne(comptime T: type) comptime_int {
- return if (@typeInfo(T).Float.bits == 80) 1 << floatFractionalBits(T) else 0;
+ return if (@typeInfo(T).float.bits == 80) 1 << floatFractionalBits(T) else 0;
}
/// Creates floating point type T from an unbiased exponent and raw mantissa.
inline fn reconstructFloat(comptime T: type, comptime exponent: comptime_int, comptime mantissa: comptime_int) T {
- const TBits = @Type(.{ .Int = .{ .signedness = .unsigned, .bits = @bitSizeOf(T) } });
+ const TBits = @Type(.{ .int = .{ .signedness = .unsigned, .bits = @bitSizeOf(T) } });
const biased_exponent = @as(TBits, exponent + floatExponentMax(T));
return @as(T, @bitCast((biased_exponent << floatMantissaBits(T)) | @as(TBits, mantissa)));
}
/// Returns the number of bits in the exponent of floating point type T.
pub inline fn floatExponentBits(comptime T: type) comptime_int {
- comptime assert(@typeInfo(T) == .Float);
+ comptime assert(@typeInfo(T) == .float);
- return switch (@typeInfo(T).Float.bits) {
+ return switch (@typeInfo(T).float.bits) {
16 => 5,
32 => 8,
64 => 11,
@@ -32,9 +32,9 @@ pub inline fn floatExponentBits(comptime T: type) comptime_int {
/// Returns the number of bits in the mantissa of floating point type T.
pub inline fn floatMantissaBits(comptime T: type) comptime_int {
- comptime assert(@typeInfo(T) == .Float);
+ comptime assert(@typeInfo(T) == .float);
- return switch (@typeInfo(T).Float.bits) {
+ return switch (@typeInfo(T).float.bits) {
16 => 10,
32 => 23,
64 => 52,
@@ -46,12 +46,12 @@ pub inline fn floatMantissaBits(comptime T: type) comptime_int {
/// Returns the number of fractional bits in the mantissa of floating point type T.
pub inline fn floatFractionalBits(comptime T: type) comptime_int {
- comptime assert(@typeInfo(T) == .Float);
+ comptime assert(@typeInfo(T) == .float);
// standard IEEE floats have an implicit 0.m or 1.m integer part
// f80 is special and has an explicitly stored bit in the MSB
// this function corresponds to `MANT_DIG - 1' from C
- return switch (@typeInfo(T).Float.bits) {
+ return switch (@typeInfo(T).float.bits) {
16 => 10,
32 => 23,
64 => 52,
@@ -97,8 +97,8 @@ pub inline fn floatEps(comptime T: type) T {
/// Returns the local epsilon of floating point type T.
pub inline fn floatEpsAt(comptime T: type, x: T) T {
switch (@typeInfo(T)) {
- .Float => |F| {
- const U: type = @Type(.{ .Int = .{ .signedness = .unsigned, .bits = F.bits } });
+ .float => |F| {
+ const U: type = @Type(.{ .int = .{ .signedness = .unsigned, .bits = F.bits } });
const u: U = @bitCast(x);
const y: T = @bitCast(u ^ 1);
return @abs(x - y);
diff --git a/lib/std/math/frexp.zig b/lib/std/math/frexp.zig
index 97b578db98..3fb3406075 100644
--- a/lib/std/math/frexp.zig
+++ b/lib/std/math/frexp.zig
@@ -21,7 +21,7 @@ pub fn Frexp(comptime T: type) type {
pub fn frexp(x: anytype) Frexp(@TypeOf(x)) {
const T: type = @TypeOf(x);
- const bits: comptime_int = @typeInfo(T).Float.bits;
+ const bits: comptime_int = @typeInfo(T).float.bits;
const Int: type = std.meta.Int(.unsigned, bits);
const exp_bits: comptime_int = math.floatExponentBits(T);
diff --git a/lib/std/math/gcd.zig b/lib/std/math/gcd.zig
index 298bf5fc2b..36ba8e3614 100644
--- a/lib/std/math/gcd.zig
+++ b/lib/std/math/gcd.zig
@@ -8,8 +8,8 @@ pub fn gcd(a: anytype, b: anytype) @TypeOf(a, b) {
// only unsigned integers are allowed and not both must be zero
comptime switch (@typeInfo(@TypeOf(a, b))) {
- .Int => |int| std.debug.assert(int.signedness == .unsigned),
- .ComptimeInt => {
+ .int => |int| std.debug.assert(int.signedness == .unsigned),
+ .comptime_int => {
std.debug.assert(a >= 0);
std.debug.assert(b >= 0);
},
diff --git a/lib/std/math/hypot.zig b/lib/std/math/hypot.zig
index ddc9408aba..e90b6505ce 100644
--- a/lib/std/math/hypot.zig
+++ b/lib/std/math/hypot.zig
@@ -23,8 +23,8 @@ const floatMax = math.floatMax;
pub fn hypot(x: anytype, y: anytype) @TypeOf(x, y) {
const T = @TypeOf(x, y);
switch (@typeInfo(T)) {
- .Float => {},
- .ComptimeFloat => return @sqrt(x * x + y * y),
+ .float => {},
+ .comptime_float => return @sqrt(x * x + y * y),
else => @compileError("hypot not implemented for " ++ @typeName(T)),
}
const lower = @sqrt(floatMin(T));
diff --git a/lib/std/math/ilogb.zig b/lib/std/math/ilogb.zig
index 6f4bb13189..ba6075208d 100644
--- a/lib/std/math/ilogb.zig
+++ b/lib/std/math/ilogb.zig
@@ -26,7 +26,7 @@ pub const fp_ilogbnan = minInt(i32);
pub const fp_ilogb0 = minInt(i32);
fn ilogbX(comptime T: type, x: T) i32 {
- const typeWidth = @typeInfo(T).Float.bits;
+ const typeWidth = @typeInfo(T).float.bits;
const significandBits = math.floatMantissaBits(T);
const exponentBits = math.floatExponentBits(T);
diff --git a/lib/std/math/isfinite.zig b/lib/std/math/isfinite.zig
index 5d5bfd2a41..8f4e170989 100644
--- a/lib/std/math/isfinite.zig
+++ b/lib/std/math/isfinite.zig
@@ -5,7 +5,7 @@ const expect = std.testing.expect;
/// Returns whether x is a finite value.
pub fn isFinite(x: anytype) bool {
const T = @TypeOf(x);
- const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);
+ const TBits = std.meta.Int(.unsigned, @typeInfo(T).float.bits);
const remove_sign = ~@as(TBits, 0) >> 1;
return @as(TBits, @bitCast(x)) & remove_sign < @as(TBits, @bitCast(math.inf(T)));
}
diff --git a/lib/std/math/isinf.zig b/lib/std/math/isinf.zig
index 7a2e3943d6..220f43209d 100644
--- a/lib/std/math/isinf.zig
+++ b/lib/std/math/isinf.zig
@@ -5,7 +5,7 @@ const expect = std.testing.expect;
/// Returns whether x is an infinity, ignoring sign.
pub inline fn isInf(x: anytype) bool {
const T = @TypeOf(x);
- const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);
+ const TBits = std.meta.Int(.unsigned, @typeInfo(T).float.bits);
const remove_sign = ~@as(TBits, 0) >> 1;
return @as(TBits, @bitCast(x)) & remove_sign == @as(TBits, @bitCast(math.inf(T)));
}
diff --git a/lib/std/math/isnormal.zig b/lib/std/math/isnormal.zig
index 1ecaf39330..f3d09441e7 100644
--- a/lib/std/math/isnormal.zig
+++ b/lib/std/math/isnormal.zig
@@ -5,7 +5,7 @@ const expect = std.testing.expect;
/// Returns whether x is neither zero, subnormal, infinity, or NaN.
pub fn isNormal(x: anytype) bool {
const T = @TypeOf(x);
- const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);
+ const TBits = std.meta.Int(.unsigned, @typeInfo(T).float.bits);
const increment_exp = 1 << math.floatMantissaBits(T);
const remove_sign = ~@as(TBits, 0) >> 1;
diff --git a/lib/std/math/iszero.zig b/lib/std/math/iszero.zig
index 2d288d01e8..57d8250afd 100644
--- a/lib/std/math/iszero.zig
+++ b/lib/std/math/iszero.zig
@@ -5,7 +5,7 @@ const expect = std.testing.expect;
/// Returns whether x is positive zero.
pub inline fn isPositiveZero(x: anytype) bool {
const T = @TypeOf(x);
- const bit_count = @typeInfo(T).Float.bits;
+ const bit_count = @typeInfo(T).float.bits;
const TBits = std.meta.Int(.unsigned, bit_count);
return @as(TBits, @bitCast(x)) == @as(TBits, 0);
}
@@ -13,7 +13,7 @@ pub inline fn isPositiveZero(x: anytype) bool {
/// Returns whether x is negative zero.
pub inline fn isNegativeZero(x: anytype) bool {
const T = @TypeOf(x);
- const bit_count = @typeInfo(T).Float.bits;
+ const bit_count = @typeInfo(T).float.bits;
const TBits = std.meta.Int(.unsigned, bit_count);
return @as(TBits, @bitCast(x)) == @as(TBits, 1) << (bit_count - 1);
}
diff --git a/lib/std/math/ldexp.zig b/lib/std/math/ldexp.zig
index c785f719f0..3b982a9bc2 100644
--- a/lib/std/math/ldexp.zig
+++ b/lib/std/math/ldexp.zig
@@ -7,7 +7,7 @@ const expect = std.testing.expect;
/// Returns x * 2^n.
pub fn ldexp(x: anytype, n: i32) @TypeOf(x) {
const T = @TypeOf(x);
- const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);
+ const TBits = std.meta.Int(.unsigned, @typeInfo(T).float.bits);
const exponent_bits = math.floatExponentBits(T);
const mantissa_bits = math.floatMantissaBits(T);
diff --git a/lib/std/math/log.zig b/lib/std/math/log.zig
index 3ff13a7f19..47846fa688 100644
--- a/lib/std/math/log.zig
+++ b/lib/std/math/log.zig
@@ -14,26 +14,26 @@ pub fn log(comptime T: type, base: T, x: T) T {
return math.log2(x);
} else if (base == 10) {
return math.log10(x);
- } else if ((@typeInfo(T) == .Float or @typeInfo(T) == .ComptimeFloat) and base == math.e) {
+ } else if ((@typeInfo(T) == .float or @typeInfo(T) == .comptime_float) and base == math.e) {
return @log(x);
}
const float_base = math.lossyCast(f64, base);
switch (@typeInfo(T)) {
- .ComptimeFloat => {
+ .comptime_float => {
return @as(comptime_float, @log(@as(f64, x)) / @log(float_base));
},
- .ComptimeInt => {
+ .comptime_int => {
return @as(comptime_int, math.log_int(comptime_int, base, x));
},
- .Int => |IntType| switch (IntType.signedness) {
+ .int => |IntType| switch (IntType.signedness) {
.signed => @compileError("log not implemented for signed integers"),
.unsigned => return @as(T, math.log_int(T, base, x)),
},
- .Float => {
+ .float => {
switch (T) {
f32 => return @as(f32, @floatCast(@log(@as(f64, x)) / @log(float_base))),
f64 => return @log(x) / @log(float_base),
diff --git a/lib/std/math/log10.zig b/lib/std/math/log10.zig
index 5b3ee8a840..6f3d9a47f6 100644
--- a/lib/std/math/log10.zig
+++ b/lib/std/math/log10.zig
@@ -12,14 +12,14 @@ const testing = std.testing;
pub fn log10(x: anytype) @TypeOf(x) {
const T = @TypeOf(x);
switch (@typeInfo(T)) {
- .ComptimeFloat => {
+ .comptime_float => {
return @as(comptime_float, @log10(x));
},
- .Float => return @log10(x),
- .ComptimeInt => {
+ .float => return @log10(x),
+ .comptime_int => {
return @as(comptime_int, @floor(@log10(@as(f64, x))));
},
- .Int => |IntType| switch (IntType.signedness) {
+ .int => |IntType| switch (IntType.signedness) {
.signed => @compileError("log10 not implemented for signed integers"),
.unsigned => return log10_int(x),
},
@@ -37,12 +37,12 @@ pub fn log10(x: anytype) @TypeOf(x) {
pub fn log10_int(x: anytype) std.math.Log2Int(@TypeOf(x)) {
const T = @TypeOf(x);
const OutT = std.math.Log2Int(T);
- if (@typeInfo(T) != .Int or @typeInfo(T).Int.signedness != .unsigned)
+ if (@typeInfo(T) != .int or @typeInfo(T).int.signedness != .unsigned)
@compileError("log10_int requires an unsigned integer, found " ++ @typeName(T));
std.debug.assert(x != 0);
- const bit_size = @typeInfo(T).Int.bits;
+ const bit_size = @typeInfo(T).int.bits;
if (bit_size <= 8) {
return @as(OutT, @intCast(log10_int_u8(x)));
diff --git a/lib/std/math/log2.zig b/lib/std/math/log2.zig
index 0902f3e10c..01a1bd3856 100644
--- a/lib/std/math/log2.zig
+++ b/lib/std/math/log2.zig
@@ -13,11 +13,11 @@ const expect = std.testing.expect;
pub fn log2(x: anytype) @TypeOf(x) {
const T = @TypeOf(x);
switch (@typeInfo(T)) {
- .ComptimeFloat => {
+ .comptime_float => {
return @as(comptime_float, @log2(x));
},
- .Float => return @log2(x),
- .ComptimeInt => comptime {
+ .float => return @log2(x),
+ .comptime_int => comptime {
var x_shifted = x;
// First, calculate floorPowerOfTwo(x)
var shift_amt = 1;
@@ -34,7 +34,7 @@ pub fn log2(x: anytype) @TypeOf(x) {
}
return result;
},
- .Int => |IntType| switch (IntType.signedness) {
+ .int => |IntType| switch (IntType.signedness) {
.signed => @compileError("log2 not implemented for signed integers"),
.unsigned => return math.log2_int(T, x),
},
diff --git a/lib/std/math/log_int.zig b/lib/std/math/log_int.zig
index edf5c31782..376aa69a4d 100644
--- a/lib/std/math/log_int.zig
+++ b/lib/std/math/log_int.zig
@@ -8,8 +8,8 @@ const Log2Int = math.Log2Int;
/// Asserts that `base > 1` and `x > 0`.
pub fn log_int(comptime T: type, base: T, x: T) Log2Int(T) {
const valid = switch (@typeInfo(T)) {
- .ComptimeInt => true,
- .Int => |IntType| IntType.signedness == .unsigned,
+ .comptime_int => true,
+ .int => |IntType| IntType.signedness == .unsigned,
else => false,
};
if (!valid) @compileError("log_int requires an unsigned integer, found " ++ @typeName(T));
@@ -64,9 +64,7 @@ test "log_int" {
// Test all unsigned integers with 2, 3, ..., 64 bits.
// We cannot test 0 or 1 bits since base must be > 1.
inline for (2..64 + 1) |bits| {
- const T = @Type(std.builtin.Type{
- .Int = std.builtin.Type.Int{ .signedness = .unsigned, .bits = @intCast(bits) },
- });
+ const T = @Type(.{ .int = .{ .signedness = .unsigned, .bits = @intCast(bits) } });
// for base = 2, 3, ..., min(maxInt(T),1024)
var base: T = 1;
diff --git a/lib/std/math/nextafter.zig b/lib/std/math/nextafter.zig
index b88648229b..12418b5a1a 100644
--- a/lib/std/math/nextafter.zig
+++ b/lib/std/math/nextafter.zig
@@ -14,15 +14,15 @@ const expect = std.testing.expect;
///
pub fn nextAfter(comptime T: type, x: T, y: T) T {
return switch (@typeInfo(T)) {
- .Int, .ComptimeInt => nextAfterInt(T, x, y),
- .Float => nextAfterFloat(T, x, y),
+ .int, .comptime_int => nextAfterInt(T, x, y),
+ .float => nextAfterFloat(T, x, y),
else => @compileError("expected int or non-comptime float, found '" ++ @typeName(T) ++ "'"),
};
}
fn nextAfterInt(comptime T: type, x: T, y: T) T {
- comptime assert(@typeInfo(T) == .Int or @typeInfo(T) == .ComptimeInt);
- return if (@typeInfo(T) == .Int and @bitSizeOf(T) < 2)
+ comptime assert(@typeInfo(T) == .int or @typeInfo(T) == .comptime_int);
+ return if (@typeInfo(T) == .int and @bitSizeOf(T) < 2)
// Special case for `i0`, `u0`, `i1`, and `u1`.
y
else if (y > x)
@@ -38,7 +38,7 @@ fn nextAfterInt(comptime T: type, x: T, y: T) T {
// <https://github.com/mingw-w64/mingw-w64/blob/e89de847dd3e05bb8e46344378ce3e124f4e7d1c/mingw-w64-crt/math/nextafterl.c>
fn nextAfterFloat(comptime T: type, x: T, y: T) T {
- comptime assert(@typeInfo(T) == .Float);
+ comptime assert(@typeInfo(T) == .float);
if (x == y) {
// Returning `y` ensures that (0.0, -0.0) returns -0.0 and that (-0.0, 0.0) returns 0.0.
return y;
@@ -320,7 +320,7 @@ test "float" {
/// Helps ensure that 0.0 doesn't compare equal to -0.0.
fn bitwiseEqual(comptime T: type, x: T, y: T) bool {
- comptime assert(@typeInfo(T) == .Float);
+ comptime assert(@typeInfo(T) == .float);
const Bits = std.meta.Int(.unsigned, @bitSizeOf(T));
return @as(Bits, @bitCast(x)) == @as(Bits, @bitCast(y));
}
diff --git a/lib/std/math/pow.zig b/lib/std/math/pow.zig
index 2e50cc16dd..7409561e1f 100644
--- a/lib/std/math/pow.zig
+++ b/lib/std/math/pow.zig
@@ -31,7 +31,7 @@ const expect = std.testing.expect;
/// - pow(-inf, y) = pow(-0, -y)
/// - pow(x, y) = nan for finite x < 0 and finite non-integer y
pub fn pow(comptime T: type, x: T, y: T) T {
- if (@typeInfo(T) == .Int) {
+ if (@typeInfo(T) == .int) {
return math.powi(T, x, y) catch unreachable;
}
@@ -122,7 +122,7 @@ pub fn pow(comptime T: type, x: T, y: T) T {
if (yf != 0 and x < 0) {
return math.nan(T);
}
- if (yi >= 1 << (@typeInfo(T).Float.bits - 1)) {
+ if (yi >= 1 << (@typeInfo(T).float.bits - 1)) {
return @exp(y * @log(x));
}
@@ -144,7 +144,7 @@ pub fn pow(comptime T: type, x: T, y: T) T {
var xe = r2.exponent;
var x1 = r2.significand;
- var i = @as(std.meta.Int(.signed, @typeInfo(T).Float.bits), @intFromFloat(yi));
+ var i = @as(std.meta.Int(.signed, @typeInfo(T).float.bits), @intFromFloat(yi));
while (i != 0) : (i >>= 1) {
const overflow_shift = math.floatExponentBits(T) + 1;
if (xe < -(1 << overflow_shift) or (1 << overflow_shift) < xe) {
diff --git a/lib/std/math/powi.zig b/lib/std/math/powi.zig
index 271d24352a..aed79e097c 100644
--- a/lib/std/math/powi.zig
+++ b/lib/std/math/powi.zig
@@ -27,7 +27,7 @@ pub fn powi(comptime T: type, x: T, y: T) (error{
Overflow,
Underflow,
}!T) {
- const bit_size = @typeInfo(T).Int.bits;
+ const bit_size = @typeInfo(T).int.bits;
// `y & 1 == 0` won't compile when `does_one_overflow`.
const does_one_overflow = math.maxInt(T) < 1;
diff --git a/lib/std/math/signbit.zig b/lib/std/math/signbit.zig
index eeb729ceb7..97dd03613a 100644
--- a/lib/std/math/signbit.zig
+++ b/lib/std/math/signbit.zig
@@ -5,7 +5,7 @@ const expect = std.testing.expect;
/// Returns whether x is negative or negative 0.
pub fn signbit(x: anytype) bool {
const T = @TypeOf(x);
- const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);
+ const TBits = std.meta.Int(.unsigned, @typeInfo(T).float.bits);
return @as(TBits, @bitCast(x)) >> (@bitSizeOf(T) - 1) != 0;
}
diff --git a/lib/std/math/sqrt.zig b/lib/std/math/sqrt.zig
index a000911897..0753277bb7 100644
--- a/lib/std/math/sqrt.zig
+++ b/lib/std/math/sqrt.zig
@@ -15,8 +15,8 @@ const maxInt = std.math.maxInt;
pub fn sqrt(x: anytype) Sqrt(@TypeOf(x)) {
const T = @TypeOf(x);
switch (@typeInfo(T)) {
- .Float, .ComptimeFloat => return @sqrt(x),
- .ComptimeInt => comptime {
+ .float, .comptime_float => return @sqrt(x),
+ .comptime_int => comptime {
if (x > maxInt(u128)) {
@compileError("sqrt not implemented for comptime_int greater than 128 bits");
}
@@ -25,7 +25,7 @@ pub fn sqrt(x: anytype) Sqrt(@TypeOf(x)) {
}
return @as(T, sqrt_int(u128, x));
},
- .Int => |IntType| switch (IntType.signedness) {
+ .int => |IntType| switch (IntType.signedness) {
.signed => @compileError("sqrt not implemented for signed integers"),
.unsigned => return sqrt_int(T, x),
},
@@ -34,10 +34,10 @@ pub fn sqrt(x: anytype) Sqrt(@TypeOf(x)) {
}
fn sqrt_int(comptime T: type, value: T) Sqrt(T) {
- if (@typeInfo(T).Int.bits <= 2) {
+ if (@typeInfo(T).int.bits <= 2) {
return if (value == 0) 0 else 1; // shortcut for small number of bits to simplify general case
} else {
- const bits = @typeInfo(T).Int.bits;
+ const bits = @typeInfo(T).int.bits;
const max = math.maxInt(T);
const minustwo = (@as(T, 2) ^ max) + 1; // unsigned int cannot represent -2
var op = value;
@@ -80,7 +80,7 @@ test sqrt_int {
/// Returns the return type `sqrt` will return given an operand of type `T`.
pub fn Sqrt(comptime T: type) type {
return switch (@typeInfo(T)) {
- .Int => |int| std.meta.Int(.unsigned, (int.bits + 1) / 2),
+ .int => |int| @Type(.{ .int = .{ .signedness = .unsigned, .bits = (int.bits + 1) / 2 } }),
else => T,
};
}
diff --git a/lib/std/mem.zig b/lib/std/mem.zig
index c2c168a2ae..b4580b1aa4 100644
--- a/lib/std/mem.zig
+++ b/lib/std/mem.zig
@@ -229,22 +229,22 @@ pub fn copyBackwards(comptime T: type, dest: []T, source: []const T) void {
/// This can be used to zero-initialize any type for which it makes sense. Structs will be initialized recursively.
pub fn zeroes(comptime T: type) T {
switch (@typeInfo(T)) {
- .ComptimeInt, .Int, .ComptimeFloat, .Float => {
+ .comptime_int, .int, .comptime_float, .float => {
return @as(T, 0);
},
- .Enum => {
+ .@"enum" => {
return @as(T, @enumFromInt(0));
},
- .Void => {
+ .void => {
return {};
},
- .Bool => {
+ .bool => {
return false;
},
- .Optional, .Null => {
+ .optional, .null => {
return null;
},
- .Struct => |struct_info| {
+ .@"struct" => |struct_info| {
if (@sizeOf(T) == 0) return undefined;
if (struct_info.layout == .@"extern") {
var item: T = undefined;
@@ -260,7 +260,7 @@ pub fn zeroes(comptime T: type) T {
return structure;
}
},
- .Pointer => |ptr_info| {
+ .pointer => |ptr_info| {
switch (ptr_info.size) {
.Slice => {
if (ptr_info.sentinel) |sentinel| {
@@ -281,17 +281,17 @@ pub fn zeroes(comptime T: type) T {
},
}
},
- .Array => |info| {
+ .array => |info| {
if (info.sentinel) |sentinel_ptr| {
const sentinel = @as(*align(1) const info.child, @ptrCast(sentinel_ptr)).*;
return [_:sentinel]info.child{zeroes(info.child)} ** info.len;
}
return [_]info.child{zeroes(info.child)} ** info.len;
},
- .Vector => |info| {
+ .vector => |info| {
return @splat(zeroes(info.child));
},
- .Union => |info| {
+ .@"union" => |info| {
if (info.layout == .@"extern") {
var item: T = undefined;
@memset(asBytes(&item), 0);
@@ -299,16 +299,16 @@ pub fn zeroes(comptime T: type) T {
}
@compileError("Can't set a " ++ @typeName(T) ++ " to zero.");
},
- .EnumLiteral,
- .ErrorUnion,
- .ErrorSet,
- .Fn,
- .Type,
- .NoReturn,
- .Undefined,
- .Opaque,
- .Frame,
- .AnyFrame,
+ .enum_literal,
+ .error_union,
+ .error_set,
+ .@"fn",
+ .type,
+ .noreturn,
+ .undefined,
+ .@"opaque",
+ .frame,
+ .@"anyframe",
=> {
@compileError("Can't set a " ++ @typeName(T) ++ " to zero.");
},
@@ -423,9 +423,9 @@ pub fn zeroInit(comptime T: type, init: anytype) T {
const Init = @TypeOf(init);
switch (@typeInfo(T)) {
- .Struct => |struct_info| {
+ .@"struct" => |struct_info| {
switch (@typeInfo(Init)) {
- .Struct => |init_info| {
+ .@"struct" => |init_info| {
if (init_info.is_tuple) {
if (init_info.fields.len > struct_info.fields.len) {
@compileError("Tuple initializer has more elements than there are fields in `" ++ @typeName(T) ++ "`");
@@ -449,7 +449,7 @@ pub fn zeroInit(comptime T: type, init: anytype) T {
@field(value, field.name) = @field(init, init_info.fields[i].name);
} else if (@hasField(@TypeOf(init), field.name)) {
switch (@typeInfo(field.type)) {
- .Struct => {
+ .@"struct" => {
@field(value, field.name) = zeroInit(field.type, @field(init, field.name));
},
else => {
@@ -461,7 +461,7 @@ pub fn zeroInit(comptime T: type, init: anytype) T {
@field(value, field.name) = default_value;
} else {
switch (@typeInfo(field.type)) {
- .Struct => {
+ .@"struct" => {
@field(value, field.name) = std.mem.zeroInit(field.type, .{});
},
else => {
@@ -752,10 +752,10 @@ test indexOfDiff {
/// `[*c]` pointers are assumed to be 0-terminated and assumed to not be allowzero.
fn Span(comptime T: type) type {
switch (@typeInfo(T)) {
- .Optional => |optional_info| {
+ .optional => |optional_info| {
return ?Span(optional_info.child);
},
- .Pointer => |ptr_info| {
+ .pointer => |ptr_info| {
var new_ptr_info = ptr_info;
switch (ptr_info.size) {
.C => {
@@ -766,7 +766,7 @@ fn Span(comptime T: type) type {
.One, .Slice => @compileError("invalid type given to std.mem.span: " ++ @typeName(T)),
}
new_ptr_info.size = .Slice;
- return @Type(.{ .Pointer = new_ptr_info });
+ return @Type(.{ .pointer = new_ptr_info });
},
else => {},
}
@@ -789,7 +789,7 @@ test Span {
/// Pointer attributes such as const are preserved.
/// `[*c]` pointers are assumed to be non-null and 0-terminated.
pub fn span(ptr: anytype) Span(@TypeOf(ptr)) {
- if (@typeInfo(@TypeOf(ptr)) == .Optional) {
+ if (@typeInfo(@TypeOf(ptr)) == .optional) {
if (ptr) |non_null| {
return span(non_null);
} else {
@@ -798,7 +798,7 @@ pub fn span(ptr: anytype) Span(@TypeOf(ptr)) {
}
const Result = Span(@TypeOf(ptr));
const l = len(ptr);
- const ptr_info = @typeInfo(Result).Pointer;
+ const ptr_info = @typeInfo(Result).pointer;
if (ptr_info.sentinel) |s_ptr| {
const s = @as(*align(1) const ptr_info.child, @ptrCast(s_ptr)).*;
return ptr[0..l :s];
@@ -817,15 +817,15 @@ test span {
/// Helper for the return type of sliceTo()
fn SliceTo(comptime T: type, comptime end: std.meta.Elem(T)) type {
switch (@typeInfo(T)) {
- .Optional => |optional_info| {
+ .optional => |optional_info| {
return ?SliceTo(optional_info.child, end);
},
- .Pointer => |ptr_info| {
+ .pointer => |ptr_info| {
var new_ptr_info = ptr_info;
new_ptr_info.size = .Slice;
switch (ptr_info.size) {
.One => switch (@typeInfo(ptr_info.child)) {
- .Array => |array_info| {
+ .array => |array_info| {
new_ptr_info.child = array_info.child;
// The return type must only be sentinel terminated if we are guaranteed
// to find the value searched for, which is only the case if it matches
@@ -861,7 +861,7 @@ fn SliceTo(comptime T: type, comptime end: std.meta.Elem(T)) type {
new_ptr_info.is_allowzero = false;
},
}
- return @Type(.{ .Pointer = new_ptr_info });
+ return @Type(.{ .pointer = new_ptr_info });
},
else => {},
}
@@ -876,13 +876,13 @@ fn SliceTo(comptime T: type, comptime end: std.meta.Elem(T)) type {
/// Pointer properties such as mutability and alignment are preserved.
/// C pointers are assumed to be non-null.
pub fn sliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) SliceTo(@TypeOf(ptr), end) {
- if (@typeInfo(@TypeOf(ptr)) == .Optional) {
+ if (@typeInfo(@TypeOf(ptr)) == .optional) {
const non_null = ptr orelse return null;
return sliceTo(non_null, end);
}
const Result = SliceTo(@TypeOf(ptr), end);
const length = lenSliceTo(ptr, end);
- const ptr_info = @typeInfo(Result).Pointer;
+ const ptr_info = @typeInfo(Result).pointer;
if (ptr_info.sentinel) |s_ptr| {
const s = @as(*align(1) const ptr_info.child, @ptrCast(s_ptr)).*;
return ptr[0..length :s];
@@ -933,9 +933,9 @@ test sliceTo {
/// Private helper for sliceTo(). If you want the length, use sliceTo(foo, x).len
fn lenSliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) usize {
switch (@typeInfo(@TypeOf(ptr))) {
- .Pointer => |ptr_info| switch (ptr_info.size) {
+ .pointer => |ptr_info| switch (ptr_info.size) {
.One => switch (@typeInfo(ptr_info.child)) {
- .Array => |array_info| {
+ .array => |array_info| {
if (array_info.sentinel) |sentinel_ptr| {
const sentinel = @as(*align(1) const array_info.child, @ptrCast(sentinel_ptr)).*;
if (sentinel == end) {
@@ -1015,7 +1015,7 @@ test lenSliceTo {
/// `[*c]` pointers are assumed to be non-null and 0-terminated.
pub fn len(value: anytype) usize {
switch (@typeInfo(@TypeOf(value))) {
- .Pointer => |info| switch (info.size) {
+ .pointer => |info| switch (info.size) {
.Many => {
const sentinel_ptr = info.sentinel orelse
@compileError("invalid type given to std.mem.len: " ++ @typeName(@TypeOf(value)));
@@ -1051,7 +1051,7 @@ pub fn indexOfSentinel(comptime T: type, comptime sentinel: T, p: [*:sentinel]co
if (backend_supports_vectors and
!std.debug.inValgrind() and // https://github.com/ziglang/zig/issues/17717
!@inComptime() and
- (@typeInfo(T) == .Int or @typeInfo(T) == .Float) and std.math.isPowerOfTwo(@bitSizeOf(T)))
+ (@typeInfo(T) == .int or @typeInfo(T) == .float) and std.math.isPowerOfTwo(@bitSizeOf(T)))
{
switch (@import("builtin").cpu.arch) {
// The below branch assumes that reading past the end of the buffer is valid, as long
@@ -1202,7 +1202,7 @@ pub fn indexOfScalarPos(comptime T: type, slice: []const T, start_index: usize,
if (backend_supports_vectors and
!std.debug.inValgrind() and // https://github.com/ziglang/zig/issues/17717
!@inComptime() and
- (@typeInfo(T) == .Int or @typeInfo(T) == .Float) and std.math.isPowerOfTwo(@bitSizeOf(T)))
+ (@typeInfo(T) == .int or @typeInfo(T) == .float) and std.math.isPowerOfTwo(@bitSizeOf(T)))
{
if (std.simd.suggestVectorLength(T)) |block_len| {
// For Intel Nehalem (2009) and AMD Bulldozer (2012) or later, unaligned loads on aligned data result
@@ -1602,8 +1602,8 @@ test containsAtLeast {
/// T specifies the return type, which must be large enough to store
/// the result.
pub fn readVarInt(comptime ReturnType: type, bytes: []const u8, endian: Endian) ReturnType {
- const bits = @typeInfo(ReturnType).Int.bits;
- const signedness = @typeInfo(ReturnType).Int.signedness;
+ const bits = @typeInfo(ReturnType).int.bits;
+ const signedness = @typeInfo(ReturnType).int.signedness;
const WorkType = std.meta.Int(signedness, @max(16, bits));
var result: WorkType = 0;
switch (endian) {
@@ -1635,7 +1635,7 @@ test readVarInt {
try testing.expect(readVarInt(i16, &[_]u8{ 0xff, 0xfd }, .big) == -3);
try testing.expect(readVarInt(i16, &[_]u8{ 0xfc, 0xff }, .little) == -4);
- // Return type can be oversized (bytes.len * 8 < @typeInfo(ReturnType).Int.bits)
+ // Return type can be oversized (bytes.len * 8 < @typeInfo(ReturnType).int.bits)
try testing.expect(readVarInt(u9, &[_]u8{0x12}, .little) == 0x12);
try testing.expect(readVarInt(u9, &[_]u8{0xde}, .big) == 0xde);
try testing.expect(readVarInt(u80, &[_]u8{ 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x24 }, .big) == 0x123456789abcdef024);
@@ -1719,7 +1719,7 @@ test readVarPackedInt {
/// Reads an integer from memory with bit count specified by T.
/// The bit count of T must be evenly divisible by 8.
/// This function cannot fail and cannot cause undefined behavior.
-pub inline fn readInt(comptime T: type, buffer: *const [@divExact(@typeInfo(T).Int.bits, 8)]u8, endian: Endian) T {
+pub inline fn readInt(comptime T: type, buffer: *const [@divExact(@typeInfo(T).int.bits, 8)]u8, endian: Endian) T {
const value: T = @bitCast(buffer.*);
return if (endian == native_endian) value else @byteSwap(value);
}
@@ -1844,7 +1844,7 @@ test "comptime read/write int" {
/// Writes an integer to memory, storing it in twos-complement.
/// This function always succeeds, has defined behavior for all inputs, but
/// the integer bit width must be divisible by 8.
-pub inline fn writeInt(comptime T: type, buffer: *[@divExact(@typeInfo(T).Int.bits, 8)]u8, value: T, endian: Endian) void {
+pub inline fn writeInt(comptime T: type, buffer: *[@divExact(@typeInfo(T).int.bits, 8)]u8, value: T, endian: Endian) void {
buffer.* = @bitCast(if (endian == native_endian) value else @byteSwap(value));
}
@@ -2047,20 +2047,20 @@ test writeVarPackedInt {
/// (Changing their endianness)
pub fn byteSwapAllFields(comptime S: type, ptr: *S) void {
switch (@typeInfo(S)) {
- .Struct => {
+ .@"struct" => {
inline for (std.meta.fields(S)) |f| {
switch (@typeInfo(f.type)) {
- .Struct => |struct_info| if (struct_info.backing_integer) |Int| {
+ .@"struct" => |struct_info| if (struct_info.backing_integer) |Int| {
@field(ptr, f.name) = @bitCast(@byteSwap(@as(Int, @bitCast(@field(ptr, f.name)))));
} else {
byteSwapAllFields(f.type, &@field(ptr, f.name));
},
- .Array => byteSwapAllFields(f.type, &@field(ptr, f.name)),
- .Enum => {
+ .array => byteSwapAllFields(f.type, &@field(ptr, f.name)),
+ .@"enum" => {
@field(ptr, f.name) = @enumFromInt(@byteSwap(@intFromEnum(@field(ptr, f.name))));
},
- .Bool => {},
- .Float => |float_info| {
+ .bool => {},
+ .float => |float_info| {
@field(ptr, f.name) = @bitCast(@byteSwap(@as(std.meta.Int(.unsigned, float_info.bits), @bitCast(@field(ptr, f.name)))));
},
else => {
@@ -2069,15 +2069,15 @@ pub fn byteSwapAllFields(comptime S: type, ptr: *S) void {
}
}
},
- .Array => {
+ .array => {
for (ptr) |*item| {
switch (@typeInfo(@TypeOf(item.*))) {
- .Struct, .Array => byteSwapAllFields(@TypeOf(item.*), item),
- .Enum => {
+ .@"struct", .array => byteSwapAllFields(@TypeOf(item.*), item),
+ .@"enum" => {
item.* = @enumFromInt(@byteSwap(@intFromEnum(item.*)));
},
- .Bool => {},
- .Float => |float_info| {
+ .bool => {},
+ .float => |float_info| {
item.* = @bitCast(@byteSwap(@as(std.meta.Int(.unsigned, float_info.bits), @bitCast(item.*))));
},
else => {
@@ -3560,21 +3560,21 @@ test reverse {
fn ReverseIterator(comptime T: type) type {
const Pointer = blk: {
switch (@typeInfo(T)) {
- .Pointer => |ptr_info| switch (ptr_info.size) {
+ .pointer => |ptr_info| switch (ptr_info.size) {
.One => switch (@typeInfo(ptr_info.child)) {
- .Array => |array_info| {
+ .array => |array_info| {
var new_ptr_info = ptr_info;
new_ptr_info.size = .Many;
new_ptr_info.child = array_info.child;
new_ptr_info.sentinel = array_info.sentinel;
- break :blk @Type(.{ .Pointer = new_ptr_info });
+ break :blk @Type(.{ .pointer = new_ptr_info });
},
else => {},
},
.Slice => {
var new_ptr_info = ptr_info;
new_ptr_info.size = .Many;
- break :blk @Type(.{ .Pointer = new_ptr_info });
+ break :blk @Type(.{ .pointer = new_ptr_info });
},
else => {},
},
@@ -3583,8 +3583,8 @@ fn ReverseIterator(comptime T: type) type {
@compileError("expected slice or pointer to array, found '" ++ @typeName(T) ++ "'");
};
const Element = std.meta.Elem(Pointer);
- const ElementPointer = @Type(.{ .Pointer = ptr: {
- var ptr = @typeInfo(Pointer).Pointer;
+ const ElementPointer = @Type(.{ .pointer = ptr: {
+ var ptr = @typeInfo(Pointer).pointer;
ptr.size = .One;
ptr.child = Element;
ptr.sentinel = null;
@@ -3891,11 +3891,11 @@ pub fn alignPointerOffset(ptr: anytype, align_to: usize) ?usize {
const T = @TypeOf(ptr);
const info = @typeInfo(T);
- if (info != .Pointer or info.Pointer.size != .Many)
+ if (info != .pointer or info.pointer.size != .Many)
@compileError("expected many item pointer, got " ++ @typeName(T));
// Do nothing if the pointer is already well-aligned.
- if (align_to <= info.Pointer.alignment)
+ if (align_to <= info.pointer.alignment)
return 0;
// Calculate the aligned base address with an eye out for overflow.
@@ -3907,7 +3907,7 @@ pub fn alignPointerOffset(ptr: anytype, align_to: usize) ?usize {
// The delta is expressed in terms of bytes, turn it into a number of child
// type elements.
const delta = ov[0] - addr;
- const pointee_size = @sizeOf(info.Pointer.child);
+ const pointee_size = @sizeOf(info.pointer.child);
if (delta % pointee_size != 0) return null;
return delta / pointee_size;
}
@@ -3948,9 +3948,9 @@ fn CopyPtrAttrs(
comptime size: std.builtin.Type.Pointer.Size,
comptime child: type,
) type {
- const info = @typeInfo(source).Pointer;
+ const info = @typeInfo(source).pointer;
return @Type(.{
- .Pointer = .{
+ .pointer = .{
.size = size,
.is_const = info.is_const,
.is_volatile = info.is_volatile,
@@ -4019,8 +4019,8 @@ test "asBytes preserves pointer attributes" {
const inPtr = @as(*align(16) const volatile u32, @ptrCast(&inArr));
const outSlice = asBytes(inPtr);
- const in = @typeInfo(@TypeOf(inPtr)).Pointer;
- const out = @typeInfo(@TypeOf(outSlice)).Pointer;
+ const in = @typeInfo(@TypeOf(inPtr)).pointer;
+ const out = @typeInfo(@TypeOf(outSlice)).pointer;
try testing.expectEqual(in.is_const, out.is_const);
try testing.expectEqual(in.is_volatile, out.is_volatile);
@@ -4102,8 +4102,8 @@ test "bytesAsValue preserves pointer attributes" {
const inSlice = @as(*align(16) const volatile [4]u8, @ptrCast(&inArr))[0..];
const outPtr = bytesAsValue(u32, inSlice);
- const in = @typeInfo(@TypeOf(inSlice)).Pointer;
- const out = @typeInfo(@TypeOf(outPtr)).Pointer;
+ const in = @typeInfo(@TypeOf(inSlice)).pointer;
+ const out = @typeInfo(@TypeOf(outPtr)).pointer;
try testing.expectEqual(in.is_const, out.is_const);
try testing.expectEqual(in.is_volatile, out.is_volatile);
@@ -4204,8 +4204,8 @@ test "bytesAsSlice preserves pointer attributes" {
const inSlice = @as(*align(16) const volatile [4]u8, @ptrCast(&inArr))[0..];
const outSlice = bytesAsSlice(u16, inSlice);
- const in = @typeInfo(@TypeOf(inSlice)).Pointer;
- const out = @typeInfo(@TypeOf(outSlice)).Pointer;
+ const in = @typeInfo(@TypeOf(inSlice)).pointer;
+ const out = @typeInfo(@TypeOf(outSlice)).pointer;
try testing.expectEqual(in.is_const, out.is_const);
try testing.expectEqual(in.is_volatile, out.is_volatile);
@@ -4303,8 +4303,8 @@ test "sliceAsBytes preserves pointer attributes" {
const inSlice = @as(*align(16) const volatile [2]u16, @ptrCast(&inArr))[0..];
const outSlice = sliceAsBytes(inSlice);
- const in = @typeInfo(@TypeOf(inSlice)).Pointer;
- const out = @typeInfo(@TypeOf(outSlice)).Pointer;
+ const in = @typeInfo(@TypeOf(inSlice)).pointer;
+ const out = @typeInfo(@TypeOf(outSlice)).pointer;
try testing.expectEqual(in.is_const, out.is_const);
try testing.expectEqual(in.is_volatile, out.is_volatile);
@@ -4346,14 +4346,14 @@ pub fn doNotOptimizeAway(val: anytype) void {
const max_gp_register_bits = @bitSizeOf(c_long);
const t = @typeInfo(@TypeOf(val));
switch (t) {
- .Void, .Null, .ComptimeInt, .ComptimeFloat => return,
- .Enum => doNotOptimizeAway(@intFromEnum(val)),
- .Bool => doNotOptimizeAway(@intFromBool(val)),
- .Int => {
- const bits = t.Int.bits;
+ .void, .null, .comptime_int, .comptime_float => return,
+ .@"enum" => doNotOptimizeAway(@intFromEnum(val)),
+ .bool => doNotOptimizeAway(@intFromBool(val)),
+ .int => {
+ const bits = t.int.bits;
if (bits <= max_gp_register_bits and builtin.zig_backend != .stage2_c) {
const val2 = @as(
- std.meta.Int(t.Int.signedness, @max(8, std.math.ceilPowerOfTwoAssert(u16, bits))),
+ std.meta.Int(t.int.signedness, @max(8, std.math.ceilPowerOfTwoAssert(u16, bits))),
val,
);
asm volatile (""
@@ -4362,15 +4362,15 @@ pub fn doNotOptimizeAway(val: anytype) void {
);
} else doNotOptimizeAway(&val);
},
- .Float => {
- if ((t.Float.bits == 32 or t.Float.bits == 64) and builtin.zig_backend != .stage2_c) {
+ .float => {
+ if ((t.float.bits == 32 or t.float.bits == 64) and builtin.zig_backend != .stage2_c) {
asm volatile (""
:
: [val] "rm" (val),
);
} else doNotOptimizeAway(&val);
},
- .Pointer => {
+ .pointer => {
if (builtin.zig_backend == .stage2_c) {
doNotOptimizeAwayC(val);
} else {
@@ -4381,8 +4381,8 @@ pub fn doNotOptimizeAway(val: anytype) void {
);
}
},
- .Array => {
- if (t.Array.len * @sizeOf(t.Array.child) <= 64) {
+ .array => {
+ if (t.array.len * @sizeOf(t.array.child) <= 64) {
for (val) |v| doNotOptimizeAway(v);
} else doNotOptimizeAway(&val);
},
@@ -4518,9 +4518,9 @@ test "freeing empty string with null-terminated sentinel" {
/// Returns a slice with the given new alignment,
/// all other pointer attributes copied from `AttributeSource`.
fn AlignedSlice(comptime AttributeSource: type, comptime new_alignment: usize) type {
- const info = @typeInfo(AttributeSource).Pointer;
+ const info = @typeInfo(AttributeSource).pointer;
return @Type(.{
- .Pointer = .{
+ .pointer = .{
.size = .Slice,
.is_const = info.is_const,
.is_volatile = info.is_volatile,
@@ -4659,7 +4659,7 @@ test "read/write(Var)PackedInt" {
try expect(diff_bits << @as(Log2T, @intCast(@bitSizeOf(BackingType) - offset)) == 0);
}
- const signedness = @typeInfo(PackedType).Int.signedness;
+ const signedness = @typeInfo(PackedType).int.signedness;
const NextPowerOfTwoInt = std.meta.Int(signedness, try comptime std.math.ceilPowerOfTwo(u16, @bitSizeOf(PackedType)));
const ui64 = std.meta.Int(signedness, 64);
inline for ([_]type{ PackedType, NextPowerOfTwoInt, ui64 }) |U| {
diff --git a/lib/std/mem/Allocator.zig b/lib/std/mem/Allocator.zig
index 1cd6285355..0d4ab9141f 100644
--- a/lib/std/mem/Allocator.zig
+++ b/lib/std/mem/Allocator.zig
@@ -109,7 +109,7 @@ pub fn create(self: Allocator, comptime T: type) Error!*T {
/// `ptr` should be the return value of `create`, or otherwise
/// have the same address and alignment property.
pub fn destroy(self: Allocator, ptr: anytype) void {
- const info = @typeInfo(@TypeOf(ptr)).Pointer;
+ const info = @typeInfo(@TypeOf(ptr)).pointer;
if (info.size != .One) @compileError("ptr must be a single item pointer");
const T = info.child;
if (@sizeOf(T) == 0) return;
@@ -232,7 +232,7 @@ fn allocBytesWithAlignment(self: Allocator, comptime alignment: u29, byte_count:
/// the pointer, however the allocator implementation may refuse the resize
/// request by returning `false`.
pub fn resize(self: Allocator, old_mem: anytype, new_n: usize) bool {
- const Slice = @typeInfo(@TypeOf(old_mem)).Pointer;
+ const Slice = @typeInfo(@TypeOf(old_mem)).pointer;
const T = Slice.child;
if (new_n == 0) {
self.free(old_mem);
@@ -253,7 +253,7 @@ pub fn resize(self: Allocator, old_mem: anytype, new_n: usize) bool {
/// can be larger, smaller, or the same size as the old memory allocation.
/// If `new_n` is 0, this is the same as `free` and it always succeeds.
pub fn realloc(self: Allocator, old_mem: anytype, new_n: usize) t: {
- const Slice = @typeInfo(@TypeOf(old_mem)).Pointer;
+ const Slice = @typeInfo(@TypeOf(old_mem)).pointer;
break :t Error![]align(Slice.alignment) Slice.child;
} {
return self.reallocAdvanced(old_mem, new_n, @returnAddress());
@@ -265,10 +265,10 @@ pub fn reallocAdvanced(
new_n: usize,
return_address: usize,
) t: {
- const Slice = @typeInfo(@TypeOf(old_mem)).Pointer;
+ const Slice = @typeInfo(@TypeOf(old_mem)).pointer;
break :t Error![]align(Slice.alignment) Slice.child;
} {
- const Slice = @typeInfo(@TypeOf(old_mem)).Pointer;
+ const Slice = @typeInfo(@TypeOf(old_mem)).pointer;
const T = Slice.child;
if (old_mem.len == 0) {
return self.allocAdvancedWithRetAddr(T, Slice.alignment, new_n, return_address);
@@ -304,7 +304,7 @@ pub fn reallocAdvanced(
/// Free an array allocated with `alloc`. To free a single item,
/// see `destroy`.
pub fn free(self: Allocator, memory: anytype) void {
- const Slice = @typeInfo(@TypeOf(memory)).Pointer;
+ const Slice = @typeInfo(@TypeOf(memory)).pointer;
const bytes = mem.sliceAsBytes(memory);
const bytes_len = bytes.len + if (Slice.sentinel != null) @sizeOf(Slice.child) else 0;
if (bytes_len == 0) return;
@@ -332,13 +332,13 @@ pub fn dupeZ(allocator: Allocator, comptime T: type, m: []const T) Error![:0]T {
/// TODO replace callsites with `@log2` after this proposal is implemented:
/// https://github.com/ziglang/zig/issues/13642
inline fn log2a(x: anytype) switch (@typeInfo(@TypeOf(x))) {
- .Int => math.Log2Int(@TypeOf(x)),
- .ComptimeInt => comptime_int,
+ .int => math.Log2Int(@TypeOf(x)),
+ .comptime_int => comptime_int,
else => @compileError("int please"),
} {
switch (@typeInfo(@TypeOf(x))) {
- .Int => return math.log2_int(@TypeOf(x), x),
- .ComptimeInt => return math.log2(x),
+ .int => return math.log2_int(@TypeOf(x), x),
+ .comptime_int => return math.log2(x),
else => @compileError("bad"),
}
}
diff --git a/lib/std/meta.zig b/lib/std/meta.zig
index a06674f086..3d3bfca1f9 100644
--- a/lib/std/meta.zig
+++ b/lib/std/meta.zig
@@ -21,11 +21,11 @@ pub fn stringToEnum(comptime T: type, str: []const u8) ?T {
// TODO The '100' here is arbitrary and should be increased when possible:
// - https://github.com/ziglang/zig/issues/4055
// - https://github.com/ziglang/zig/issues/3863
- if (@typeInfo(T).Enum.fields.len <= 100) {
+ if (@typeInfo(T).@"enum".fields.len <= 100) {
const kvs = comptime build_kvs: {
const EnumKV = struct { []const u8, T };
- var kvs_array: [@typeInfo(T).Enum.fields.len]EnumKV = undefined;
- for (@typeInfo(T).Enum.fields, 0..) |enumField, i| {
+ var kvs_array: [@typeInfo(T).@"enum".fields.len]EnumKV = undefined;
+ for (@typeInfo(T).@"enum".fields, 0..) |enumField, i| {
kvs_array[i] = .{ enumField.name, @field(T, enumField.name) };
}
break :build_kvs kvs_array[0..];
@@ -33,7 +33,7 @@ pub fn stringToEnum(comptime T: type, str: []const u8) ?T {
const map = std.StaticStringMap(T).initComptime(kvs);
return map.get(str);
} else {
- inline for (@typeInfo(T).Enum.fields) |enumField| {
+ inline for (@typeInfo(T).@"enum".fields) |enumField| {
if (mem.eql(u8, str, enumField.name)) {
return @field(T, enumField.name);
}
@@ -58,11 +58,11 @@ test stringToEnum {
/// If T is a pointer type the alignment of the type it points to is returned.
pub fn alignment(comptime T: type) comptime_int {
return switch (@typeInfo(T)) {
- .Optional => |info| switch (@typeInfo(info.child)) {
- .Pointer, .Fn => alignment(info.child),
+ .optional => |info| switch (@typeInfo(info.child)) {
+ .pointer, .@"fn" => alignment(info.child),
else => @alignOf(T),
},
- .Pointer => |info| info.alignment,
+ .pointer => |info| info.alignment,
else => @alignOf(T),
};
}
@@ -81,10 +81,10 @@ test alignment {
/// Given a parameterized type (array, vector, pointer, optional), returns the "child type".
pub fn Child(comptime T: type) type {
return switch (@typeInfo(T)) {
- .Array => |info| info.child,
- .Vector => |info| info.child,
- .Pointer => |info| info.child,
- .Optional => |info| info.child,
+ .array => |info| info.child,
+ .vector => |info| info.child,
+ .pointer => |info| info.child,
+ .optional => |info| info.child,
else => @compileError("Expected pointer, optional, array or vector type, found '" ++ @typeName(T) ++ "'"),
};
}
@@ -100,17 +100,17 @@ test Child {
/// Given a "memory span" type (array, slice, vector, or pointer to such), returns the "element type".
pub fn Elem(comptime T: type) type {
switch (@typeInfo(T)) {
- .Array => |info| return info.child,
- .Vector => |info| return info.child,
- .Pointer => |info| switch (info.size) {
+ .array => |info| return info.child,
+ .vector => |info| return info.child,
+ .pointer => |info| switch (info.size) {
.One => switch (@typeInfo(info.child)) {
- .Array => |array_info| return array_info.child,
- .Vector => |vector_info| return vector_info.child,
+ .array => |array_info| return array_info.child,
+ .vector => |vector_info| return vector_info.child,
else => {},
},
.Many, .C, .Slice => return info.child,
},
- .Optional => |info| return Elem(info.child),
+ .optional => |info| return Elem(info.child),
else => {},
}
@compileError("Expected pointer, slice, array or vector type, found '" ++ @typeName(T) ++ "'");
@@ -132,18 +132,18 @@ test Elem {
/// Result is always comptime-known.
pub inline fn sentinel(comptime T: type) ?Elem(T) {
switch (@typeInfo(T)) {
- .Array => |info| {
+ .array => |info| {
const sentinel_ptr = info.sentinel orelse return null;
return @as(*const info.child, @ptrCast(sentinel_ptr)).*;
},
- .Pointer => |info| {
+ .pointer => |info| {
switch (info.size) {
.Many, .Slice => {
const sentinel_ptr = info.sentinel orelse return null;
return @as(*align(1) const info.child, @ptrCast(sentinel_ptr)).*;
},
.One => switch (@typeInfo(info.child)) {
- .Array => |array_info| {
+ .array => |array_info| {
const sentinel_ptr = array_info.sentinel orelse return null;
return @as(*align(1) const array_info.child, @ptrCast(sentinel_ptr)).*;
},
@@ -177,17 +177,17 @@ fn testSentinel() !void {
/// Given a "memory span" type, returns the same type except with the given sentinel value.
pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {
switch (@typeInfo(T)) {
- .Pointer => |info| switch (info.size) {
+ .pointer => |info| switch (info.size) {
.One => switch (@typeInfo(info.child)) {
- .Array => |array_info| return @Type(.{
- .Pointer = .{
+ .array => |array_info| return @Type(.{
+ .pointer = .{
.size = info.size,
.is_const = info.is_const,
.is_volatile = info.is_volatile,
.alignment = info.alignment,
.address_space = info.address_space,
.child = @Type(.{
- .Array = .{
+ .array = .{
.len = array_info.len,
.child = array_info.child,
.sentinel = @as(?*const anyopaque, @ptrCast(&sentinel_val)),
@@ -200,7 +200,7 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {
else => {},
},
.Many, .Slice => return @Type(.{
- .Pointer = .{
+ .pointer = .{
.size = info.size,
.is_const = info.is_const,
.is_volatile = info.is_volatile,
@@ -213,12 +213,12 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {
}),
else => {},
},
- .Optional => |info| switch (@typeInfo(info.child)) {
- .Pointer => |ptr_info| switch (ptr_info.size) {
+ .optional => |info| switch (@typeInfo(info.child)) {
+ .pointer => |ptr_info| switch (ptr_info.size) {
.Many => return @Type(.{
- .Optional = .{
+ .optional = .{
.child = @Type(.{
- .Pointer = .{
+ .pointer = .{
.size = ptr_info.size,
.is_const = ptr_info.is_const,
.is_volatile = ptr_info.is_volatile,
@@ -244,8 +244,8 @@ pub const assumeSentinel = @compileError("This function has been removed, consid
pub fn containerLayout(comptime T: type) Type.ContainerLayout {
return switch (@typeInfo(T)) {
- .Struct => |info| info.layout,
- .Union => |info| info.layout,
+ .@"struct" => |info| info.layout,
+ .@"union" => |info| info.layout,
else => @compileError("expected struct or union type, found '" ++ @typeName(T) ++ "'"),
};
}
@@ -276,10 +276,10 @@ test containerLayout {
/// directly when you know what kind of type it is.
pub fn declarations(comptime T: type) []const Type.Declaration {
return switch (@typeInfo(T)) {
- .Struct => |info| info.decls,
- .Enum => |info| info.decls,
- .Union => |info| info.decls,
- .Opaque => |info| info.decls,
+ .@"struct" => |info| info.decls,
+ .@"enum" => |info| info.decls,
+ .@"union" => |info| info.decls,
+ .@"opaque" => |info| info.decls,
else => @compileError("Expected struct, enum, union, or opaque type, found '" ++ @typeName(T) ++ "'"),
};
}
@@ -350,17 +350,17 @@ test declarationInfo {
}
}
pub fn fields(comptime T: type) switch (@typeInfo(T)) {
- .Struct => []const Type.StructField,
- .Union => []const Type.UnionField,
- .ErrorSet => []const Type.Error,
- .Enum => []const Type.EnumField,
+ .@"struct" => []const Type.StructField,
+ .@"union" => []const Type.UnionField,
+ .@"enum" => []const Type.EnumField,
+ .error_set => []const Type.Error,
else => @compileError("Expected struct, union, error set or enum type, found '" ++ @typeName(T) ++ "'"),
} {
return switch (@typeInfo(T)) {
- .Struct => |info| info.fields,
- .Union => |info| info.fields,
- .Enum => |info| info.fields,
- .ErrorSet => |errors| errors.?, // must be non global error set
+ .@"struct" => |info| info.fields,
+ .@"union" => |info| info.fields,
+ .@"enum" => |info| info.fields,
+ .error_set => |errors| errors.?, // must be non global error set
else => @compileError("Expected struct, union, error set or enum type, found '" ++ @typeName(T) ++ "'"),
};
}
@@ -395,10 +395,10 @@ test fields {
}
pub fn fieldInfo(comptime T: type, comptime field: FieldEnum(T)) switch (@typeInfo(T)) {
- .Struct => Type.StructField,
- .Union => Type.UnionField,
- .ErrorSet => Type.Error,
- .Enum => Type.EnumField,
+ .@"struct" => Type.StructField,
+ .@"union" => Type.UnionField,
+ .@"enum" => Type.EnumField,
+ .error_set => Type.Error,
else => @compileError("Expected struct, union, error set or enum type, found '" ++ @typeName(T) ++ "'"),
} {
return fields(T)[@intFromEnum(field)];
@@ -430,7 +430,7 @@ test fieldInfo {
}
pub fn FieldType(comptime T: type, comptime field: FieldEnum(T)) type {
- if (@typeInfo(T) != .Struct and @typeInfo(T) != .Union) {
+ if (@typeInfo(T) != .@"struct" and @typeInfo(T) != .@"union") {
@compileError("Expected struct or union, found '" ++ @typeName(T) ++ "'");
}
@@ -528,7 +528,7 @@ pub fn FieldEnum(comptime T: type) type {
if (field_infos.len == 0) {
return @Type(.{
- .Enum = .{
+ .@"enum" = .{
.tag_type = u0,
.fields = &.{},
.decls = &.{},
@@ -537,8 +537,8 @@ pub fn FieldEnum(comptime T: type) type {
});
}
- if (@typeInfo(T) == .Union) {
- if (@typeInfo(T).Union.tag_type) |tag_type| {
+ if (@typeInfo(T) == .@"union") {
+ if (@typeInfo(T).@"union".tag_type) |tag_type| {
for (std.enums.values(tag_type), 0..) |v, i| {
if (@intFromEnum(v) != i) break; // enum values not consecutive
if (!std.mem.eql(u8, @tagName(v), field_infos[i].name)) break; // fields out of order
@@ -557,7 +557,7 @@ pub fn FieldEnum(comptime T: type) type {
};
}
return @Type(.{
- .Enum = .{
+ .@"enum" = .{
.tag_type = std.math.IntFittingRange(0, field_infos.len - 1),
.fields = &enumFields,
.decls = &decls,
@@ -568,17 +568,17 @@ pub fn FieldEnum(comptime T: type) type {
fn expectEqualEnum(expected: anytype, actual: @TypeOf(expected)) !void {
// TODO: https://github.com/ziglang/zig/issues/7419
- // testing.expectEqual(@typeInfo(expected).Enum, @typeInfo(actual).Enum);
+ // testing.expectEqual(@typeInfo(expected).@"enum", @typeInfo(actual).@"enum");
try testing.expectEqual(
- @typeInfo(expected).Enum.tag_type,
- @typeInfo(actual).Enum.tag_type,
+ @typeInfo(expected).@"enum".tag_type,
+ @typeInfo(actual).@"enum".tag_type,
);
// For comparing decls and fields, we cannot use the meta eql function here
// because the language does not guarantee that the slice pointers for field names
// and decl names will be the same.
comptime {
- const expected_fields = @typeInfo(expected).Enum.fields;
- const actual_fields = @typeInfo(actual).Enum.fields;
+ const expected_fields = @typeInfo(expected).@"enum".fields;
+ const actual_fields = @typeInfo(actual).@"enum".fields;
if (expected_fields.len != actual_fields.len) return error.FailedTest;
for (expected_fields, 0..) |expected_field, i| {
const actual_field = actual_fields[i];
@@ -587,8 +587,8 @@ fn expectEqualEnum(expected: anytype, actual: @TypeOf(expected)) !void {
}
}
comptime {
- const expected_decls = @typeInfo(expected).Enum.decls;
- const actual_decls = @typeInfo(actual).Enum.decls;
+ const expected_decls = @typeInfo(expected).@"enum".decls;
+ const actual_decls = @typeInfo(actual).@"enum".decls;
if (expected_decls.len != actual_decls.len) return error.FailedTest;
for (expected_decls, 0..) |expected_decl, i| {
const actual_decl = actual_decls[i];
@@ -596,8 +596,8 @@ fn expectEqualEnum(expected: anytype, actual: @TypeOf(expected)) !void {
}
}
try testing.expectEqual(
- @typeInfo(expected).Enum.is_exhaustive,
- @typeInfo(actual).Enum.is_exhaustive,
+ @typeInfo(expected).@"enum".is_exhaustive,
+ @typeInfo(actual).@"enum".is_exhaustive,
);
}
@@ -627,7 +627,7 @@ pub fn DeclEnum(comptime T: type) type {
enumDecls[i] = .{ .name = field.name ++ "", .value = i };
}
return @Type(.{
- .Enum = .{
+ .@"enum" = .{
.tag_type = std.math.IntFittingRange(0, fieldInfos.len - 1),
.fields = &enumDecls,
.decls = &decls,
@@ -661,8 +661,8 @@ test DeclEnum {
pub fn Tag(comptime T: type) type {
return switch (@typeInfo(T)) {
- .Enum => |info| info.tag_type,
- .Union => |info| info.tag_type orelse @compileError(@typeName(T) ++ " has no tag type"),
+ .@"enum" => |info| info.tag_type,
+ .@"union" => |info| info.tag_type orelse @compileError(@typeName(T) ++ " has no tag type"),
else => @compileError("expected enum or union type, found '" ++ @typeName(T) ++ "'"),
};
}
@@ -708,7 +708,7 @@ test activeTag {
const TagPayloadType = TagPayload;
pub fn TagPayloadByName(comptime U: type, comptime tag_name: []const u8) type {
- const info = @typeInfo(U).Union;
+ const info = @typeInfo(U).@"union";
inline for (info.fields) |field_info| {
if (comptime mem.eql(u8, field_info.name, tag_name))
@@ -742,20 +742,20 @@ pub fn eql(a: anytype, b: @TypeOf(a)) bool {
const T = @TypeOf(a);
switch (@typeInfo(T)) {
- .Struct => |info| {
+ .@"struct" => |info| {
inline for (info.fields) |field_info| {
if (!eql(@field(a, field_info.name), @field(b, field_info.name))) return false;
}
return true;
},
- .ErrorUnion => {
+ .error_union => {
if (a) |a_p| {
if (b) |b_p| return eql(a_p, b_p) else |_| return false;
} else |a_e| {
if (b) |_| return false else |b_e| return a_e == b_e;
}
},
- .Union => |info| {
+ .@"union" => |info| {
if (info.tag_type) |UnionTag| {
const tag_a: UnionTag = a;
const tag_b: UnionTag = b;
@@ -768,26 +768,26 @@ pub fn eql(a: anytype, b: @TypeOf(a)) bool {
@compileError("cannot compare untagged union type " ++ @typeName(T));
},
- .Array => {
+ .array => {
if (a.len != b.len) return false;
for (a, 0..) |e, i|
if (!eql(e, b[i])) return false;
return true;
},
- .Vector => |info| {
+ .vector => |info| {
var i: usize = 0;
while (i < info.len) : (i += 1) {
if (!eql(a[i], b[i])) return false;
}
return true;
},
- .Pointer => |info| {
+ .pointer => |info| {
return switch (info.size) {
.One, .Many, .C => a == b,
.Slice => a.ptr == b.ptr and a.len == b.len,
};
},
- .Optional => {
+ .optional => {
if (a == null and b == null) return true;
if (a == null or b == null) return false;
return eql(a.?, b.?);
@@ -893,7 +893,7 @@ test intToEnum {
pub const IntToEnumError = error{InvalidEnumTag};
pub fn intToEnum(comptime EnumTag: type, tag_int: anytype) IntToEnumError!EnumTag {
- const enum_info = @typeInfo(EnumTag).Enum;
+ const enum_info = @typeInfo(EnumTag).@"enum";
if (!enum_info.is_exhaustive) {
if (std.math.cast(enum_info.tag_type, tag_int)) |tag| {
@@ -955,7 +955,7 @@ pub const IntType = @compileError("replaced by std.meta.Int");
pub fn Int(comptime signedness: std.builtin.Signedness, comptime bit_count: u16) type {
return @Type(.{
- .Int = .{
+ .int = .{
.signedness = signedness,
.bits = bit_count,
},
@@ -964,7 +964,7 @@ pub fn Int(comptime signedness: std.builtin.Signedness, comptime bit_count: u16)
pub fn Float(comptime bit_count: u8) type {
return @Type(.{
- .Float = .{ .bits = bit_count },
+ .float = .{ .bits = bit_count },
});
}
@@ -984,10 +984,10 @@ test Float {
/// - `ArgsTuple(fn (a: u32, b: f16) noreturn)` ⇒ `tuple { u32, f16 }`
pub fn ArgsTuple(comptime Function: type) type {
const info = @typeInfo(Function);
- if (info != .Fn)
+ if (info != .@"fn")
@compileError("ArgsTuple expects a function type");
- const function_info = info.Fn;
+ const function_info = info.@"fn";
if (function_info.is_var_args)
@compileError("Cannot create ArgsTuple for variadic function");
@@ -1026,7 +1026,7 @@ fn CreateUniqueTuple(comptime N: comptime_int, comptime types: [N]type) type {
}
return @Type(.{
- .Struct = .{
+ .@"struct" = .{
.is_tuple = true,
.layout = .auto,
.decls = &.{},
@@ -1043,9 +1043,9 @@ const TupleTester = struct {
fn assertTuple(comptime expected: anytype, comptime Actual: type) void {
const info = @typeInfo(Actual);
- if (info != .Struct)
+ if (info != .@"struct")
@compileError("Expected struct type");
- if (!info.Struct.is_tuple)
+ if (!info.@"struct".is_tuple)
@compileError("Struct type must be a tuple type");
const fields_list = std.meta.fields(Actual);
@@ -1115,13 +1115,13 @@ test isError {
/// `false` otherwise. Result is always comptime-known.
pub inline fn hasFn(comptime T: type, comptime name: []const u8) bool {
switch (@typeInfo(T)) {
- .Struct, .Union, .Enum, .Opaque => {},
+ .@"struct", .@"union", .@"enum", .@"opaque" => {},
else => return false,
}
if (!@hasDecl(T, name))
return false;
- return @typeInfo(@TypeOf(@field(T, name))) == .Fn;
+ return @typeInfo(@TypeOf(@field(T, name))) == .@"fn";
}
test hasFn {
@@ -1144,7 +1144,7 @@ test hasFn {
/// Result is always comptime-known.
pub inline fn hasMethod(comptime T: type, comptime name: []const u8) bool {
return switch (@typeInfo(T)) {
- .Pointer => |P| switch (P.size) {
+ .pointer => |P| switch (P.size) {
.One => hasFn(P.child, name),
.Many, .Slice, .C => false,
},
@@ -1191,29 +1191,29 @@ pub inline fn hasUniqueRepresentation(comptime T: type) bool {
return switch (@typeInfo(T)) {
else => false, // TODO can we know if it's true for some of these types ?
- .AnyFrame,
- .Enum,
- .ErrorSet,
- .Fn,
+ .@"anyframe",
+ .@"enum",
+ .error_set,
+ .@"fn",
=> true,
- .Bool => false,
+ .bool => false,
- .Int => |info| @sizeOf(T) * 8 == info.bits,
+ .int => |info| @sizeOf(T) * 8 == info.bits,
- .Pointer => |info| info.size != .Slice,
+ .pointer => |info| info.size != .Slice,
- .Optional => |info| switch (@typeInfo(info.child)) {
- .Pointer => |ptr| !ptr.is_allowzero and switch (ptr.size) {
+ .optional => |info| switch (@typeInfo(info.child)) {
+ .pointer => |ptr| !ptr.is_allowzero and switch (ptr.size) {
.Slice, .C => false,
.One, .Many => true,
},
else => false,
},
- .Array => |info| hasUniqueRepresentation(info.child),
+ .array => |info| hasUniqueRepresentation(info.child),
- .Struct => |info| {
+ .@"struct" => |info| {
if (info.layout == .@"packed") return @sizeOf(T) * 8 == @bitSizeOf(T);
var sum_size = @as(usize, 0);
@@ -1226,7 +1226,7 @@ pub inline fn hasUniqueRepresentation(comptime T: type) bool {
return @sizeOf(T) == sum_size;
},
- .Vector => |info| hasUniqueRepresentation(info.child) and
+ .vector => |info| hasUniqueRepresentation(info.child) and
@sizeOf(T) == @sizeOf(info.child) * info.len,
};
}
diff --git a/lib/std/meta/trailer_flags.zig b/lib/std/meta/trailer_flags.zig
index 9e223768a7..e00d32c789 100644
--- a/lib/std/meta/trailer_flags.zig
+++ b/lib/std/meta/trailer_flags.zig
@@ -14,14 +14,14 @@ pub fn TrailerFlags(comptime Fields: type) type {
bits: Int,
pub const Int = meta.Int(.unsigned, bit_count);
- pub const bit_count = @typeInfo(Fields).Struct.fields.len;
+ pub const bit_count = @typeInfo(Fields).@"struct".fields.len;
pub const FieldEnum = std.meta.FieldEnum(Fields);
pub const ActiveFields = std.enums.EnumFieldStruct(FieldEnum, bool, false);
pub const FieldValues = blk: {
var fields: [bit_count]Type.StructField = undefined;
- for (@typeInfo(Fields).Struct.fields, 0..) |struct_field, i| {
+ for (@typeInfo(Fields).@"struct".fields, 0..) |struct_field, i| {
fields[i] = Type.StructField{
.name = struct_field.name,
.type = ?struct_field.type,
@@ -31,7 +31,7 @@ pub fn TrailerFlags(comptime Fields: type) type {
};
}
break :blk @Type(.{
- .Struct = .{
+ .@"struct" = .{
.layout = .auto,
.fields = &fields,
.decls = &.{},
@@ -61,7 +61,7 @@ pub fn TrailerFlags(comptime Fields: type) type {
/// `fields` is a boolean struct where each active field is set to `true`
pub fn init(fields: ActiveFields) Self {
var self: Self = .{ .bits = 0 };
- inline for (@typeInfo(Fields).Struct.fields, 0..) |field, i| {
+ inline for (@typeInfo(Fields).@"struct".fields, 0..) |field, i| {
if (@field(fields, field.name))
self.bits |= 1 << i;
}
@@ -70,7 +70,7 @@ pub fn TrailerFlags(comptime Fields: type) type {
/// `fields` is a struct with each field set to an optional value
pub fn setMany(self: Self, p: [*]align(@alignOf(Fields)) u8, fields: FieldValues) void {
- inline for (@typeInfo(Fields).Struct.fields, 0..) |field, i| {
+ inline for (@typeInfo(Fields).@"struct".fields, 0..) |field, i| {
if (@field(fields, field.name)) |value|
self.set(p, @as(FieldEnum, @enumFromInt(i)), value);
}
@@ -101,7 +101,7 @@ pub fn TrailerFlags(comptime Fields: type) type {
pub fn offset(self: Self, comptime field: FieldEnum) usize {
var off: usize = 0;
- inline for (@typeInfo(Fields).Struct.fields, 0..) |field_info, i| {
+ inline for (@typeInfo(Fields).@"struct".fields, 0..) |field_info, i| {
const active = (self.bits & (1 << i)) != 0;
if (i == @intFromEnum(field)) {
assert(active);
@@ -114,12 +114,12 @@ pub fn TrailerFlags(comptime Fields: type) type {
}
pub fn Field(comptime field: FieldEnum) type {
- return @typeInfo(Fields).Struct.fields[@intFromEnum(field)].type;
+ return @typeInfo(Fields).@"struct".fields[@intFromEnum(field)].type;
}
pub fn sizeInBytes(self: Self) usize {
var off: usize = 0;
- inline for (@typeInfo(Fields).Struct.fields, 0..) |field, i| {
+ inline for (@typeInfo(Fields).@"struct".fields, 0..) |field, i| {
if (@sizeOf(field.type) == 0)
continue;
if ((self.bits & (1 << i)) != 0) {
diff --git a/lib/std/multi_array_list.zig b/lib/std/multi_array_list.zig
index cfe77f11b5..0d9272d492 100644
--- a/lib/std/multi_array_list.zig
+++ b/lib/std/multi_array_list.zig
@@ -24,10 +24,9 @@ pub fn MultiArrayList(comptime T: type) type {
capacity: usize = 0,
const Elem = switch (@typeInfo(T)) {
- .Struct => T,
- .Union => |u| struct {
- pub const Bare =
- @Type(.{ .Union = .{
+ .@"struct" => T,
+ .@"union" => |u| struct {
+ pub const Bare = @Type(.{ .@"union" = .{
.layout = u.layout,
.tag_type = null,
.fields = u.fields,
@@ -84,8 +83,8 @@ pub fn MultiArrayList(comptime T: type) type {
pub fn set(self: *Slice, index: usize, elem: T) void {
const e = switch (@typeInfo(T)) {
- .Struct => elem,
- .Union => Elem.fromT(elem),
+ .@"struct" => elem,
+ .@"union" => Elem.fromT(elem),
else => unreachable,
};
inline for (fields, 0..) |field_info, i| {
@@ -99,8 +98,8 @@ pub fn MultiArrayList(comptime T: type) type {
@field(result, field_info.name) = self.items(@as(Field, @enumFromInt(i)))[index];
}
return switch (@typeInfo(T)) {
- .Struct => result,
- .Union => Elem.toT(result.tags, result.data),
+ .@"struct" => result,
+ .@"union" => Elem.toT(result.tags, result.data),
else => unreachable,
};
}
@@ -287,8 +286,8 @@ pub fn MultiArrayList(comptime T: type) type {
assert(index <= self.len);
self.len += 1;
const entry = switch (@typeInfo(T)) {
- .Struct => elem,
- .Union => Elem.fromT(elem),
+ .@"struct" => elem,
+ .@"union" => Elem.fromT(elem),
else => unreachable,
};
const slices = self.slice();
@@ -557,7 +556,7 @@ pub fn MultiArrayList(comptime T: type) type {
.is_comptime = fields[i].is_comptime,
.alignment = fields[i].alignment,
};
- break :entry @Type(.{ .Struct = .{
+ break :entry @Type(.{ .@"struct" = .{
.layout = .@"extern",
.fields = &entry_fields,
.decls = &.{},
diff --git a/lib/std/os/emscripten.zig b/lib/std/os/emscripten.zig
index 6792728390..6c6a34ac47 100644
--- a/lib/std/os/emscripten.zig
+++ b/lib/std/os/emscripten.zig
@@ -560,7 +560,7 @@ pub const Sigaction = extern struct {
};
pub const sigset_t = [1024 / 32]u32;
-pub const empty_sigset = [_]u32{0} ** @typeInfo(sigset_t).Array.len;
+pub const empty_sigset = [_]u32{0} ** @typeInfo(sigset_t).array.len;
pub const siginfo_t = extern struct {
signo: i32,
errno: i32,
diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig
index 60b5decdd3..df9d491a5e 100644
--- a/lib/std/os/linux.zig
+++ b/lib/std/os/linux.zig
@@ -1547,7 +1547,7 @@ pub fn seteuid(euid: uid_t) usize {
// The setresuid(2) man page says that if -1 is passed the corresponding
// id will not be changed. Since uid_t is unsigned, this wraps around to the
// max value in C.
- comptime assert(@typeInfo(uid_t) == .Int and @typeInfo(uid_t).Int.signedness == .unsigned);
+ comptime assert(@typeInfo(uid_t) == .int and @typeInfo(uid_t).int.signedness == .unsigned);
return setresuid(std.math.maxInt(uid_t), euid, std.math.maxInt(uid_t));
}
@@ -1558,7 +1558,7 @@ pub fn setegid(egid: gid_t) usize {
// The setresgid(2) man page says that if -1 is passed the corresponding
// id will not be changed. Since gid_t is unsigned, this wraps around to the
// max value in C.
- comptime assert(@typeInfo(uid_t) == .Int and @typeInfo(uid_t).Int.signedness == .unsigned);
+ comptime assert(@typeInfo(uid_t) == .int and @typeInfo(uid_t).int.signedness == .unsigned);
return setresgid(std.math.maxInt(gid_t), egid, std.math.maxInt(gid_t));
}
@@ -1673,7 +1673,7 @@ pub fn sigaction(sig: u6, noalias act: ?*const Sigaction, noalias oact: ?*Sigact
return 0;
}
-const usize_bits = @typeInfo(usize).Int.bits;
+const usize_bits = @typeInfo(usize).int.bits;
pub fn sigaddset(set: *sigset_t, sig: u6) void {
const s = sig - 1;
@@ -1734,7 +1734,7 @@ pub fn sendmsg(fd: i32, msg: *const msghdr_const, flags: u32) usize {
}
pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize {
- if (@typeInfo(usize).Int.bits > @typeInfo(@typeInfo(mmsghdr).Struct.fields[1].type).Int.bits) {
+ if (@typeInfo(usize).int.bits > @typeInfo(@typeInfo(mmsghdr).@"struct".fields[1].type).int.bits) {
// workaround kernel brokenness:
// if adding up all iov_len overflows a i32 then split into multiple calls
// see https://www.openwall.com/lists/musl/2014/06/07/5
@@ -4904,7 +4904,7 @@ pub const NSIG = if (is_mips) 128 else 65;
pub const sigset_t = [1024 / 32]u32;
-pub const all_mask: sigset_t = [_]u32{0xffffffff} ** @typeInfo(sigset_t).Array.len;
+pub const all_mask: sigset_t = [_]u32{0xffffffff} ** @typeInfo(sigset_t).array.len;
pub const app_mask: sigset_t = [2]u32{ 0xfffffffc, 0x7fffffff } ++ [_]u32{0xffffffff} ** 30;
const k_sigaction_funcs = struct {
@@ -4947,7 +4947,7 @@ pub const Sigaction = extern struct {
restorer: ?*const fn () callconv(.C) void = null,
};
-const sigset_len = @typeInfo(sigset_t).Array.len;
+const sigset_len = @typeInfo(sigset_t).array.len;
pub const empty_sigset = [_]u32{0} ** sigset_len;
pub const filled_sigset = [_]u32{(1 << (31 & (usize_bits - 1))) - 1} ++ [_]u32{0} ** (sigset_len - 1);
@@ -7420,7 +7420,7 @@ pub const MADV = struct {
};
pub const POSIX_FADV = switch (native_arch) {
- .s390x => if (@typeInfo(usize).Int.bits == 64) struct {
+ .s390x => if (@typeInfo(usize).int.bits == 64) struct {
pub const NORMAL = 0;
pub const RANDOM = 1;
pub const SEQUENTIAL = 2;
diff --git a/lib/std/os/linux/bpf.zig b/lib/std/os/linux/bpf.zig
index 7661ba9d7c..f35ccf4f1a 100644
--- a/lib/std/os/linux/bpf.zig
+++ b/lib/std/os/linux/bpf.zig
@@ -459,7 +459,7 @@ pub const Insn = packed struct {
};
fn imm_reg(code: u8, dst: Reg, src: anytype, off: i16) Insn {
- const imm_or_reg = if (@TypeOf(src) == Reg or @typeInfo(@TypeOf(src)) == .EnumLiteral)
+ const imm_or_reg = if (@TypeOf(src) == Reg or @typeInfo(@TypeOf(src)) == .enum_literal)
ImmOrReg{ .reg = @as(Reg, src) }
else
ImmOrReg{ .imm = src };
diff --git a/lib/std/os/uefi/protocol/device_path.zig b/lib/std/os/uefi/protocol/device_path.zig
index a08eee193c..b59ebb7be0 100644
--- a/lib/std/os/uefi/protocol/device_path.zig
+++ b/lib/std/os/uefi/protocol/device_path.zig
@@ -76,7 +76,7 @@ pub const DevicePath = extern struct {
}
pub fn getDevicePath(self: *const DevicePath) ?uefi.DevicePath {
- inline for (@typeInfo(uefi.DevicePath).Union.fields) |ufield| {
+ inline for (@typeInfo(uefi.DevicePath).@"union".fields) |ufield| {
const enum_value = std.meta.stringToEnum(uefi.DevicePath.Type, ufield.name);
// Got the associated union type for self.type, now
@@ -94,7 +94,7 @@ pub const DevicePath = extern struct {
}
pub fn initSubtype(self: *const DevicePath, comptime TUnion: type) ?TUnion {
- const type_info = @typeInfo(TUnion).Union;
+ const type_info = @typeInfo(TUnion).@"union";
const TTag = type_info.tag_type.?;
inline for (type_info.fields) |subtype| {
diff --git a/lib/std/os/uefi/status.zig b/lib/std/os/uefi/status.zig
index e975b92a15..79a939e6b9 100644
--- a/lib/std/os/uefi/status.zig
+++ b/lib/std/os/uefi/status.zig
@@ -1,6 +1,6 @@
const testing = @import("std").testing;
-const high_bit = 1 << @typeInfo(usize).Int.bits - 1;
+const high_bit = 1 << @typeInfo(usize).int.bits - 1;
pub const Status = enum(usize) {
/// The operation completed successfully.
@@ -186,7 +186,7 @@ pub const Status = enum(usize) {
};
pub fn err(self: Status) EfiError!void {
- inline for (@typeInfo(EfiError).ErrorSet.?) |efi_err| {
+ inline for (@typeInfo(EfiError).error_set.?) |efi_err| {
if (self == @field(Status, efi_err.name)) {
return @field(EfiError, efi_err.name);
}
diff --git a/lib/std/posix.zig b/lib/std/posix.zig
index fcd923ad9c..9e1631dd20 100644
--- a/lib/std/posix.zig
+++ b/lib/std/posix.zig
@@ -6181,7 +6181,7 @@ pub fn sendfile(
var total_written: usize = 0;
// Prevents EOVERFLOW.
- const size_t = std.meta.Int(.unsigned, @typeInfo(usize).Int.bits - 1);
+ const size_t = std.meta.Int(.unsigned, @typeInfo(usize).int.bits - 1);
const max_count = switch (native_os) {
.linux => 0x7ffff000,
.macos, .ios, .watchos, .tvos, .visionos => maxInt(i32),
@@ -6988,7 +6988,7 @@ pub const PrctlError = error{
} || UnexpectedError;
pub fn prctl(option: PR, args: anytype) PrctlError!u31 {
- if (@typeInfo(@TypeOf(args)) != .Struct)
+ if (@typeInfo(@TypeOf(args)) != .@"struct")
@compileError("Expected tuple or struct argument, found " ++ @typeName(@TypeOf(args)));
if (args.len > 4)
@compileError("prctl takes a maximum of 4 optional arguments");
diff --git a/lib/std/posix/test.zig b/lib/std/posix/test.zig
index 7ba9a7701e..474de28f6d 100644
--- a/lib/std/posix/test.zig
+++ b/lib/std/posix/test.zig
@@ -782,7 +782,7 @@ test "fsync" {
test "getrlimit and setrlimit" {
if (posix.system.rlimit_resource == void) return error.SkipZigTest;
- inline for (@typeInfo(posix.rlimit_resource).Enum.fields) |field| {
+ inline for (@typeInfo(posix.rlimit_resource).@"enum".fields) |field| {
const resource: posix.rlimit_resource = @enumFromInt(field.value);
const limit = try posix.getrlimit(resource);
diff --git a/lib/std/process/Child.zig b/lib/std/process/Child.zig
index dfe0c6578e..2002bad20e 100644
--- a/lib/std/process/Child.zig
+++ b/lib/std/process/Child.zig
@@ -1112,7 +1112,7 @@ fn windowsCreateProcessPathExt(
}
var io_status: windows.IO_STATUS_BLOCK = undefined;
- const num_supported_pathext = @typeInfo(WindowsExtension).Enum.fields.len;
+ const num_supported_pathext = @typeInfo(WindowsExtension).@"enum".fields.len;
var pathext_seen = [_]bool{false} ** num_supported_pathext;
var any_pathext_seen = false;
var unappended_exists = false;
diff --git a/lib/std/segmented_list.zig b/lib/std/segmented_list.zig
index a729c368ed..72397dc1ab 100644
--- a/lib/std/segmented_list.zig
+++ b/lib/std/segmented_list.zig
@@ -99,7 +99,7 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type
pub const prealloc_count = prealloc_item_count;
fn AtType(comptime SelfType: type) type {
- if (@typeInfo(SelfType).Pointer.is_const) {
+ if (@typeInfo(SelfType).pointer.is_const) {
return *const T;
} else {
return *T;
diff --git a/lib/std/simd.zig b/lib/std/simd.zig
index 236b9fbab8..6817c7e082 100644
--- a/lib/std/simd.zig
+++ b/lib/std/simd.zig
@@ -105,8 +105,8 @@ test "suggestVectorLengthForCpu works with signed and unsigned values" {
fn vectorLength(comptime VectorType: type) comptime_int {
return switch (@typeInfo(VectorType)) {
- .Vector => |info| info.len,
- .Array => |info| info.len,
+ .vector => |info| info.len,
+ .array => |info| info.len,
else => @compileError("Invalid type " ++ @typeName(VectorType)),
};
}
@@ -128,8 +128,8 @@ pub inline fn iota(comptime T: type, comptime len: usize) @Vector(len, T) {
var out: [len]T = undefined;
for (&out, 0..) |*element, i| {
element.* = switch (@typeInfo(T)) {
- .Int => @as(T, @intCast(i)),
- .Float => @as(T, @floatFromInt(i)),
+ .int => @as(T, @intCast(i)),
+ .float => @as(T, @floatFromInt(i)),
else => @compileError("Can't use type " ++ @typeName(T) ++ " in iota."),
};
}
@@ -417,18 +417,18 @@ pub fn prefixScan(comptime op: std.builtin.ReduceOp, comptime hop: isize, vec: a
const Child = std.meta.Child(VecType);
const identity = comptime switch (@typeInfo(Child)) {
- .Bool => switch (op) {
+ .bool => switch (op) {
.Or, .Xor => false,
.And => true,
else => @compileError("Invalid prefixScan operation " ++ @tagName(op) ++ " for vector of booleans."),
},
- .Int => switch (op) {
+ .int => switch (op) {
.Max => std.math.minInt(Child),
.Add, .Or, .Xor => 0,
.Mul => 1,
.And, .Min => std.math.maxInt(Child),
},
- .Float => switch (op) {
+ .float => switch (op) {
.Max => -std.math.inf(Child),
.Add => 0,
.Mul => 1,
diff --git a/lib/std/start.zig b/lib/std/start.zig
index 5872e46be7..ea6f347bd6 100644
--- a/lib/std/start.zig
+++ b/lib/std/start.zig
@@ -30,7 +30,7 @@ comptime {
if (simplified_logic) {
if (builtin.output_mode == .Exe) {
if ((builtin.link_libc or builtin.object_format == .c) and @hasDecl(root, "main")) {
- if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) {
+ if (@typeInfo(@TypeOf(root.main)).@"fn".calling_convention != .C) {
@export(&main2, .{ .name = "main" });
}
} else if (builtin.os.tag == .windows) {
@@ -55,7 +55,7 @@ comptime {
if (builtin.link_libc and @hasDecl(root, "main")) {
if (native_arch.isWasm()) {
@export(&mainWithoutEnv, .{ .name = "main" });
- } else if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) {
+ } else if (@typeInfo(@TypeOf(root.main)).@"fn".calling_convention != .C) {
@export(&main, .{ .name = "main" });
}
} else if (native_os == .windows) {
@@ -205,7 +205,7 @@ fn EfiMain(handle: uefi.Handle, system_table: *uefi.tables.SystemTable) callconv
uefi.handle = handle;
uefi.system_table = system_table;
- switch (@typeInfo(@TypeOf(root.main)).Fn.return_type.?) {
+ switch (@typeInfo(@TypeOf(root.main)).@"fn".return_type.?) {
noreturn => {
root.main();
},
@@ -599,7 +599,7 @@ fn mainWithoutEnv(c_argc: c_int, c_argv: [*][*:0]c_char) callconv(.C) c_int {
const bad_main_ret = "expected return type of main to be 'void', '!void', 'noreturn', 'u8', or '!u8'";
pub inline fn callMain() u8 {
- const ReturnType = @typeInfo(@TypeOf(root.main)).Fn.return_type.?;
+ const ReturnType = @typeInfo(@TypeOf(root.main)).@"fn".return_type.?;
switch (ReturnType) {
void => {
@@ -610,7 +610,7 @@ pub inline fn callMain() u8 {
return root.main();
},
else => {
- if (@typeInfo(ReturnType) != .ErrorUnion) @compileError(bad_main_ret);
+ if (@typeInfo(ReturnType) != .error_union) @compileError(bad_main_ret);
const result = root.main() catch |err| {
if (builtin.zig_backend == .stage2_riscv64) {
@@ -635,7 +635,7 @@ pub inline fn callMain() u8 {
pub fn call_wWinMain() std.os.windows.INT {
const peb = std.os.windows.peb();
- const MAIN_HINSTANCE = @typeInfo(@TypeOf(root.wWinMain)).Fn.params[0].type.?;
+ const MAIN_HINSTANCE = @typeInfo(@TypeOf(root.wWinMain)).@"fn".params[0].type.?;
const hInstance = @as(MAIN_HINSTANCE, @ptrCast(peb.ImageBaseAddress));
const lpCmdLine: [*:0]u16 = @ptrCast(peb.ProcessParameters.CommandLine.Buffer);
diff --git a/lib/std/testing.zig b/lib/std/testing.zig
index 80e8ab13bb..35bb13bf0d 100644
--- a/lib/std/testing.zig
+++ b/lib/std/testing.zig
@@ -64,33 +64,33 @@ pub inline fn expectEqual(expected: anytype, actual: anytype) !void {
fn expectEqualInner(comptime T: type, expected: T, actual: T) !void {
switch (@typeInfo(@TypeOf(actual))) {
- .NoReturn,
- .Opaque,
- .Frame,
- .AnyFrame,
+ .noreturn,
+ .@"opaque",
+ .frame,
+ .@"anyframe",
=> @compileError("value of type " ++ @typeName(@TypeOf(actual)) ++ " encountered"),
- .Undefined,
- .Null,
- .Void,
+ .undefined,
+ .null,
+ .void,
=> return,
- .Type => {
+ .type => {
if (actual != expected) {
print("expected type {s}, found type {s}\n", .{ @typeName(expected), @typeName(actual) });
return error.TestExpectedEqual;
}
},
- .Bool,
- .Int,
- .Float,
- .ComptimeFloat,
- .ComptimeInt,
- .EnumLiteral,
- .Enum,
- .Fn,
- .ErrorSet,
+ .bool,
+ .int,
+ .float,
+ .comptime_float,
+ .comptime_int,
+ .enum_literal,
+ .@"enum",
+ .@"fn",
+ .error_set,
=> {
if (actual != expected) {
print("expected {}, found {}\n", .{ expected, actual });
@@ -98,7 +98,7 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void {
}
},
- .Pointer => |pointer| {
+ .pointer => |pointer| {
switch (pointer.size) {
.One, .Many, .C => {
if (actual != expected) {
@@ -119,9 +119,9 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void {
}
},
- .Array => |array| try expectEqualSlices(array.child, &expected, &actual),
+ .array => |array| try expectEqualSlices(array.child, &expected, &actual),
- .Vector => |info| {
+ .vector => |info| {
var i: usize = 0;
while (i < info.len) : (i += 1) {
if (!std.meta.eql(expected[i], actual[i])) {
@@ -133,13 +133,13 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void {
}
},
- .Struct => |structType| {
+ .@"struct" => |structType| {
inline for (structType.fields) |field| {
try expectEqual(@field(expected, field.name), @field(actual, field.name));
}
},
- .Union => |union_info| {
+ .@"union" => |union_info| {
if (union_info.tag_type == null) {
@compileError("Unable to compare untagged union values");
}
@@ -157,7 +157,7 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void {
}
},
- .Optional => {
+ .optional => {
if (expected) |expected_payload| {
if (actual) |actual_payload| {
try expectEqual(expected_payload, actual_payload);
@@ -173,7 +173,7 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void {
}
},
- .ErrorUnion => {
+ .error_union => {
if (expected) |expected_payload| {
if (actual) |actual_payload| {
try expectEqual(expected_payload, actual_payload);
@@ -237,12 +237,12 @@ pub inline fn expectApproxEqAbs(expected: anytype, actual: anytype, tolerance: a
fn expectApproxEqAbsInner(comptime T: type, expected: T, actual: T, tolerance: T) !void {
switch (@typeInfo(T)) {
- .Float => if (!math.approxEqAbs(T, expected, actual, tolerance)) {
+ .float => if (!math.approxEqAbs(T, expected, actual, tolerance)) {
print("actual {}, not within absolute tolerance {} of expected {}\n", .{ actual, tolerance, expected });
return error.TestExpectedApproxEqAbs;
},
- .ComptimeFloat => @compileError("Cannot approximately compare two comptime_float values"),
+ .comptime_float => @compileError("Cannot approximately compare two comptime_float values"),
else => @compileError("Unable to compare non floating point values"),
}
@@ -273,12 +273,12 @@ pub inline fn expectApproxEqRel(expected: anytype, actual: anytype, tolerance: a
fn expectApproxEqRelInner(comptime T: type, expected: T, actual: T, tolerance: T) !void {
switch (@typeInfo(T)) {
- .Float => if (!math.approxEqRel(T, expected, actual, tolerance)) {
+ .float => if (!math.approxEqRel(T, expected, actual, tolerance)) {
print("actual {}, not within relative tolerance {} of expected {}\n", .{ actual, tolerance, expected });
return error.TestExpectedApproxEqRel;
},
- .ComptimeFloat => @compileError("Cannot approximately compare two comptime_float values"),
+ .comptime_float => @compileError("Cannot approximately compare two comptime_float values"),
else => @compileError("Unable to compare non floating point values"),
}
@@ -415,7 +415,7 @@ fn SliceDiffer(comptime T: type) type {
const full_index = self.start_index + i;
const diff = if (i < self.actual.len) !std.meta.eql(self.actual[i], value) else true;
if (diff) try self.ttyconf.setColor(writer, .red);
- if (@typeInfo(T) == .Pointer) {
+ if (@typeInfo(T) == .pointer) {
try writer.print("[{}]{*}: {any}\n", .{ full_index, value, value });
} else {
try writer.print("[{}]: {any}\n", .{ full_index, value });
@@ -505,10 +505,10 @@ pub fn expectEqualSentinel(comptime T: type, comptime sentinel: T, expected: [:s
const expected_value_sentinel = blk: {
switch (@typeInfo(@TypeOf(expected))) {
- .Pointer => {
+ .pointer => {
break :blk expected[expected.len];
},
- .Array => |array_info| {
+ .array => |array_info| {
const indexable_outside_of_bounds = @as([]const array_info.child, &expected);
break :blk indexable_outside_of_bounds[indexable_outside_of_bounds.len];
},
@@ -518,10 +518,10 @@ pub fn expectEqualSentinel(comptime T: type, comptime sentinel: T, expected: [:s
const actual_value_sentinel = blk: {
switch (@typeInfo(@TypeOf(actual))) {
- .Pointer => {
+ .pointer => {
break :blk actual[actual.len];
},
- .Array => |array_info| {
+ .array => |array_info| {
const indexable_outside_of_bounds = @as([]const array_info.child, &actual);
break :blk indexable_outside_of_bounds[indexable_outside_of_bounds.len];
},
@@ -689,33 +689,33 @@ pub inline fn expectEqualDeep(expected: anytype, actual: anytype) error{TestExpe
fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpectedEqual}!void {
switch (@typeInfo(@TypeOf(actual))) {
- .NoReturn,
- .Opaque,
- .Frame,
- .AnyFrame,
+ .noreturn,
+ .@"opaque",
+ .frame,
+ .@"anyframe",
=> @compileError("value of type " ++ @typeName(@TypeOf(actual)) ++ " encountered"),
- .Undefined,
- .Null,
- .Void,
+ .undefined,
+ .null,
+ .void,
=> return,
- .Type => {
+ .type => {
if (actual != expected) {
print("expected type {s}, found type {s}\n", .{ @typeName(expected), @typeName(actual) });
return error.TestExpectedEqual;
}
},
- .Bool,
- .Int,
- .Float,
- .ComptimeFloat,
- .ComptimeInt,
- .EnumLiteral,
- .Enum,
- .Fn,
- .ErrorSet,
+ .bool,
+ .int,
+ .float,
+ .comptime_float,
+ .comptime_int,
+ .enum_literal,
+ .@"enum",
+ .@"fn",
+ .error_set,
=> {
if (actual != expected) {
print("expected {}, found {}\n", .{ expected, actual });
@@ -723,7 +723,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe
}
},
- .Pointer => |pointer| {
+ .pointer => |pointer| {
switch (pointer.size) {
// We have no idea what is behind those pointers, so the best we can do is `==` check.
.C, .Many => {
@@ -735,7 +735,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe
.One => {
// Length of those pointers are runtime value, so the best we can do is `==` check.
switch (@typeInfo(pointer.child)) {
- .Fn, .Opaque => {
+ .@"fn", .@"opaque" => {
if (actual != expected) {
print("expected {*}, found {*}\n", .{ expected, actual });
return error.TestExpectedEqual;
@@ -762,7 +762,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe
}
},
- .Array => |_| {
+ .array => |_| {
if (expected.len != actual.len) {
print("Array len not the same, expected {d}, found {d}\n", .{ expected.len, actual.len });
return error.TestExpectedEqual;
@@ -778,9 +778,9 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe
}
},
- .Vector => |info| {
- if (info.len != @typeInfo(@TypeOf(actual)).Vector.len) {
- print("Vector len not the same, expected {d}, found {d}\n", .{ info.len, @typeInfo(@TypeOf(actual)).Vector.len });
+ .vector => |info| {
+ if (info.len != @typeInfo(@TypeOf(actual)).vector.len) {
+ print("Vector len not the same, expected {d}, found {d}\n", .{ info.len, @typeInfo(@TypeOf(actual)).vector.len });
return error.TestExpectedEqual;
}
var i: usize = 0;
@@ -794,7 +794,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe
}
},
- .Struct => |structType| {
+ .@"struct" => |structType| {
inline for (structType.fields) |field| {
expectEqualDeep(@field(expected, field.name), @field(actual, field.name)) catch |e| {
print("Field {s} incorrect. expected {any}, found {any}\n", .{ field.name, @field(expected, field.name), @field(actual, field.name) });
@@ -803,7 +803,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe
}
},
- .Union => |union_info| {
+ .@"union" => |union_info| {
if (union_info.tag_type == null) {
@compileError("Unable to compare untagged union values");
}
@@ -823,7 +823,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe
}
},
- .Optional => {
+ .optional => {
if (expected) |expected_payload| {
if (actual) |actual_payload| {
try expectEqualDeep(expected_payload, actual_payload);
@@ -839,7 +839,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe
}
},
- .ErrorUnion => {
+ .error_union => {
if (expected) |expected_payload| {
if (actual) |actual_payload| {
try expectEqualDeep(expected_payload, actual_payload);
@@ -1036,20 +1036,20 @@ test {
/// }
/// ```
pub fn checkAllAllocationFailures(backing_allocator: std.mem.Allocator, comptime test_fn: anytype, extra_args: anytype) !void {
- switch (@typeInfo(@typeInfo(@TypeOf(test_fn)).Fn.return_type.?)) {
- .ErrorUnion => |info| {
+ switch (@typeInfo(@typeInfo(@TypeOf(test_fn)).@"fn".return_type.?)) {
+ .error_union => |info| {
if (info.payload != void) {
@compileError("Return type must be !void");
}
},
else => @compileError("Return type must be !void"),
}
- if (@typeInfo(@TypeOf(extra_args)) != .Struct) {
+ if (@typeInfo(@TypeOf(extra_args)) != .@"struct") {
@compileError("Expected tuple or struct argument, found " ++ @typeName(@TypeOf(extra_args)));
}
const ArgsTuple = std.meta.ArgsTuple(@TypeOf(test_fn));
- const fn_args_fields = @typeInfo(ArgsTuple).Struct.fields;
+ const fn_args_fields = @typeInfo(ArgsTuple).@"struct".fields;
if (fn_args_fields.len == 0 or fn_args_fields[0].type != std.mem.Allocator) {
@compileError("The provided function must have an " ++ @typeName(std.mem.Allocator) ++ " as its first argument");
}
@@ -1061,7 +1061,7 @@ pub fn checkAllAllocationFailures(backing_allocator: std.mem.Allocator, comptime
// Setup the tuple that will actually be used with @call (we'll need to insert
// the failing allocator in field @"0" before each @call)
var args: ArgsTuple = undefined;
- inline for (@typeInfo(@TypeOf(extra_args)).Struct.fields, 0..) |field, i| {
+ inline for (@typeInfo(@TypeOf(extra_args)).@"struct".fields, 0..) |field, i| {
const arg_i_str = comptime str: {
var str_buf: [100]u8 = undefined;
const args_i = i + 1;
@@ -1129,7 +1129,7 @@ pub fn refAllDeclsRecursive(comptime T: type) void {
inline for (comptime std.meta.declarations(T)) |decl| {
if (@TypeOf(@field(T, decl.name)) == type) {
switch (@typeInfo(@field(T, decl.name))) {
- .Struct, .Enum, .Union, .Opaque => refAllDeclsRecursive(@field(T, decl.name)),
+ .@"struct", .@"enum", .@"union", .@"opaque" => refAllDeclsRecursive(@field(T, decl.name)),
else => {},
}
}
diff --git a/lib/std/zig.zig b/lib/std/zig.zig
index c11b5319c5..325b7bea90 100644
--- a/lib/std/zig.zig
+++ b/lib/std/zig.zig
@@ -246,7 +246,7 @@ pub const BuildId = union(enum) {
hexstring: HexString,
pub fn eql(a: BuildId, b: BuildId) bool {
- const Tag = @typeInfo(BuildId).Union.tag_type.?;
+ const Tag = @typeInfo(BuildId).@"union".tag_type.?;
const a_tag: Tag = a;
const b_tag: Tag = b;
if (a_tag != b_tag) return false;
@@ -654,7 +654,7 @@ pub fn parseTargetQueryOrReportFatalError(
help: {
var help_text = std.ArrayList(u8).init(allocator);
defer help_text.deinit();
- inline for (@typeInfo(std.Target.ObjectFormat).Enum.fields) |field| {
+ inline for (@typeInfo(std.Target.ObjectFormat).@"enum".fields) |field| {
help_text.writer().print(" {s}\n", .{field.name}) catch break :help;
}
std.log.info("available object formats:\n{s}", .{help_text.items});
diff --git a/lib/std/zig/AstGen.zig b/lib/std/zig/AstGen.zig
index 4e36e3e365..309472f9ea 100644
--- a/lib/std/zig/AstGen.zig
+++ b/lib/std/zig/AstGen.zig
@@ -153,7 +153,7 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir {
try astgen.instructions.ensureTotalCapacity(gpa, tree.nodes.len);
// First few indexes of extra are reserved and set at the end.
- const reserved_count = @typeInfo(Zir.ExtraIndex).Enum.fields.len;
+ const reserved_count = @typeInfo(Zir.ExtraIndex).@"enum".fields.len;
try astgen.extra.ensureTotalCapacity(gpa, tree.nodes.len + reserved_count);
astgen.extra.items.len += reserved_count;
@@ -197,7 +197,7 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir {
astgen.extra.items[err_index] = 0;
} else {
try astgen.extra.ensureUnusedCapacity(gpa, 1 + astgen.compile_errors.items.len *
- @typeInfo(Zir.Inst.CompileErrors.Item).Struct.fields.len);
+ @typeInfo(Zir.Inst.CompileErrors.Item).@"struct".fields.len);
astgen.extra.items[err_index] = astgen.addExtraAssumeCapacity(Zir.Inst.CompileErrors{
.items_len = @intCast(astgen.compile_errors.items.len),
@@ -212,8 +212,8 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir {
if (astgen.imports.count() == 0) {
astgen.extra.items[imports_index] = 0;
} else {
- try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Imports).Struct.fields.len +
- astgen.imports.count() * @typeInfo(Zir.Inst.Imports.Item).Struct.fields.len);
+ try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Imports).@"struct".fields.len +
+ astgen.imports.count() * @typeInfo(Zir.Inst.Imports.Item).@"struct".fields.len);
astgen.extra.items[imports_index] = astgen.addExtraAssumeCapacity(Zir.Inst.Imports{
.imports_len = @intCast(astgen.imports.count()),
@@ -1885,7 +1885,7 @@ fn structInitExprAnon(
const payload_index = try addExtra(astgen, Zir.Inst.StructInitAnon{
.fields_len = @intCast(struct_init.ast.fields.len),
});
- const field_size = @typeInfo(Zir.Inst.StructInitAnon.Item).Struct.fields.len;
+ const field_size = @typeInfo(Zir.Inst.StructInitAnon.Item).@"struct".fields.len;
var extra_index: usize = try reserveExtra(astgen, struct_init.ast.fields.len * field_size);
for (struct_init.ast.fields) |field_init| {
@@ -1916,7 +1916,7 @@ fn structInitExprTyped(
const payload_index = try addExtra(astgen, Zir.Inst.StructInit{
.fields_len = @intCast(struct_init.ast.fields.len),
});
- const field_size = @typeInfo(Zir.Inst.StructInit.Item).Struct.fields.len;
+ const field_size = @typeInfo(Zir.Inst.StructInit.Item).@"struct".fields.len;
var extra_index: usize = try reserveExtra(astgen, struct_init.ast.fields.len * field_size);
for (struct_init.ast.fields) |field_init| {
@@ -2464,7 +2464,7 @@ fn labeledBlockExpr(
};
// We need to call `rvalue` to write through to the pointer only if we had a
// result pointer and aren't forwarding it.
- const LocTag = @typeInfo(ResultInfo.Loc).Union.tag_type.?;
+ const LocTag = @typeInfo(ResultInfo.Loc).@"union".tag_type.?;
const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl);
// Reserve the Block ZIR instruction index so that we can put it into the GenZir struct
@@ -3864,7 +3864,7 @@ fn ptrType(
const gpa = gz.astgen.gpa;
try gz.instructions.ensureUnusedCapacity(gpa, 1);
try gz.astgen.instructions.ensureUnusedCapacity(gpa, 1);
- try gz.astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.PtrType).Struct.fields.len +
+ try gz.astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.PtrType).@"struct".fields.len +
trailing_count);
const payload_index = gz.astgen.addExtraAssumeCapacity(Zir.Inst.PtrType{
@@ -5939,7 +5939,7 @@ fn errorSetDecl(gz: *GenZir, ri: ResultInfo, node: Ast.Node.Index) InnerError!Zi
const main_tokens = tree.nodes.items(.main_token);
const token_tags = tree.tokens.items(.tag);
- const payload_index = try reserveExtra(astgen, @typeInfo(Zir.Inst.ErrorSetDecl).Struct.fields.len);
+ const payload_index = try reserveExtra(astgen, @typeInfo(Zir.Inst.ErrorSetDecl).@"struct".fields.len);
var fields_len: usize = 0;
{
var idents: std.AutoHashMapUnmanaged(Zir.NullTerminatedString, Ast.TokenIndex) = .{};
@@ -6078,7 +6078,7 @@ fn orelseCatchExpr(
};
// We need to call `rvalue` to write through to the pointer only if we had a
// result pointer and aren't forwarding it.
- const LocTag = @typeInfo(ResultInfo.Loc).Union.tag_type.?;
+ const LocTag = @typeInfo(ResultInfo.Loc).@"union".tag_type.?;
const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl);
const do_err_trace = astgen.fn_block != null and (cond_op == .is_non_err or cond_op == .is_non_err_ptr);
@@ -6347,7 +6347,7 @@ fn ifExpr(
};
// We need to call `rvalue` to write through to the pointer only if we had a
// result pointer and aren't forwarding it.
- const LocTag = @typeInfo(ResultInfo.Loc).Union.tag_type.?;
+ const LocTag = @typeInfo(ResultInfo.Loc).@"union".tag_type.?;
const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl);
var block_scope = parent_gz.makeSubBlock(scope);
@@ -6537,7 +6537,7 @@ fn setCondBrPayload(
const else_body_len = astgen.countBodyLenAfterFixups(else_body);
try astgen.extra.ensureUnusedCapacity(
astgen.gpa,
- @typeInfo(Zir.Inst.CondBr).Struct.fields.len + then_body_len + else_body_len,
+ @typeInfo(Zir.Inst.CondBr).@"struct".fields.len + then_body_len + else_body_len,
);
const zir_datas = astgen.instructions.items(.data);
@@ -6573,7 +6573,7 @@ fn whileExpr(
};
// We need to call `rvalue` to write through to the pointer only if we had a
// result pointer and aren't forwarding it.
- const LocTag = @typeInfo(ResultInfo.Loc).Union.tag_type.?;
+ const LocTag = @typeInfo(ResultInfo.Loc).@"union".tag_type.?;
const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl);
if (while_full.label_token) |label_token| {
@@ -6853,7 +6853,7 @@ fn forExpr(
};
// We need to call `rvalue` to write through to the pointer only if we had a
// result pointer and aren't forwarding it.
- const LocTag = @typeInfo(ResultInfo.Loc).Union.tag_type.?;
+ const LocTag = @typeInfo(ResultInfo.Loc).@"union".tag_type.?;
const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl);
const is_inline = for_full.inline_token != null;
@@ -6951,7 +6951,7 @@ fn forExpr(
// nicer error reporting as well as fewer ZIR bytes emitted.
const len: Zir.Inst.Ref = len: {
const lens_len: u32 = @intCast(lens.len);
- try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.MultiOp).Struct.fields.len + lens_len);
+ try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.MultiOp).@"struct".fields.len + lens_len);
const len = try parent_gz.addPlNode(.for_len, node, Zir.Inst.MultiOp{
.operands_len = lens_len,
});
@@ -7188,7 +7188,7 @@ fn switchExprErrUnion(
// We need to call `rvalue` to write through to the pointer only if we had a
// result pointer and aren't forwarding it.
- const LocTag = @typeInfo(ResultInfo.Loc).Union.tag_type.?;
+ const LocTag = @typeInfo(ResultInfo.Loc).@"union".tag_type.?;
const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl);
var scalar_cases_len: u32 = 0;
var multi_cases_len: u32 = 0;
@@ -7622,10 +7622,10 @@ fn switchExprErrUnion(
// Now that the item expressions are generated we can add this.
try parent_gz.instructions.append(gpa, switch_block);
- try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.SwitchBlockErrUnion).Struct.fields.len +
+ try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.SwitchBlockErrUnion).@"struct".fields.len +
@intFromBool(multi_cases_len != 0) +
payloads.items.len - case_table_end +
- (case_table_end - case_table_start) * @typeInfo(Zir.Inst.As).Struct.fields.len);
+ (case_table_end - case_table_start) * @typeInfo(Zir.Inst.As).@"struct".fields.len);
const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.SwitchBlockErrUnion{
.operand = raw_operand,
@@ -7705,7 +7705,7 @@ fn switchExpr(
};
// We need to call `rvalue` to write through to the pointer only if we had a
// result pointer and aren't forwarding it.
- const LocTag = @typeInfo(ResultInfo.Loc).Union.tag_type.?;
+ const LocTag = @typeInfo(ResultInfo.Loc).@"union".tag_type.?;
const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl);
// We perform two passes over the AST. This first pass is to collect information
@@ -8068,11 +8068,11 @@ fn switchExpr(
// Now that the item expressions are generated we can add this.
try parent_gz.instructions.append(gpa, switch_block);
- try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.SwitchBlock).Struct.fields.len +
+ try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.SwitchBlock).@"struct".fields.len +
@intFromBool(multi_cases_len != 0) +
@intFromBool(any_has_tag_capture) +
payloads.items.len - case_table_end +
- (case_table_end - case_table_start) * @typeInfo(Zir.Inst.As).Struct.fields.len);
+ (case_table_end - case_table_start) * @typeInfo(Zir.Inst.As).@"struct".fields.len);
const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.SwitchBlock{
.operand = raw_operand,
@@ -8971,7 +8971,7 @@ fn ptrCast(
const node_datas = tree.nodes.items(.data);
const node_tags = tree.nodes.items(.tag);
- const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).Struct.backing_integer.?;
+ const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).@"struct".backing_integer.?;
var flags: Zir.Inst.FullPtrCastFlags = .{};
// Note that all pointer cast builtins have one parameter, so we only need
@@ -12080,7 +12080,7 @@ const GenZir = struct {
const body_len = astgen.countBodyLenAfterFixups(body);
try astgen.extra.ensureUnusedCapacity(
gpa,
- @typeInfo(Zir.Inst.BoolBr).Struct.fields.len + body_len,
+ @typeInfo(Zir.Inst.BoolBr).@"struct".fields.len + body_len,
);
const zir_datas = astgen.instructions.items(.data);
zir_datas[@intFromEnum(bool_br)].pl_node.payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.BoolBr{
@@ -12099,7 +12099,7 @@ const GenZir = struct {
const body_len = astgen.countBodyLenAfterFixups(body);
try astgen.extra.ensureUnusedCapacity(
gpa,
- @typeInfo(Zir.Inst.Block).Struct.fields.len + body_len,
+ @typeInfo(Zir.Inst.Block).@"struct".fields.len + body_len,
);
const zir_datas = astgen.instructions.items(.data);
zir_datas[@intFromEnum(inst)].pl_node.payload_index = astgen.addExtraAssumeCapacity(
@@ -12117,7 +12117,7 @@ const GenZir = struct {
const body_len = astgen.countBodyLenAfterFixups(body);
try astgen.extra.ensureUnusedCapacity(
gpa,
- @typeInfo(Zir.Inst.Try).Struct.fields.len + body_len,
+ @typeInfo(Zir.Inst.Try).@"struct".fields.len + body_len,
);
const zir_datas = astgen.instructions.items(.data);
zir_datas[@intFromEnum(inst)].pl_node.payload_index = astgen.addExtraAssumeCapacity(
@@ -12235,7 +12235,7 @@ const GenZir = struct {
try astgen.extra.ensureUnusedCapacity(
gpa,
- @typeInfo(Zir.Inst.FuncFancy).Struct.fields.len +
+ @typeInfo(Zir.Inst.FuncFancy).@"struct".fields.len +
fancyFnExprExtraLen(astgen, align_body, args.align_ref) +
fancyFnExprExtraLen(astgen, addrspace_body, args.addrspace_ref) +
fancyFnExprExtraLen(astgen, section_body, args.section_ref) +
@@ -12354,7 +12354,7 @@ const GenZir = struct {
} else {
try astgen.extra.ensureUnusedCapacity(
gpa,
- @typeInfo(Zir.Inst.Func).Struct.fields.len + 1 +
+ @typeInfo(Zir.Inst.Func).@"struct".fields.len + 1 +
fancyFnExprExtraLen(astgen, ret_body, ret_ref) +
body_len + src_locs_and_hash.len,
);
@@ -12428,7 +12428,7 @@ const GenZir = struct {
try astgen.extra.ensureUnusedCapacity(
gpa,
- @typeInfo(Zir.Inst.ExtendedVar).Struct.fields.len +
+ @typeInfo(Zir.Inst.ExtendedVar).@"struct".fields.len +
@intFromBool(args.lib_name != .empty) +
@intFromBool(args.align_inst != .none) +
@intFromBool(args.init != .none),
@@ -12590,7 +12590,7 @@ const GenZir = struct {
const param_body = param_gz.instructionsSlice();
const body_len = gz.astgen.countBodyLenAfterFixups(param_body);
try gz.astgen.instructions.ensureUnusedCapacity(gpa, 1);
- try gz.astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Param).Struct.fields.len + body_len);
+ try gz.astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Param).@"struct".fields.len + body_len);
const doc_comment_index = if (first_doc_comment) |first|
try gz.astgen.docCommentAsStringFromFirst(abs_tok_index, first)
@@ -12663,7 +12663,7 @@ const GenZir = struct {
try astgen.instructions.ensureUnusedCapacity(gpa, 1);
try astgen.extra.ensureUnusedCapacity(
gpa,
- @typeInfo(Zir.Inst.NodeMultiOp).Struct.fields.len + operands.len,
+ @typeInfo(Zir.Inst.NodeMultiOp).@"struct".fields.len + operands.len,
);
const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.NodeMultiOp{
@@ -12904,7 +12904,7 @@ const GenZir = struct {
) !Zir.Inst.Index {
const gpa = gz.astgen.gpa;
try gz.astgen.instructions.ensureUnusedCapacity(gpa, 1);
- try gz.astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Break).Struct.fields.len);
+ try gz.astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Break).@"struct".fields.len);
const new_index: Zir.Inst.Index = @enumFromInt(gz.astgen.instructions.len);
gz.astgen.instructions.appendAssumeCapacity(.{
@@ -13027,7 +13027,7 @@ const GenZir = struct {
try astgen.instructions.ensureUnusedCapacity(gpa, 1);
try astgen.extra.ensureUnusedCapacity(
gpa,
- @typeInfo(Zir.Inst.AllocExtended).Struct.fields.len +
+ @typeInfo(Zir.Inst.AllocExtended).@"struct".fields.len +
@intFromBool(args.type_inst != .none) +
@intFromBool(args.align_inst != .none),
);
@@ -13079,9 +13079,9 @@ const GenZir = struct {
try gz.instructions.ensureUnusedCapacity(gpa, 1);
try astgen.instructions.ensureUnusedCapacity(gpa, 1);
- try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Asm).Struct.fields.len +
- args.outputs.len * @typeInfo(Zir.Inst.Asm.Output).Struct.fields.len +
- args.inputs.len * @typeInfo(Zir.Inst.Asm.Input).Struct.fields.len +
+ try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Asm).@"struct".fields.len +
+ args.outputs.len * @typeInfo(Zir.Inst.Asm.Output).@"struct".fields.len +
+ args.inputs.len * @typeInfo(Zir.Inst.Asm.Input).@"struct".fields.len +
args.clobbers.len);
const payload_index = gz.astgen.addExtraAssumeCapacity(Zir.Inst.Asm{
@@ -13190,7 +13190,7 @@ const GenZir = struct {
const fields_hash_arr: [4]u32 = @bitCast(args.fields_hash);
- try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.StructDecl).Struct.fields.len + 3);
+ try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.StructDecl).@"struct".fields.len + 3);
const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.StructDecl{
.fields_hash_0 = fields_hash_arr[0],
.fields_hash_1 = fields_hash_arr[1],
@@ -13251,7 +13251,7 @@ const GenZir = struct {
const fields_hash_arr: [4]u32 = @bitCast(args.fields_hash);
- try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.UnionDecl).Struct.fields.len + 5);
+ try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.UnionDecl).@"struct".fields.len + 5);
const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.UnionDecl{
.fields_hash_0 = fields_hash_arr[0],
.fields_hash_1 = fields_hash_arr[1],
@@ -13313,7 +13313,7 @@ const GenZir = struct {
const fields_hash_arr: [4]u32 = @bitCast(args.fields_hash);
- try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.EnumDecl).Struct.fields.len + 5);
+ try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.EnumDecl).@"struct".fields.len + 5);
const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.EnumDecl{
.fields_hash_0 = fields_hash_arr[0],
.fields_hash_1 = fields_hash_arr[1],
@@ -13366,7 +13366,7 @@ const GenZir = struct {
assert(args.src_node != 0);
- try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.OpaqueDecl).Struct.fields.len + 2);
+ try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.OpaqueDecl).@"struct".fields.len + 2);
const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.OpaqueDecl{
.src_line = astgen.source_line,
.src_node = args.src_node,
diff --git a/lib/std/zig/ErrorBundle.zig b/lib/std/zig/ErrorBundle.zig
index 2d69ff901d..63e0748d8d 100644
--- a/lib/std/zig/ErrorBundle.zig
+++ b/lib/std/zig/ErrorBundle.zig
@@ -108,7 +108,7 @@ pub fn getSourceLocation(eb: ErrorBundle, index: SourceLocationIndex) SourceLoca
pub fn getNotes(eb: ErrorBundle, index: MessageIndex) []const MessageIndex {
const notes_len = eb.getErrorMessage(index).notes_len;
- const start = @intFromEnum(index) + @typeInfo(ErrorMessage).Struct.fields.len;
+ const start = @intFromEnum(index) + @typeInfo(ErrorMessage).@"struct".fields.len;
return @as([]const MessageIndex, @ptrCast(eb.extra[start..][0..notes_len]));
}
@@ -119,7 +119,7 @@ pub fn getCompileLogOutput(eb: ErrorBundle) [:0]const u8 {
/// Returns the requested data, as well as the new index which is at the start of the
/// trailers for the object.
fn extraData(eb: ErrorBundle, comptime T: type, index: usize) struct { data: T, end: usize } {
- const fields = @typeInfo(T).Struct.fields;
+ const fields = @typeInfo(T).@"struct".fields;
var i: usize = index;
var result: T = undefined;
inline for (fields) |field| {
@@ -456,7 +456,7 @@ pub const Wip = struct {
pub fn reserveNotes(wip: *Wip, notes_len: u32) !u32 {
try wip.extra.ensureUnusedCapacity(wip.gpa, notes_len +
- notes_len * @typeInfo(ErrorBundle.ErrorMessage).Struct.fields.len);
+ notes_len * @typeInfo(ErrorBundle.ErrorMessage).@"struct".fields.len);
wip.extra.items.len += notes_len;
return @intCast(wip.extra.items.len - notes_len);
}
@@ -616,13 +616,13 @@ pub const Wip = struct {
fn addExtra(wip: *Wip, extra: anytype) Allocator.Error!u32 {
const gpa = wip.gpa;
- const fields = @typeInfo(@TypeOf(extra)).Struct.fields;
+ const fields = @typeInfo(@TypeOf(extra)).@"struct".fields;
try wip.extra.ensureUnusedCapacity(gpa, fields.len);
return addExtraAssumeCapacity(wip, extra);
}
fn addExtraAssumeCapacity(wip: *Wip, extra: anytype) u32 {
- const fields = @typeInfo(@TypeOf(extra)).Struct.fields;
+ const fields = @typeInfo(@TypeOf(extra)).@"struct".fields;
const result: u32 = @intCast(wip.extra.items.len);
wip.extra.items.len += fields.len;
setExtra(wip, result, extra);
@@ -630,7 +630,7 @@ pub const Wip = struct {
}
fn setExtra(wip: *Wip, index: usize, extra: anytype) void {
- const fields = @typeInfo(@TypeOf(extra)).Struct.fields;
+ const fields = @typeInfo(@TypeOf(extra)).@"struct".fields;
var i = index;
inline for (fields) |field| {
wip.extra.items[i] = switch (field.type) {
diff --git a/lib/std/zig/Server.zig b/lib/std/zig/Server.zig
index 0ed9cfcd0b..6400c30965 100644
--- a/lib/std/zig/Server.zig
+++ b/lib/std/zig/Server.zig
@@ -282,9 +282,9 @@ fn bswap(x: anytype) @TypeOf(x) {
const T = @TypeOf(x);
switch (@typeInfo(T)) {
- .Enum => return @as(T, @enumFromInt(@byteSwap(@intFromEnum(x)))),
- .Int => return @byteSwap(x),
- .Struct => |info| switch (info.layout) {
+ .@"enum" => return @as(T, @enumFromInt(@byteSwap(@intFromEnum(x)))),
+ .int => return @byteSwap(x),
+ .@"struct" => |info| switch (info.layout) {
.@"extern" => {
var result: T = undefined;
inline for (info.fields) |field| {
diff --git a/lib/std/zig/Zir.zig b/lib/std/zig/Zir.zig
index 02eb38f9c4..af4ddaad6a 100644
--- a/lib/std/zig/Zir.zig
+++ b/lib/std/zig/Zir.zig
@@ -68,7 +68,7 @@ fn ExtraData(comptime T: type) type {
/// Returns the requested data, as well as the new index which is at the start of the
/// trailers for the object.
pub fn extraData(code: Zir, comptime T: type, index: usize) ExtraData(T) {
- const fields = @typeInfo(T).Struct.fields;
+ const fields = @typeInfo(T).@"struct".fields;
var i: usize = index;
var result: T = undefined;
inline for (fields) |field| {
@@ -1823,7 +1823,7 @@ pub const Inst = struct {
// Uncomment to view how many tag slots are available.
//comptime {
- // @compileLog("ZIR tags left: ", 256 - @typeInfo(Tag).Enum.fields.len);
+ // @compileLog("ZIR tags left: ", 256 - @typeInfo(Tag).@"enum".fields.len);
//}
};
@@ -3551,7 +3551,7 @@ pub fn declIterator(zir: Zir, decl_inst: Zir.Inst.Index) DeclIterator {
},
.struct_decl => {
const small: Inst.StructDecl.Small = @bitCast(extended.small);
- var extra_index: u32 = @intCast(extended.operand + @typeInfo(Inst.StructDecl).Struct.fields.len);
+ var extra_index: u32 = @intCast(extended.operand + @typeInfo(Inst.StructDecl).@"struct".fields.len);
const captures_len = if (small.has_captures_len) captures_len: {
const captures_len = zir.extra[extra_index];
extra_index += 1;
@@ -3584,7 +3584,7 @@ pub fn declIterator(zir: Zir, decl_inst: Zir.Inst.Index) DeclIterator {
},
.enum_decl => {
const small: Inst.EnumDecl.Small = @bitCast(extended.small);
- var extra_index: u32 = @intCast(extended.operand + @typeInfo(Inst.EnumDecl).Struct.fields.len);
+ var extra_index: u32 = @intCast(extended.operand + @typeInfo(Inst.EnumDecl).@"struct".fields.len);
extra_index += @intFromBool(small.has_tag_type);
const captures_len = if (small.has_captures_len) captures_len: {
const captures_len = zir.extra[extra_index];
@@ -3609,7 +3609,7 @@ pub fn declIterator(zir: Zir, decl_inst: Zir.Inst.Index) DeclIterator {
},
.union_decl => {
const small: Inst.UnionDecl.Small = @bitCast(extended.small);
- var extra_index: u32 = @intCast(extended.operand + @typeInfo(Inst.UnionDecl).Struct.fields.len);
+ var extra_index: u32 = @intCast(extended.operand + @typeInfo(Inst.UnionDecl).@"struct".fields.len);
extra_index += @intFromBool(small.has_tag_type);
const captures_len = if (small.has_captures_len) captures_len: {
const captures_len = zir.extra[extra_index];
@@ -3634,7 +3634,7 @@ pub fn declIterator(zir: Zir, decl_inst: Zir.Inst.Index) DeclIterator {
},
.opaque_decl => {
const small: Inst.OpaqueDecl.Small = @bitCast(extended.small);
- var extra_index: u32 = @intCast(extended.operand + @typeInfo(Inst.OpaqueDecl).Struct.fields.len);
+ var extra_index: u32 = @intCast(extended.operand + @typeInfo(Inst.OpaqueDecl).@"struct".fields.len);
const decls_len = if (small.has_decls_len) decls_len: {
const decls_len = zir.extra[extra_index];
extra_index += 1;
@@ -4607,7 +4607,7 @@ pub fn getAssociatedSrcHash(zir: Zir, inst: Zir.Inst.Index) ?std.zig.SrcHash {
const extra_index = extra.end +
extra.data.ret_body_len +
extra.data.body_len +
- @typeInfo(Inst.Func.SrcLocs).Struct.fields.len;
+ @typeInfo(Inst.Func.SrcLocs).@"struct".fields.len;
return @bitCast([4]u32{
zir.extra[extra_index + 0],
zir.extra[extra_index + 1],
@@ -4647,7 +4647,7 @@ pub fn getAssociatedSrcHash(zir: Zir, inst: Zir.Inst.Index) ?std.zig.SrcHash {
} else extra_index += @intFromBool(bits.has_ret_ty_ref);
extra_index += @intFromBool(bits.has_any_noalias);
extra_index += extra.data.body_len;
- extra_index += @typeInfo(Zir.Inst.Func.SrcLocs).Struct.fields.len;
+ extra_index += @typeInfo(Zir.Inst.Func.SrcLocs).@"struct".fields.len;
return @bitCast([4]u32{
zir.extra[extra_index + 0],
zir.extra[extra_index + 1],
diff --git a/lib/std/zig/c_translation.zig b/lib/std/zig/c_translation.zig
index 504f134b41..39f7fa9a11 100644
--- a/lib/std/zig/c_translation.zig
+++ b/lib/std/zig/c_translation.zig
@@ -9,60 +9,60 @@ pub fn cast(comptime DestType: type, target: anytype) DestType {
// this function should behave like transCCast in translate-c, except it's for macros
const SourceType = @TypeOf(target);
switch (@typeInfo(DestType)) {
- .Fn => return castToPtr(*const DestType, SourceType, target),
- .Pointer => return castToPtr(DestType, SourceType, target),
- .Optional => |dest_opt| {
- if (@typeInfo(dest_opt.child) == .Pointer) {
+ .@"fn" => return castToPtr(*const DestType, SourceType, target),
+ .pointer => return castToPtr(DestType, SourceType, target),
+ .optional => |dest_opt| {
+ if (@typeInfo(dest_opt.child) == .pointer) {
return castToPtr(DestType, SourceType, target);
- } else if (@typeInfo(dest_opt.child) == .Fn) {
+ } else if (@typeInfo(dest_opt.child) == .@"fn") {
return castToPtr(?*const dest_opt.child, SourceType, target);
}
},
- .Int => {
+ .int => {
switch (@typeInfo(SourceType)) {
- .Pointer => {
+ .pointer => {
return castInt(DestType, @intFromPtr(target));
},
- .Optional => |opt| {
- if (@typeInfo(opt.child) == .Pointer) {
+ .optional => |opt| {
+ if (@typeInfo(opt.child) == .pointer) {
return castInt(DestType, @intFromPtr(target));
}
},
- .Int => {
+ .int => {
return castInt(DestType, target);
},
- .Fn => {
+ .@"fn" => {
return castInt(DestType, @intFromPtr(&target));
},
- .Bool => {
+ .bool => {
return @intFromBool(target);
},
else => {},
}
},
- .Float => {
+ .float => {
switch (@typeInfo(SourceType)) {
- .Int => return @as(DestType, @floatFromInt(target)),
- .Float => return @as(DestType, @floatCast(target)),
- .Bool => return @as(DestType, @floatFromInt(@intFromBool(target))),
+ .int => return @as(DestType, @floatFromInt(target)),
+ .float => return @as(DestType, @floatCast(target)),
+ .bool => return @as(DestType, @floatFromInt(@intFromBool(target))),
else => {},
}
},
- .Union => |info| {
+ .@"union" => |info| {
inline for (info.fields) |field| {
if (field.type == SourceType) return @unionInit(DestType, field.name, target);
}
@compileError("cast to union type '" ++ @typeName(DestType) ++ "' from type '" ++ @typeName(SourceType) ++ "' which is not present in union");
},
- .Bool => return cast(usize, target) != 0,
+ .bool => return cast(usize, target) != 0,
else => {},
}
return @as(DestType, target);
}
fn castInt(comptime DestType: type, target: anytype) DestType {
- const dest = @typeInfo(DestType).Int;
- const source = @typeInfo(@TypeOf(target)).Int;
+ const dest = @typeInfo(DestType).int;
+ const source = @typeInfo(@TypeOf(target)).int;
if (dest.bits < source.bits)
return @as(DestType, @bitCast(@as(std.meta.Int(source.signedness, dest.bits), @truncate(target))))
@@ -76,20 +76,20 @@ fn castPtr(comptime DestType: type, target: anytype) DestType {
fn castToPtr(comptime DestType: type, comptime SourceType: type, target: anytype) DestType {
switch (@typeInfo(SourceType)) {
- .Int => {
+ .int => {
return @as(DestType, @ptrFromInt(castInt(usize, target)));
},
- .ComptimeInt => {
+ .comptime_int => {
if (target < 0)
return @as(DestType, @ptrFromInt(@as(usize, @bitCast(@as(isize, @intCast(target))))))
else
return @as(DestType, @ptrFromInt(@as(usize, @intCast(target))));
},
- .Pointer => {
+ .pointer => {
return castPtr(DestType, target);
},
- .Optional => |target_opt| {
- if (@typeInfo(target_opt.child) == .Pointer) {
+ .optional => |target_opt| {
+ if (@typeInfo(target_opt.child) == .pointer) {
return castPtr(DestType, target);
}
},
@@ -100,8 +100,8 @@ fn castToPtr(comptime DestType: type, comptime SourceType: type, target: anytype
fn ptrInfo(comptime PtrType: type) std.builtin.Type.Pointer {
return switch (@typeInfo(PtrType)) {
- .Optional => |opt_info| @typeInfo(opt_info.child).Pointer,
- .Pointer => |ptr_info| ptr_info,
+ .optional => |opt_info| @typeInfo(opt_info.child).pointer,
+ .pointer => |ptr_info| ptr_info,
else => unreachable,
};
}
@@ -144,17 +144,17 @@ test "cast" {
pub fn sizeof(target: anytype) usize {
const T: type = if (@TypeOf(target) == type) target else @TypeOf(target);
switch (@typeInfo(T)) {
- .Float, .Int, .Struct, .Union, .Array, .Bool, .Vector => return @sizeOf(T),
- .Fn => {
+ .float, .int, .@"struct", .@"union", .array, .bool, .vector => return @sizeOf(T),
+ .@"fn" => {
// sizeof(main) in C returns 1
return 1;
},
- .Null => return @sizeOf(*anyopaque),
- .Void => {
+ .null => return @sizeOf(*anyopaque),
+ .void => {
// Note: sizeof(void) is 1 on clang/gcc and 0 on MSVC.
return 1;
},
- .Opaque => {
+ .@"opaque" => {
if (T == anyopaque) {
// Note: sizeof(void) is 1 on clang/gcc and 0 on MSVC.
return 1;
@@ -162,24 +162,24 @@ pub fn sizeof(target: anytype) usize {
@compileError("Cannot use C sizeof on opaque type " ++ @typeName(T));
}
},
- .Optional => |opt| {
- if (@typeInfo(opt.child) == .Pointer) {
+ .optional => |opt| {
+ if (@typeInfo(opt.child) == .pointer) {
return sizeof(opt.child);
} else {
@compileError("Cannot use C sizeof on non-pointer optional " ++ @typeName(T));
}
},
- .Pointer => |ptr| {
+ .pointer => |ptr| {
if (ptr.size == .Slice) {
@compileError("Cannot use C sizeof on slice type " ++ @typeName(T));
}
// for strings, sizeof("a") returns 2.
// normal pointer decay scenarios from C are handled
- // in the .Array case above, but strings remain literals
+ // in the .array case above, but strings remain literals
// and are therefore always pointers, so they need to be
// specially handled here.
- if (ptr.size == .One and ptr.is_const and @typeInfo(ptr.child) == .Array) {
- const array_info = @typeInfo(ptr.child).Array;
+ if (ptr.size == .One and ptr.is_const and @typeInfo(ptr.child) == .array) {
+ const array_info = @typeInfo(ptr.child).array;
if ((array_info.child == u8 or array_info.child == u16) and
array_info.sentinel != null and
@as(*align(1) const array_info.child, @ptrCast(array_info.sentinel.?)).* == 0)
@@ -195,8 +195,8 @@ pub fn sizeof(target: anytype) usize {
}
return @sizeOf(T);
},
- .ComptimeFloat => return @sizeOf(f64), // TODO c_double #3999
- .ComptimeInt => {
+ .comptime_float => return @sizeOf(f64), // TODO c_double #3999
+ .comptime_int => {
// TODO to get the correct result we have to translate
// `1073741824 * 4` as `int(1073741824) *% int(4)` since
// sizeof(1073741824 * 4) != sizeof(4294967296).
@@ -262,7 +262,7 @@ fn PromoteIntLiteralReturnType(comptime SuffixType: type, comptime number: compt
const signed_oct_hex = [_]type{ c_int, c_uint, c_long, c_ulong, c_longlong, c_ulonglong };
const unsigned = [_]type{ c_uint, c_ulong, c_ulonglong };
- const list: []const type = if (@typeInfo(SuffixType).Int.signedness == .unsigned)
+ const list: []const type = if (@typeInfo(SuffixType).int.signedness == .unsigned)
&unsigned
else if (base == .decimal)
&signed_decimal
@@ -339,8 +339,8 @@ test "shuffleVectorIndex" {
/// from SelfType for pointing to a C flexible array of ElementType.
pub fn FlexibleArrayType(comptime SelfType: type, comptime ElementType: type) type {
switch (@typeInfo(SelfType)) {
- .Pointer => |ptr| {
- return @Type(.{ .Pointer = .{
+ .pointer => |ptr| {
+ return @Type(.{ .pointer = .{
.size = .C,
.is_const = ptr.is_const,
.is_volatile = ptr.is_volatile,
@@ -372,7 +372,7 @@ test "Flexible Array Type" {
/// the type and denominator is -1. C has undefined behavior for those two cases; this function has safety
/// checked undefined behavior
pub fn signedRemainder(numerator: anytype, denominator: anytype) @TypeOf(numerator, denominator) {
- std.debug.assert(@typeInfo(@TypeOf(numerator, denominator)).Int.signedness == .signed);
+ std.debug.assert(@typeInfo(@TypeOf(numerator, denominator)).int.signedness == .signed);
if (denominator > 0) return @rem(numerator, denominator);
return numerator - @divTrunc(numerator, denominator) * denominator;
}
@@ -384,15 +384,15 @@ pub const Macros = struct {
fn L_SUFFIX_ReturnType(comptime number: anytype) type {
switch (@typeInfo(@TypeOf(number))) {
- .Int, .ComptimeInt => return @TypeOf(promoteIntLiteral(c_long, number, .decimal)),
- .Float, .ComptimeFloat => return c_longdouble,
+ .int, .comptime_int => return @TypeOf(promoteIntLiteral(c_long, number, .decimal)),
+ .float, .comptime_float => return c_longdouble,
else => @compileError("Invalid value for L suffix"),
}
}
pub fn L_SUFFIX(comptime number: anytype) L_SUFFIX_ReturnType(number) {
switch (@typeInfo(@TypeOf(number))) {
- .Int, .ComptimeInt => return promoteIntLiteral(c_long, number, .decimal),
- .Float, .ComptimeFloat => @compileError("TODO: c_longdouble initialization from comptime_float not supported"),
+ .int, .comptime_int => return promoteIntLiteral(c_long, number, .decimal),
+ .float, .comptime_float => @compileError("TODO: c_longdouble initialization from comptime_float not supported"),
else => @compileError("Invalid value for L suffix"),
}
}
@@ -420,13 +420,13 @@ pub const Macros = struct {
/// A 2-argument function-like macro defined as #define FOO(A, B) (A)(B)
/// could be either: cast B to A, or call A with the value B.
pub fn CAST_OR_CALL(a: anytype, b: anytype) switch (@typeInfo(@TypeOf(a))) {
- .Type => a,
- .Fn => |fn_info| fn_info.return_type orelse void,
+ .type => a,
+ .@"fn" => |fn_info| fn_info.return_type orelse void,
else => |info| @compileError("Unexpected argument type: " ++ @tagName(info)),
} {
switch (@typeInfo(@TypeOf(a))) {
- .Type => return cast(a, b),
- .Fn => return a(b),
+ .type => return cast(a, b),
+ .@"fn" => return a(b),
else => unreachable, // return type will be a compile error otherwise
}
}
@@ -444,7 +444,7 @@ fn PromotedIntType(comptime T: type) type {
c_int, c_uint, c_long, c_ulong, c_longlong, c_ulonglong => T,
else => if (T == comptime_int) {
@compileError("Cannot promote `" ++ @typeName(T) ++ "`; a fixed-size number type is required");
- } else if (@typeInfo(T) == .Int) {
+ } else if (@typeInfo(T) == .int) {
@compileError("Cannot promote `" ++ @typeName(T) ++ "`; a C ABI type is required");
} else {
@compileError("Attempted to promote invalid type `" ++ @typeName(T) ++ "`");
@@ -490,8 +490,8 @@ fn ArithmeticConversion(comptime A: type, comptime B: type) type {
if (A_Promoted == B_Promoted) return A_Promoted;
- const a_signed = @typeInfo(A_Promoted).Int.signedness == .signed;
- const b_signed = @typeInfo(B_Promoted).Int.signedness == .signed;
+ const a_signed = @typeInfo(A_Promoted).int.signedness == .signed;
+ const b_signed = @typeInfo(B_Promoted).int.signedness == .signed;
if (a_signed == b_signed) {
return if (integerRank(A_Promoted) > integerRank(B_Promoted)) A_Promoted else B_Promoted;
@@ -544,8 +544,8 @@ pub const MacroArithmetic = struct {
const a_casted = cast(ResType, a);
const b_casted = cast(ResType, b);
switch (@typeInfo(ResType)) {
- .Float => return a_casted / b_casted,
- .Int => return @divTrunc(a_casted, b_casted),
+ .float => return a_casted / b_casted,
+ .int => return @divTrunc(a_casted, b_casted),
else => unreachable,
}
}
@@ -555,8 +555,8 @@ pub const MacroArithmetic = struct {
const a_casted = cast(ResType, a);
const b_casted = cast(ResType, b);
switch (@typeInfo(ResType)) {
- .Int => {
- if (@typeInfo(ResType).Int.signedness == .signed) {
+ .int => {
+ if (@typeInfo(ResType).int.signedness == .signed) {
return signedRemainder(a_casted, b_casted);
} else {
return a_casted % b_casted;
diff --git a/lib/std/zig/parser_test.zig b/lib/std/zig/parser_test.zig
index 530aa924d0..d399c58c9c 100644
--- a/lib/std/zig/parser_test.zig
+++ b/lib/std/zig/parser_test.zig
@@ -2548,7 +2548,7 @@ test "zig fmt: same-line comment after non-block if expression" {
test "zig fmt: same-line comment on comptime expression" {
try testCanonical(
\\test "" {
- \\ comptime assert(@typeInfo(T) == .Int); // must pass an integer to absInt
+ \\ comptime assert(@typeInfo(T) == .int); // must pass an integer to absInt
\\}
\\
);
diff --git a/lib/std/zig/system/windows.zig b/lib/std/zig/system/windows.zig
index 4c8e911a9f..43d407c3a0 100644
--- a/lib/std/zig/system/windows.zig
+++ b/lib/std/zig/system/windows.zig
@@ -56,11 +56,11 @@ fn getCpuInfoFromRegistry(core: usize, args: anytype) !void {
const ArgsType = @TypeOf(args);
const args_type_info = @typeInfo(ArgsType);
- if (args_type_info != .Struct) {
+ if (args_type_info != .@"struct") {
@compileError("expected tuple or struct argument, found " ++ @typeName(ArgsType));
}
- const fields_info = args_type_info.Struct.fields;
+ const fields_info = args_type_info.@"struct".fields;
// Originally, I wanted to issue a single call with a more complex table structure such that we
// would sequentially visit each CPU#d subkey in the registry and pull the value of interest into