diff --git a/doc/langref.html.in b/doc/langref.html.in index 4ac9cf47e0..e244d69e25 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -550,7 +550,7 @@ pub fn main() void { {#syntax#}i7{#endsyntax#} refers to a signed 7-bit integer. The maximum allowed bit-width of an integer type is {#syntax#}65535{#endsyntax#}.
- {#see_also|Integers|Floats|void|Errors|@IntType#} + {#see_also|Integers|Floats|void|Errors|@Type#} {#header_close#} {#header_open|Primitive Values#}@@ -6671,18 +6667,6 @@ comptime {
{#see_also|Alignment#} {#header_close#} - {#header_open|@ArgType#} -{#syntax#}@ArgType(comptime T: type, comptime n: usize) type{#endsyntax#}
- - This builtin function takes a function type and returns the type of the parameter at index {#syntax#}n{#endsyntax#}. -
-- {#syntax#}T{#endsyntax#} must be a function type. -
-- Note: This function is deprecated. Use {#link|@typeInfo#} instead. -
- {#header_close#} {#header_open|@as#}{#syntax#}@as(comptime T: type, expression) T{#endsyntax#}
@@ -6816,7 +6800,7 @@ async fn func(y: *i32) void {
Asserts that {#syntax#}@sizeOf(@TypeOf(value)) == @sizeOf(DestType){#endsyntax#}.
- Asserts that {#syntax#}@typeId(DestType) != @import("builtin").TypeId.Pointer{#endsyntax#}. Use {#syntax#}@ptrCast{#endsyntax#} or {#syntax#}@intToPtr{#endsyntax#} if you need this. + Asserts that {#syntax#}@typeInfo(DestType) != .Pointer{#endsyntax#}. Use {#syntax#}@ptrCast{#endsyntax#} or {#syntax#}@intToPtr{#endsyntax#} if you need this.
Can be used for these things for example: @@ -7269,7 +7253,7 @@ test "main" {
Floored division. Rounds toward negative infinity. For unsigned integers it is the same as {#syntax#}numerator / denominator{#endsyntax#}. Caller guarantees {#syntax#}denominator != 0{#endsyntax#} and - {#syntax#}!(@typeId(T) == builtin.TypeId.Int and T.is_signed and numerator == std.math.minInt(T) and denominator == -1){#endsyntax#}. + {#syntax#}!(@typeInfo(T) == .Int and T.is_signed and numerator == std.math.minInt(T) and denominator == -1){#endsyntax#}.
Truncated division. Rounds toward zero. For unsigned integers it is the same as {#syntax#}numerator / denominator{#endsyntax#}. Caller guarantees {#syntax#}denominator != 0{#endsyntax#} and - {#syntax#}!(@typeId(T) == builtin.TypeId.Int and T.is_signed and numerator == std.math.minInt(T) and denominator == -1){#endsyntax#}. + {#syntax#}!(@typeInfo(T) == .Int and T.is_signed and numerator == std.math.minInt(T) and denominator == -1){#endsyntax#}.
{#syntax#}@errorToInt(err: var) @IntType(false, @sizeOf(anyerror) * 8){#endsyntax#}
+ {#syntax#}@errorToInt(err: var) std.meta.IntType(false, @sizeOf(anyerror) * 8){#endsyntax#}
Supports the following types:
@@ -7635,7 +7619,7 @@ test "@hasDecl" { {#header_close#} {#header_open|@intToError#} -{#syntax#}@intToError(value: @IntType(false, @sizeOf(anyerror) * 8)) anyerror{#endsyntax#}
+ {#syntax#}@intToError(value: std.meta.IntType(false, @sizeOf(anyerror) * 8)) anyerror{#endsyntax#}
Converts from the integer representation of an error into {#link|The Global Error Set#} type.
@@ -7668,44 +7652,6 @@ test "@hasDecl" { {#header_close#} - {#header_open|@IntType#} -{#syntax#}@IntType(comptime is_signed: bool, comptime bit_count: u16) type{#endsyntax#}
- - This function returns an integer type with the given signness and bit count. The maximum - bit count for an integer type is {#syntax#}65535{#endsyntax#}. -
-- Deprecated. Use {#link|@Type#}. -
- {#header_close#} - - {#header_open|@memberCount#} -{#syntax#}@memberCount(comptime T: type) comptime_int{#endsyntax#}
- - This function returns the number of members in a struct, enum, or union type. -
-- The result is a compile time constant. -
-- It does not include functions, variables, or constants. -
- {#header_close#} - {#header_open|@memberName#} -{#syntax#}@memberName(comptime T: type, comptime index: usize) [N]u8{#endsyntax#}
- Returns the field name of a struct, union, or enum.
-- The result is a compile time constant. -
-- It does not include functions, variables, or constants. -
- {#header_close#} - {#header_open|@memberType#} -{#syntax#}@memberType(comptime T: type, comptime index: usize) type{#endsyntax#}
- Returns the field type of a struct or union.
- {#header_close#} - {#header_open|@memcpy#}{#syntax#}@memcpy(noalias dest: [*]u8, noalias source: [*]const u8, byte_count: usize){#endsyntax#}
@@ -8401,43 +8347,6 @@ test "integer truncation" {
{#syntax#}@typeId(comptime T: type) @import("builtin").TypeId{#endsyntax#}
- - Returns which kind of type something is. Possible values: -
- {#code_begin|syntax#} -pub const TypeId = enum { - Type, - Void, - Bool, - NoReturn, - Int, - Float, - Pointer, - Array, - Struct, - ComptimeFloat, - ComptimeInt, - Undefined, - Null, - Optional, - ErrorUnion, - ErrorSet, - Enum, - Union, - Fn, - BoundFn, - Opaque, - Frame, - AnyFrame, - Vector, - EnumLiteral, -}; - {#code_end#} - {#header_close#} - {#header_open|@typeInfo#}{#syntax#}@typeInfo(comptime T: type) @import("std").builtin.TypeInfo{#endsyntax#}
diff --git a/lib/std/build.zig b/lib/std/build.zig
index 85aa86fd98..29837d56d9 100644
--- a/lib/std/build.zig
+++ b/lib/std/build.zig
@@ -609,13 +609,13 @@ pub const Builder = struct {
}
fn typeToEnum(comptime T: type) TypeId {
- return switch (@typeId(T)) {
- builtin.TypeId.Int => TypeId.Int,
- builtin.TypeId.Float => TypeId.Float,
- builtin.TypeId.Bool => TypeId.Bool,
+ return switch (@typeInfo(T)) {
+ .Int => .Int,
+ .Float => .Float,
+ .Bool => .Bool,
else => switch (T) {
- []const u8 => TypeId.String,
- []const []const u8 => TypeId.List,
+ []const u8 => .String,
+ []const []const u8 => .List,
else => @compileError("Unsupported type: " ++ @typeName(T)),
},
};
@@ -627,11 +627,11 @@ pub const Builder = struct {
pub fn typeIdName(id: TypeId) []const u8 {
return switch (id) {
- TypeId.Bool => "bool",
- TypeId.Int => "int",
- TypeId.Float => "float",
- TypeId.String => "string",
- TypeId.List => "list",
+ .Bool => "bool",
+ .Int => "int",
+ .Float => "float",
+ .String => "string",
+ .List => "list",
};
}
diff --git a/lib/std/child_process.zig b/lib/std/child_process.zig
index 171a330bac..bb8ed2e8a0 100644
--- a/lib/std/child_process.zig
+++ b/lib/std/child_process.zig
@@ -851,7 +851,7 @@ fn forkChildErrReport(fd: i32, err: ChildProcess.SpawnError) noreturn {
os.exit(1);
}
-const ErrInt = @IntType(false, @sizeOf(anyerror) * 8);
+const ErrInt = std.meta.IntType(false, @sizeOf(anyerror) * 8);
fn writeIntFd(fd: i32, value: ErrInt) !void {
const file = File{
diff --git a/lib/std/debug/leb128.zig b/lib/std/debug/leb128.zig
index dba57e1f97..1d81b9390a 100644
--- a/lib/std/debug/leb128.zig
+++ b/lib/std/debug/leb128.zig
@@ -2,7 +2,7 @@ const std = @import("std");
const testing = std.testing;
pub fn readULEB128(comptime T: type, in_stream: var) !T {
- const ShiftT = @IntType(false, std.math.log2(T.bit_count));
+ const ShiftT = std.meta.IntType(false, std.math.log2(T.bit_count));
var result: T = 0;
var shift: usize = 0;
@@ -27,7 +27,7 @@ pub fn readULEB128(comptime T: type, in_stream: var) !T {
}
pub fn readULEB128Mem(comptime T: type, ptr: *[*]const u8) !T {
- const ShiftT = @IntType(false, std.math.log2(T.bit_count));
+ const ShiftT = std.meta.IntType(false, std.math.log2(T.bit_count));
var result: T = 0;
var shift: usize = 0;
@@ -55,8 +55,8 @@ pub fn readULEB128Mem(comptime T: type, ptr: *[*]const u8) !T {
}
pub fn readILEB128(comptime T: type, in_stream: var) !T {
- const UT = @IntType(false, T.bit_count);
- const ShiftT = @IntType(false, std.math.log2(T.bit_count));
+ const UT = std.meta.IntType(false, T.bit_count);
+ const ShiftT = std.meta.IntType(false, std.math.log2(T.bit_count));
var result: UT = 0;
var shift: usize = 0;
@@ -87,8 +87,8 @@ pub fn readILEB128(comptime T: type, in_stream: var) !T {
}
pub fn readILEB128Mem(comptime T: type, ptr: *[*]const u8) !T {
- const UT = @IntType(false, T.bit_count);
- const ShiftT = @IntType(false, std.math.log2(T.bit_count));
+ const UT = std.meta.IntType(false, T.bit_count);
+ const ShiftT = std.meta.IntType(false, std.math.log2(T.bit_count));
var result: UT = 0;
var shift: usize = 0;
diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig
index 0fe096a015..b9c6dd0033 100644
--- a/lib/std/fmt.zig
+++ b/lib/std/fmt.zig
@@ -82,7 +82,7 @@ pub fn format(
comptime fmt: []const u8,
args: var,
) Errors!void {
- const ArgSetType = @IntType(false, 32);
+ const ArgSetType = u32;
if (@typeInfo(@TypeOf(args)) != .Struct) {
@compileError("Expected tuple or struct argument, found " ++ @typeName(@TypeOf(args)));
}
@@ -405,7 +405,7 @@ pub fn formatType(
try format(context, Errors, output, "@{x}", .{@ptrToInt(&value)});
}
},
- .Struct => {
+ .Struct => |StructT| {
if (comptime std.meta.trait.hasFn("format")(T)) {
return value.format(fmt, options, context, Errors, output);
}
@@ -416,27 +416,28 @@ pub fn formatType(
}
comptime var field_i = 0;
try output(context, "{");
- inline while (field_i < @memberCount(T)) : (field_i += 1) {
+ inline for (StructT.fields) |f| {
if (field_i == 0) {
try output(context, " .");
} else {
try output(context, ", .");
}
- try output(context, @memberName(T, field_i));
+ try output(context, f.name);
try output(context, " = ");
- try formatType(@field(value, @memberName(T, field_i)), fmt, options, context, Errors, output, max_depth - 1);
+ try formatType(@field(value, f.name), fmt, options, context, Errors, output, max_depth - 1);
+ field_i += 1;
}
try output(context, " }");
},
.Pointer => |ptr_info| switch (ptr_info.size) {
.One => switch (@typeInfo(ptr_info.child)) {
- builtin.TypeId.Array => |info| {
+ .Array => |info| {
if (info.child == u8) {
return formatText(value, fmt, options, context, Errors, output);
}
return format(context, Errors, output, "{}@{x}", .{ @typeName(T.Child), @ptrToInt(value) });
},
- builtin.TypeId.Enum, builtin.TypeId.Union, builtin.TypeId.Struct => {
+ .Enum, .Union, .Struct => {
return formatType(value.*, fmt, options, context, Errors, output, max_depth);
},
else => return format(context, Errors, output, "{}@{x}", .{ @typeName(T.Child), @ptrToInt(value) }),
@@ -509,7 +510,7 @@ fn formatValue(
}
const T = @TypeOf(value);
- switch (@typeId(T)) {
+ switch (@typeInfo(T)) {
.Float => return formatFloatValue(value, fmt, options, context, Errors, output),
.Int, .ComptimeInt => return formatIntValue(value, fmt, options, context, Errors, output),
.Bool => return output(context, if (value) "true" else "false"),
@@ -943,7 +944,7 @@ fn formatIntSigned(
.fill = options.fill,
};
- const uint = @IntType(false, @TypeOf(value).bit_count);
+ const uint = std.meta.IntType(false, @TypeOf(value).bit_count);
if (value < 0) {
const minus_sign: u8 = '-';
try output(context, @as(*const [1]u8, &minus_sign)[0..]);
@@ -971,7 +972,7 @@ fn formatIntUnsigned(
assert(base >= 2);
var buf: [math.max(@TypeOf(value).bit_count, 1)]u8 = undefined;
const min_int_bits = comptime math.max(@TypeOf(value).bit_count, @TypeOf(base).bit_count);
- const MinInt = @IntType(@TypeOf(value).is_signed, min_int_bits);
+ const MinInt = std.meta.IntType(@TypeOf(value).is_signed, min_int_bits);
var a: MinInt = value;
var index: usize = buf.len;
diff --git a/lib/std/fmt/parse_float.zig b/lib/std/fmt/parse_float.zig
index 1456dd8e57..aa6e414336 100644
--- a/lib/std/fmt/parse_float.zig
+++ b/lib/std/fmt/parse_float.zig
@@ -393,7 +393,7 @@ test "fmt.parseFloat" {
const epsilon = 1e-7;
inline for ([_]type{ f16, f32, f64, f128 }) |T| {
- const Z = @IntType(false, T.bit_count);
+ const Z = std.meta.IntType(false, T.bit_count);
testing.expectError(error.InvalidCharacter, parseFloat(T, ""));
testing.expectError(error.InvalidCharacter, parseFloat(T, " 1"));
diff --git a/lib/std/hash/auto_hash.zig b/lib/std/hash/auto_hash.zig
index adde71875e..1bd7dfc05b 100644
--- a/lib/std/hash/auto_hash.zig
+++ b/lib/std/hash/auto_hash.zig
@@ -93,7 +93,7 @@ pub fn hash(hasher: var, key: var, comptime strat: HashStrategy) void {
// TODO Check if the situation is better after #561 is resolved.
.Int => @call(.{ .modifier = .always_inline }, hasher.update, .{std.mem.asBytes(&key)}),
- .Float => |info| hash(hasher, @bitCast(@IntType(false, info.bits), key), strat),
+ .Float => |info| hash(hasher, @bitCast(std.meta.IntType(false, info.bits), key), strat),
.Bool => hash(hasher, @boolToInt(key), strat),
.Enum => hash(hasher, @enumToInt(key), strat),
diff --git a/lib/std/hash/wyhash.zig b/lib/std/hash/wyhash.zig
index 8d11c700cf..8fcbbbce4c 100644
--- a/lib/std/hash/wyhash.zig
+++ b/lib/std/hash/wyhash.zig
@@ -10,7 +10,7 @@ const primes = [_]u64{
};
fn read_bytes(comptime bytes: u8, data: []const u8) u64 {
- const T = @IntType(false, 8 * bytes);
+ const T = std.meta.IntType(false, 8 * bytes);
return mem.readIntSliceLittle(T, data[0..bytes]);
}
diff --git a/lib/std/heap.zig b/lib/std/heap.zig
index 135d7297a2..4295f1393d 100644
--- a/lib/std/heap.zig
+++ b/lib/std/heap.zig
@@ -1015,7 +1015,7 @@ fn testAllocatorLargeAlignment(allocator: *mem.Allocator) mem.Allocator.Error!vo
// very near usize?
if (mem.page_size << 2 > maxInt(usize)) return;
- const USizeShift = @IntType(false, std.math.log2(usize.bit_count));
+ const USizeShift = std.meta.IntType(false, std.math.log2(usize.bit_count));
const large_align = @as(u29, mem.page_size << 2);
var align_mask: usize = undefined;
diff --git a/lib/std/io.zig b/lib/std/io.zig
index b6e1b12534..548f119b4f 100644
--- a/lib/std/io.zig
+++ b/lib/std/io.zig
@@ -337,7 +337,7 @@ pub fn BitInStream(endian: builtin.Endian, comptime Error: type) type {
assert(u_bit_count >= bits);
break :bc if (u_bit_count <= u8_bit_count) u8_bit_count else u_bit_count;
};
- const Buf = @IntType(false, buf_bit_count);
+ const Buf = std.meta.IntType(false, buf_bit_count);
const BufShift = math.Log2Int(Buf);
out_bits.* = @as(usize, 0);
@@ -659,7 +659,7 @@ pub fn BitOutStream(endian: builtin.Endian, comptime Error: type) type {
assert(u_bit_count >= bits);
break :bc if (u_bit_count <= u8_bit_count) u8_bit_count else u_bit_count;
};
- const Buf = @IntType(false, buf_bit_count);
+ const Buf = std.meta.IntType(false, buf_bit_count);
const BufShift = math.Log2Int(Buf);
const buf_value = @intCast(Buf, value);
@@ -831,12 +831,12 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,
//@BUG: inferred error issue. See: #1386
fn deserializeInt(self: *Self, comptime T: type) (Error || error{EndOfStream})!T {
- comptime assert(trait.is(builtin.TypeId.Int)(T) or trait.is(builtin.TypeId.Float)(T));
+ comptime assert(trait.is(.Int)(T) or trait.is(.Float)(T));
const u8_bit_count = 8;
const t_bit_count = comptime meta.bitCount(T);
- const U = @IntType(false, t_bit_count);
+ const U = std.meta.IntType(false, t_bit_count);
const Log2U = math.Log2Int(U);
const int_size = (U.bit_count + 7) / 8;
@@ -851,7 +851,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,
if (int_size == 1) {
if (t_bit_count == 8) return @bitCast(T, buffer[0]);
- const PossiblySignedByte = @IntType(T.is_signed, 8);
+ const PossiblySignedByte = std.meta.IntType(T.is_signed, 8);
return @truncate(T, @bitCast(PossiblySignedByte, buffer[0]));
}
@@ -880,9 +880,9 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,
/// Deserializes data into the type pointed to by `ptr`
pub fn deserializeInto(self: *Self, ptr: var) !void {
const T = @TypeOf(ptr);
- comptime assert(trait.is(builtin.TypeId.Pointer)(T));
+ comptime assert(trait.is(.Pointer)(T));
- if (comptime trait.isSlice(T) or comptime trait.isPtrTo(builtin.TypeId.Array)(T)) {
+ if (comptime trait.isSlice(T) or comptime trait.isPtrTo(.Array)(T)) {
for (ptr) |*v|
try self.deserializeInto(v);
return;
@@ -891,7 +891,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,
comptime assert(trait.isSingleItemPtr(T));
const C = comptime meta.Child(T);
- const child_type_id = @typeId(C);
+ const child_type_id = @typeInfo(C);
//custom deserializer: fn(self: *Self, deserializer: var) !void
if (comptime trait.hasFn("deserialize")(C)) return C.deserialize(ptr, self);
@@ -902,10 +902,10 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,
}
switch (child_type_id) {
- builtin.TypeId.Void => return,
- builtin.TypeId.Bool => ptr.* = (try self.deserializeInt(u1)) > 0,
- builtin.TypeId.Float, builtin.TypeId.Int => ptr.* = try self.deserializeInt(C),
- builtin.TypeId.Struct => {
+ .Void => return,
+ .Bool => ptr.* = (try self.deserializeInt(u1)) > 0,
+ .Float, .Int => ptr.* = try self.deserializeInt(C),
+ .Struct => {
const info = @typeInfo(C).Struct;
inline for (info.fields) |*field_info| {
@@ -915,7 +915,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,
if (FieldType == void or FieldType == u0) continue;
//it doesn't make any sense to read pointers
- if (comptime trait.is(builtin.TypeId.Pointer)(FieldType)) {
+ if (comptime trait.is(.Pointer)(FieldType)) {
@compileError("Will not " ++ "read field " ++ name ++ " of struct " ++
@typeName(C) ++ " because it " ++ "is of pointer-type " ++
@typeName(FieldType) ++ ".");
@@ -924,7 +924,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,
try self.deserializeInto(&@field(ptr, name));
}
},
- builtin.TypeId.Union => {
+ .Union => {
const info = @typeInfo(C).Union;
if (info.tag_type) |TagType| {
//we avoid duplicate iteration over the enum tags
@@ -948,7 +948,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,
@compileError("Cannot meaningfully deserialize " ++ @typeName(C) ++
" because it is an untagged union. Use a custom deserialize().");
},
- builtin.TypeId.Optional => {
+ .Optional => {
const OC = comptime meta.Child(C);
const exists = (try self.deserializeInt(u1)) > 0;
if (!exists) {
@@ -960,7 +960,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,
const val_ptr = &ptr.*.?;
try self.deserializeInto(val_ptr);
},
- builtin.TypeId.Enum => {
+ .Enum => {
var value = try self.deserializeInt(@TagType(C));
ptr.* = try meta.intToEnum(C, value);
},
@@ -1009,12 +1009,12 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co
fn serializeInt(self: *Self, value: var) Error!void {
const T = @TypeOf(value);
- comptime assert(trait.is(builtin.TypeId.Int)(T) or trait.is(builtin.TypeId.Float)(T));
+ comptime assert(trait.is(.Int)(T) or trait.is(.Float)(T));
const t_bit_count = comptime meta.bitCount(T);
const u8_bit_count = comptime meta.bitCount(u8);
- const U = @IntType(false, t_bit_count);
+ const U = std.meta.IntType(false, t_bit_count);
const Log2U = math.Log2Int(U);
const int_size = (U.bit_count + 7) / 8;
@@ -1058,11 +1058,11 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co
return;
}
- switch (@typeId(T)) {
- builtin.TypeId.Void => return,
- builtin.TypeId.Bool => try self.serializeInt(@as(u1, @boolToInt(value))),
- builtin.TypeId.Float, builtin.TypeId.Int => try self.serializeInt(value),
- builtin.TypeId.Struct => {
+ switch (@typeInfo(T)) {
+ .Void => return,
+ .Bool => try self.serializeInt(@as(u1, @boolToInt(value))),
+ .Float, .Int => try self.serializeInt(value),
+ .Struct => {
const info = @typeInfo(T);
inline for (info.Struct.fields) |*field_info| {
@@ -1072,7 +1072,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co
if (FieldType == void or FieldType == u0) continue;
//It doesn't make sense to write pointers
- if (comptime trait.is(builtin.TypeId.Pointer)(FieldType)) {
+ if (comptime trait.is(.Pointer)(FieldType)) {
@compileError("Will not " ++ "serialize field " ++ name ++
" of struct " ++ @typeName(T) ++ " because it " ++
"is of pointer-type " ++ @typeName(FieldType) ++ ".");
@@ -1080,7 +1080,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co
try self.serialize(@field(value, name));
}
},
- builtin.TypeId.Union => {
+ .Union => {
const info = @typeInfo(T).Union;
if (info.tag_type) |TagType| {
const active_tag = meta.activeTag(value);
@@ -1101,7 +1101,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co
@compileError("Cannot meaningfully serialize " ++ @typeName(T) ++
" because it is an untagged union. Use a custom serialize().");
},
- builtin.TypeId.Optional => {
+ .Optional => {
if (value == null) {
try self.serializeInt(@as(u1, @boolToInt(false)));
return;
@@ -1112,10 +1112,10 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co
const val_ptr = &value.?;
try self.serialize(val_ptr.*);
},
- builtin.TypeId.Enum => {
+ .Enum => {
try self.serializeInt(@enumToInt(value));
},
- else => @compileError("Cannot serialize " ++ @tagName(@typeId(T)) ++ " types (unimplemented)."),
+ else => @compileError("Cannot serialize " ++ @tagName(@typeInfo(T)) ++ " types (unimplemented)."),
}
}
};
diff --git a/lib/std/io/test.zig b/lib/std/io/test.zig
index 7716e603a0..dae8940016 100644
--- a/lib/std/io/test.zig
+++ b/lib/std/io/test.zig
@@ -318,6 +318,7 @@ test "BitStreams with File Stream" {
}
fn testIntSerializerDeserializer(comptime endian: builtin.Endian, comptime packing: io.Packing) !void {
+ @setEvalBranchQuota(1500);
//@NOTE: if this test is taking too long, reduce the maximum tested bitsize
const max_test_bitsize = 128;
@@ -341,8 +342,8 @@ fn testIntSerializerDeserializer(comptime endian: builtin.Endian, comptime packi
comptime var i = 0;
inline while (i <= max_test_bitsize) : (i += 1) {
- const U = @IntType(false, i);
- const S = @IntType(true, i);
+ const U = std.meta.IntType(false, i);
+ const S = std.meta.IntType(true, i);
try serializer.serializeInt(@as(U, i));
if (i != 0) try serializer.serializeInt(@as(S, -1)) else try serializer.serialize(@as(S, 0));
}
@@ -350,8 +351,8 @@ fn testIntSerializerDeserializer(comptime endian: builtin.Endian, comptime packi
i = 0;
inline while (i <= max_test_bitsize) : (i += 1) {
- const U = @IntType(false, i);
- const S = @IntType(true, i);
+ const U = std.meta.IntType(false, i);
+ const S = std.meta.IntType(true, i);
const x = try deserializer.deserializeInt(U);
const y = try deserializer.deserializeInt(S);
expect(x == @as(U, i));
diff --git a/lib/std/math.zig b/lib/std/math.zig
index 5885964c34..c99de8f9dc 100644
--- a/lib/std/math.zig
+++ b/lib/std/math.zig
@@ -1,6 +1,4 @@
-const builtin = @import("builtin");
const std = @import("std.zig");
-const TypeId = builtin.TypeId;
const assert = std.debug.assert;
const testing = std.testing;
@@ -89,7 +87,7 @@ pub const snan = @import("math/nan.zig").snan;
pub const inf = @import("math/inf.zig").inf;
pub fn approxEq(comptime T: type, x: T, y: T, epsilon: T) bool {
- assert(@typeId(T) == TypeId.Float);
+ assert(@typeInfo(T) == .Float);
return fabs(x - y) < epsilon;
}
@@ -198,7 +196,7 @@ test "" {
}
pub fn floatMantissaBits(comptime T: type) comptime_int {
- assert(@typeId(T) == builtin.TypeId.Float);
+ assert(@typeInfo(T) == .Float);
return switch (T.bit_count) {
16 => 10,
@@ -211,7 +209,7 @@ pub fn floatMantissaBits(comptime T: type) comptime_int {
}
pub fn floatExponentBits(comptime T: type) comptime_int {
- assert(@typeId(T) == builtin.TypeId.Float);
+ assert(@typeInfo(T) == .Float);
return switch (T.bit_count) {
16 => 5,
@@ -446,7 +444,7 @@ pub fn Log2Int(comptime T: type) type {
count += 1;
}
- return @IntType(false, count);
+ return std.meta.IntType(false, count);
}
pub fn IntFittingRange(comptime from: comptime_int, comptime to: comptime_int) type {
@@ -462,7 +460,7 @@ pub fn IntFittingRange(comptime from: comptime_int, comptime to: comptime_int) t
if (is_signed) {
magnitude_bits += 1;
}
- return @IntType(is_signed, magnitude_bits);
+ return std.meta.IntType(is_signed, magnitude_bits);
}
test "math.IntFittingRange" {
@@ -526,7 +524,7 @@ fn testOverflow() void {
pub fn absInt(x: var) !@TypeOf(x) {
const T = @TypeOf(x);
- comptime assert(@typeId(T) == builtin.TypeId.Int); // must pass an integer to absInt
+ comptime assert(@typeInfo(T) == .Int); // must pass an integer to absInt
comptime assert(T.is_signed); // must pass a signed integer to absInt
if (x == minInt(@TypeOf(x))) {
@@ -560,7 +558,7 @@ fn testAbsFloat() void {
pub fn divTrunc(comptime T: type, numerator: T, denominator: T) !T {
@setRuntimeSafety(false);
if (denominator == 0) return error.DivisionByZero;
- if (@typeId(T) == builtin.TypeId.Int and T.is_signed and numerator == minInt(T) and denominator == -1) return error.Overflow;
+ if (@typeInfo(T) == .Int and T.is_signed and numerator == minInt(T) and denominator == -1) return error.Overflow;
return @divTrunc(numerator, denominator);
}
@@ -581,7 +579,7 @@ fn testDivTrunc() void {
pub fn divFloor(comptime T: type, numerator: T, denominator: T) !T {
@setRuntimeSafety(false);
if (denominator == 0) return error.DivisionByZero;
- if (@typeId(T) == builtin.TypeId.Int and T.is_signed and numerator == minInt(T) and denominator == -1) return error.Overflow;
+ if (@typeInfo(T) == .Int and T.is_signed and numerator == minInt(T) and denominator == -1) return error.Overflow;
return @divFloor(numerator, denominator);
}
@@ -602,7 +600,7 @@ fn testDivFloor() void {
pub fn divExact(comptime T: type, numerator: T, denominator: T) !T {
@setRuntimeSafety(false);
if (denominator == 0) return error.DivisionByZero;
- if (@typeId(T) == builtin.TypeId.Int and T.is_signed and numerator == minInt(T) and denominator == -1) return error.Overflow;
+ if (@typeInfo(T) == .Int and T.is_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;
@@ -676,13 +674,13 @@ pub fn absCast(x: var) t: {
if (@TypeOf(x) == comptime_int) {
break :t comptime_int;
} else {
- break :t @IntType(false, @TypeOf(x).bit_count);
+ break :t std.meta.IntType(false, @TypeOf(x).bit_count);
}
} {
if (@TypeOf(x) == comptime_int) {
return if (x < 0) -x else x;
}
- const uint = @IntType(false, @TypeOf(x).bit_count);
+ const uint = std.meta.IntType(false, @TypeOf(x).bit_count);
if (x >= 0) return @intCast(uint, x);
return @intCast(uint, -(x + 1)) + 1;
@@ -703,10 +701,10 @@ test "math.absCast" {
/// Returns the negation of the integer parameter.
/// Result is a signed integer.
-pub fn negateCast(x: var) !@IntType(true, @TypeOf(x).bit_count) {
+pub fn negateCast(x: var) !std.meta.IntType(true, @TypeOf(x).bit_count) {
if (@TypeOf(x).is_signed) return negate(x);
- const int = @IntType(true, @TypeOf(x).bit_count);
+ const int = std.meta.IntType(true, @TypeOf(x).bit_count);
if (x > -minInt(int)) return error.Overflow;
if (x == -minInt(int)) return minInt(int);
@@ -727,8 +725,8 @@ test "math.negateCast" {
/// Cast an integer to a different integer type. If the value doesn't fit,
/// return an error.
pub fn cast(comptime T: type, x: var) (error{Overflow}!T) {
- comptime assert(@typeId(T) == builtin.TypeId.Int); // must pass an integer
- comptime assert(@typeId(@TypeOf(x)) == builtin.TypeId.Int); // must pass an integer
+ comptime assert(@typeInfo(T) == .Int); // must pass an integer
+ comptime assert(@typeInfo(@TypeOf(x)) == .Int); // must pass an integer
if (maxInt(@TypeOf(x)) > maxInt(T) and x > maxInt(T)) {
return error.Overflow;
} else if (minInt(@TypeOf(x)) < minInt(T) and x < minInt(T)) {
@@ -792,11 +790,11 @@ fn testFloorPowerOfTwo() void {
/// 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) @IntType(T.is_signed, T.bit_count + 1) {
- comptime assert(@typeId(T) == builtin.TypeId.Int);
+pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) std.meta.IntType(T.is_signed, T.bit_count + 1) {
+ comptime assert(@typeInfo(T) == .Int);
comptime assert(!T.is_signed);
assert(value != 0);
- comptime const PromotedType = @IntType(T.is_signed, T.bit_count + 1);
+ comptime const PromotedType = std.meta.IntType(T.is_signed, T.bit_count + 1);
comptime const shiftType = std.math.Log2Int(PromotedType);
return @as(PromotedType, 1) << @intCast(shiftType, T.bit_count - @clz(T, value - 1));
}
@@ -805,9 +803,9 @@ pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) @IntType(T.is_signed, T
/// 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(@typeId(T) == builtin.TypeId.Int);
+ comptime assert(@typeInfo(T) == .Int);
comptime assert(!T.is_signed);
- comptime const PromotedType = @IntType(T.is_signed, T.bit_count + 1);
+ comptime const PromotedType = std.meta.IntType(T.is_signed, T.bit_count + 1);
comptime const overflowBit = @as(PromotedType, 1) << T.bit_count;
var x = ceilPowerOfTwoPromote(T, value);
if (overflowBit & x != 0) {
@@ -878,10 +876,10 @@ test "std.math.log2_int_ceil" {
pub fn lossyCast(comptime T: type, value: var) T {
switch (@typeInfo(@TypeOf(value))) {
- builtin.TypeId.Int => return @intToFloat(T, value),
- builtin.TypeId.Float => return @floatCast(T, value),
- builtin.TypeId.ComptimeInt => return @as(T, value),
- builtin.TypeId.ComptimeFloat => return @as(T, value),
+ .Int => return @intToFloat(T, value),
+ .Float => return @floatCast(T, value),
+ .ComptimeInt => return @as(T, value),
+ .ComptimeFloat => return @as(T, value),
else => @compileError("bad type"),
}
}
@@ -949,8 +947,8 @@ test "max value type" {
testing.expect(x == 2147483647);
}
-pub fn mulWide(comptime T: type, a: T, b: T) @IntType(T.is_signed, T.bit_count * 2) {
- const ResultInt = @IntType(T.is_signed, T.bit_count * 2);
+pub fn mulWide(comptime T: type, a: T, b: T) std.meta.IntType(T.is_signed, T.bit_count * 2) {
+ const ResultInt = std.meta.IntType(T.is_signed, T.bit_count * 2);
return @as(ResultInt, a) * @as(ResultInt, b);
}
diff --git a/lib/std/math/big/int.zig b/lib/std/math/big/int.zig
index d42d9fc676..8fda3f647a 100644
--- a/lib/std/math/big/int.zig
+++ b/lib/std/math/big/int.zig
@@ -1,5 +1,4 @@
const std = @import("../../std.zig");
-const builtin = @import("builtin");
const debug = std.debug;
const testing = std.testing;
const math = std.math;
@@ -9,10 +8,8 @@ const ArrayList = std.ArrayList;
const maxInt = std.math.maxInt;
const minInt = std.math.minInt;
-const TypeId = builtin.TypeId;
-
pub const Limb = usize;
-pub const DoubleLimb = @IntType(false, 2 * Limb.bit_count);
+pub const DoubleLimb = std.meta.IntType(false, 2 * Limb.bit_count);
pub const Log2Limb = math.Log2Int(Limb);
comptime {
@@ -270,8 +267,8 @@ pub const Int = struct {
const T = @TypeOf(value);
switch (@typeInfo(T)) {
- TypeId.Int => |info| {
- const UT = if (T.is_signed) @IntType(false, T.bit_count - 1) else T;
+ .Int => |info| {
+ const UT = if (T.is_signed) std.meta.IntType(false, T.bit_count - 1) else T;
try self.ensureCapacity(@sizeOf(UT) / @sizeOf(Limb));
self.metadata = 0;
@@ -294,7 +291,7 @@ pub const Int = struct {
}
}
},
- TypeId.ComptimeInt => {
+ .ComptimeInt => {
comptime var w_value = if (value < 0) -value else value;
const req_limbs = @divFloor(math.log2(w_value), Limb.bit_count) + 1;
@@ -332,9 +329,9 @@ pub const Int = struct {
///
/// Returns an error if self cannot be narrowed into the requested type without truncation.
pub fn to(self: Int, comptime T: type) ConvertError!T {
- switch (@typeId(T)) {
- TypeId.Int => {
- const UT = @IntType(false, T.bit_count);
+ switch (@typeInfo(T)) {
+ .Int => {
+ const UT = std.meta.IntType(false, T.bit_count);
if (self.bitCountTwosComp() > T.bit_count) {
return error.TargetTooSmall;
diff --git a/lib/std/math/big/rational.zig b/lib/std/math/big/rational.zig
index 438c6c94fc..a57183a623 100644
--- a/lib/std/math/big/rational.zig
+++ b/lib/std/math/big/rational.zig
@@ -1,5 +1,4 @@
const std = @import("../../std.zig");
-const builtin = @import("builtin");
const debug = std.debug;
const math = std.math;
const mem = std.mem;
@@ -7,8 +6,6 @@ const testing = std.testing;
const Allocator = mem.Allocator;
const ArrayList = std.ArrayList;
-const TypeId = builtin.TypeId;
-
const bn = @import("int.zig");
const Limb = bn.Limb;
const DoubleLimb = bn.DoubleLimb;
@@ -129,9 +126,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(@typeId(T) == builtin.TypeId.Float);
+ debug.assert(@typeInfo(T) == .Float);
- const UnsignedIntType = @IntType(false, T.bit_count);
+ const UnsignedIntType = std.meta.IntType(false, T.bit_count);
const f_bits = @bitCast(UnsignedIntType, f);
const exponent_bits = math.floatExponentBits(T);
@@ -187,10 +184,10 @@ 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(@typeId(T) == builtin.TypeId.Float);
+ debug.assert(@typeInfo(T) == .Float);
const fsize = T.bit_count;
- const BitReprType = @IntType(false, T.bit_count);
+ const BitReprType = std.meta.IntType(false, T.bit_count);
const msize = math.floatMantissaBits(T);
const msize1 = msize + 1;
@@ -465,7 +462,7 @@ pub const Rational = struct {
}
};
-const SignedDoubleLimb = @IntType(true, DoubleLimb.bit_count);
+const SignedDoubleLimb = std.meta.IntType(true, DoubleLimb.bit_count);
fn gcd(rma: *Int, x: Int, y: Int) !void {
rma.assertWritable();
@@ -653,7 +650,7 @@ test "big.rational gcd one large" {
}
fn extractLowBits(a: Int, comptime T: type) T {
- testing.expect(@typeId(T) == builtin.TypeId.Int);
+ testing.expect(@typeInfo(T) == .Int);
if (T.bit_count <= Limb.bit_count) {
return @truncate(T, a.limbs[0]);
diff --git a/lib/std/math/cos.zig b/lib/std/math/cos.zig
index 248243e288..8a599aece4 100644
--- a/lib/std/math/cos.zig
+++ b/lib/std/math/cos.zig
@@ -44,7 +44,7 @@ const pi4c = 2.69515142907905952645E-15;
const m4pi = 1.273239544735162542821171882678754627704620361328125;
fn cos_(comptime T: type, x_: T) T {
- const I = @IntType(true, T.bit_count);
+ const I = std.meta.IntType(true, T.bit_count);
var x = x_;
if (math.isNan(x) or math.isInf(x)) {
diff --git a/lib/std/math/ln.zig b/lib/std/math/ln.zig
index da3e60202d..555a786907 100644
--- a/lib/std/math/ln.zig
+++ b/lib/std/math/ln.zig
@@ -7,8 +7,6 @@
const std = @import("../std.zig");
const math = std.math;
const expect = std.testing.expect;
-const builtin = @import("builtin");
-const TypeId = builtin.TypeId;
/// Returns the natural logarithm of x.
///
@@ -19,21 +17,21 @@ const TypeId = builtin.TypeId;
/// - ln(nan) = nan
pub fn ln(x: var) @TypeOf(x) {
const T = @TypeOf(x);
- switch (@typeId(T)) {
- TypeId.ComptimeFloat => {
+ switch (@typeInfo(T)) {
+ .ComptimeFloat => {
return @as(comptime_float, ln_64(x));
},
- TypeId.Float => {
+ .Float => {
return switch (T) {
f32 => ln_32(x),
f64 => ln_64(x),
else => @compileError("ln not implemented for " ++ @typeName(T)),
};
},
- TypeId.ComptimeInt => {
+ .ComptimeInt => {
return @as(comptime_int, math.floor(ln_64(@as(f64, x))));
},
- TypeId.Int => {
+ .Int => {
return @as(T, math.floor(ln_64(@as(f64, x))));
},
else => @compileError("ln not implemented for " ++ @typeName(T)),
diff --git a/lib/std/math/log.zig b/lib/std/math/log.zig
index 9d77397e17..6f5025cd50 100644
--- a/lib/std/math/log.zig
+++ b/lib/std/math/log.zig
@@ -6,8 +6,6 @@
const std = @import("../std.zig");
const math = std.math;
-const builtin = @import("builtin");
-const TypeId = builtin.TypeId;
const expect = std.testing.expect;
/// Returns the logarithm of x for the provided base.
@@ -16,24 +14,24 @@ 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 ((@typeId(T) == TypeId.Float or @typeId(T) == TypeId.ComptimeFloat) and base == math.e) {
+ } else if ((@typeInfo(T) == .Float or @typeInfo(T) == .ComptimeFloat) and base == math.e) {
return math.ln(x);
}
const float_base = math.lossyCast(f64, base);
- switch (@typeId(T)) {
- TypeId.ComptimeFloat => {
+ switch (@typeInfo(T)) {
+ .ComptimeFloat => {
return @as(comptime_float, math.ln(@as(f64, x)) / math.ln(float_base));
},
- TypeId.ComptimeInt => {
+ .ComptimeInt => {
return @as(comptime_int, math.floor(math.ln(@as(f64, x)) / math.ln(float_base)));
},
- builtin.TypeId.Int => {
+ .Int => {
// TODO implement integer log without using float math
return @floatToInt(T, math.floor(math.ln(@intToFloat(f64, x)) / math.ln(float_base)));
},
- builtin.TypeId.Float => {
+ .Float => {
switch (T) {
f32 => return @floatCast(f32, math.ln(@as(f64, x)) / math.ln(float_base)),
f64 => return math.ln(x) / math.ln(float_base),
diff --git a/lib/std/math/log10.zig b/lib/std/math/log10.zig
index a0deee69d1..7367af28c6 100644
--- a/lib/std/math/log10.zig
+++ b/lib/std/math/log10.zig
@@ -7,8 +7,6 @@
const std = @import("../std.zig");
const math = std.math;
const testing = std.testing;
-const builtin = @import("builtin");
-const TypeId = builtin.TypeId;
const maxInt = std.math.maxInt;
/// Returns the base-10 logarithm of x.
@@ -20,21 +18,21 @@ const maxInt = std.math.maxInt;
/// - log10(nan) = nan
pub fn log10(x: var) @TypeOf(x) {
const T = @TypeOf(x);
- switch (@typeId(T)) {
- TypeId.ComptimeFloat => {
+ switch (@typeInfo(T)) {
+ .ComptimeFloat => {
return @as(comptime_float, log10_64(x));
},
- TypeId.Float => {
+ .Float => {
return switch (T) {
f32 => log10_32(x),
f64 => log10_64(x),
else => @compileError("log10 not implemented for " ++ @typeName(T)),
};
},
- TypeId.ComptimeInt => {
+ .ComptimeInt => {
return @as(comptime_int, math.floor(log10_64(@as(f64, x))));
},
- TypeId.Int => {
+ .Int => {
return @floatToInt(T, math.floor(log10_64(@intToFloat(f64, x))));
},
else => @compileError("log10 not implemented for " ++ @typeName(T)),
diff --git a/lib/std/math/log2.zig b/lib/std/math/log2.zig
index d3b655a56a..54f8bc2baa 100644
--- a/lib/std/math/log2.zig
+++ b/lib/std/math/log2.zig
@@ -7,8 +7,6 @@
const std = @import("../std.zig");
const math = std.math;
const expect = std.testing.expect;
-const builtin = @import("builtin");
-const TypeId = builtin.TypeId;
const maxInt = std.math.maxInt;
/// Returns the base-2 logarithm of x.
@@ -20,18 +18,18 @@ const maxInt = std.math.maxInt;
/// - log2(nan) = nan
pub fn log2(x: var) @TypeOf(x) {
const T = @TypeOf(x);
- switch (@typeId(T)) {
- TypeId.ComptimeFloat => {
+ switch (@typeInfo(T)) {
+ .ComptimeFloat => {
return @as(comptime_float, log2_64(x));
},
- TypeId.Float => {
+ .Float => {
return switch (T) {
f32 => log2_32(x),
f64 => log2_64(x),
else => @compileError("log2 not implemented for " ++ @typeName(T)),
};
},
- TypeId.ComptimeInt => comptime {
+ .ComptimeInt => comptime {
var result = 0;
var x_shifted = x;
while (b: {
@@ -40,7 +38,7 @@ pub fn log2(x: var) @TypeOf(x) {
}) : (result += 1) {}
return result;
},
- TypeId.Int => {
+ .Int => {
return math.log2_int(T, x);
},
else => @compileError("log2 not implemented for " ++ @typeName(T)),
diff --git a/lib/std/math/pow.zig b/lib/std/math/pow.zig
index 18c9f80634..4f623377e6 100644
--- a/lib/std/math/pow.zig
+++ b/lib/std/math/pow.zig
@@ -145,7 +145,7 @@ pub fn pow(comptime T: type, x: T, y: T) T {
var xe = r2.exponent;
var x1 = r2.significand;
- var i = @floatToInt(@IntType(true, T.bit_count), yi);
+ var i = @floatToInt(std.meta.IntType(true, T.bit_count), 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/sin.zig b/lib/std/math/sin.zig
index 00225449bb..0c339ba1f2 100644
--- a/lib/std/math/sin.zig
+++ b/lib/std/math/sin.zig
@@ -45,7 +45,7 @@ const pi4c = 2.69515142907905952645E-15;
const m4pi = 1.273239544735162542821171882678754627704620361328125;
fn sin_(comptime T: type, x_: T) T {
- const I = @IntType(true, T.bit_count);
+ const I = std.meta.IntType(true, T.bit_count);
var x = x_;
if (x == 0 or math.isNan(x)) {
diff --git a/lib/std/math/sqrt.zig b/lib/std/math/sqrt.zig
index 800a7574ae..e5d8a822f5 100644
--- a/lib/std/math/sqrt.zig
+++ b/lib/std/math/sqrt.zig
@@ -31,7 +31,7 @@ pub fn sqrt(x: var) Sqrt(@TypeOf(x)) {
}
}
-fn sqrt_int(comptime T: type, value: T) @IntType(false, T.bit_count / 2) {
+fn sqrt_int(comptime T: type, value: T) std.meta.IntType(false, T.bit_count / 2) {
var op = value;
var res: T = 0;
var one: T = 1 << (T.bit_count - 2);
@@ -50,7 +50,7 @@ fn sqrt_int(comptime T: type, value: T) @IntType(false, T.bit_count / 2) {
one >>= 2;
}
- const ResultType = @IntType(false, T.bit_count / 2);
+ const ResultType = std.meta.IntType(false, T.bit_count / 2);
return @intCast(ResultType, res);
}
@@ -66,7 +66,7 @@ test "math.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| @IntType(false, int.bits / 2),
+ .Int => |int| std.meta.IntType(false, int.bits / 2),
else => T,
};
}
diff --git a/lib/std/math/tan.zig b/lib/std/math/tan.zig
index 01a0314d74..737f5b0e09 100644
--- a/lib/std/math/tan.zig
+++ b/lib/std/math/tan.zig
@@ -38,7 +38,7 @@ const pi4c = 2.69515142907905952645E-15;
const m4pi = 1.273239544735162542821171882678754627704620361328125;
fn tan_(comptime T: type, x_: T) T {
- const I = @IntType(true, T.bit_count);
+ const I = std.meta.IntType(true, T.bit_count);
var x = x_;
if (x == 0 or math.isNan(x)) {
diff --git a/lib/std/mem.zig b/lib/std/mem.zig
index 20ad567431..4e7beba17d 100644
--- a/lib/std/mem.zig
+++ b/lib/std/mem.zig
@@ -708,7 +708,7 @@ pub fn writeIntSliceLittle(comptime T: type, buffer: []u8, value: T) void {
assert(buffer.len >= @divExact(T.bit_count, 8));
// TODO I want to call writeIntLittle here but comptime eval facilities aren't good enough
- const uint = @IntType(false, T.bit_count);
+ const uint = std.meta.IntType(false, T.bit_count);
var bits = @truncate(uint, value);
for (buffer) |*b| {
b.* = @truncate(u8, bits);
@@ -725,7 +725,7 @@ pub fn writeIntSliceBig(comptime T: type, buffer: []u8, value: T) void {
assert(buffer.len >= @divExact(T.bit_count, 8));
// TODO I want to call writeIntBig here but comptime eval facilities aren't good enough
- const uint = @IntType(false, T.bit_count);
+ const uint = std.meta.IntType(false, T.bit_count);
var bits = @truncate(uint, value);
var index: usize = buffer.len;
while (index != 0) {
diff --git a/lib/std/meta.zig b/lib/std/meta.zig
index 300bca3d0e..58fd6b9da7 100644
--- a/lib/std/meta.zig
+++ b/lib/std/meta.zig
@@ -536,9 +536,8 @@ test "intToEnum with error return" {
pub const IntToEnumError = error{InvalidEnumTag};
pub fn intToEnum(comptime Tag: type, tag_int: var) IntToEnumError!Tag {
- comptime var i = 0;
- inline while (i != @memberCount(Tag)) : (i += 1) {
- const this_tag_value = @field(Tag, @memberName(Tag, i));
+ inline for (@typeInfo(Tag).Enum.fields) |f| {
+ const this_tag_value = @field(Tag, f.name);
if (tag_int == @enumToInt(this_tag_value)) {
return this_tag_value;
}
@@ -581,3 +580,12 @@ pub fn declList(comptime Namespace: type, comptime Decl: type) []const *const De
return &array;
}
}
+
+pub fn IntType(comptime is_signed: bool, comptime bit_count: u16) type {
+ return @Type(TypeInfo{
+ .Int = .{
+ .is_signed = is_signed,
+ .bits = bit_count,
+ },
+ });
+}
diff --git a/lib/std/meta/trait.zig b/lib/std/meta/trait.zig
index b17a4a2a93..c0fb8c5025 100644
--- a/lib/std/meta/trait.zig
+++ b/lib/std/meta/trait.zig
@@ -1,5 +1,5 @@
const std = @import("../std.zig");
-const builtin = @import("builtin");
+const builtin = std.builtin;
const mem = std.mem;
const debug = std.debug;
const testing = std.testing;
@@ -54,7 +54,7 @@ pub fn hasFn(comptime name: []const u8) TraitFn {
if (!comptime isContainer(T)) return false;
if (!comptime @hasDecl(T, name)) return false;
const DeclType = @TypeOf(@field(T, name));
- return @typeId(DeclType) == .Fn;
+ return @typeInfo(DeclType) == .Fn;
}
};
return Closure.trait;
@@ -105,7 +105,7 @@ test "std.meta.trait.hasField" {
pub fn is(comptime id: builtin.TypeId) TraitFn {
const Closure = struct {
pub fn trait(comptime T: type) bool {
- return id == @typeId(T);
+ return id == @typeInfo(T);
}
};
return Closure.trait;
@@ -123,7 +123,7 @@ pub fn isPtrTo(comptime id: builtin.TypeId) TraitFn {
const Closure = struct {
pub fn trait(comptime T: type) bool {
if (!comptime isSingleItemPtr(T)) return false;
- return id == @typeId(meta.Child(T));
+ return id == @typeInfo(meta.Child(T));
}
};
return Closure.trait;
@@ -139,7 +139,7 @@ pub fn isSliceOf(comptime id: builtin.TypeId) TraitFn {
const Closure = struct {
pub fn trait(comptime T: type) bool {
if (!comptime isSlice(T)) return false;
- return id == @typeId(meta.Child(T));
+ return id == @typeInfo(meta.Child(T));
}
};
return Closure.trait;
@@ -285,7 +285,7 @@ test "std.meta.trait.isIndexable" {
}
pub fn isNumber(comptime T: type) bool {
- return switch (@typeId(T)) {
+ return switch (@typeInfo(T)) {
.Int, .Float, .ComptimeInt, .ComptimeFloat => true,
else => false,
};
@@ -320,7 +320,7 @@ test "std.meta.trait.isConstPtr" {
}
pub fn isContainer(comptime T: type) bool {
- return switch (@typeId(T)) {
+ return switch (@typeInfo(T)) {
.Struct, .Union, .Enum => true,
else => false,
};
diff --git a/lib/std/os.zig b/lib/std/os.zig
index b501c81b36..3b60a08cef 100644
--- a/lib/std/os.zig
+++ b/lib/std/os.zig
@@ -3349,7 +3349,7 @@ pub fn res_mkquery(
// Make a reasonably unpredictable id
var ts: timespec = undefined;
clock_gettime(CLOCK_REALTIME, &ts) catch {};
- const UInt = @IntType(false, @TypeOf(ts.tv_nsec).bit_count);
+ const UInt = std.meta.IntType(false, @TypeOf(ts.tv_nsec).bit_count);
const unsec = @bitCast(UInt, ts.tv_nsec);
const id = @truncate(u32, unsec + unsec / 65536);
q[0] = @truncate(u8, id / 256);
diff --git a/lib/std/os/bits/linux.zig b/lib/std/os/bits/linux.zig
index 8077d4b16a..c5a9a7d774 100644
--- a/lib/std/os/bits/linux.zig
+++ b/lib/std/os/bits/linux.zig
@@ -1004,7 +1004,7 @@ pub const dl_phdr_info = extern struct {
pub const CPU_SETSIZE = 128;
pub const cpu_set_t = [CPU_SETSIZE / @sizeOf(usize)]usize;
-pub const cpu_count_t = @IntType(false, std.math.log2(CPU_SETSIZE * 8));
+pub const cpu_count_t = std.meta.IntType(false, std.math.log2(CPU_SETSIZE * 8));
pub fn CPU_COUNT(set: cpu_set_t) cpu_count_t {
var sum: cpu_count_t = 0;
diff --git a/lib/std/packed_int_array.zig b/lib/std/packed_int_array.zig
index 3dfa55e74b..63b6fffa73 100644
--- a/lib/std/packed_int_array.zig
+++ b/lib/std/packed_int_array.zig
@@ -34,13 +34,13 @@ pub fn PackedIntIo(comptime Int: type, comptime endian: builtin.Endian) type {
//we bitcast the desired Int type to an unsigned version of itself
// to avoid issues with shifting signed ints.
- const UnInt = @IntType(false, int_bits);
+ const UnInt = std.meta.IntType(false, int_bits);
//The maximum container int type
- const MinIo = @IntType(false, min_io_bits);
+ const MinIo = std.meta.IntType(false, min_io_bits);
//The minimum container int type
- const MaxIo = @IntType(false, max_io_bits);
+ const MaxIo = std.meta.IntType(false, max_io_bits);
return struct {
pub fn get(bytes: []const u8, index: usize, bit_offset: u7) Int {
@@ -322,7 +322,7 @@ test "PackedIntArray" {
inline while (bits <= 256) : (bits += 1) {
//alternate unsigned and signed
const even = bits % 2 == 0;
- const I = @IntType(even, bits);
+ const I = std.meta.IntType(even, bits);
const PackedArray = PackedIntArray(I, int_count);
const expected_bytes = ((bits * int_count) + 7) / 8;
@@ -369,7 +369,7 @@ test "PackedIntSlice" {
inline while (bits <= 256) : (bits += 1) {
//alternate unsigned and signed
const even = bits % 2 == 0;
- const I = @IntType(even, bits);
+ const I = std.meta.IntType(even, bits);
const P = PackedIntSlice(I);
var data = P.init(&buffer, int_count);
@@ -399,7 +399,7 @@ test "PackedIntSlice of PackedInt(Array/Slice)" {
comptime var bits = 0;
inline while (bits <= max_bits) : (bits += 1) {
- const Int = @IntType(false, bits);
+ const Int = std.meta.IntType(false, bits);
const PackedArray = PackedIntArray(Int, int_count);
var packed_array = @as(PackedArray, undefined);
diff --git a/lib/std/rand.zig b/lib/std/rand.zig
index 0bdc593545..31891f5f0e 100644
--- a/lib/std/rand.zig
+++ b/lib/std/rand.zig
@@ -45,8 +45,8 @@ pub const Random = struct {
/// Returns a random int `i` such that `0 <= i <= maxInt(T)`.
/// `i` is evenly distributed.
pub fn int(r: *Random, comptime T: type) T {
- const UnsignedT = @IntType(false, T.bit_count);
- const ByteAlignedT = @IntType(false, @divTrunc(T.bit_count + 7, 8) * 8);
+ const UnsignedT = std.meta.IntType(false, T.bit_count);
+ const ByteAlignedT = std.meta.IntType(false, @divTrunc(T.bit_count + 7, 8) * 8);
var rand_bytes: [@sizeOf(ByteAlignedT)]u8 = undefined;
r.bytes(rand_bytes[0..]);
@@ -85,9 +85,9 @@ pub const Random = struct {
comptime assert(T.bit_count <= 64); // TODO: workaround: LLVM ERROR: Unsupported library call operation!
assert(0 < less_than);
// Small is typically u32
- const Small = @IntType(false, @divTrunc(T.bit_count + 31, 32) * 32);
+ const Small = std.meta.IntType(false, @divTrunc(T.bit_count + 31, 32) * 32);
// Large is typically u64
- const Large = @IntType(false, Small.bit_count * 2);
+ const Large = std.meta.IntType(false, Small.bit_count * 2);
// adapted from:
// http://www.pcg-random.org/posts/bounded-rands.html
@@ -99,7 +99,7 @@ pub const Random = struct {
// TODO: workaround for https://github.com/ziglang/zig/issues/1770
// should be:
// var t: Small = -%less_than;
- var t: Small = @bitCast(Small, -%@bitCast(@IntType(true, Small.bit_count), @as(Small, less_than)));
+ var t: Small = @bitCast(Small, -%@bitCast(std.meta.IntType(true, Small.bit_count), @as(Small, less_than)));
if (t >= less_than) {
t -= less_than;
@@ -145,7 +145,7 @@ pub const Random = struct {
assert(at_least < less_than);
if (T.is_signed) {
// Two's complement makes this math pretty easy.
- const UnsignedT = @IntType(false, T.bit_count);
+ const UnsignedT = std.meta.IntType(false, T.bit_count);
const lo = @bitCast(UnsignedT, at_least);
const hi = @bitCast(UnsignedT, less_than);
const result = lo +% r.uintLessThanBiased(UnsignedT, hi -% lo);
@@ -163,7 +163,7 @@ pub const Random = struct {
assert(at_least < less_than);
if (T.is_signed) {
// Two's complement makes this math pretty easy.
- const UnsignedT = @IntType(false, T.bit_count);
+ const UnsignedT = std.meta.IntType(false, T.bit_count);
const lo = @bitCast(UnsignedT, at_least);
const hi = @bitCast(UnsignedT, less_than);
const result = lo +% r.uintLessThan(UnsignedT, hi -% lo);
@@ -180,7 +180,7 @@ pub const Random = struct {
assert(at_least <= at_most);
if (T.is_signed) {
// Two's complement makes this math pretty easy.
- const UnsignedT = @IntType(false, T.bit_count);
+ const UnsignedT = std.meta.IntType(false, T.bit_count);
const lo = @bitCast(UnsignedT, at_least);
const hi = @bitCast(UnsignedT, at_most);
const result = lo +% r.uintAtMostBiased(UnsignedT, hi -% lo);
@@ -198,7 +198,7 @@ pub const Random = struct {
assert(at_least <= at_most);
if (T.is_signed) {
// Two's complement makes this math pretty easy.
- const UnsignedT = @IntType(false, T.bit_count);
+ const UnsignedT = std.meta.IntType(false, T.bit_count);
const lo = @bitCast(UnsignedT, at_least);
const hi = @bitCast(UnsignedT, at_most);
const result = lo +% r.uintAtMost(UnsignedT, hi -% lo);
@@ -281,7 +281,7 @@ pub const Random = struct {
/// This function introduces a minor bias.
pub fn limitRangeBiased(comptime T: type, random_int: T, less_than: T) T {
comptime assert(T.is_signed == false);
- const T2 = @IntType(false, T.bit_count * 2);
+ const T2 = std.meta.IntType(false, T.bit_count * 2);
// adapted from:
// http://www.pcg-random.org/posts/bounded-rands.html
diff --git a/lib/std/special/build_runner.zig b/lib/std/special/build_runner.zig
index dc13435cb0..baf21570ec 100644
--- a/lib/std/special/build_runner.zig
+++ b/lib/std/special/build_runner.zig
@@ -128,7 +128,7 @@ pub fn main() !void {
}
fn runBuild(builder: *Builder) anyerror!void {
- switch (@typeId(@TypeOf(root.build).ReturnType)) {
+ switch (@typeInfo(@TypeOf(root.build).ReturnType)) {
.Void => root.build(builder),
.ErrorUnion => try root.build(builder),
else => @compileError("expected return type of build to be 'void' or '!void'"),
diff --git a/lib/std/special/c.zig b/lib/std/special/c.zig
index 0a911ba52b..56ae3d0d8f 100644
--- a/lib/std/special/c.zig
+++ b/lib/std/special/c.zig
@@ -511,7 +511,7 @@ export fn roundf(a: f32) f32 {
fn generic_fmod(comptime T: type, x: T, y: T) T {
@setRuntimeSafety(false);
- const uint = @IntType(false, T.bit_count);
+ const uint = std.meta.IntType(false, T.bit_count);
const log2uint = math.Log2Int(uint);
const digits = if (T == f32) 23 else 52;
const exp_bits = if (T == f32) 9 else 12;
diff --git a/lib/std/special/compiler_rt/addXf3.zig b/lib/std/special/compiler_rt/addXf3.zig
index 4294752baa..8bb9751378 100644
--- a/lib/std/special/compiler_rt/addXf3.zig
+++ b/lib/std/special/compiler_rt/addXf3.zig
@@ -54,21 +54,21 @@ pub fn __aeabi_dsub(a: f64, b: f64) callconv(.AAPCS) f64 {
}
// TODO: restore inline keyword, see: https://github.com/ziglang/zig/issues/2154
-fn normalize(comptime T: type, significand: *@IntType(false, T.bit_count)) i32 {
- const Z = @IntType(false, T.bit_count);
- const S = @IntType(false, T.bit_count - @clz(Z, @as(Z, T.bit_count) - 1));
+fn normalize(comptime T: type, significand: *std.meta.IntType(false, T.bit_count)) i32 {
+ const Z = std.meta.IntType(false, T.bit_count);
+ const S = std.meta.IntType(false, T.bit_count - @clz(Z, @as(Z, T.bit_count) - 1));
const significandBits = std.math.floatMantissaBits(T);
const implicitBit = @as(Z, 1) << significandBits;
- const shift = @clz(@IntType(false, T.bit_count), significand.*) - @clz(Z, implicitBit);
+ const shift = @clz(std.meta.IntType(false, T.bit_count), significand.*) - @clz(Z, implicitBit);
significand.* <<= @intCast(S, shift);
return 1 - shift;
}
// TODO: restore inline keyword, see: https://github.com/ziglang/zig/issues/2154
fn addXf3(comptime T: type, a: T, b: T) T {
- const Z = @IntType(false, T.bit_count);
- const S = @IntType(false, T.bit_count - @clz(Z, @as(Z, T.bit_count) - 1));
+ const Z = std.meta.IntType(false, T.bit_count);
+ const S = std.meta.IntType(false, T.bit_count - @clz(Z, @as(Z, T.bit_count) - 1));
const typeWidth = T.bit_count;
const significandBits = std.math.floatMantissaBits(T);
@@ -182,7 +182,7 @@ fn addXf3(comptime T: type, a: T, b: T) T {
// If partial cancellation occured, we need to left-shift the result
// and adjust the exponent:
if (aSignificand < implicitBit << 3) {
- const shift = @intCast(i32, @clz(Z, aSignificand)) - @intCast(i32, @clz(@IntType(false, T.bit_count), implicitBit << 3));
+ const shift = @intCast(i32, @clz(Z, aSignificand)) - @intCast(i32, @clz(std.meta.IntType(false, T.bit_count), implicitBit << 3));
aSignificand <<= @intCast(S, shift);
aExponent -= shift;
}
diff --git a/lib/std/special/compiler_rt/compareXf2.zig b/lib/std/special/compiler_rt/compareXf2.zig
index 15e49e3cc1..34871a5025 100644
--- a/lib/std/special/compiler_rt/compareXf2.zig
+++ b/lib/std/special/compiler_rt/compareXf2.zig
@@ -22,8 +22,8 @@ const GE = extern enum(i32) {
pub fn cmp(comptime T: type, comptime RT: type, a: T, b: T) RT {
@setRuntimeSafety(builtin.is_test);
- const srep_t = @IntType(true, T.bit_count);
- const rep_t = @IntType(false, T.bit_count);
+ const srep_t = std.meta.IntType(true, T.bit_count);
+ const rep_t = std.meta.IntType(false, T.bit_count);
const significandBits = std.math.floatMantissaBits(T);
const exponentBits = std.math.floatExponentBits(T);
@@ -68,7 +68,7 @@ pub fn cmp(comptime T: type, comptime RT: type, a: T, b: T) RT {
pub fn unordcmp(comptime T: type, a: T, b: T) i32 {
@setRuntimeSafety(builtin.is_test);
- const rep_t = @IntType(false, T.bit_count);
+ const rep_t = std.meta.IntType(false, T.bit_count);
const significandBits = std.math.floatMantissaBits(T);
const exponentBits = std.math.floatExponentBits(T);
diff --git a/lib/std/special/compiler_rt/divdf3.zig b/lib/std/special/compiler_rt/divdf3.zig
index f0c0d1247c..7e870feec9 100644
--- a/lib/std/special/compiler_rt/divdf3.zig
+++ b/lib/std/special/compiler_rt/divdf3.zig
@@ -7,8 +7,8 @@ const builtin = @import("builtin");
pub fn __divdf3(a: f64, b: f64) callconv(.C) f64 {
@setRuntimeSafety(builtin.is_test);
- const Z = @IntType(false, f64.bit_count);
- const SignedZ = @IntType(true, f64.bit_count);
+ const Z = std.meta.IntType(false, f64.bit_count);
+ const SignedZ = std.meta.IntType(true, f64.bit_count);
const typeWidth = f64.bit_count;
const significandBits = std.math.floatMantissaBits(f64);
@@ -312,9 +312,9 @@ fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void {
}
}
-fn normalize(comptime T: type, significand: *@IntType(false, T.bit_count)) i32 {
+fn normalize(comptime T: type, significand: *std.meta.IntType(false, T.bit_count)) i32 {
@setRuntimeSafety(builtin.is_test);
- const Z = @IntType(false, T.bit_count);
+ const Z = std.meta.IntType(false, T.bit_count);
const significandBits = std.math.floatMantissaBits(T);
const implicitBit = @as(Z, 1) << significandBits;
diff --git a/lib/std/special/compiler_rt/divsf3.zig b/lib/std/special/compiler_rt/divsf3.zig
index e51f94e19d..0cb149a610 100644
--- a/lib/std/special/compiler_rt/divsf3.zig
+++ b/lib/std/special/compiler_rt/divsf3.zig
@@ -7,7 +7,7 @@ const builtin = @import("builtin");
pub fn __divsf3(a: f32, b: f32) callconv(.C) f32 {
@setRuntimeSafety(builtin.is_test);
- const Z = @IntType(false, f32.bit_count);
+ const Z = std.meta.IntType(false, f32.bit_count);
const typeWidth = f32.bit_count;
const significandBits = std.math.floatMantissaBits(f32);
@@ -185,9 +185,9 @@ pub fn __divsf3(a: f32, b: f32) callconv(.C) f32 {
}
}
-fn normalize(comptime T: type, significand: *@IntType(false, T.bit_count)) i32 {
+fn normalize(comptime T: type, significand: *std.meta.IntType(false, T.bit_count)) i32 {
@setRuntimeSafety(builtin.is_test);
- const Z = @IntType(false, T.bit_count);
+ const Z = std.meta.IntType(false, T.bit_count);
const significandBits = std.math.floatMantissaBits(T);
const implicitBit = @as(Z, 1) << significandBits;
diff --git a/lib/std/special/compiler_rt/extendXfYf2.zig b/lib/std/special/compiler_rt/extendXfYf2.zig
index 4e63d93ac5..58da88e586 100644
--- a/lib/std/special/compiler_rt/extendXfYf2.zig
+++ b/lib/std/special/compiler_rt/extendXfYf2.zig
@@ -30,11 +30,11 @@ pub fn __aeabi_f2d(arg: f32) callconv(.AAPCS) f64 {
const CHAR_BIT = 8;
-fn extendXfYf2(comptime dst_t: type, comptime src_t: type, a: @IntType(false, @typeInfo(src_t).Float.bits)) dst_t {
+fn extendXfYf2(comptime dst_t: type, comptime src_t: type, a: std.meta.IntType(false, @typeInfo(src_t).Float.bits)) dst_t {
@setRuntimeSafety(builtin.is_test);
- const src_rep_t = @IntType(false, @typeInfo(src_t).Float.bits);
- const dst_rep_t = @IntType(false, @typeInfo(dst_t).Float.bits);
+ const src_rep_t = std.meta.IntType(false, @typeInfo(src_t).Float.bits);
+ const dst_rep_t = std.meta.IntType(false, @typeInfo(dst_t).Float.bits);
const srcSigBits = std.math.floatMantissaBits(src_t);
const dstSigBits = std.math.floatMantissaBits(dst_t);
const SrcShift = std.math.Log2Int(src_rep_t);
diff --git a/lib/std/special/compiler_rt/fixint.zig b/lib/std/special/compiler_rt/fixint.zig
index 426ee1d58a..3a401c1e6a 100644
--- a/lib/std/special/compiler_rt/fixint.zig
+++ b/lib/std/special/compiler_rt/fixint.zig
@@ -45,7 +45,7 @@ pub fn fixint(comptime fp_t: type, comptime fixint_t: type, a: fp_t) fixint_t {
if (exponent < 0) return 0;
// The unsigned result needs to be large enough to handle an fixint_t or rep_t
- const fixuint_t = @IntType(false, fixint_t.bit_count);
+ const fixuint_t = std.meta.IntType(false, fixint_t.bit_count);
const UintResultType = if (fixint_t.bit_count > rep_t.bit_count) fixuint_t else rep_t;
var uint_result: UintResultType = undefined;
diff --git a/lib/std/special/compiler_rt/fixuint.zig b/lib/std/special/compiler_rt/fixuint.zig
index 977d3c16c9..d8e3e9a0e0 100644
--- a/lib/std/special/compiler_rt/fixuint.zig
+++ b/lib/std/special/compiler_rt/fixuint.zig
@@ -10,7 +10,7 @@ pub fn fixuint(comptime fp_t: type, comptime fixuint_t: type, a: fp_t) fixuint_t
f128 => u128,
else => unreachable,
};
- const srep_t = @IntType(true, rep_t.bit_count);
+ const srep_t = @import("std").meta.IntType(true, rep_t.bit_count);
const significandBits = switch (fp_t) {
f32 => 23,
f64 => 52,
diff --git a/lib/std/special/compiler_rt/floatsiXf.zig b/lib/std/special/compiler_rt/floatsiXf.zig
index ef3aba34d4..550a7ec246 100644
--- a/lib/std/special/compiler_rt/floatsiXf.zig
+++ b/lib/std/special/compiler_rt/floatsiXf.zig
@@ -5,8 +5,8 @@ const maxInt = std.math.maxInt;
fn floatsiXf(comptime T: type, a: i32) T {
@setRuntimeSafety(builtin.is_test);
- const Z = @IntType(false, T.bit_count);
- const S = @IntType(false, T.bit_count - @clz(Z, @as(Z, T.bit_count) - 1));
+ const Z = std.meta.IntType(false, T.bit_count);
+ const S = std.meta.IntType(false, T.bit_count - @clz(Z, @as(Z, T.bit_count) - 1));
if (a == 0) {
return @as(T, 0.0);
diff --git a/lib/std/special/compiler_rt/mulXf3.zig b/lib/std/special/compiler_rt/mulXf3.zig
index 103692f610..a40c0f1e70 100644
--- a/lib/std/special/compiler_rt/mulXf3.zig
+++ b/lib/std/special/compiler_rt/mulXf3.zig
@@ -28,7 +28,7 @@ pub fn __aeabi_dmul(a: f64, b: f64) callconv(.C) f64 {
fn mulXf3(comptime T: type, a: T, b: T) T {
@setRuntimeSafety(builtin.is_test);
- const Z = @IntType(false, T.bit_count);
+ const Z = std.meta.IntType(false, T.bit_count);
const typeWidth = T.bit_count;
const significandBits = std.math.floatMantissaBits(T);
@@ -264,9 +264,9 @@ fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void {
}
}
-fn normalize(comptime T: type, significand: *@IntType(false, T.bit_count)) i32 {
+fn normalize(comptime T: type, significand: *std.meta.IntType(false, T.bit_count)) i32 {
@setRuntimeSafety(builtin.is_test);
- const Z = @IntType(false, T.bit_count);
+ const Z = std.meta.IntType(false, T.bit_count);
const significandBits = std.math.floatMantissaBits(T);
const implicitBit = @as(Z, 1) << significandBits;
diff --git a/lib/std/special/compiler_rt/negXf2.zig b/lib/std/special/compiler_rt/negXf2.zig
index c41b1b48d7..d1038d6456 100644
--- a/lib/std/special/compiler_rt/negXf2.zig
+++ b/lib/std/special/compiler_rt/negXf2.zig
@@ -19,7 +19,7 @@ pub fn __aeabi_dneg(arg: f64) callconv(.AAPCS) f64 {
}
fn negXf2(comptime T: type, a: T) T {
- const Z = @IntType(false, T.bit_count);
+ const Z = std.meta.IntType(false, T.bit_count);
const typeWidth = T.bit_count;
const significandBits = std.math.floatMantissaBits(T);
diff --git a/lib/std/special/compiler_rt/truncXfYf2.zig b/lib/std/special/compiler_rt/truncXfYf2.zig
index 0a09dea84c..7c83c66ec0 100644
--- a/lib/std/special/compiler_rt/truncXfYf2.zig
+++ b/lib/std/special/compiler_rt/truncXfYf2.zig
@@ -36,8 +36,8 @@ pub fn __aeabi_f2h(a: f32) callconv(.AAPCS) u16 {
}
inline fn truncXfYf2(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t {
- const src_rep_t = @IntType(false, @typeInfo(src_t).Float.bits);
- const dst_rep_t = @IntType(false, @typeInfo(dst_t).Float.bits);
+ const src_rep_t = std.meta.IntType(false, @typeInfo(src_t).Float.bits);
+ const dst_rep_t = std.meta.IntType(false, @typeInfo(dst_t).Float.bits);
const srcSigBits = std.math.floatMantissaBits(src_t);
const dstSigBits = std.math.floatMantissaBits(dst_t);
const SrcShift = std.math.Log2Int(src_rep_t);
diff --git a/lib/std/special/compiler_rt/udivmod.zig b/lib/std/special/compiler_rt/udivmod.zig
index 96fb7b3bdd..1cf2589b16 100644
--- a/lib/std/special/compiler_rt/udivmod.zig
+++ b/lib/std/special/compiler_rt/udivmod.zig
@@ -10,8 +10,8 @@ const high = 1 - low;
pub fn udivmod(comptime DoubleInt: type, a: DoubleInt, b: DoubleInt, maybe_rem: ?*DoubleInt) DoubleInt {
@setRuntimeSafety(is_test);
- const SingleInt = @IntType(false, @divExact(DoubleInt.bit_count, 2));
- const SignedDoubleInt = @IntType(true, DoubleInt.bit_count);
+ const SingleInt = @import("std").meta.IntType(false, @divExact(DoubleInt.bit_count, 2));
+ const SignedDoubleInt = @import("std").meta.IntType(true, DoubleInt.bit_count);
const Log2SingleInt = @import("std").math.Log2Int(SingleInt);
const n = @ptrCast(*const [2]SingleInt, &a).*; // TODO issue #421
diff --git a/lib/std/target.zig b/lib/std/target.zig
index 83d3dafbc2..cf83bb1f7a 100644
--- a/lib/std/target.zig
+++ b/lib/std/target.zig
@@ -222,7 +222,7 @@ pub const Target = union(enum) {
pub const needed_bit_count = 154;
pub const byte_count = (needed_bit_count + 7) / 8;
pub const usize_count = (byte_count + (@sizeOf(usize) - 1)) / @sizeOf(usize);
- pub const Index = std.math.Log2Int(@IntType(false, usize_count * @bitSizeOf(usize)));
+ pub const Index = std.math.Log2Int(std.meta.IntType(false, usize_count * @bitSizeOf(usize)));
pub const ShiftInt = std.math.Log2Int(usize);
pub const empty = Set{ .ints = [1]usize{0} ** usize_count };
diff --git a/lib/std/thread.zig b/lib/std/thread.zig
index c482405c44..fcc71ae5a5 100644
--- a/lib/std/thread.zig
+++ b/lib/std/thread.zig
@@ -148,7 +148,7 @@ pub const Thread = struct {
const default_stack_size = 16 * 1024 * 1024;
const Context = @TypeOf(context);
- comptime assert(@ArgType(@TypeOf(startFn), 0) == Context);
+ comptime assert(@typeInfo(@TypeOf(startFn)).Fn.args[0].arg_type.? == Context);
if (builtin.os == builtin.Os.windows) {
const WinThread = struct {
@@ -158,7 +158,7 @@ pub const Thread = struct {
};
fn threadMain(raw_arg: windows.LPVOID) callconv(.C) windows.DWORD {
const arg = if (@sizeOf(Context) == 0) {} else @ptrCast(*Context, @alignCast(@alignOf(Context), raw_arg)).*;
- switch (@typeId(@TypeOf(startFn).ReturnType)) {
+ switch (@typeInfo(@TypeOf(startFn).ReturnType)) {
.Int => {
return startFn(arg);
},
@@ -201,7 +201,7 @@ pub const Thread = struct {
fn linuxThreadMain(ctx_addr: usize) callconv(.C) u8 {
const arg = if (@sizeOf(Context) == 0) {} else @intToPtr(*const Context, ctx_addr).*;
- switch (@typeId(@TypeOf(startFn).ReturnType)) {
+ switch (@typeInfo(@TypeOf(startFn).ReturnType)) {
.Int => {
return startFn(arg);
},
diff --git a/lib/std/zig/ast.zig b/lib/std/zig/ast.zig
index f96428a6bc..bc4f6350d6 100644
--- a/lib/std/zig/ast.zig
+++ b/lib/std/zig/ast.zig
@@ -457,10 +457,9 @@ pub const Node = struct {
}
pub fn iterate(base: *Node, index: usize) ?*Node {
- comptime var i = 0;
- inline while (i < @memberCount(Id)) : (i += 1) {
- if (base.id == @field(Id, @memberName(Id, i))) {
- const T = @field(Node, @memberName(Id, i));
+ inline for (@typeInfo(Id).Enum.fields) |f| {
+ if (base.id == @field(Id, f.name)) {
+ const T = @field(Node, f.name);
return @fieldParentPtr(T, "base", base).iterate(index);
}
}
@@ -468,10 +467,9 @@ pub const Node = struct {
}
pub fn firstToken(base: *const Node) TokenIndex {
- comptime var i = 0;
- inline while (i < @memberCount(Id)) : (i += 1) {
- if (base.id == @field(Id, @memberName(Id, i))) {
- const T = @field(Node, @memberName(Id, i));
+ inline for (@typeInfo(Id).Enum.fields) |f| {
+ if (base.id == @field(Id, f.name)) {
+ const T = @field(Node, f.name);
return @fieldParentPtr(T, "base", base).firstToken();
}
}
@@ -479,10 +477,9 @@ pub const Node = struct {
}
pub fn lastToken(base: *const Node) TokenIndex {
- comptime var i = 0;
- inline while (i < @memberCount(Id)) : (i += 1) {
- if (base.id == @field(Id, @memberName(Id, i))) {
- const T = @field(Node, @memberName(Id, i));
+ inline for (@typeInfo(Id).Enum.fields) |f| {
+ if (base.id == @field(Id, f.name)) {
+ const T = @field(Node, f.name);
return @fieldParentPtr(T, "base", base).lastToken();
}
}
@@ -490,10 +487,9 @@ pub const Node = struct {
}
pub fn typeToId(comptime T: type) Id {
- comptime var i = 0;
- inline while (i < @memberCount(Id)) : (i += 1) {
- if (T == @field(Node, @memberName(Id, i))) {
- return @field(Id, @memberName(Id, i));
+ inline for (@typeInfo(Id).Enum.fields) |f| {
+ if (T == @field(Node, f.name)) {
+ return @field(Id, f.name);
}
}
unreachable;
diff --git a/lib/std/zig/parser_test.zig b/lib/std/zig/parser_test.zig
index 5f28dd3b06..9a023bb525 100644
--- a/lib/std/zig/parser_test.zig
+++ b/lib/std/zig/parser_test.zig
@@ -1410,7 +1410,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(@typeId(T) == builtin.TypeId.Int); // must pass an integer to absInt
+ \\ comptime assert(@typeInfo(T) == .Int); // must pass an integer to absInt
\\}
\\
);
diff --git a/lib/std/zig/render.zig b/lib/std/zig/render.zig
index 069635d42e..ee6ee37d5d 100644
--- a/lib/std/zig/render.zig
+++ b/lib/std/zig/render.zig
@@ -1,5 +1,4 @@
const std = @import("../std.zig");
-const builtin = @import("builtin");
const assert = std.debug.assert;
const mem = std.mem;
const ast = std.zig.ast;
@@ -14,7 +13,7 @@ pub const Error = error{
/// Returns whether anything changed
pub fn render(allocator: *mem.Allocator, stream: var, tree: *ast.Tree) (@TypeOf(stream).Child.Error || Error)!bool {
- comptime assert(@typeId(@TypeOf(stream)) == builtin.TypeId.Pointer);
+ comptime assert(@typeInfo(@TypeOf(stream)) == .Pointer);
var anything_changed: bool = false;
diff --git a/src-self-hosted/ir.zig b/src-self-hosted/ir.zig
index a8f4980fa8..576294a7d7 100644
--- a/src-self-hosted/ir.zig
+++ b/src-self-hosted/ir.zig
@@ -76,20 +76,18 @@ pub const Inst = struct {
}
pub fn typeToId(comptime T: type) Id {
- comptime var i = 0;
- inline while (i < @memberCount(Id)) : (i += 1) {
- if (T == @field(Inst, @memberName(Id, i))) {
- return @field(Id, @memberName(Id, i));
+ inline for (@typeInfo(Id).Enum.fields) |f| {
+ if (T == @field(Inst, f.name)) {
+ return @field(Id, f.name);
}
}
unreachable;
}
pub fn dump(base: *const Inst) void {
- comptime var i = 0;
- inline while (i < @memberCount(Id)) : (i += 1) {
- if (base.id == @field(Id, @memberName(Id, i))) {
- const T = @field(Inst, @memberName(Id, i));
+ inline for (@typeInfo(Id).Enum.fields) |f| {
+ if (base.id == @field(Id, f.name)) {
+ const T = @field(Inst, f.name);
std.debug.warn("#{} = {}(", .{ base.debug_id, @tagName(base.id) });
@fieldParentPtr(T, "base", base).dump();
std.debug.warn(")", .{});
@@ -100,10 +98,9 @@ pub const Inst = struct {
}
pub fn hasSideEffects(base: *const Inst) bool {
- comptime var i = 0;
- inline while (i < @memberCount(Id)) : (i += 1) {
- if (base.id == @field(Id, @memberName(Id, i))) {
- const T = @field(Inst, @memberName(Id, i));
+ inline for (@typeInfo(Id).Enum.fields) |f| {
+ if (base.id == @field(Id, f.name)) {
+ const T = @field(Inst, f.name);
return @fieldParentPtr(T, "base", base).hasSideEffects();
}
}
@@ -1805,21 +1802,19 @@ pub const Builder = struct {
};
// Look at the params and ref() other instructions
- comptime var i = 0;
- inline while (i < @memberCount(I.Params)) : (i += 1) {
- const FieldType = comptime @TypeOf(@field(@as(I.Params, undefined), @memberName(I.Params, i)));
- switch (FieldType) {
- *Inst => @field(inst.params, @memberName(I.Params, i)).ref(self),
- *BasicBlock => @field(inst.params, @memberName(I.Params, i)).ref(self),
- ?*Inst => if (@field(inst.params, @memberName(I.Params, i))) |other| other.ref(self),
+ inline for (@typeInfo(I.Params).Struct.fields) |f| {
+ switch (f.fiedl_type) {
+ *Inst => @field(inst.params, f.name).ref(self),
+ *BasicBlock => @field(inst.params, f.name).ref(self),
+ ?*Inst => if (@field(inst.params, f.name)) |other| other.ref(self),
[]*Inst => {
// TODO https://github.com/ziglang/zig/issues/1269
- for (@field(inst.params, @memberName(I.Params, i))) |other|
+ for (@field(inst.params, f.name)) |other|
other.ref(self);
},
[]*BasicBlock => {
// TODO https://github.com/ziglang/zig/issues/1269
- for (@field(inst.params, @memberName(I.Params, i))) |other|
+ for (@field(inst.params, f.name)) |other|
other.ref(self);
},
Type.Pointer.Mut,
@@ -1831,7 +1826,7 @@ pub const Builder = struct {
=> {},
// it's ok to add more types here, just make sure that
// any instructions and basic blocks are ref'd appropriately
- else => @compileError("unrecognized type in Params: " ++ @typeName(FieldType)),
+ else => @compileError("unrecognized type in Params: " ++ @typeName(f.field_type)),
}
}
diff --git a/src-self-hosted/translate_c.zig b/src-self-hosted/translate_c.zig
index cd8d0b9d63..b33c758c38 100644
--- a/src-self-hosted/translate_c.zig
+++ b/src-self-hosted/translate_c.zig
@@ -5381,15 +5381,15 @@ fn parseCPrimaryExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8,
return error.ParseError;
}
- //if (@typeId(@TypeOf(x)) == .Pointer)
+ //if (@typeInfo(@TypeOf(x)) == .Pointer)
// @ptrCast(dest, x)
- //else if (@typeId(@TypeOf(x)) == .Integer)
+ //else if (@typeInfo(@TypeOf(x)) == .Integer)
// @intToPtr(dest, x)
//else
// @as(dest, x)
const if_1 = try transCreateNodeIf(c);
- const type_id_1 = try transCreateNodeBuiltinFnCall(c, "@typeId");
+ const type_id_1 = try transCreateNodeBuiltinFnCall(c, "@typeInfo");
const type_of_1 = try transCreateNodeBuiltinFnCall(c, "@TypeOf");
try type_id_1.params.push(&type_of_1.base);
try type_of_1.params.push(node_to_cast);
@@ -5416,7 +5416,7 @@ fn parseCPrimaryExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8,
if_1.@"else" = else_1;
const if_2 = try transCreateNodeIf(c);
- const type_id_2 = try transCreateNodeBuiltinFnCall(c, "@typeId");
+ const type_id_2 = try transCreateNodeBuiltinFnCall(c, "@typeInfo");
const type_of_2 = try transCreateNodeBuiltinFnCall(c, "@TypeOf");
try type_id_2.params.push(&type_of_2.base);
try type_of_2.params.push(node_to_cast);
diff --git a/src-self-hosted/type.zig b/src-self-hosted/type.zig
index 67e1aebdca..70ed754cea 100644
--- a/src-self-hosted/type.zig
+++ b/src-self-hosted/type.zig
@@ -1042,7 +1042,7 @@ fn hashAny(x: var, comptime seed: u64) u32 {
switch (@typeInfo(@TypeOf(x))) {
.Int => |info| {
comptime var rng = comptime std.rand.DefaultPrng.init(seed);
- const unsigned_x = @bitCast(@IntType(false, info.bits), x);
+ const unsigned_x = @bitCast(std.meta.IntType(false, info.bits), x);
if (info.bits <= 32) {
return @as(u32, unsigned_x) *% comptime rng.random.scalar(u32);
} else {
diff --git a/src/all_types.hpp b/src/all_types.hpp
index 117a0004f0..022a34038e 100644
--- a/src/all_types.hpp
+++ b/src/all_types.hpp
@@ -1695,9 +1695,6 @@ enum BuiltinFnId {
BuiltinFnIdMemset,
BuiltinFnIdSizeof,
BuiltinFnIdAlignOf,
- BuiltinFnIdMemberCount,
- BuiltinFnIdMemberType,
- BuiltinFnIdMemberName,
BuiltinFnIdField,
BuiltinFnIdTypeInfo,
BuiltinFnIdType,
@@ -1757,7 +1754,6 @@ enum BuiltinFnId {
BuiltinFnIdIntToErr,
BuiltinFnIdEnumToInt,
BuiltinFnIdIntToEnum,
- BuiltinFnIdIntType,
BuiltinFnIdVectorType,
BuiltinFnIdShuffle,
BuiltinFnIdSplat,
@@ -1777,7 +1773,6 @@ enum BuiltinFnId {
BuiltinFnIdBitOffsetOf,
BuiltinFnIdNewStackCall,
BuiltinFnIdAsyncCall,
- BuiltinFnIdTypeId,
BuiltinFnIdShlExact,
BuiltinFnIdShrExact,
BuiltinFnIdSetEvalBranchQuota,
@@ -1785,7 +1780,6 @@ enum BuiltinFnId {
BuiltinFnIdOpaqueType,
BuiltinFnIdThis,
BuiltinFnIdSetAlignStack,
- BuiltinFnIdArgType,
BuiltinFnIdExport,
BuiltinFnIdErrorReturnTrace,
BuiltinFnIdAtomicRmw,
@@ -2630,7 +2624,6 @@ enum IrInstSrcId {
IrInstSrcIdIntToFloat,
IrInstSrcIdFloatToInt,
IrInstSrcIdBoolToInt,
- IrInstSrcIdIntType,
IrInstSrcIdVectorType,
IrInstSrcIdShuffleVector,
IrInstSrcIdSplat,
@@ -2638,9 +2631,6 @@ enum IrInstSrcId {
IrInstSrcIdMemset,
IrInstSrcIdMemcpy,
IrInstSrcIdSlice,
- IrInstSrcIdMemberCount,
- IrInstSrcIdMemberType,
- IrInstSrcIdMemberName,
IrInstSrcIdBreakpoint,
IrInstSrcIdReturnAddress,
IrInstSrcIdFrameAddress,
@@ -2677,7 +2667,6 @@ enum IrInstSrcId {
IrInstSrcIdTypeInfo,
IrInstSrcIdType,
IrInstSrcIdHasField,
- IrInstSrcIdTypeId,
IrInstSrcIdSetEvalBranchQuota,
IrInstSrcIdPtrType,
IrInstSrcIdAlignCast,
@@ -3636,13 +3625,6 @@ struct IrInstSrcBoolToInt {
IrInstSrc *target;
};
-struct IrInstSrcIntType {
- IrInstSrc base;
-
- IrInstSrc *is_signed;
- IrInstSrc *bit_count;
-};
-
struct IrInstSrcVectorType {
IrInstSrc base;
@@ -3715,26 +3697,6 @@ struct IrInstGenSlice {
bool safety_check_on;
};
-struct IrInstSrcMemberCount {
- IrInstSrc base;
-
- IrInstSrc *container;
-};
-
-struct IrInstSrcMemberType {
- IrInstSrc base;
-
- IrInstSrc *container_type;
- IrInstSrc *member_index;
-};
-
-struct IrInstSrcMemberName {
- IrInstSrc base;
-
- IrInstSrc *container_type;
- IrInstSrc *member_index;
-};
-
struct IrInstSrcBreakpoint {
IrInstSrc base;
};
@@ -4142,12 +4104,6 @@ struct IrInstSrcHasField {
IrInstSrc *field_name;
};
-struct IrInstSrcTypeId {
- IrInstSrc base;
-
- IrInstSrc *type_value;
-};
-
struct IrInstSrcSetEvalBranchQuota {
IrInstSrc base;
diff --git a/src/codegen.cpp b/src/codegen.cpp
index 12293cd9b3..f9d2566da7 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -8152,9 +8152,6 @@ static void define_builtin_fns(CodeGen *g) {
create_builtin_fn(g, BuiltinFnIdMemset, "memset", 3);
create_builtin_fn(g, BuiltinFnIdSizeof, "sizeOf", 1);
create_builtin_fn(g, BuiltinFnIdAlignOf, "alignOf", 1);
- create_builtin_fn(g, BuiltinFnIdMemberCount, "memberCount", 1);
- create_builtin_fn(g, BuiltinFnIdMemberType, "memberType", 2);
- create_builtin_fn(g, BuiltinFnIdMemberName, "memberName", 2);
create_builtin_fn(g, BuiltinFnIdField, "field", 2);
create_builtin_fn(g, BuiltinFnIdTypeInfo, "typeInfo", 1);
create_builtin_fn(g, BuiltinFnIdType, "Type", 1);
@@ -8192,7 +8189,6 @@ static void define_builtin_fns(CodeGen *g) {
create_builtin_fn(g, BuiltinFnIdIntToEnum, "intToEnum", 2);
create_builtin_fn(g, BuiltinFnIdCompileErr, "compileError", 1);
create_builtin_fn(g, BuiltinFnIdCompileLog, "compileLog", SIZE_MAX);
- create_builtin_fn(g, BuiltinFnIdIntType, "IntType", 2); // TODO rename to Int
create_builtin_fn(g, BuiltinFnIdVectorType, "Vector", 2);
create_builtin_fn(g, BuiltinFnIdShuffle, "shuffle", 4);
create_builtin_fn(g, BuiltinFnIdSplat, "splat", 2);
@@ -8231,14 +8227,12 @@ static void define_builtin_fns(CodeGen *g) {
create_builtin_fn(g, BuiltinFnIdMulAdd, "mulAdd", 4);
create_builtin_fn(g, BuiltinFnIdNewStackCall, "newStackCall", SIZE_MAX);
create_builtin_fn(g, BuiltinFnIdAsyncCall, "asyncCall", SIZE_MAX);
- create_builtin_fn(g, BuiltinFnIdTypeId, "typeId", 1);
create_builtin_fn(g, BuiltinFnIdShlExact, "shlExact", 2);
create_builtin_fn(g, BuiltinFnIdShrExact, "shrExact", 2);
create_builtin_fn(g, BuiltinFnIdSetEvalBranchQuota, "setEvalBranchQuota", 1);
create_builtin_fn(g, BuiltinFnIdAlignCast, "alignCast", 2);
create_builtin_fn(g, BuiltinFnIdOpaqueType, "OpaqueType", 0);
create_builtin_fn(g, BuiltinFnIdSetAlignStack, "setAlignStack", 1);
- create_builtin_fn(g, BuiltinFnIdArgType, "ArgType", 2);
create_builtin_fn(g, BuiltinFnIdExport, "export", 2);
create_builtin_fn(g, BuiltinFnIdErrorReturnTrace, "errorReturnTrace", 0);
create_builtin_fn(g, BuiltinFnIdAtomicRmw, "atomicRmw", 5);
diff --git a/src/ir.cpp b/src/ir.cpp
index 80fef04496..80b8c93abd 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -389,8 +389,6 @@ static void destroy_instruction_src(IrInstSrc *inst) {
return heap::c_allocator.destroy(reinterpret_cast