zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit cd23f7a814bf81b3c06f4d016bcb006520a3158e (tree)
parent 3d56df1716601440f580df3eee7e12bea44d919b
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Wed,  6 May 2026 19:35:40 +0200

Merge pull request 'std.meta: Remove Int/Tuple in favor of @Int/@Tuple' (#35188) from linus/zig:deprecated-std-meta into master

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/35188
Reviewed-by: Andrew Kelley <andrew@ziglang.org>

Diffstat:
Mlib/compiler/resinator/errors.zig | 14+++++++-------
Mlib/compiler_rt.zig | 8++++----
Mlib/compiler_rt/addf3.zig | 2+-
Mlib/compiler_rt/comparef.zig | 6+++---
Mlib/compiler_rt/count0bits.zig | 2+-
Mlib/compiler_rt/divdf3.zig | 4++--
Mlib/compiler_rt/divsf3.zig | 2+-
Mlib/compiler_rt/divtf3.zig | 2+-
Mlib/compiler_rt/divxf3.zig | 2+-
Mlib/compiler_rt/extendf.zig | 10+++++-----
Mlib/compiler_rt/fabs.zig | 2+-
Mlib/compiler_rt/float_from_int.zig | 7+++----
Mlib/compiler_rt/fmax.zig | 2+-
Mlib/compiler_rt/fmin.zig | 2+-
Mlib/compiler_rt/fmod.zig | 4++--
Mlib/compiler_rt/mulf3.zig | 4++--
Mlib/compiler_rt/truncf.zig | 6+++---
Mlib/std/Build/abi.zig | 2+-
Mlib/std/Io/Threaded.zig | 2+-
Mlib/std/Io/Writer.zig | 4++--
Mlib/std/Random.zig | 12++++++------
Mlib/std/Target.zig | 2+-
Mlib/std/bit_set.zig | 6+++---
Mlib/std/c.zig | 10+++++-----
Mlib/std/compress/zstd/Decompress.zig | 10+++++-----
Mlib/std/crypto/aes_ccm.zig | 4++--
Mlib/std/crypto/cmac.zig | 2+-
Mlib/std/crypto/codecs/asn1/der/Encoder.zig | 2+-
Mlib/std/crypto/ff.zig | 5++---
Mlib/std/crypto/keccak_p.zig | 2+-
Mlib/std/crypto/ml_dsa.zig | 12++++++------
Mlib/std/crypto/ml_kem.zig | 12++++++------
Mlib/std/crypto/modes.zig | 2+-
Mlib/std/crypto/pcurves/common.zig | 9++++-----
Mlib/std/crypto/timing_safe.zig | 10+++++-----
Mlib/std/enums.zig | 10+++++-----
Mlib/std/fmt.zig | 2+-
Mlib/std/fmt/parse_float.zig | 2+-
Mlib/std/hash/wyhash.zig | 2+-
Mlib/std/heap/debug_allocator.zig | 2+-
Mlib/std/json/static_test.zig | 4++--
Mlib/std/leb128.zig | 4++--
Mlib/std/math.zig | 16++++++++--------
Mlib/std/math/big.zig | 8++++----
Mlib/std/math/big/int.zig | 4++--
Mlib/std/math/big/int_test.zig | 4++--
Mlib/std/math/copysign.zig | 2+-
Mlib/std/math/frexp.zig | 8++++----
Mlib/std/math/ilogb.zig | 2+-
Mlib/std/math/isfinite.zig | 2+-
Mlib/std/math/isinf.zig | 2+-
Mlib/std/math/isnan.zig | 3+--
Mlib/std/math/isnormal.zig | 4++--
Mlib/std/math/iszero.zig | 4++--
Mlib/std/math/ldexp.zig | 4++--
Mlib/std/math/nextafter.zig | 4++--
Mlib/std/math/pow.zig | 2+-
Mlib/std/mem.zig | 40++++++++++++++++++++--------------------
Mlib/std/meta.zig | 38+++-----------------------------------
Mlib/std/meta/trailer_flags.zig | 2+-
Mlib/std/os/emscripten.zig | 2+-
Mlib/std/os/linux.zig | 2+-
Mlib/std/os/linux/ioctl.zig | 4++--
Mlib/std/os/uefi/tables/runtime_services.zig | 2+-
Mlib/std/posix.zig | 2+-
Mlib/std/testing.zig | 2+-
Mlib/std/zig/llvm/Builder.zig | 6+++---
Mlib/std/zig/llvm/bitcode_writer.zig | 6+++---
Mlib/std/zig/llvm/ir.zig | 16++++++++--------
Msrc/Air/Liveness.zig | 2+-
Msrc/InternPool.zig | 4++--
Msrc/codegen/c.zig | 2+-
Msrc/codegen/riscv64/bits.zig | 2+-
Msrc/codegen/spirv/Assembler.zig | 2+-
Msrc/codegen/spirv/Section.zig | 2+-
Mtest/behavior/abs.zig | 2+-
Mtest/behavior/atomics.zig | 6+++---
Mtest/behavior/bit_shifting.zig | 4++--
Mtest/behavior/bitcast.zig | 14+++++++-------
Mtest/behavior/math.zig | 2+-
Mtest/behavior/tuple.zig | 8++++----
81 files changed, 209 insertions(+), 245 deletions(-)

diff --git a/lib/compiler/resinator/errors.zig b/lib/compiler/resinator/errors.zig @@ -43,7 +43,7 @@ pub const Diagnostics = struct { try self.errors.append(self.allocator, error_details); } - const SmallestStringIndexType = std.meta.Int(.unsigned, @min( + const SmallestStringIndexType = @Int(.unsigned, @min( @bitSizeOf(ErrorDetails.FileOpenError.FilenameStringIndex), @min( @bitSizeOf(ErrorDetails.IconReadError.FilenameStringIndex), @@ -165,7 +165,7 @@ pub const ErrorDetails = struct { err: FileOpenErrorEnum, filename_string_index: FilenameStringIndex, - pub const FilenameStringIndex = std.meta.Int(.unsigned, 32 - @bitSizeOf(FileOpenErrorEnum)); + pub const FilenameStringIndex = @Int(.unsigned, 32 - @bitSizeOf(FileOpenErrorEnum)); pub const FileOpenErrorEnum = std.meta.FieldEnum(Io.File.OpenError || Io.File.StatError); pub fn enumFromError(err: (Io.File.OpenError || Io.File.StatError)) FileOpenErrorEnum { @@ -180,7 +180,7 @@ pub const ErrorDetails = struct { icon_type: enum(u1) { cursor, icon }, filename_string_index: FilenameStringIndex, - pub const FilenameStringIndex = std.meta.Int(.unsigned, 32 - @bitSizeOf(IconReadErrorEnum) - 1); + pub const FilenameStringIndex = @Int(.unsigned, 32 - @bitSizeOf(IconReadErrorEnum) - 1); pub const IconReadErrorEnum = std.meta.FieldEnum(ico.ReadError); pub fn enumFromError(err: ico.ReadError) IconReadErrorEnum { @@ -197,14 +197,14 @@ pub const ErrorDetails = struct { bitmap_version: ico.BitmapHeader.Version = .unknown, _: Padding = 0, - pub const Padding = std.meta.Int(.unsigned, 15 - @bitSizeOf(ico.BitmapHeader.Version) - @bitSizeOf(ico.ImageFormat)); + pub const Padding = @Int(.unsigned, 15 - @bitSizeOf(ico.BitmapHeader.Version) - @bitSizeOf(ico.ImageFormat)); }; pub const BitmapReadError = packed struct(u32) { err: BitmapReadErrorEnum, filename_string_index: FilenameStringIndex, - pub const FilenameStringIndex = std.meta.Int(.unsigned, 32 - @bitSizeOf(BitmapReadErrorEnum)); + pub const FilenameStringIndex = @Int(.unsigned, 32 - @bitSizeOf(BitmapReadErrorEnum)); pub const BitmapReadErrorEnum = std.meta.FieldEnum(bmp.ReadError); pub fn enumFromError(err: bmp.ReadError) BitmapReadErrorEnum { @@ -218,14 +218,14 @@ pub const ErrorDetails = struct { dib_version: ico.BitmapHeader.Version, filename_string_index: FilenameStringIndex, - pub const FilenameStringIndex = std.meta.Int(.unsigned, 32 - @bitSizeOf(ico.BitmapHeader.Version)); + pub const FilenameStringIndex = @Int(.unsigned, 32 - @bitSizeOf(ico.BitmapHeader.Version)); }; pub const AcceleratorError = packed struct(u32) { err: AcceleratorErrorEnum, _: Padding = 0, - pub const Padding = std.meta.Int(.unsigned, 32 - @bitSizeOf(AcceleratorErrorEnum)); + pub const Padding = @Int(.unsigned, 32 - @bitSizeOf(AcceleratorErrorEnum)); pub const AcceleratorErrorEnum = std.meta.FieldEnum(res.ParseAcceleratorKeyStringError); pub fn enumFromError(err: res.ParseAcceleratorKeyStringError) AcceleratorErrorEnum { diff --git a/lib/compiler_rt.zig b/lib/compiler_rt.zig @@ -574,8 +574,8 @@ pub fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void { } } -pub fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeInfo(T).float.bits)) i32 { - const Z = std.meta.Int(.unsigned, @typeInfo(T).float.bits); +pub fn normalize(comptime T: type, significand: *@Int(.unsigned, @typeInfo(T).float.bits)) i32 { + const Z = @Int(.unsigned, @typeInfo(T).float.bits); const integerBit = @as(Z, 1) << std.math.floatFractionalBits(T); const shift = @clz(significand.*) - @clz(integerBit); @@ -625,8 +625,8 @@ fn __aeabi_fneg(a: f32) callconv(.{ .arm_aapcs = .{} }) f32 { pub fn HalveInt(comptime T: type, comptime signed_half: bool) type { return extern union { pub const bits = @divExact(@typeInfo(T).int.bits, 2); - pub const HalfTU = std.meta.Int(.unsigned, bits); - pub const HalfTS = std.meta.Int(.signed, bits); + pub const HalfTU = @Int(.unsigned, bits); + pub const HalfTS = @Int(.signed, bits); pub const HalfT = if (signed_half) HalfTS else HalfTU; all: T, diff --git a/lib/compiler_rt/addf3.zig b/lib/compiler_rt/addf3.zig @@ -8,7 +8,7 @@ const normalize = compiler_rt.normalize; /// https://github.com/llvm/llvm-project/blob/02d85149a05cb1f6dc49f0ba7a2ceca53718ae17/compiler-rt/lib/builtins/fp_add_impl.inc pub inline fn addf3(comptime T: type, a: T, b: T) T { const bits = @typeInfo(T).float.bits; - const Z = std.meta.Int(.unsigned, bits); + const Z = @Int(.unsigned, bits); const typeWidth = bits; const significandBits = math.floatMantissaBits(T); diff --git a/lib/compiler_rt/comparef.zig b/lib/compiler_rt/comparef.zig @@ -162,8 +162,8 @@ pub const GE = enum(i32) { pub inline fn cmpf2(comptime T: type, comptime RT: type, a: T, b: T) RT { const bits = @typeInfo(T).float.bits; - const srep_t = std.meta.Int(.signed, bits); - const rep_t = std.meta.Int(.unsigned, bits); + const srep_t = @Int(.signed, bits); + const rep_t = @Int(.unsigned, bits); const significandBits = std.math.floatMantissaBits(T); const exponentBits = std.math.floatExponentBits(T); @@ -253,7 +253,7 @@ test "cmp_f80" { } pub inline fn unordcmp(comptime T: type, a: T, b: T) i32 { - const rep_t = std.meta.Int(.unsigned, @typeInfo(T).float.bits); + const rep_t = @Int(.unsigned, @typeInfo(T).float.bits); const significandBits = std.math.floatMantissaBits(T); const exponentBits = std.math.floatExponentBits(T); diff --git a/lib/compiler_rt/count0bits.zig b/lib/compiler_rt/count0bits.zig @@ -198,7 +198,7 @@ pub fn __ctzti2(a: i128) callconv(.c) i32 { } inline fn ffsXi2(comptime T: type, a: T) i32 { - var x: std.meta.Int(.unsigned, @typeInfo(T).int.bits) = @bitCast(a); + var x: @Int(.unsigned, @typeInfo(T).int.bits) = @bitCast(a); var n: T = 1; // adapted from Number of trailing zeroes (see ctzXi2) var mask: @TypeOf(x) = std.math.maxInt(@TypeOf(x)); diff --git a/lib/compiler_rt/divdf3.zig b/lib/compiler_rt/divdf3.zig @@ -26,8 +26,8 @@ fn __aeabi_ddiv(a: f64, b: f64) callconv(.{ .arm_aapcs = .{} }) f64 { } inline fn div(a: f64, b: f64) f64 { - const Z = std.meta.Int(.unsigned, 64); - const SignedZ = std.meta.Int(.signed, 64); + const Z = @Int(.unsigned, 64); + const SignedZ = @Int(.signed, 64); const significandBits = std.math.floatMantissaBits(f64); const exponentBits = std.math.floatExponentBits(f64); diff --git a/lib/compiler_rt/divsf3.zig b/lib/compiler_rt/divsf3.zig @@ -25,7 +25,7 @@ fn __aeabi_fdiv(a: f32, b: f32) callconv(.{ .arm_aapcs = .{} }) f32 { } inline fn div(a: f32, b: f32) f32 { - const Z = std.meta.Int(.unsigned, 32); + const Z = @Int(.unsigned, 32); const significandBits = std.math.floatMantissaBits(f32); const exponentBits = std.math.floatExponentBits(f32); diff --git a/lib/compiler_rt/divtf3.zig b/lib/compiler_rt/divtf3.zig @@ -24,7 +24,7 @@ fn _Qp_div(c: *f128, a: *const f128, b: *const f128) callconv(.c) void { } inline fn div(a: f128, b: f128) f128 { - const Z = std.meta.Int(.unsigned, 128); + const Z = @Int(.unsigned, 128); const significandBits = std.math.floatMantissaBits(f128); const exponentBits = std.math.floatExponentBits(f128); diff --git a/lib/compiler_rt/divxf3.zig b/lib/compiler_rt/divxf3.zig @@ -13,7 +13,7 @@ comptime { pub fn __divxf3(a: f80, b: f80) callconv(.c) f80 { const T = f80; - const Z = std.meta.Int(.unsigned, @bitSizeOf(T)); + const Z = @Int(.unsigned, @bitSizeOf(T)); const significandBits = std.math.floatMantissaBits(T); const fractionalBits = std.math.floatFractionalBits(T); diff --git a/lib/compiler_rt/extendf.zig b/lib/compiler_rt/extendf.zig @@ -3,10 +3,10 @@ const std = @import("std"); pub inline fn extendf( comptime dst_t: type, comptime src_t: type, - a: std.meta.Int(.unsigned, @typeInfo(src_t).float.bits), + a: @Int(.unsigned, @typeInfo(src_t).float.bits), ) dst_t { - const src_rep_t = std.meta.Int(.unsigned, @typeInfo(src_t).float.bits); - const dst_rep_t = std.meta.Int(.unsigned, @typeInfo(dst_t).float.bits); + const src_rep_t = @Int(.unsigned, @typeInfo(src_t).float.bits); + const dst_rep_t = @Int(.unsigned, @typeInfo(dst_t).float.bits); const srcSigBits = std.math.floatMantissaBits(src_t); const dstSigBits = std.math.floatMantissaBits(dst_t); @@ -70,8 +70,8 @@ pub inline fn extendf( return @bitCast(result); } -pub inline fn extend_f80(comptime src_t: type, a: std.meta.Int(.unsigned, @typeInfo(src_t).float.bits)) f80 { - const src_rep_t = std.meta.Int(.unsigned, @typeInfo(src_t).float.bits); +pub inline fn extend_f80(comptime src_t: type, a: @Int(.unsigned, @typeInfo(src_t).float.bits)) f80 { + const src_rep_t = @Int(.unsigned, @typeInfo(src_t).float.bits); const src_sig_bits = std.math.floatMantissaBits(src_t); const dst_int_bit = 0x8000000000000000; const dst_sig_bits = std.math.floatMantissaBits(f80) - 1; // -1 for the integer bit diff --git a/lib/compiler_rt/fabs.zig b/lib/compiler_rt/fabs.zig @@ -47,7 +47,7 @@ pub fn fabsl(x: c_longdouble) callconv(.c) c_longdouble { inline fn generic_fabs(x: anytype) @TypeOf(x) { const T = @TypeOf(x); - const TBits = std.meta.Int(.unsigned, @typeInfo(T).float.bits); + const TBits = @Int(.unsigned, @typeInfo(T).float.bits); const float_bits: TBits = @bitCast(x); const remove_sign = ~@as(TBits, 0) >> 1; return @bitCast(float_bits & remove_sign); diff --git a/lib/compiler_rt/float_from_int.zig b/lib/compiler_rt/float_from_int.zig @@ -1,5 +1,4 @@ const std = @import("std"); -const Int = std.meta.Int; const math = std.math; pub fn floatFromInt(comptime T: type, x: anytype) T { @@ -7,14 +6,14 @@ pub fn floatFromInt(comptime T: type, x: anytype) T { // Various constants whose values follow from the type parameters. // Any reasonable optimizer will fold and propagate all of these. - const Z = Int(.unsigned, @bitSizeOf(@TypeOf(x))); - const uT = Int(.unsigned, @bitSizeOf(T)); + const Z = @Int(.unsigned, @bitSizeOf(@TypeOf(x))); + const uT = @Int(.unsigned, @bitSizeOf(T)); const inf = math.inf(T); const float_bits = @bitSizeOf(T); const int_bits = @bitSizeOf(@TypeOf(x)); const exp_bits = math.floatExponentBits(T); const fractional_bits = math.floatFractionalBits(T); - const exp_bias = math.maxInt(Int(.unsigned, exp_bits - 1)); + const exp_bias = math.maxInt(@Int(.unsigned, exp_bits - 1)); const implicit_bit = if (T != f80) @as(uT, 1) << fractional_bits else 0; const max_exp = exp_bias; diff --git a/lib/compiler_rt/fmax.zig b/lib/compiler_rt/fmax.zig @@ -59,7 +59,7 @@ inline fn generic_fmax(comptime T: type, x: T, y: T) T { test "generic_fmax" { inline for ([_]type{ f32, f64, c_longdouble, f80, f128 }) |T| { const nan_val = math.nan(T); - const Int = std.meta.Int(.unsigned, @bitSizeOf(T)); + const Int = @Int(.unsigned, @bitSizeOf(T)); try std.testing.expect(math.isNan(generic_fmax(T, nan_val, nan_val))); try std.testing.expectEqual(@as(T, 1.0), generic_fmax(T, nan_val, 1.0)); diff --git a/lib/compiler_rt/fmin.zig b/lib/compiler_rt/fmin.zig @@ -59,7 +59,7 @@ inline fn generic_fmin(comptime T: type, x: T, y: T) T { test "generic_fmin" { inline for ([_]type{ f32, f64, c_longdouble, f80, f128 }) |T| { const nan_val = math.nan(T); - const Int = std.meta.Int(.unsigned, @bitSizeOf(T)); + const Int = @Int(.unsigned, @bitSizeOf(T)); try std.testing.expect(math.isNan(generic_fmin(T, nan_val, nan_val))); try std.testing.expectEqual(@as(T, 1.0), generic_fmin(T, nan_val, 1.0)); diff --git a/lib/compiler_rt/fmod.zig b/lib/compiler_rt/fmod.zig @@ -36,7 +36,7 @@ pub fn fmod(x: f64, y: f64) callconv(.c) f64 { /// Logic and flow heavily inspired by MUSL fmodl for 113 mantissa digits pub fn __fmodx(a: f80, b: f80) callconv(.c) f80 { const T = f80; - const Z = std.meta.Int(.unsigned, @bitSizeOf(T)); + const Z = @Int(.unsigned, @bitSizeOf(T)); const significandBits = math.floatMantissaBits(T); const fractionalBits = math.floatFractionalBits(T); @@ -260,7 +260,7 @@ pub fn fmodl(a: c_longdouble, b: c_longdouble) callconv(.c) c_longdouble { inline fn generic_fmod(comptime T: type, x: T, y: T) T { const bits = @typeInfo(T).float.bits; - const uint = std.meta.Int(.unsigned, bits); + const uint = @Int(.unsigned, bits); comptime assert(T == f32 or T == f64); const digits = if (T == f32) 23 else 52; const exp_bits = if (T == f32) 9 else 12; diff --git a/lib/compiler_rt/mulf3.zig b/lib/compiler_rt/mulf3.zig @@ -12,7 +12,7 @@ pub inline fn mulf3(comptime T: type, a: T, b: T) T { const fractionalBits = math.floatFractionalBits(T); const exponentBits = math.floatExponentBits(T); - const Z = std.meta.Int(.unsigned, typeWidth); + const Z = @Int(.unsigned, typeWidth); // ZSignificand is large enough to contain the significand, including an explicit integer bit const ZSignificand = PowerOfTwoSignificandZ(T); @@ -195,7 +195,7 @@ fn normalize(comptime T: type, significand: *PowerOfTwoSignificandZ(T)) i32 { /// the significand of T, including an explicit integer bit fn PowerOfTwoSignificandZ(comptime T: type) type { const bits = math.ceilPowerOfTwoAssert(u16, math.floatFractionalBits(T) + 1); - return std.meta.Int(.unsigned, bits); + return @Int(.unsigned, bits); } test { diff --git a/lib/compiler_rt/truncf.zig b/lib/compiler_rt/truncf.zig @@ -1,8 +1,8 @@ const std = @import("std"); pub inline fn truncf(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t { - const src_rep_t = std.meta.Int(.unsigned, @typeInfo(src_t).float.bits); - const dst_rep_t = std.meta.Int(.unsigned, @typeInfo(dst_t).float.bits); + const src_rep_t = @Int(.unsigned, @typeInfo(src_t).float.bits); + const dst_rep_t = @Int(.unsigned, @typeInfo(dst_t).float.bits); const srcSigBits = std.math.floatMantissaBits(src_t); const dstSigBits = std.math.floatMantissaBits(dst_t); @@ -100,7 +100,7 @@ pub inline fn truncf(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t } pub inline fn trunc_f80(comptime dst_t: type, a: f80) dst_t { - const dst_rep_t = std.meta.Int(.unsigned, @typeInfo(dst_t).float.bits); + const dst_rep_t = @Int(.unsigned, @typeInfo(dst_t).float.bits); const src_sig_bits = std.math.floatMantissaBits(f80) - 1; // -1 for the integer bit const dst_sig_bits = std.math.floatMantissaBits(dst_t); diff --git a/lib/std/Build/abi.zig b/lib/std/Build/abi.zig @@ -266,7 +266,7 @@ pub const fuzz = struct { .comptime_int => x, .bool => @intFromBool(x), .@"enum" => @intFromEnum(x), - else => @as(std.meta.Int(.unsigned, @bitSizeOf(T)), @bitCast(x)), + else => @as(@Int(.unsigned, @bitSizeOf(T)), @bitCast(x)), .int => |i| x: { comptime { diff --git a/lib/std/Io/Threaded.zig b/lib/std/Io/Threaded.zig @@ -15574,7 +15574,7 @@ fn readIntFd(fd: posix.fd_t) !ErrInt { return @intCast(std.mem.readInt(u64, &buffer, .little)); } -const ErrInt = std.meta.Int(.unsigned, @sizeOf(anyerror) * 8); +const ErrInt = @Int(.unsigned, @sizeOf(anyerror) * 8); fn destroyPipe(pipe: [2]posix.fd_t) void { if (pipe[0] != -1) closeFd(pipe[0]); diff --git a/lib/std/Io/Writer.zig b/lib/std/Io/Writer.zig @@ -1517,7 +1517,7 @@ pub fn printIntAny( // The type must have the same size as `base` or be wider in order for the // division to work const min_int_bits = comptime @max(value_info.bits, 8); - const MinInt = std.meta.Int(.unsigned, min_int_bits); + const MinInt = @Int(.unsigned, min_int_bits); const abs_value = @abs(value); // The worst case in terms of space needed is base 2, plus 1 for the sign @@ -1637,7 +1637,7 @@ pub fn printFloatHex(w: *Writer, value: anytype, case: std.fmt.Case, opt_precisi }); const T = @TypeOf(v); - const TU = std.meta.Int(.unsigned, @bitSizeOf(T)); + const TU = @Int(.unsigned, @bitSizeOf(T)); const mantissa_bits = std.math.floatMantissaBits(T); const fractional_bits = std.math.floatFractionalBits(T); diff --git a/lib/std/Random.zig b/lib/std/Random.zig @@ -125,9 +125,9 @@ pub fn enumValueWithIndex(r: Random, comptime EnumType: type, comptime Index: ty /// `i` is evenly distributed. pub fn int(r: Random, comptime T: type) T { const bits = @typeInfo(T).int.bits; - const UnsignedT = std.meta.Int(.unsigned, bits); + const UnsignedT = @Int(.unsigned, bits); const ceil_bytes = comptime std.math.divCeil(u16, bits, 8) catch unreachable; - const ByteAlignedT = std.meta.Int(.unsigned, ceil_bytes * 8); + const ByteAlignedT = @Int(.unsigned, ceil_bytes * 8); var rand_bytes: [ceil_bytes]u8 = undefined; r.bytes(&rand_bytes); @@ -215,7 +215,7 @@ pub fn intRangeLessThanBiased(r: Random, comptime T: type, at_least: T, less_tha 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); + const UnsignedT = @Int(.unsigned, info.bits); const lo: UnsignedT = @bitCast(at_least); const hi: UnsignedT = @bitCast(less_than); const result = lo +% r.uintLessThanBiased(UnsignedT, hi -% lo); @@ -234,7 +234,7 @@ pub fn intRangeLessThan(r: Random, comptime T: type, at_least: T, less_than: T) 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); + const UnsignedT = @Int(.unsigned, info.bits); const lo: UnsignedT = @bitCast(at_least); const hi: UnsignedT = @bitCast(less_than); const result = lo +% r.uintLessThan(UnsignedT, hi -% lo); @@ -252,7 +252,7 @@ pub fn intRangeAtMostBiased(r: Random, comptime T: type, at_least: T, at_most: T 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); + const UnsignedT = @Int(.unsigned, info.bits); const lo: UnsignedT = @bitCast(at_least); const hi: UnsignedT = @bitCast(at_most); const result = lo +% r.uintAtMostBiased(UnsignedT, hi -% lo); @@ -271,7 +271,7 @@ pub fn intRangeAtMost(r: Random, comptime T: type, at_least: T, at_most: T) T { 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); + const UnsignedT = @Int(.unsigned, info.bits); const lo: UnsignedT = @bitCast(at_least); const hi: UnsignedT = @bitCast(at_most); const result = lo +% r.uintAtMost(UnsignedT, hi -% lo); diff --git a/lib/std/Target.zig b/lib/std/Target.zig @@ -1228,7 +1228,7 @@ pub const Cpu = struct { pub const needed_bit_count = 347; 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(std.meta.Int(.unsigned, usize_count * @bitSizeOf(usize))); + pub const Index = std.math.Log2Int(@Int(.unsigned, usize_count * @bitSizeOf(usize))); pub const ShiftInt = std.math.Log2Int(usize); pub const empty: Set = .{ .ints = @splat(0) }; diff --git a/lib/std/bit_set.zig b/lib/std/bit_set.zig @@ -65,7 +65,7 @@ pub fn Integer(comptime size: u16) type { pub const bit_length: usize = size; /// The integer type used to represent a mask in this bit set - pub const MaskInt = std.meta.Int(.unsigned, size); + pub const MaskInt = @Int(.unsigned, size); /// The integer type used to shift a mask in this bit set pub const ShiftInt = std.math.Log2Int(MaskInt); @@ -359,7 +359,7 @@ pub fn Array(comptime MaskIntType: type, comptime size: usize) type { if (!std.math.isPowerOfTwo(@bitSizeOf(MaskIntType))) { var desired_bits = std.math.ceilPowerOfTwoAssert(usize, @bitSizeOf(MaskIntType)); if (desired_bits < byte_size) desired_bits = byte_size; - const FixedMaskType = std.meta.Int(.unsigned, desired_bits); + const FixedMaskType = @Int(.unsigned, desired_bits); @compileError("Array was passed integer type " ++ @typeName(MaskIntType) ++ ", which is not a power of two. Please round this up to a power of two integer size (i.e. " ++ @typeName(FixedMaskType) ++ ")."); } @@ -370,7 +370,7 @@ pub fn Array(comptime MaskIntType: type, comptime size: usize) type { if (@bitSizeOf(MaskIntType) != @sizeOf(MaskIntType) * byte_size) { var desired_bits = @sizeOf(MaskIntType) * byte_size; desired_bits = std.math.ceilPowerOfTwoAssert(usize, desired_bits); - const FixedMaskType = std.meta.Int(.unsigned, desired_bits); + const FixedMaskType = @Int(.unsigned, desired_bits); @compileError("Array was passed integer type " ++ @typeName(MaskIntType) ++ ", which contains padding bits. Please round this up to an unpadded integer size (i.e. " ++ @typeName(FixedMaskType) ++ ")."); } diff --git a/lib/std/c.zig b/lib/std/c.zig @@ -7186,7 +7186,7 @@ pub const RTLD = switch (native_os) { NOW: bool = false, GLOBAL: bool = false, LOCAL: bool = false, - _: std.meta.Int(.unsigned, @bitSizeOf(c_int) - 6) = 0, + _: @Int(.unsigned, @bitSizeOf(c_int) - 6) = 0, }, else => void, }; @@ -7366,7 +7366,7 @@ pub const AI = if (builtin.abi.isAndroid()) packed struct(u32) { V4MAPPED: bool = false, ALL: bool = false, ADDRCONFIG: bool = false, - _: std.meta.Int(.unsigned, @bitSizeOf(c_int) - 7) = 0, + _: @Int(.unsigned, @bitSizeOf(c_int) - 7) = 0, }, else => void, }; @@ -7399,7 +7399,7 @@ pub const NI = switch (native_os) { NAMEREQD: bool = false, NOFQDN: bool = false, DGRAM: bool = false, - _: std.meta.Int(.unsigned, @bitSizeOf(c_int) - 5) = 0, + _: @Int(.unsigned, @bitSizeOf(c_int) - 5) = 0, }, .freebsd, .haiku => packed struct(u32) { NOFQDN: bool = false, @@ -8635,7 +8635,7 @@ pub const O = switch (native_os) { CLOEXEC: bool = false, DIRECT: bool = false, SYNC: bool = false, - _: std.meta.Int(.unsigned, @bitSizeOf(c_int) - 14) = 0, + _: @Int(.unsigned, @bitSizeOf(c_int) - 14) = 0, }, else => void, }; @@ -8789,7 +8789,7 @@ pub const MAP = switch (native_os) { RANDOMIZED: bool = false, PURGEABLE: bool = false, FIXED_NOREPLACE: bool = false, - _: std.meta.Int(.unsigned, @bitSizeOf(c_int) - 11) = 0, + _: @Int(.unsigned, @bitSizeOf(c_int) - 11) = 0, }, else => void, }; diff --git a/lib/std/compress/zstd/Decompress.zig b/lib/std/compress/zstd/Decompress.zig @@ -533,7 +533,7 @@ pub const Frame = struct { table: Table, accuracy_log: u8, - const State = std.meta.Int(.unsigned, max_accuracy_log); + const State = @Int(.unsigned, max_accuracy_log); }; } @@ -1783,7 +1783,7 @@ const ReverseBitReader = struct { } fn initBits(comptime T: type, out: anytype, num: u16) Bits(T) { - const UT = std.meta.Int(.unsigned, @bitSizeOf(T)); + const UT = @Int(.unsigned, @bitSizeOf(T)); return .{ @bitCast(@as(UT, @intCast(out))), num, @@ -1803,7 +1803,7 @@ const ReverseBitReader = struct { } fn readBitsTuple(self: *ReverseBitReader, comptime T: type, num: u16) !Bits(T) { - const UT = std.meta.Int(.unsigned, @bitSizeOf(T)); + const UT = @Int(.unsigned, @bitSizeOf(T)); const U = if (@bitSizeOf(T) < 8) u8 else UT; if (num <= self.count) return initBits(T, self.removeBits(@intCast(num)), num); @@ -1871,7 +1871,7 @@ const BitReader = struct { count: u4 = 0, fn initBits(comptime T: type, out: anytype, num: u16) Bits(T) { - const UT = std.meta.Int(.unsigned, @bitSizeOf(T)); + const UT = @Int(.unsigned, @bitSizeOf(T)); return .{ @bitCast(@as(UT, @intCast(out))), num, @@ -1891,7 +1891,7 @@ const BitReader = struct { } fn readBitsTuple(self: *@This(), comptime T: type, num: u16) !Bits(T) { - const UT = std.meta.Int(.unsigned, @bitSizeOf(T)); + const UT = @Int(.unsigned, @bitSizeOf(T)); const U = if (@bitSizeOf(T) < 8) u8 else UT; if (num <= self.count) return initBits(T, self.removeBits(@intCast(num)), num); diff --git a/lib/std/crypto/aes_ccm.zig b/lib/std/crypto/aes_ccm.zig @@ -171,7 +171,7 @@ fn AesCcm(comptime BlockCipher: type, comptime tag_len: usize, comptime nonce_le block[0] = L - 1; // flags @memcpy(block[1..][0..nonce_length], &npub); // Counter goes in the last L bytes - const CounterInt = std.meta.Int(.unsigned, L * 8); + const CounterInt = @Int(.unsigned, L * 8); mem.writeInt(CounterInt, block[1 + nonce_length ..][0..L], @as(CounterInt, @intCast(counter)), .big); } @@ -229,7 +229,7 @@ fn AesCcm(comptime BlockCipher: type, comptime tag_len: usize, comptime nonce_le @memcpy(block[1..][0..nonce_length], &npub); // Encode message length in last L bytes - const LengthInt = std.meta.Int(.unsigned, L * 8); + const LengthInt = @Int(.unsigned, L * 8); mem.writeInt(LengthInt, block[1 + nonce_length ..][0..L], @as(LengthInt, @intCast(msg_len)), .big); } diff --git a/lib/std/crypto/cmac.zig b/lib/std/crypto/cmac.zig @@ -74,7 +74,7 @@ pub fn Cmac(comptime BlockCipher: type) type { } fn double(l: Block) Block { - const Int = std.meta.Int(.unsigned, block_length * 8); + const Int = @Int(.unsigned, block_length * 8); const l_ = mem.readInt(Int, &l, .big); const l_2 = switch (block_length) { 8 => (l_ << 1) ^ (0x1b & -%(l_ >> 63)), // mod x^64 + x^4 + x^3 + x + 1 diff --git a/lib/std/crypto/codecs/asn1/der/Encoder.zig b/lib/std/crypto/codecs/asn1/der/Encoder.zig @@ -129,7 +129,7 @@ fn int(self: *Encoder, comptime T: type, value: T) !void { const needs_padding: u1 = if (value == 0) 1 else if (bits_needed > 8) brk: { - const RightShift = std.meta.Int(.unsigned, @bitSizeOf(@TypeOf(bits_needed)) - 1); + const RightShift = @Int(.unsigned, @bitSizeOf(@TypeOf(bits_needed)) - 1); const right_shift: RightShift = @intCast(bits_needed - 9); break :brk if (value >> right_shift == 0x1ff) 1 else 0; } else 0; diff --git a/lib/std/crypto/ff.zig b/lib/std/crypto/ff.zig @@ -10,7 +10,6 @@ const builtin = @import("builtin"); const crypto = std.crypto; const math = std.math; const mem = std.mem; -const meta = std.meta; const testing = std.testing; const assert = std.debug.assert; const Endian = std.builtin.Endian; @@ -25,7 +24,7 @@ const carry_bits = 1; const t_bits: usize = @bitSizeOf(Limb) - carry_bits; // A TLimb is a Limb that is truncated to t_bits. -const TLimb = meta.Int(.unsigned, t_bits); +const TLimb = @Int(.unsigned, t_bits); const native_endian = builtin.target.cpu.arch.endian(); @@ -906,7 +905,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 = meta.Int(.unsigned, half_bits); + const Half = @Int(.unsigned, half_bits); const x0 = @as(Half, @truncate(x)); const x1 = @as(Half, @truncate(x >> half_bits)); const y0 = @as(Half, @truncate(y)); diff --git a/lib/std/crypto/keccak_p.zig b/lib/std/crypto/keccak_p.zig @@ -9,7 +9,7 @@ const mode = @import("builtin").mode; /// The Keccak-f permutation. pub fn KeccakF(comptime f: u11) type { comptime assert(f >= 200 and f <= 1600 and f % 200 == 0); // invalid bit size - const T = std.meta.Int(.unsigned, f / 25); + const T = @Int(.unsigned, f / 25); const Block = [25]T; const PI = [_]u5{ diff --git a/lib/std/crypto/ml_dsa.zig b/lib/std/crypto/ml_dsa.zig @@ -3413,7 +3413,7 @@ fn modularInverse(comptime T: type, comptime a: T, comptime p: T) T { // Use a signed type for EEA computation const type_info = @typeInfo(T); const SignedT = if (type_info == .int and type_info.int.signedness == .unsigned) - std.meta.Int(.signed, type_info.int.bits) + @Int(.signed, type_info.int.bits) else T; @@ -3436,7 +3436,7 @@ fn modularInverse(comptime T: type, comptime a: T, comptime p: T) T { fn modularPow(comptime T: type, comptime a: T, s: T, comptime p: T) T { const type_info = @typeInfo(T); const bits = type_info.int.bits; - const WideT = std.meta.Int(.unsigned, bits * 2); + const WideT = @Int(.unsigned, bits * 2); var ret: T = 1; var base: T = a; @@ -3465,14 +3465,14 @@ fn bitMask(comptime T: type, bit: T) T { /// Creates a mask from the sign bit of a signed integer. /// Returns all 1s (0xFF...FF) if x < 0, all 0s if x >= 0. -fn signMask(comptime T: type, x: T) std.meta.Int(.unsigned, @typeInfo(T).int.bits) { +fn signMask(comptime T: type, x: T) @Int(.unsigned, @typeInfo(T).int.bits) { const type_info = @typeInfo(T); if (type_info != .int) { @compileError("signMask requires an integer type"); } const bits = type_info.int.bits; - const SignedT = std.meta.Int(.signed, bits); + const SignedT = @Int(.signed, bits); // Convert to signed if needed, arithmetic right shift to propagate sign bit const x_signed: SignedT = if (type_info.int.signedness == .signed) x else @bitCast(x); @@ -3499,8 +3499,8 @@ fn montgomeryReduce( const m: OutT = @truncate(m_full); const yR = x -% @as(InT, m) * @as(InT, q); - const y_shifted = @as(std.meta.Int(.unsigned, @typeInfo(InT).Int.bits), @bitCast(yR)) >> r_bits; - return @bitCast(@as(std.meta.Int(.unsigned, @typeInfo(OutT).Int.bits), @truncate(y_shifted))); + const y_shifted = @as(@Int(.unsigned, @typeInfo(InT).Int.bits), @bitCast(yR)) >> r_bits; + return @bitCast(@as(@Int(.unsigned, @typeInfo(OutT).Int.bits), @truncate(y_shifted))); } /// Uniform sampling using SHAKE-128 with rejection sampling. diff --git a/lib/std/crypto/ml_kem.zig b/lib/std/crypto/ml_kem.zig @@ -1794,7 +1794,7 @@ fn modularInverse(comptime T: type, comptime a: T, comptime p: T) T { // Use a signed type for EEA computation const type_info = @typeInfo(T); const SignedT = if (type_info == .int and type_info.int.signedness == .unsigned) - std.meta.Int(.signed, type_info.int.bits) + @Int(.signed, type_info.int.bits) else T; @@ -1817,7 +1817,7 @@ fn modularInverse(comptime T: type, comptime a: T, comptime p: T) T { fn modularPow(comptime T: type, comptime a: T, s: T, comptime p: T) T { const type_info = @typeInfo(T); const bits = type_info.int.bits; - const WideT = std.meta.Int(.unsigned, bits * 2); + const WideT = @Int(.unsigned, bits * 2); var ret: T = 1; var base: T = a; @@ -1846,14 +1846,14 @@ fn bitMask(comptime T: type, bit: T) T { /// Creates a mask from the sign bit of a signed integer. /// Returns all 1s (0xFF...FF) if x < 0, all 0s if x >= 0. -fn signMask(comptime T: type, x: T) std.meta.Int(.unsigned, @typeInfo(T).int.bits) { +fn signMask(comptime T: type, x: T) @Int(.unsigned, @typeInfo(T).int.bits) { const type_info = @typeInfo(T); if (type_info != .int) { @compileError("signMask requires an integer type"); } const bits = type_info.int.bits; - const SignedT = std.meta.Int(.signed, bits); + const SignedT = @Int(.signed, bits); // Convert to signed if needed, arithmetic right shift to propagate sign bit const x_signed: SignedT = if (type_info.int.signedness == .signed) x else @bitCast(x); @@ -1898,8 +1898,8 @@ fn montgomeryReduce( const m: OutT = @truncate(m_full); const yR = x -% @as(InT, m) * @as(InT, q); - const y_shifted = @as(std.meta.Int(.unsigned, @typeInfo(InT).Int.bits), @bitCast(yR)) >> r_bits; - return @bitCast(@as(std.meta.Int(.unsigned, @typeInfo(OutT).Int.bits), @truncate(y_shifted))); + const y_shifted = @as(@Int(.unsigned, @typeInfo(InT).Int.bits), @bitCast(yR)) >> r_bits; + return @bitCast(@as(@Int(.unsigned, @typeInfo(OutT).Int.bits), @truncate(y_shifted))); } /// Uniform sampling using SHAKE-128 with rejection sampling. diff --git a/lib/std/crypto/modes.zig b/lib/std/crypto/modes.zig @@ -40,7 +40,7 @@ pub fn ctrSlice( var counterBlock = iv; var i: usize = 0; - const CounterInt = std.meta.Int(.unsigned, counter_size * 8); + const CounterInt = @Int(.unsigned, counter_size * 8); const parallel_count = BlockCipher.block.parallel.optimal_parallel_blocks; const wide_block_length = parallel_count * block_length; diff --git a/lib/std/crypto/pcurves/common.zig b/lib/std/crypto/pcurves/common.zig @@ -2,7 +2,6 @@ const std = @import("std"); const crypto = std.crypto; const debug = std.debug; const mem = std.mem; -const meta = std.meta; const NonCanonicalError = crypto.errors.NonCanonicalError; const NotSquareError = crypto.errors.NotSquareError; @@ -54,7 +53,7 @@ pub fn Field(comptime params: FieldParams) type { var s = if (endian == .little) s_ else orderSwap(s_); const field_order_s = comptime fos: { var fos: [encoded_length]u8 = undefined; - mem.writeInt(std.meta.Int(.unsigned, encoded_length * 8), &fos, field_order, .little); + mem.writeInt(@Int(.unsigned, encoded_length * 8), &fos, field_order, .little); break :fos fos; }; if (crypto.timing_safe.compare(u8, &s, &field_order_s, .little) != .lt) { @@ -90,7 +89,7 @@ pub fn Field(comptime params: FieldParams) type { } /// Element as an integer. - pub const IntRepr = meta.Int(.unsigned, params.field_bits); + pub const IntRepr = @Int(.unsigned, params.field_bits); /// Create a field element from an integer. pub fn fromInt(comptime x: IntRepr) NonCanonicalError!Fe { @@ -270,7 +269,7 @@ pub fn Field(comptime params: FieldParams) type { const ls = x126.sqn(126).mul(x126).sqn(3).mul(t111).sqn(33).mul(x32).sqn(95).mul(x31); return ls.equivalent(Fe.one); } else { - const ls = x2.pow(std.meta.Int(.unsigned, field_bits), (field_order - 1) / 2); // Legendre symbol + const ls = x2.pow(@Int(.unsigned, field_bits), (field_order - 1) / 2); // Legendre symbol return ls.equivalent(Fe.one); } } @@ -307,7 +306,7 @@ pub fn Field(comptime params: FieldParams) type { const x108 = x54.sqn(54).mul(x54); return x108.sqn(108).mul(x108).sqn(7).mul(t1111111).sqn(23).mul(x22).sqn(6).mul(t11).sqn(2); } else { - return x2.pow(std.meta.Int(.unsigned, field_bits), (field_order + 1) / 4); + return x2.pow(@Int(.unsigned, field_bits), (field_order + 1) / 4); } } diff --git a/lib/std/crypto/timing_safe.zig b/lib/std/crypto/timing_safe.zig @@ -21,8 +21,8 @@ pub fn eql(comptime T: type, a: T, b: T) bool { acc |= x ^ b[i]; } const s = @typeInfo(C).int.bits; - const Cu = std.meta.Int(.unsigned, s); - const Cext = std.meta.Int(.unsigned, s + 1); + const Cu = @Int(.unsigned, s); + const Cext = @Int(.unsigned, s + 1); return @as(bool, @bitCast(@as(u1, @truncate((@as(Cext, @as(Cu, @bitCast(acc))) -% 1) >> s)))); }, .vector => |info| { @@ -32,8 +32,8 @@ pub fn eql(comptime T: type, a: T, b: T) bool { } const acc = @reduce(.Or, a ^ b); const s = @typeInfo(C).int.bits; - const Cu = std.meta.Int(.unsigned, s); - const Cext = std.meta.Int(.unsigned, s + 1); + const Cu = @Int(.unsigned, s); + const Cext = @Int(.unsigned, s + 1); return @as(bool, @bitCast(@as(u1, @truncate((@as(Cext, @as(Cu, @bitCast(acc))) -% 1) >> s)))); }, else => { @@ -50,7 +50,7 @@ pub fn compare(comptime T: type, a: []const T, b: []const T, endian: Endian) Ord .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); + const Cext = @Int(.unsigned, bits + 1); var gt: T = 0; var eq: T = 1; if (endian == .little) { diff --git a/lib/std/enums.zig b/lib/std/enums.zig @@ -1291,7 +1291,7 @@ pub fn EnumIndexer(comptime E: type) type { const min_value = std.math.minInt(BackingInt); const max_value = std.math.maxInt(BackingInt); - const RangeType = std.meta.Int(.unsigned, @bitSizeOf(BackingInt)); + const RangeType = @Int(.unsigned, @bitSizeOf(BackingInt)); pub const count: comptime_int = std.math.maxInt(RangeType) + 1; pub fn indexOf(e: E) usize { @@ -1307,7 +1307,7 @@ pub fn EnumIndexer(comptime E: type) type { if (backing_int_sign == .unsigned) return @enumFromInt(i); - return @enumFromInt(@as(std.meta.Int(.signed, @bitSizeOf(RangeType) + 1), @intCast(i)) + min_value); + return @enumFromInt(@as(@Int(.signed, @bitSizeOf(RangeType) + 1), @intCast(i)) + min_value); } }; } @@ -1380,14 +1380,14 @@ test "EnumIndexer non-exhaustive" { i4, i8, i16, - std.meta.Int(.signed, @bitSizeOf(isize) - 1), + @Int(.signed, @bitSizeOf(isize) - 1), isize, u1, u2, u3, u4, u16, - std.meta.Int(.unsigned, @bitSizeOf(usize) - 1), + @Int(.unsigned, @bitSizeOf(usize) - 1), usize, }; inline for (backing_ints) |BackingInt| { @@ -1400,7 +1400,7 @@ test "EnumIndexer non-exhaustive" { const min_tag: E = @enumFromInt(std.math.minInt(BackingInt)); const max_tag: E = @enumFromInt(std.math.maxInt(BackingInt)); - const RangedType = std.meta.Int(.unsigned, @bitSizeOf(BackingInt)); + const RangedType = @Int(.unsigned, @bitSizeOf(BackingInt)); const max_index: comptime_int = std.math.maxInt(RangedType); const number_zero_tag_index: usize = switch (@typeInfo(BackingInt).int.signedness) { .unsigned => 0, diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig @@ -433,7 +433,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 = @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; diff --git a/lib/std/fmt/parse_float.zig b/lib/std/fmt/parse_float.zig @@ -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 = @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/wyhash.zig b/lib/std/hash/wyhash.zig @@ -130,7 +130,7 @@ pub const Wyhash = struct { inline fn read(comptime bytes: usize, data: []const u8) u64 { std.debug.assert(bytes <= 8); - const T = std.meta.Int(.unsigned, 8 * bytes); + const T = @Int(.unsigned, 8 * bytes); return @as(u64, std.mem.readInt(T, data[0..bytes], .little)); } diff --git a/lib/std/heap/debug_allocator.zig b/lib/std/heap/debug_allocator.zig @@ -189,7 +189,7 @@ pub fn DebugAllocator(comptime config: Config) type { const page_size = config.page_size; const page_align: mem.Alignment = .fromByteUnits(page_size); /// Integer type for pointing to slots in a small allocation - const SlotIndex = std.meta.Int(.unsigned, math.log2(page_size) + 1); + const SlotIndex = @Int(.unsigned, math.log2(page_size) + 1); const total_requested_bytes_init = if (config.enable_memory_limit) @as(usize, 0) else {}; const requested_memory_limit_init = if (config.enable_memory_limit) @as(usize, math.maxInt(usize)) else {}; diff --git a/lib/std/json/static_test.zig b/lib/std/json/static_test.zig @@ -663,7 +663,7 @@ test "parse into tuple" { float: f64, string: []const u8, }; - const T = std.meta.Tuple(&.{ + const T = @Tuple(&.{ i64, f64, bool, @@ -673,7 +673,7 @@ test "parse into tuple" { foo: i32, bar: []const u8, }, - std.meta.Tuple(&.{ u8, []const u8, u8 }), + @Tuple(&.{ u8, []const u8, u8 }), Union, }); const str = diff --git a/lib/std/leb128.zig b/lib/std/leb128.zig @@ -9,7 +9,7 @@ const testing = std.testing; /// An example use case of this is in emitting DWARF info where one wants to make a ULEB128 field /// "relocatable", meaning that it becomes possible to later go back and patch the number to be a /// different value without shifting all the following code. -pub fn writeUnsignedFixed(comptime l: usize, ptr: *[l]u8, int: std.meta.Int(.unsigned, l * 7)) void { +pub fn writeUnsignedFixed(comptime l: usize, ptr: *[l]u8, int: @Int(.unsigned, l * 7)) void { writeUnsignedExtended(ptr, int); } @@ -65,7 +65,7 @@ test writeUnsignedFixed { /// An example use case of this is in emitting DWARF info where one wants to make a ILEB128 field /// "relocatable", meaning that it becomes possible to later go back and patch the number to be a /// 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 { +pub fn writeSignedFixed(comptime l: usize, ptr: *[l]u8, int: @Int(.signed, l * 7)) void { const T = @TypeOf(int); const U = if (@typeInfo(T).int.bits < 8) u8 else T; var value: U = @intCast(int); diff --git a/lib/std/math.zig b/lib/std/math.zig @@ -779,7 +779,7 @@ pub fn Log2Int(comptime T: type) type { if (T == comptime_int) return comptime_int; const bits: u16 = @typeInfo(T).int.bits; const log2_bits = 16 - @clz(bits - 1); - return std.meta.Int(.unsigned, log2_bits); + return @Int(.unsigned, log2_bits); } /// Returns an unsigned int type that can hold the number of bits in T. @@ -788,7 +788,7 @@ pub fn Log2IntCeil(comptime T: type) type { if (T == comptime_int) return comptime_int; const bits: u16 = @typeInfo(T).int.bits; const log2_bits = 16 - @clz(bits); - return std.meta.Int(.unsigned, log2_bits); + return @Int(.unsigned, log2_bits); } /// Returns the smallest integer type that can hold both from and to. @@ -1048,10 +1048,10 @@ 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))) { +pub fn negateCast(x: anytype) !@Int(.signed, @bitSizeOf(@TypeOf(x))) { if (@typeInfo(@TypeOf(x)).int.signedness == .signed) return negate(x); - const int = std.meta.Int(.signed, @bitSizeOf(@TypeOf(x))); + const int = @Int(.signed, @bitSizeOf(@TypeOf(x))); if (x > -minInt(int)) return error.Overflow; if (x == -minInt(int)) return minInt(int); @@ -1177,7 +1177,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 = @Int(.unsigned, @typeInfo(T).int.bits); if (value <= 0) return 0; return @as(T, 1) << log2_int(uT, @as(uT, @intCast(value))); } @@ -1212,7 +1212,7 @@ 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) { +pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) @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); @@ -1497,11 +1497,11 @@ 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( +pub fn mulWide(comptime T: type, a: T, b: T) @Int( @typeInfo(T).int.signedness, @typeInfo(T).int.bits * 2, ) { - const ResultInt = std.meta.Int( + const ResultInt = @Int( @typeInfo(T).int.signedness, @typeInfo(T).int.bits * 2, ); diff --git a/lib/std/math/big.zig b/lib/std/math/big.zig @@ -4,10 +4,10 @@ const assert = std.debug.assert; pub const int = @import("big/int.zig"); pub const Limb = usize; 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); -pub const SignedDoubleLimb = std.meta.Int(.signed, 2 * limb_info.bits); +pub const SignedLimb = @Int(.signed, limb_info.bits); +pub const DoubleLimb = @Int(.unsigned, 2 * limb_info.bits); +pub const HalfLimb = @Int(.unsigned, limb_info.bits / 2); +pub const SignedDoubleLimb = @Int(.signed, 2 * limb_info.bits); pub const Log2Limb = std.math.Log2Int(Limb); comptime { diff --git a/lib/std/math/big/int.zig b/lib/std/math/big/int.zig @@ -2047,7 +2047,7 @@ pub const Mutable = struct { var limb = switch (signedness) { .unsigned => mem.readVarPackedInt(Limb, buffer, bit_index + bit_offset, bit_count - bit_index, endian, .unsigned), .signed => b: { - const SLimb = std.meta.Int(.signed, @bitSizeOf(Limb)); + const SLimb = @Int(.signed, @bitSizeOf(Limb)); const limb = mem.readVarPackedInt(SLimb, buffer, bit_index + bit_offset, bit_count - bit_index, endian, .signed); break :b @as(Limb, @bitCast(limb)); }, @@ -2284,7 +2284,7 @@ pub const Const = struct { // Make sure -0 is handled correctly. if (self.eqlZero()) return 0; - const Unsigned = std.meta.Int(.unsigned, info.bits); + const Unsigned = @Int(.unsigned, info.bits); if (!self.fitsInTwosComp(info.signedness, info.bits)) { return error.TargetTooSmall; diff --git a/lib/std/math/big/int_test.zig b/lib/std/math/big/int_test.zig @@ -2370,7 +2370,7 @@ test "truncate multi to single signed" { test "truncate multi to multi unsigned" { const bits = @typeInfo(SignedDoubleLimb).int.bits; - const Int = std.meta.Int(.unsigned, bits - 1); + const Int = @Int(.unsigned, bits - 1); var a = try Managed.initSet(testing.allocator, maxInt(SignedDoubleLimb)); defer a.deinit(); @@ -2386,7 +2386,7 @@ test "truncate multi to multi signed" { try a.truncate(&a, .signed, @bitSizeOf(Limb) + 1); - try testing.expectEqual(-1 << @bitSizeOf(Limb), try a.toInt(std.meta.Int(.signed, @bitSizeOf(Limb) + 1))); + try testing.expectEqual(-1 << @bitSizeOf(Limb), try a.toInt(@Int(.signed, @bitSizeOf(Limb) + 1))); } test "truncate negative multi to single" { diff --git 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 = @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/frexp.zig b/lib/std/math/frexp.zig @@ -22,16 +22,16 @@ pub fn frexp(x: anytype) Frexp(@TypeOf(x)) { const T: type = @TypeOf(x); const bits: comptime_int = @typeInfo(T).float.bits; - const Int: type = std.meta.Int(.unsigned, bits); + const Int: type = @Int(.unsigned, bits); const exp_bits: comptime_int = math.floatExponentBits(T); const mant_bits: comptime_int = math.floatMantissaBits(T); const frac_bits: comptime_int = math.floatFractionalBits(T); const exp_min: comptime_int = math.floatExponentMin(T); - const ExpInt: type = std.meta.Int(.unsigned, exp_bits); - const MantInt: type = std.meta.Int(.unsigned, mant_bits); - const FracInt: type = std.meta.Int(.unsigned, frac_bits); + const ExpInt: type = @Int(.unsigned, exp_bits); + const MantInt: type = @Int(.unsigned, mant_bits); + const FracInt: type = @Int(.unsigned, frac_bits); const unreal_exponent: comptime_int = (1 << exp_bits) - 1; const bias: comptime_int = (1 << (exp_bits - 1)) - 2; diff --git a/lib/std/math/ilogb.zig b/lib/std/math/ilogb.zig @@ -30,7 +30,7 @@ fn ilogbX(comptime T: type, x: T) i32 { const significandBits = math.floatMantissaBits(T); const exponentBits = math.floatExponentBits(T); - const Z = std.meta.Int(.unsigned, typeWidth); + const Z = @Int(.unsigned, typeWidth); const signBit = (@as(Z, 1) << (significandBits + exponentBits)); const maxExponent = ((1 << exponentBits) - 1); diff --git 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 = @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 @@ -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 = @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/isnan.zig b/lib/std/math/isnan.zig @@ -1,7 +1,6 @@ const std = @import("../std.zig"); const builtin = @import("builtin"); const math = std.math; -const meta = std.meta; const expect = std.testing.expect; pub fn isNan(x: anytype) bool { @@ -12,7 +11,7 @@ pub fn isNan(x: anytype) bool { /// this is tracked by https://github.com/ziglang/zig/issues/14366 pub fn isSignalNan(x: anytype) bool { const T = @TypeOf(x); - const U = meta.Int(.unsigned, @bitSizeOf(T)); + const U = @Int(.unsigned, @bitSizeOf(T)); const quiet_signal_bit_mask = 1 << (math.floatFractionalBits(T) - 1); return isNan(x) and (@as(U, @bitCast(x)) & quiet_signal_bit_mask == 0); } diff --git 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 = @Int(.unsigned, @typeInfo(T).float.bits); const increment_exp = 1 << math.floatMantissaBits(T); const remove_sign = ~@as(TBits, 0) >> 1; @@ -22,7 +22,7 @@ pub fn isNormal(x: anytype) bool { test isNormal { // TODO add `c_longdouble' when math.inf(T) supports it inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| { - const TBits = std.meta.Int(.unsigned, @bitSizeOf(T)); + const TBits = @Int(.unsigned, @bitSizeOf(T)); // normals try expect(isNormal(@as(T, 1.0))); diff --git a/lib/std/math/iszero.zig b/lib/std/math/iszero.zig @@ -6,7 +6,7 @@ const expect = std.testing.expect; pub inline fn isPositiveZero(x: anytype) bool { const T = @TypeOf(x); const bit_count = @typeInfo(T).float.bits; - const TBits = std.meta.Int(.unsigned, bit_count); + const TBits = @Int(.unsigned, bit_count); return @as(TBits, @bitCast(x)) == @as(TBits, 0); } @@ -14,7 +14,7 @@ pub inline fn isPositiveZero(x: anytype) bool { pub inline fn isNegativeZero(x: anytype) bool { const T = @TypeOf(x); const bit_count = @typeInfo(T).float.bits; - const TBits = std.meta.Int(.unsigned, bit_count); + const TBits = @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 @@ -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 = @Int(.unsigned, @typeInfo(T).float.bits); const exponent_bits = math.floatExponentBits(T); const mantissa_bits = math.floatMantissaBits(T); @@ -103,7 +103,7 @@ test ldexp { // Multiplications might flush the denormals to zero, esp. at // runtime, so we manually construct the constants here instead. - const Z = std.meta.Int(.unsigned, @bitSizeOf(T)); + const Z = @Int(.unsigned, @bitSizeOf(T)); const EightTimesTrueMin = @as(T, @bitCast(@as(Z, 8))); const TwoTimesTrueMin = @as(T, @bitCast(@as(Z, 2))); diff --git a/lib/std/math/nextafter.zig b/lib/std/math/nextafter.zig @@ -90,7 +90,7 @@ fn nextAfterFloat(comptime T: type, x: T, y: T) T { return x_parts.toFloat(); } else { - const Bits = std.meta.Int(.unsigned, @bitSizeOf(T)); + const Bits = @Int(.unsigned, @bitSizeOf(T)); var x_bits: Bits = @bitCast(x); if ((x > 0.0) == (y > x)) { x_bits += 1; @@ -320,6 +320,6 @@ 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); - const Bits = std.meta.Int(.unsigned, @bitSizeOf(T)); + const Bits = @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 @@ -147,7 +147,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(@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/mem.zig b/lib/std/mem.zig @@ -1777,7 +1777,7 @@ pub fn readVarInt(comptime ReturnType: type, bytes: []const u8, endian: Endian) assert(@typeInfo(ReturnType).int.bits >= bytes.len * 8); const bits = @typeInfo(ReturnType).int.bits; const signedness = @typeInfo(ReturnType).int.signedness; - const WorkType = std.meta.Int(signedness, @max(16, bits)); + const WorkType = @Int(signedness, @max(16, bits)); var result: WorkType = 0; switch (endian) { .big => { @@ -1828,8 +1828,8 @@ pub fn readVarPackedInt( endian: std.builtin.Endian, signedness: std.builtin.Signedness, ) T { - const uN = std.meta.Int(.unsigned, @bitSizeOf(T)); - const iN = std.meta.Int(.signed, @bitSizeOf(T)); + const uN = @Int(.unsigned, @bitSizeOf(T)); + const iN = @Int(.signed, @bitSizeOf(T)); const Log2N = std.math.Log2Int(T); const read_size = (bit_count + (bit_offset % 8) + 7) / 8; @@ -1921,7 +1921,7 @@ test readInt { } fn readPackedIntLittle(comptime T: type, bytes: []const u8, bit_offset: usize) T { - const uN = std.meta.Int(.unsigned, @bitSizeOf(T)); + const uN = @Int(.unsigned, @bitSizeOf(T)); const Log2N = std.math.Log2Int(T); const bit_count = @as(usize, @bitSizeOf(T)); @@ -1929,7 +1929,7 @@ fn readPackedIntLittle(comptime T: type, bytes: []const u8, bit_offset: usize) T const load_size = (bit_count + 7) / 8; const load_tail_bits = @as(u3, @intCast((load_size * 8) - bit_count)); - const LoadInt = std.meta.Int(.unsigned, load_size * 8); + const LoadInt = @Int(.unsigned, load_size * 8); if (bit_count == 0) return 0; @@ -1947,7 +1947,7 @@ fn readPackedIntLittle(comptime T: type, bytes: []const u8, bit_offset: usize) T } fn readPackedIntBig(comptime T: type, bytes: []const u8, bit_offset: usize) T { - const uN = std.meta.Int(.unsigned, @bitSizeOf(T)); + const uN = @Int(.unsigned, @bitSizeOf(T)); const Log2N = std.math.Log2Int(T); const bit_count = @as(usize, @bitSizeOf(T)); @@ -1956,7 +1956,7 @@ fn readPackedIntBig(comptime T: type, bytes: []const u8, bit_offset: usize) T { const load_size = (bit_count + 7) / 8; const load_tail_bits = @as(u3, @intCast((load_size * 8) - bit_count)); - const LoadInt = std.meta.Int(.unsigned, load_size * 8); + const LoadInt = @Int(.unsigned, load_size * 8); if (bit_count == 0) return 0; @@ -2061,7 +2061,7 @@ test writeInt { } fn writePackedIntLittle(comptime T: type, bytes: []u8, bit_offset: usize, value: T) void { - const uN = std.meta.Int(.unsigned, @bitSizeOf(T)); + const uN = @Int(.unsigned, @bitSizeOf(T)); const Log2N = std.math.Log2Int(T); const bit_count = @as(usize, @bitSizeOf(T)); @@ -2069,7 +2069,7 @@ fn writePackedIntLittle(comptime T: type, bytes: []u8, bit_offset: usize, value: const store_size = (@bitSizeOf(T) + 7) / 8; const store_tail_bits = @as(u3, @intCast((store_size * 8) - bit_count)); - const StoreInt = std.meta.Int(.unsigned, store_size * 8); + const StoreInt = @Int(.unsigned, store_size * 8); if (bit_count == 0) return; @@ -2094,7 +2094,7 @@ fn writePackedIntLittle(comptime T: type, bytes: []u8, bit_offset: usize, value: } fn writePackedIntBig(comptime T: type, bytes: []u8, bit_offset: usize, value: T) void { - const uN = std.meta.Int(.unsigned, @bitSizeOf(T)); + const uN = @Int(.unsigned, @bitSizeOf(T)); const Log2N = std.math.Log2Int(T); const bit_count = @as(usize, @bitSizeOf(T)); @@ -2103,7 +2103,7 @@ fn writePackedIntBig(comptime T: type, bytes: []u8, bit_offset: usize, value: T) const store_size = (@bitSizeOf(T) + 7) / 8; const store_tail_bits = @as(u3, @intCast((store_size * 8) - bit_count)); - const StoreInt = std.meta.Int(.unsigned, store_size * 8); + const StoreInt = @Int(.unsigned, store_size * 8); if (bit_count == 0) return; @@ -2160,7 +2160,7 @@ test writePackedInt { /// If negative, the written value is sign-extended. pub fn writeVarPackedInt(bytes: []u8, bit_offset: usize, bit_count: usize, value: anytype, endian: std.builtin.Endian) void { const T = @TypeOf(value); - const uN = std.meta.Int(.unsigned, @bitSizeOf(T)); + const uN = @Int(.unsigned, @bitSizeOf(T)); const bit_shift = @as(u3, @intCast(bit_offset % 8)); const write_size = (bit_count + bit_shift + 7) / 8; @@ -2242,7 +2242,7 @@ pub fn byteSwapAllFieldsAligned(comptime S: type, comptime a: Alignment, ptr: *a }, .bool => {}, .float => |float_info| { - @field(ptr, f.name) = @bitCast(@byteSwap(@as(std.meta.Int(.unsigned, float_info.bits), @bitCast(@field(ptr, f.name))))); + @field(ptr, f.name) = @bitCast(@byteSwap(@as(@Int(.unsigned, float_info.bits), @bitCast(@field(ptr, f.name))))); }, else => { @field(ptr, f.name) = @byteSwap(@field(ptr, f.name)); @@ -2262,7 +2262,7 @@ pub fn byteSwapAllFieldsAligned(comptime S: type, comptime a: Alignment, ptr: *a } } - const BackingInt = std.meta.Int(.unsigned, @bitSizeOf(S)); + const BackingInt = @Int(.unsigned, @bitSizeOf(S)); ptr.* = @bitCast(@byteSwap(@as(BackingInt, @bitCast(ptr.*)))); }, .array => |info| { @@ -2370,7 +2370,7 @@ pub fn byteSwapAllElements(comptime Elem: type, slice: []Elem) void { }, .bool => {}, .float => |float_info| { - elem.* = @bitCast(@byteSwap(@as(std.meta.Int(.unsigned, float_info.bits), @bitCast(elem.*)))); + elem.* = @bitCast(@byteSwap(@as(@Int(.unsigned, float_info.bits), @bitCast(elem.*)))); }, else => { elem.* = @byteSwap(elem.*); @@ -4800,7 +4800,7 @@ pub fn doNotOptimizeAway(val: anytype) void { 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))), + @Int(t.int.signedness, @max(8, std.math.ceilPowerOfTwoAssert(u16, bits))), val, ); asm volatile ("" @@ -5035,8 +5035,8 @@ test "read/write(Var)PackedInt" { if (@bitSizeOf(PackedType) > @bitSizeOf(BackingType)) continue; - const iPackedType = std.meta.Int(.signed, @bitSizeOf(PackedType)); - const uPackedType = std.meta.Int(.unsigned, @bitSizeOf(PackedType)); + const iPackedType = @Int(.signed, @bitSizeOf(PackedType)); + const uPackedType = @Int(.unsigned, @bitSizeOf(PackedType)); const Log2T = std.math.Log2Int(BackingType); const offset_at_end = @bitSizeOf(BackingType) - @bitSizeOf(PackedType); @@ -5103,8 +5103,8 @@ test "read/write(Var)PackedInt" { } 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); + const NextPowerOfTwoInt = @Int(signedness, try std.math.ceilPowerOfTwo(u16, @bitSizeOf(PackedType))); + const ui64 = @Int(signedness, 64); inline for ([_]type{ PackedType, NextPowerOfTwoInt, ui64 }) |U| { { // Variable-size Read/Write (Native-endian) diff --git a/lib/std/meta.zig b/lib/std/meta.zig @@ -751,11 +751,6 @@ pub fn fieldIndex(comptime T: type, comptime name: []const u8) ?comptime_int { return null; } -/// Deprecated: use @Int -pub fn Int(comptime signedness: std.builtin.Signedness, comptime bit_count: u16) type { - return @Int(signedness, bit_count); -} - pub fn Float(comptime bit_count: u8) type { return switch (bit_count) { 16 => f16, @@ -796,14 +791,7 @@ pub fn ArgsTuple(comptime Function: type) type { argument_field_list[i] = T; } - return Tuple(&argument_field_list); -} - -/// Deprecated; use `@Tuple` instead. -/// -/// To be removed after Zig 0.16.0 releases. -pub fn Tuple(comptime types: []const type) type { - return @Tuple(types); + return @Tuple(&argument_field_list); } const TupleTester = struct { @@ -839,33 +827,13 @@ test ArgsTuple { TupleTester.assertTuple(.{u32}, ArgsTuple(fn (comptime a: u32) []const u8)); } -test Tuple { - TupleTester.assertTuple(.{}, Tuple(&[_]type{})); - TupleTester.assertTuple(.{u32}, Tuple(&[_]type{u32})); - TupleTester.assertTuple(.{ u32, f16 }, Tuple(&[_]type{ u32, f16 })); - TupleTester.assertTuple(.{ u32, f16, []const u8, void }, Tuple(&[_]type{ u32, f16, []const u8, void })); -} - -test "Tuple deduplication" { - const T1 = std.meta.Tuple(&.{ u32, f32, i8 }); - const T2 = std.meta.Tuple(&.{ u32, f32, i8 }); - const T3 = std.meta.Tuple(&.{ u32, f32, i7 }); - - if (T1 != T2) { - @compileError("std.meta.Tuple doesn't deduplicate tuple types."); - } - if (T1 == T3) { - @compileError("std.meta.Tuple fails to generate different types."); - } -} - test "ArgsTuple forwarding" { - const T1 = std.meta.Tuple(&.{ u32, f32, i8 }); + const T1 = @Tuple(&.{ u32, f32, i8 }); const T2 = std.meta.ArgsTuple(fn (u32, f32, i8) void); const T3 = std.meta.ArgsTuple(fn (u32, f32, i8) callconv(.c) noreturn); if (T1 != T2) { - @compileError("std.meta.ArgsTuple produces different types than std.meta.Tuple"); + @compileError("std.meta.ArgsTuple produces different types than @Tuple"); } if (T1 != T3) { @compileError("std.meta.ArgsTuple produces different types for the same argument lists."); diff --git a/lib/std/meta/trailer_flags.zig b/lib/std/meta/trailer_flags.zig @@ -13,7 +13,7 @@ pub fn TrailerFlags(comptime Fields: type) type { return struct { bits: Int, - pub const Int = meta.Int(.unsigned, bit_count); + pub const Int = @Int(.unsigned, bit_count); pub const bit_count = @typeInfo(Fields).@"struct".fields.len; pub const FieldEnum = std.meta.FieldEnum(Fields); diff --git a/lib/std/os/emscripten.zig b/lib/std/os/emscripten.zig @@ -17,7 +17,7 @@ pub const CLOCK = linux.CLOCK; pub const CPU_SETSIZE = 128; pub const cpu_set_t = [CPU_SETSIZE / @sizeOf(usize)]usize; -pub const cpu_count_t = std.meta.Int(.unsigned, std.math.log2(CPU_SETSIZE * 8)); +pub const cpu_count_t = @Int(.unsigned, 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/os/linux.zig b/lib/std/os/linux.zig @@ -6291,7 +6291,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 = std.meta.Int(.unsigned, std.math.log2(CPU_SETSIZE * 8)); +pub const cpu_count_t = @Int(.unsigned, 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/os/linux/ioctl.zig b/lib/std/os/linux/ioctl.zig @@ -15,12 +15,12 @@ const bits = switch (@import("builtin").cpu.arch) { else => .{ .size = 14, .dir = 2, .none = 0, .read = 2, .write = 1 }, }; -const Direction = std.meta.Int(.unsigned, bits.dir); +const Direction = @Int(.unsigned, bits.dir); pub const Request = packed struct { nr: u8, io_type: u8, - size: std.meta.Int(.unsigned, bits.size), + size: @Int(.unsigned, bits.size), dir: Direction, }; diff --git a/lib/std/os/uefi/tables/runtime_services.zig b/lib/std/os/uefi/tables/runtime_services.zig @@ -419,7 +419,7 @@ pub const RuntimeServices = extern struct { pub const DebugDisposition = enum(usize) { const Bits = packed struct(usize) { optional_ptr: bool = false, - _pad: std.meta.Int(.unsigned, @bitSizeOf(usize) - 1) = 0, + _pad: @Int(.unsigned, @bitSizeOf(usize) - 1) = 0, }; pointer = @bitCast(Bits{}), diff --git a/lib/std/posix.zig b/lib/std/posix.zig @@ -803,7 +803,7 @@ pub fn dl_iterate_phdr( } }.callbackC, @ptrCast(@constCast(&context)))) { 0 => return, - else => |err| return @as(Error, @errorCast(@errorFromInt(@as(std.meta.Int(.unsigned, @bitSizeOf(anyerror)), @intCast(err))))), + else => |err| return @as(Error, @errorCast(@errorFromInt(@as(@Int(.unsigned, @bitSizeOf(anyerror)), @intCast(err))))), } } diff --git a/lib/std/testing.zig b/lib/std/testing.zig @@ -163,7 +163,7 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void { } } - const BackingInt = std.meta.Int(.unsigned, @bitSizeOf(T)); + const BackingInt = @Int(.unsigned, @bitSizeOf(T)); return expectEqual( @as(BackingInt, @bitCast(expected)), @as(BackingInt, @bitCast(actual)), diff --git a/lib/std/zig/llvm/Builder.zig b/lib/std/zig/llvm/Builder.zig @@ -7657,9 +7657,9 @@ pub const Constant = enum(u32) { .float => { const Float = struct { fn Repr(comptime T: type) type { - return packed struct(std.meta.Int(.unsigned, @bitSizeOf(T))) { - mantissa: std.meta.Int(.unsigned, std.math.floatMantissaBits(T)), - exponent: std.meta.Int(.unsigned, std.math.floatExponentBits(T)), + return packed struct(@Int(.unsigned, @bitSizeOf(T))) { + mantissa: @Int(.unsigned, std.math.floatMantissaBits(T)), + exponent: @Int(.unsigned, std.math.floatExponentBits(T)), sign: u1, }; } diff --git a/lib/std/zig/llvm/bitcode_writer.zig b/lib/std/zig/llvm/bitcode_writer.zig @@ -404,7 +404,7 @@ fn charTo6Bit(c: u8) u8 { } fn BufType(comptime T: type, comptime min_len: usize) type { - return std.meta.Int(.unsigned, @max(min_len, @bitSizeOf(switch (@typeInfo(T)) { + return @Int(.unsigned, @max(min_len, @bitSizeOf(switch (@typeInfo(T)) { .comptime_int => u32, .int => |info| if (info.signedness == .unsigned) T @@ -414,7 +414,7 @@ fn BufType(comptime T: type, comptime min_len: usize) type { .bool => u1, .@"struct" => |info| switch (info.layout) { .auto, .@"extern" => @compileError("Unsupported type: " ++ @typeName(T)), - .@"packed" => std.meta.Int(.unsigned, @bitSizeOf(T)), + .@"packed" => @Int(.unsigned, @bitSizeOf(T)), }, else => @compileError("Unsupported type: " ++ @typeName(T)), }))); @@ -425,7 +425,7 @@ fn bufValue(value: anytype, comptime min_len: usize) BufType(@TypeOf(value), min .comptime_int, .int => @intCast(value), .@"enum" => @intFromEnum(value), .bool => @intFromBool(value), - .@"struct" => @intCast(@as(std.meta.Int(.unsigned, @bitSizeOf(@TypeOf(value))), @bitCast(value))), + .@"struct" => @intCast(@as(@Int(.unsigned, @bitSizeOf(@TypeOf(value))), @bitCast(value))), else => unreachable, }; } diff --git a/lib/std/zig/llvm/ir.zig b/lib/std/zig/llvm/ir.zig @@ -235,7 +235,7 @@ pub const ModuleBlock = struct { is_const: AddrSpaceAndIsConst, initid: u32, linkage: Builder.Linkage, - alignment: std.meta.Int(.unsigned, @bitSizeOf(Builder.Alignment)), + alignment: @Int(.unsigned, @bitSizeOf(Builder.Alignment)), section: usize, visibility: Builder.Visibility, thread_local: Builder.ThreadLocal, @@ -275,7 +275,7 @@ pub const ModuleBlock = struct { is_proto: bool, linkage: Builder.Linkage, paramattr: usize, - alignment: std.meta.Int(.unsigned, @bitSizeOf(Builder.Alignment)), + alignment: @Int(.unsigned, @bitSizeOf(Builder.Alignment)), section: usize, visibility: Builder.Visibility, unnamed_addr: Builder.UnnamedAddr, @@ -1214,7 +1214,7 @@ pub const ModuleBlock = struct { }; ptr: u32, ty: Builder.Type, - alignment: std.meta.Int(.unsigned, @bitSizeOf(Builder.Alignment)), + alignment: @Int(.unsigned, @bitSizeOf(Builder.Alignment)), is_volatile: bool, }; @@ -1230,7 +1230,7 @@ pub const ModuleBlock = struct { }; ptr: u32, ty: Builder.Type, - alignment: std.meta.Int(.unsigned, @bitSizeOf(Builder.Alignment)), + alignment: @Int(.unsigned, @bitSizeOf(Builder.Alignment)), is_volatile: bool, success_ordering: Builder.AtomicOrdering, sync_scope: Builder.SyncScope, @@ -1246,7 +1246,7 @@ pub const ModuleBlock = struct { }; ptr: u32, val: u32, - alignment: std.meta.Int(.unsigned, @bitSizeOf(Builder.Alignment)), + alignment: @Int(.unsigned, @bitSizeOf(Builder.Alignment)), is_volatile: bool, }; @@ -1262,7 +1262,7 @@ pub const ModuleBlock = struct { }; ptr: u32, val: u32, - alignment: std.meta.Int(.unsigned, @bitSizeOf(Builder.Alignment)), + alignment: @Int(.unsigned, @bitSizeOf(Builder.Alignment)), is_volatile: bool, success_ordering: Builder.AtomicOrdering, sync_scope: Builder.SyncScope, @@ -1317,7 +1317,7 @@ pub const ModuleBlock = struct { is_volatile: bool, success_ordering: Builder.AtomicOrdering, sync_scope: Builder.SyncScope, - alignment: std.meta.Int(.unsigned, @bitSizeOf(Builder.Alignment)), + alignment: @Int(.unsigned, @bitSizeOf(Builder.Alignment)), }; pub const CmpXchg = struct { @@ -1341,7 +1341,7 @@ pub const ModuleBlock = struct { sync_scope: Builder.SyncScope, failure_ordering: Builder.AtomicOrdering, is_weak: bool, - alignment: std.meta.Int(.unsigned, @bitSizeOf(Builder.Alignment)), + alignment: @Int(.unsigned, @bitSizeOf(Builder.Alignment)), }; pub const Fence = struct { diff --git a/src/Air/Liveness.zig b/src/Air/Liveness.zig @@ -301,7 +301,7 @@ pub fn iterateBigTomb(l: Liveness, inst: Air.Inst.Index) BigTomb { /// How many tomb bits per AIR instruction. pub const bpi = 4; -pub const Bpi = std.meta.Int(.unsigned, bpi); +pub const Bpi = @Int(.unsigned, bpi); pub const OperandInt = std.math.Log2Int(Bpi); /// Useful for decoders of Liveness information. diff --git a/src/InternPool.zig b/src/InternPool.zig @@ -2660,7 +2660,7 @@ pub const Key = union(enum) { switch (float.storage) { inline else => |val| std.hash.autoHash( &hasher, - @as(std.meta.Int(.unsigned, @bitSizeOf(@TypeOf(val))), @bitCast(val)), + @as(@Int(.unsigned, @bitSizeOf(@TypeOf(val))), @bitCast(val)), ), } return hasher.final(); @@ -3012,7 +3012,7 @@ pub const Key = union(enum) { switch (a_info.storage) { inline else => |val, tag| { - const Bits = std.meta.Int(.unsigned, @bitSizeOf(@TypeOf(val))); + const Bits = @Int(.unsigned, @bitSizeOf(@TypeOf(val))); const a_bits: Bits = @bitCast(val); const b_bits: Bits = @bitCast(@field(b_info.storage, @tagName(tag))); return a_bits == b_bits; diff --git a/src/codegen/c.zig b/src/codegen/c.zig @@ -7221,7 +7221,7 @@ fn fmtStringLiteral(str: []const u8, sentinel: ?u8) std.fmt.Alt(FormatStringCont fn undefPattern(comptime IntType: type) IntType { const int_info = @typeInfo(IntType).int; - const UnsignedType = std.meta.Int(.unsigned, int_info.bits); + const UnsignedType = @Int(.unsigned, int_info.bits); return @bitCast(@as(UnsignedType, (1 << (int_info.bits | 1)) / 3)); } diff --git a/src/codegen/riscv64/bits.zig b/src/codegen/riscv64/bits.zig @@ -118,7 +118,7 @@ pub const Immediate = union(enum) { const int_info = @typeInfo(T).int; if (int_info.signedness != .unsigned) @compileError("Immediate.asBits needs unsigned T"); return switch (imm) { - .signed => |x| @bitCast(@as(std.meta.Int(.signed, int_info.bits), @intCast(x))), + .signed => |x| @bitCast(@as(@Int(.signed, int_info.bits), @intCast(x))), .unsigned => |x| @intCast(x), }; } diff --git a/src/codegen/spirv/Assembler.zig b/src/codegen/spirv/Assembler.zig @@ -821,7 +821,7 @@ fn parseContextDependentFloat(ass: *Assembler, comptime width: u16) !void { const gpa = ass.cg.module.gpa; const Float = std.meta.Float(width); - const Int = std.meta.Int(.unsigned, width); + const Int = @Int(.unsigned, width); const tok = ass.currentToken(); try ass.expectToken(.value); diff --git a/src/codegen/spirv/Section.zig b/src/codegen/spirv/Section.zig @@ -8,7 +8,7 @@ const testing = std.testing; const spec = @import("spec.zig"); const Word = spec.Word; -const DoubleWord = std.meta.Int(.unsigned, @bitSizeOf(Word) * 2); +const DoubleWord = @Int(.unsigned, @bitSizeOf(Word) * 2); const Log2Word = std.math.Log2Int(Word); const Opcode = spec.Opcode; diff --git a/test/behavior/abs.zig b/test/behavior/abs.zig @@ -155,7 +155,7 @@ test "@abs big int <= 128 bits" { try testAbsUnsignedBigInt(); } -fn abs(comptime T: type, a: T) std.meta.Int(.unsigned, @typeInfo(T).int.bits) { +fn abs(comptime T: type, a: T) @Int(.unsigned, @typeInfo(T).int.bits) { return @abs(a); } diff --git a/test/behavior/atomics.zig b/test/behavior/atomics.zig @@ -232,7 +232,7 @@ fn testAtomicRmwInts() !void { } fn testAtomicRmwInt(comptime signedness: std.builtin.Signedness, comptime N: usize) !void { - const int = std.meta.Int(signedness, N); + const int = @Int(signedness, N); var x: int = 1; var res = @atomicRmw(int, &x, .Xchg, 3, .seq_cst); @@ -293,8 +293,8 @@ test "atomicrmw with 128-bit ints" { } fn testAtomicRmwInt128(comptime signedness: std.builtin.Signedness) !void { - const uint = std.meta.Int(.unsigned, 128); - const int = std.meta.Int(signedness, 128); + const uint = @Int(.unsigned, 128); + const int = @Int(signedness, 128); const initial: int = @as(int, @bitCast(@as(uint, 0xaaaaaaaa_bbbbbbbb_cccccccc_dddddddd))); const replacement: int = 0x00000000_00000005_00000000_00000003; diff --git a/test/behavior/bit_shifting.zig b/test/behavior/bit_shifting.zig @@ -5,10 +5,10 @@ const builtin = @import("builtin"); fn ShardedTable(comptime Key: type, comptime mask_bit_count: comptime_int, comptime V: type) type { const key_bits = @typeInfo(Key).int.bits; - std.debug.assert(Key == std.meta.Int(.unsigned, key_bits)); + std.debug.assert(Key == @Int(.unsigned, key_bits)); std.debug.assert(key_bits >= mask_bit_count); const shard_key_bits = mask_bit_count; - const ShardKey = std.meta.Int(.unsigned, mask_bit_count); + const ShardKey = @Int(.unsigned, mask_bit_count); const shift_amount = key_bits - shard_key_bits; return struct { const Self = @This(); diff --git a/test/behavior/bitcast.zig b/test/behavior/bitcast.zig @@ -49,8 +49,8 @@ test "@bitCast iX -> uX exotic integers" { } fn testBitCast(comptime N: usize) !void { - const iN = std.meta.Int(.signed, N); - const uN = std.meta.Int(.unsigned, N); + const iN = @Int(.signed, N); + const uN = @Int(.unsigned, N); try expect(conv_iN(N, -1) == maxInt(uN)); try expect(conv_uN(N, maxInt(uN)) == -1); @@ -69,12 +69,12 @@ fn testBitCast(comptime N: usize) !void { } } -fn conv_iN(comptime N: usize, x: std.meta.Int(.signed, N)) std.meta.Int(.unsigned, N) { - return @as(std.meta.Int(.unsigned, N), @bitCast(x)); +fn conv_iN(comptime N: usize, x: @Int(.signed, N)) @Int(.unsigned, N) { + return @as(@Int(.unsigned, N), @bitCast(x)); } -fn conv_uN(comptime N: usize, x: std.meta.Int(.unsigned, N)) std.meta.Int(.signed, N) { - return @as(std.meta.Int(.signed, N), @bitCast(x)); +fn conv_uN(comptime N: usize, x: @Int(.unsigned, N)) @Int(.signed, N) { + return @as(@Int(.signed, N), @bitCast(x)); } test "bitcast uX to bytes" { @@ -101,7 +101,7 @@ fn testBitCastuXToBytes(comptime N: usize) !void { // on the platforms we target. If the above behavior is restricted after all, // this test should be deleted. - const T = std.meta.Int(.unsigned, N); + const T = @Int(.unsigned, N); for ([_]T{ 0, ~@as(T, 0) }) |init_value| { var x: T = init_value; const bytes = std.mem.asBytes(&x); diff --git a/test/behavior/math.zig b/test/behavior/math.zig @@ -2359,7 +2359,7 @@ test "signed zeros are represented properly" { } fn testOne(comptime T: type) !void { - const ST = std.meta.Int(.unsigned, @typeInfo(T).float.bits); + const ST = @Int(.unsigned, @typeInfo(T).float.bits); var as_fp_val = -@as(T, 0.0); _ = &as_fp_val; const as_uint_val: ST = @bitCast(as_fp_val); diff --git a/test/behavior/tuple.zig b/test/behavior/tuple.zig @@ -233,7 +233,7 @@ test "tuple in tuple passed to generic function" { if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; const S = struct { - fn pair(x: f32, y: f32) std.meta.Tuple(&.{ f32, f32 }) { + fn pair(x: f32, y: f32) @Tuple(&.{ f32, f32 }) { return .{ x, y }; } @@ -251,7 +251,7 @@ test "coerce tuple to tuple" { if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; - const T = std.meta.Tuple(&.{u8}); + const T = @Tuple(&.{u8}); const S = struct { fn foo(x: T) !void { try expect(x[0] == 123); @@ -265,7 +265,7 @@ test "tuple type with void field" { if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; - const T = std.meta.Tuple(&[_]type{void}); + const T = @Tuple(&.{void}); const x = T{{}}; try expect(@TypeOf(x[0]) == void); } @@ -290,7 +290,7 @@ test "tuple type with void field and a runtime field" { if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; - const T = std.meta.Tuple(&[_]type{ usize, void }); + const T = @Tuple(&.{ usize, void }); var t: T = .{ 5, {} }; _ = &t; try expect(t[0] == 5);