authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-02-24 23:39:03+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-02-24 23:39:03+02:00
log538d9a5dd8e0eca02d363bbd5f749405e003f1c6
treed8ac99c166bbf72605c4d0ac3413c13d2c52b3bd
parent3458fb891d8c7072a9bff6a32db9f3105ab72aa4
signaturelock-open Commit is signed but in an unrecognized format.

remove uses of `@ArgType` and `@IntType`


45 files changed, 125 insertions(+), 193 deletions(-)

doc/langref.html.in+3-26
......@@ -550,7 +550,7 @@ pub fn main() void {
550550 {#syntax#}i7{#endsyntax#} refers to a signed 7-bit integer. The maximum allowed bit-width of an
551551 integer type is {#syntax#}65535{#endsyntax#}.
552552 </p>
553 {#see_also|Integers|Floats|void|Errors|@IntType#}
553 {#see_also|Integers|Floats|void|Errors|@Type#}
554554 {#header_close#}
555555 {#header_open|Primitive Values#}
556556 <div class="table-wrapper">
......@@ -6667,18 +6667,6 @@ comptime {
66676667 </p>
66686668 {#see_also|Alignment#}
66696669 {#header_close#}
6670 {#header_open|@ArgType#}
6671 <pre>{#syntax#}@ArgType(comptime T: type, comptime n: usize) type{#endsyntax#}</pre>
6672 <p>
6673 This builtin function takes a function type and returns the type of the parameter at index {#syntax#}n{#endsyntax#}.
6674 </p>
6675 <p>
6676 {#syntax#}T{#endsyntax#} must be a function type.
6677 </p>
6678 <p>
6679 Note: This function is deprecated. Use {#link|@typeInfo#} instead.
6680 </p>
6681 {#header_close#}
66826670
66836671 {#header_open|@as#}
66846672 <pre>{#syntax#}@as(comptime T: type, expression) T{#endsyntax#}</pre>
......@@ -7337,7 +7325,7 @@ test "main" {
73377325 {#header_close#}
73387326
73397327 {#header_open|@errorToInt#}
7340 <pre>{#syntax#}@errorToInt(err: var) @IntType(false, @sizeOf(anyerror) * 8){#endsyntax#}</pre>
7328 <pre>{#syntax#}@errorToInt(err: var) std.meta.IntType(false, @sizeOf(anyerror) * 8){#endsyntax#}</pre>
73417329 <p>
73427330 Supports the following types:
73437331 </p>
......@@ -7631,7 +7619,7 @@ test "@hasDecl" {
76317619 {#header_close#}
76327620
76337621 {#header_open|@intToError#}
7634 <pre>{#syntax#}@intToError(value: @IntType(false, @sizeOf(anyerror) * 8)) anyerror{#endsyntax#}</pre>
7622 <pre>{#syntax#}@intToError(value: std.meta.IntType(false, @sizeOf(anyerror) * 8)) anyerror{#endsyntax#}</pre>
76357623 <p>
76367624 Converts from the integer representation of an error into {#link|The Global Error Set#} type.
76377625 </p>
......@@ -7664,17 +7652,6 @@ test "@hasDecl" {
76647652 </p>
76657653 {#header_close#}
76667654
7667 {#header_open|@IntType#}
7668 <pre>{#syntax#}@IntType(comptime is_signed: bool, comptime bit_count: u16) type{#endsyntax#}</pre>
7669 <p>
7670 This function returns an integer type with the given signness and bit count. The maximum
7671 bit count for an integer type is {#syntax#}65535{#endsyntax#}.
7672 </p>
7673 <p>
7674 Deprecated. Use {#link|@Type#}.
7675 </p>
7676 {#header_close#}
7677
76787655 {#header_open|@memcpy#}
76797656 <pre>{#syntax#}@memcpy(noalias dest: [*]u8, noalias source: [*]const u8, byte_count: usize){#endsyntax#}</pre>
76807657 <p>
lib/std/child_process.zig+1-1
......@@ -851,7 +851,7 @@ fn forkChildErrReport(fd: i32, err: ChildProcess.SpawnError) noreturn {
851851 os.exit(1);
852852}
853853
854const ErrInt = @IntType(false, @sizeOf(anyerror) * 8);
854const ErrInt = std.meta.IntType(false, @sizeOf(anyerror) * 8);
855855
856856fn writeIntFd(fd: i32, value: ErrInt) !void {
857857 const file = File{
lib/std/debug/leb128.zig+6-6
......@@ -2,7 +2,7 @@ const std = @import("std");
22const testing = std.testing;
33
44pub fn readULEB128(comptime T: type, in_stream: var) !T {
5 const ShiftT = @IntType(false, std.math.log2(T.bit_count));
5 const ShiftT = std.meta.IntType(false, std.math.log2(T.bit_count));
66
77 var result: T = 0;
88 var shift: usize = 0;
......@@ -27,7 +27,7 @@ pub fn readULEB128(comptime T: type, in_stream: var) !T {
2727}
2828
2929pub fn readULEB128Mem(comptime T: type, ptr: *[*]const u8) !T {
30 const ShiftT = @IntType(false, std.math.log2(T.bit_count));
30 const ShiftT = std.meta.IntType(false, std.math.log2(T.bit_count));
3131
3232 var result: T = 0;
3333 var shift: usize = 0;
......@@ -55,8 +55,8 @@ pub fn readULEB128Mem(comptime T: type, ptr: *[*]const u8) !T {
5555}
5656
5757pub fn readILEB128(comptime T: type, in_stream: var) !T {
58 const UT = @IntType(false, T.bit_count);
59 const ShiftT = @IntType(false, std.math.log2(T.bit_count));
58 const UT = std.meta.IntType(false, T.bit_count);
59 const ShiftT = std.meta.IntType(false, std.math.log2(T.bit_count));
6060
6161 var result: UT = 0;
6262 var shift: usize = 0;
......@@ -87,8 +87,8 @@ pub fn readILEB128(comptime T: type, in_stream: var) !T {
8787}
8888
8989pub fn readILEB128Mem(comptime T: type, ptr: *[*]const u8) !T {
90 const UT = @IntType(false, T.bit_count);
91 const ShiftT = @IntType(false, std.math.log2(T.bit_count));
90 const UT = std.meta.IntType(false, T.bit_count);
91 const ShiftT = std.meta.IntType(false, std.math.log2(T.bit_count));
9292
9393 var result: UT = 0;
9494 var shift: usize = 0;
lib/std/fmt.zig+3-3
......@@ -82,7 +82,7 @@ pub fn format(
8282 comptime fmt: []const u8,
8383 args: var,
8484) Errors!void {
85 const ArgSetType = @IntType(false, 32);
85 const ArgSetType = u32;
8686 if (@typeInfo(@TypeOf(args)) != .Struct) {
8787 @compileError("Expected tuple or struct argument, found " ++ @typeName(@TypeOf(args)));
8888 }
......@@ -944,7 +944,7 @@ fn formatIntSigned(
944944 .fill = options.fill,
945945 };
946946
947 const uint = @IntType(false, @TypeOf(value).bit_count);
947 const uint = std.meta.IntType(false, @TypeOf(value).bit_count);
948948 if (value < 0) {
949949 const minus_sign: u8 = '-';
950950 try output(context, @as(*const [1]u8, &minus_sign)[0..]);
......@@ -972,7 +972,7 @@ fn formatIntUnsigned(
972972 assert(base >= 2);
973973 var buf: [math.max(@TypeOf(value).bit_count, 1)]u8 = undefined;
974974 const min_int_bits = comptime math.max(@TypeOf(value).bit_count, @TypeOf(base).bit_count);
975 const MinInt = @IntType(@TypeOf(value).is_signed, min_int_bits);
975 const MinInt = std.meta.IntType(@TypeOf(value).is_signed, min_int_bits);
976976 var a: MinInt = value;
977977 var index: usize = buf.len;
978978
lib/std/fmt/parse_float.zig+1-1
......@@ -393,7 +393,7 @@ test "fmt.parseFloat" {
393393 const epsilon = 1e-7;
394394
395395 inline for ([_]type{ f16, f32, f64, f128 }) |T| {
396 const Z = @IntType(false, T.bit_count);
396 const Z = std.meta.IntType(false, T.bit_count);
397397
398398 testing.expectError(error.InvalidCharacter, parseFloat(T, ""));
399399 testing.expectError(error.InvalidCharacter, parseFloat(T, " 1"));
lib/std/hash/auto_hash.zig+1-1
......@@ -93,7 +93,7 @@ pub fn hash(hasher: var, key: var, comptime strat: HashStrategy) void {
9393 // TODO Check if the situation is better after #561 is resolved.
9494 .Int => @call(.{ .modifier = .always_inline }, hasher.update, .{std.mem.asBytes(&key)}),
9595
96 .Float => |info| hash(hasher, @bitCast(@IntType(false, info.bits), key), strat),
96 .Float => |info| hash(hasher, @bitCast(std.meta.IntType(false, info.bits), key), strat),
9797
9898 .Bool => hash(hasher, @boolToInt(key), strat),
9999 .Enum => hash(hasher, @enumToInt(key), strat),
lib/std/hash/wyhash.zig+1-1
......@@ -10,7 +10,7 @@ const primes = [_]u64{
1010};
1111
1212fn read_bytes(comptime bytes: u8, data: []const u8) u64 {
13 const T = @IntType(false, 8 * bytes);
13 const T = std.meta.IntType(false, 8 * bytes);
1414 return mem.readIntSliceLittle(T, data[0..bytes]);
1515}
1616
lib/std/heap.zig+1-1
......@@ -1015,7 +1015,7 @@ fn testAllocatorLargeAlignment(allocator: *mem.Allocator) mem.Allocator.Error!vo
10151015 // very near usize?
10161016 if (mem.page_size << 2 > maxInt(usize)) return;
10171017
1018 const USizeShift = @IntType(false, std.math.log2(usize.bit_count));
1018 const USizeShift = std.meta.IntType(false, std.math.log2(usize.bit_count));
10191019 const large_align = @as(u29, mem.page_size << 2);
10201020
10211021 var align_mask: usize = undefined;
lib/std/io.zig+5-5
......@@ -337,7 +337,7 @@ pub fn BitInStream(endian: builtin.Endian, comptime Error: type) type {
337337 assert(u_bit_count >= bits);
338338 break :bc if (u_bit_count <= u8_bit_count) u8_bit_count else u_bit_count;
339339 };
340 const Buf = @IntType(false, buf_bit_count);
340 const Buf = std.meta.IntType(false, buf_bit_count);
341341 const BufShift = math.Log2Int(Buf);
342342
343343 out_bits.* = @as(usize, 0);
......@@ -659,7 +659,7 @@ pub fn BitOutStream(endian: builtin.Endian, comptime Error: type) type {
659659 assert(u_bit_count >= bits);
660660 break :bc if (u_bit_count <= u8_bit_count) u8_bit_count else u_bit_count;
661661 };
662 const Buf = @IntType(false, buf_bit_count);
662 const Buf = std.meta.IntType(false, buf_bit_count);
663663 const BufShift = math.Log2Int(Buf);
664664
665665 const buf_value = @intCast(Buf, value);
......@@ -836,7 +836,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,
836836 const u8_bit_count = 8;
837837 const t_bit_count = comptime meta.bitCount(T);
838838
839 const U = @IntType(false, t_bit_count);
839 const U = std.meta.IntType(false, t_bit_count);
840840 const Log2U = math.Log2Int(U);
841841 const int_size = (U.bit_count + 7) / 8;
842842
......@@ -851,7 +851,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,
851851
852852 if (int_size == 1) {
853853 if (t_bit_count == 8) return @bitCast(T, buffer[0]);
854 const PossiblySignedByte = @IntType(T.is_signed, 8);
854 const PossiblySignedByte = std.meta.IntType(T.is_signed, 8);
855855 return @truncate(T, @bitCast(PossiblySignedByte, buffer[0]));
856856 }
857857
......@@ -1014,7 +1014,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co
10141014 const t_bit_count = comptime meta.bitCount(T);
10151015 const u8_bit_count = comptime meta.bitCount(u8);
10161016
1017 const U = @IntType(false, t_bit_count);
1017 const U = std.meta.IntType(false, t_bit_count);
10181018 const Log2U = math.Log2Int(U);
10191019 const int_size = (U.bit_count + 7) / 8;
10201020
lib/std/io/test.zig+5-4
......@@ -318,6 +318,7 @@ test "BitStreams with File Stream" {
318318}
319319
320320fn testIntSerializerDeserializer(comptime endian: builtin.Endian, comptime packing: io.Packing) !void {
321 @setEvalBranchQuota(1500);
321322 //@NOTE: if this test is taking too long, reduce the maximum tested bitsize
322323 const max_test_bitsize = 128;
323324
......@@ -341,8 +342,8 @@ fn testIntSerializerDeserializer(comptime endian: builtin.Endian, comptime packi
341342
342343 comptime var i = 0;
343344 inline while (i <= max_test_bitsize) : (i += 1) {
344 const U = @IntType(false, i);
345 const S = @IntType(true, i);
345 const U = std.meta.IntType(false, i);
346 const S = std.meta.IntType(true, i);
346347 try serializer.serializeInt(@as(U, i));
347348 if (i != 0) try serializer.serializeInt(@as(S, -1)) else try serializer.serialize(@as(S, 0));
348349 }
......@@ -350,8 +351,8 @@ fn testIntSerializerDeserializer(comptime endian: builtin.Endian, comptime packi
350351
351352 i = 0;
352353 inline while (i <= max_test_bitsize) : (i += 1) {
353 const U = @IntType(false, i);
354 const S = @IntType(true, i);
354 const U = std.meta.IntType(false, i);
355 const S = std.meta.IntType(true, i);
355356 const x = try deserializer.deserializeInt(U);
356357 const y = try deserializer.deserializeInt(S);
357358 expect(x == @as(U, i));
lib/std/math.zig+11-11
......@@ -444,7 +444,7 @@ pub fn Log2Int(comptime T: type) type {
444444 count += 1;
445445 }
446446
447 return @IntType(false, count);
447 return std.meta.IntType(false, count);
448448}
449449
450450pub fn IntFittingRange(comptime from: comptime_int, comptime to: comptime_int) type {
......@@ -460,7 +460,7 @@ pub fn IntFittingRange(comptime from: comptime_int, comptime to: comptime_int) t
460460 if (is_signed) {
461461 magnitude_bits += 1;
462462 }
463 return @IntType(is_signed, magnitude_bits);
463 return std.meta.IntType(is_signed, magnitude_bits);
464464}
465465
466466test "math.IntFittingRange" {
......@@ -674,13 +674,13 @@ pub fn absCast(x: var) t: {
674674 if (@TypeOf(x) == comptime_int) {
675675 break :t comptime_int;
676676 } else {
677 break :t @IntType(false, @TypeOf(x).bit_count);
677 break :t std.meta.IntType(false, @TypeOf(x).bit_count);
678678 }
679679} {
680680 if (@TypeOf(x) == comptime_int) {
681681 return if (x < 0) -x else x;
682682 }
683 const uint = @IntType(false, @TypeOf(x).bit_count);
683 const uint = std.meta.IntType(false, @TypeOf(x).bit_count);
684684 if (x >= 0) return @intCast(uint, x);
685685
686686 return @intCast(uint, -(x + 1)) + 1;
......@@ -701,10 +701,10 @@ test "math.absCast" {
701701
702702/// Returns the negation of the integer parameter.
703703/// Result is a signed integer.
704pub fn negateCast(x: var) !@IntType(true, @TypeOf(x).bit_count) {
704pub fn negateCast(x: var) !std.meta.IntType(true, @TypeOf(x).bit_count) {
705705 if (@TypeOf(x).is_signed) return negate(x);
706706
707 const int = @IntType(true, @TypeOf(x).bit_count);
707 const int = std.meta.IntType(true, @TypeOf(x).bit_count);
708708 if (x > -minInt(int)) return error.Overflow;
709709
710710 if (x == -minInt(int)) return minInt(int);
......@@ -790,11 +790,11 @@ fn testFloorPowerOfTwo() void {
790790/// Returns the next power of two (if the value is not already a power of two).
791791/// Only unsigned integers can be used. Zero is not an allowed input.
792792/// Result is a type with 1 more bit than the input type.
793pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) @IntType(T.is_signed, T.bit_count + 1) {
793pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) std.meta.IntType(T.is_signed, T.bit_count + 1) {
794794 comptime assert(@typeInfo(T) == .Int);
795795 comptime assert(!T.is_signed);
796796 assert(value != 0);
797 comptime const PromotedType = @IntType(T.is_signed, T.bit_count + 1);
797 comptime const PromotedType = std.meta.IntType(T.is_signed, T.bit_count + 1);
798798 comptime const shiftType = std.math.Log2Int(PromotedType);
799799 return @as(PromotedType, 1) << @intCast(shiftType, T.bit_count - @clz(T, value - 1));
800800}
......@@ -805,7 +805,7 @@ pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) @IntType(T.is_signed, T
805805pub fn ceilPowerOfTwo(comptime T: type, value: T) (error{Overflow}!T) {
806806 comptime assert(@typeInfo(T) == .Int);
807807 comptime assert(!T.is_signed);
808 comptime const PromotedType = @IntType(T.is_signed, T.bit_count + 1);
808 comptime const PromotedType = std.meta.IntType(T.is_signed, T.bit_count + 1);
809809 comptime const overflowBit = @as(PromotedType, 1) << T.bit_count;
810810 var x = ceilPowerOfTwoPromote(T, value);
811811 if (overflowBit & x != 0) {
......@@ -947,8 +947,8 @@ test "max value type" {
947947 testing.expect(x == 2147483647);
948948}
949949
950pub fn mulWide(comptime T: type, a: T, b: T) @IntType(T.is_signed, T.bit_count * 2) {
951 const ResultInt = @IntType(T.is_signed, T.bit_count * 2);
950pub fn mulWide(comptime T: type, a: T, b: T) std.meta.IntType(T.is_signed, T.bit_count * 2) {
951 const ResultInt = std.meta.IntType(T.is_signed, T.bit_count * 2);
952952 return @as(ResultInt, a) * @as(ResultInt, b);
953953}
954954
lib/std/math/big/int.zig+3-3
......@@ -9,7 +9,7 @@ const maxInt = std.math.maxInt;
99const minInt = std.math.minInt;
1010
1111pub const Limb = usize;
12pub const DoubleLimb = @IntType(false, 2 * Limb.bit_count);
12pub const DoubleLimb = std.meta.IntType(false, 2 * Limb.bit_count);
1313pub const Log2Limb = math.Log2Int(Limb);
1414
1515comptime {
......@@ -268,7 +268,7 @@ pub const Int = struct {
268268
269269 switch (@typeInfo(T)) {
270270 .Int => |info| {
271 const UT = if (T.is_signed) @IntType(false, T.bit_count - 1) else T;
271 const UT = if (T.is_signed) std.meta.IntType(false, T.bit_count - 1) else T;
272272
273273 try self.ensureCapacity(@sizeOf(UT) / @sizeOf(Limb));
274274 self.metadata = 0;
......@@ -331,7 +331,7 @@ pub const Int = struct {
331331 pub fn to(self: Int, comptime T: type) ConvertError!T {
332332 switch (@typeInfo(T)) {
333333 .Int => {
334 const UT = @IntType(false, T.bit_count);
334 const UT = std.meta.IntType(false, T.bit_count);
335335
336336 if (self.bitCountTwosComp() > T.bit_count) {
337337 return error.TargetTooSmall;
lib/std/math/big/rational.zig+3-3
......@@ -128,7 +128,7 @@ pub const Rational = struct {
128128 // Translated from golang.go/src/math/big/rat.go.
129129 debug.assert(@typeInfo(T) == .Float);
130130
131 const UnsignedIntType = @IntType(false, T.bit_count);
131 const UnsignedIntType = std.meta.IntType(false, T.bit_count);
132132 const f_bits = @bitCast(UnsignedIntType, f);
133133
134134 const exponent_bits = math.floatExponentBits(T);
......@@ -187,7 +187,7 @@ pub const Rational = struct {
187187 debug.assert(@typeInfo(T) == .Float);
188188
189189 const fsize = T.bit_count;
190 const BitReprType = @IntType(false, T.bit_count);
190 const BitReprType = std.meta.IntType(false, T.bit_count);
191191
192192 const msize = math.floatMantissaBits(T);
193193 const msize1 = msize + 1;
......@@ -462,7 +462,7 @@ pub const Rational = struct {
462462 }
463463};
464464
465const SignedDoubleLimb = @IntType(true, DoubleLimb.bit_count);
465const SignedDoubleLimb = std.meta.IntType(true, DoubleLimb.bit_count);
466466
467467fn gcd(rma: *Int, x: Int, y: Int) !void {
468468 rma.assertWritable();
lib/std/math/cos.zig+1-1
......@@ -44,7 +44,7 @@ const pi4c = 2.69515142907905952645E-15;
4444const m4pi = 1.273239544735162542821171882678754627704620361328125;
4545
4646fn cos_(comptime T: type, x_: T) T {
47 const I = @IntType(true, T.bit_count);
47 const I = std.meta.IntType(true, T.bit_count);
4848
4949 var x = x_;
5050 if (math.isNan(x) or math.isInf(x)) {
lib/std/math/pow.zig+1-1
......@@ -145,7 +145,7 @@ pub fn pow(comptime T: type, x: T, y: T) T {
145145 var xe = r2.exponent;
146146 var x1 = r2.significand;
147147
148 var i = @floatToInt(@IntType(true, T.bit_count), yi);
148 var i = @floatToInt(std.meta.IntType(true, T.bit_count), yi);
149149 while (i != 0) : (i >>= 1) {
150150 const overflow_shift = math.floatExponentBits(T) + 1;
151151 if (xe < -(1 << overflow_shift) or (1 << overflow_shift) < xe) {
lib/std/math/sin.zig+1-1
......@@ -45,7 +45,7 @@ const pi4c = 2.69515142907905952645E-15;
4545const m4pi = 1.273239544735162542821171882678754627704620361328125;
4646
4747fn sin_(comptime T: type, x_: T) T {
48 const I = @IntType(true, T.bit_count);
48 const I = std.meta.IntType(true, T.bit_count);
4949
5050 var x = x_;
5151 if (x == 0 or math.isNan(x)) {
lib/std/math/sqrt.zig+3-3
......@@ -31,7 +31,7 @@ pub fn sqrt(x: var) Sqrt(@TypeOf(x)) {
3131 }
3232}
3333
34fn sqrt_int(comptime T: type, value: T) @IntType(false, T.bit_count / 2) {
34fn sqrt_int(comptime T: type, value: T) std.meta.IntType(false, T.bit_count / 2) {
3535 var op = value;
3636 var res: T = 0;
3737 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) {
5050 one >>= 2;
5151 }
5252
53 const ResultType = @IntType(false, T.bit_count / 2);
53 const ResultType = std.meta.IntType(false, T.bit_count / 2);
5454 return @intCast(ResultType, res);
5555}
5656
......@@ -66,7 +66,7 @@ test "math.sqrt_int" {
6666/// Returns the return type `sqrt` will return given an operand of type `T`.
6767pub fn Sqrt(comptime T: type) type {
6868 return switch (@typeInfo(T)) {
69 .Int => |int| @IntType(false, int.bits / 2),
69 .Int => |int| std.meta.IntType(false, int.bits / 2),
7070 else => T,
7171 };
7272}
lib/std/math/tan.zig+1-1
......@@ -38,7 +38,7 @@ const pi4c = 2.69515142907905952645E-15;
3838const m4pi = 1.273239544735162542821171882678754627704620361328125;
3939
4040fn tan_(comptime T: type, x_: T) T {
41 const I = @IntType(true, T.bit_count);
41 const I = std.meta.IntType(true, T.bit_count);
4242
4343 var x = x_;
4444 if (x == 0 or math.isNan(x)) {
lib/std/mem.zig+2-2
......@@ -708,7 +708,7 @@ pub fn writeIntSliceLittle(comptime T: type, buffer: []u8, value: T) void {
708708 assert(buffer.len >= @divExact(T.bit_count, 8));
709709
710710 // TODO I want to call writeIntLittle here but comptime eval facilities aren't good enough
711 const uint = @IntType(false, T.bit_count);
711 const uint = std.meta.IntType(false, T.bit_count);
712712 var bits = @truncate(uint, value);
713713 for (buffer) |*b| {
714714 b.* = @truncate(u8, bits);
......@@ -725,7 +725,7 @@ pub fn writeIntSliceBig(comptime T: type, buffer: []u8, value: T) void {
725725 assert(buffer.len >= @divExact(T.bit_count, 8));
726726
727727 // TODO I want to call writeIntBig here but comptime eval facilities aren't good enough
728 const uint = @IntType(false, T.bit_count);
728 const uint = std.meta.IntType(false, T.bit_count);
729729 var bits = @truncate(uint, value);
730730 var index: usize = buffer.len;
731731 while (index != 0) {
lib/std/meta.zig+9
......@@ -580,3 +580,12 @@ pub fn declList(comptime Namespace: type, comptime Decl: type) []const *const De
580580 return &array;
581581 }
582582}
583
584pub fn IntType(comptime is_signed: bool, comptime bit_count: u16) type {
585 return @Type(TypeInfo{
586 .Int = .{
587 .is_signed = is_signed,
588 .bits = bit_count,
589 },
590 });
591}
lib/std/os.zig+1-1
......@@ -3349,7 +3349,7 @@ pub fn res_mkquery(
33493349 // Make a reasonably unpredictable id
33503350 var ts: timespec = undefined;
33513351 clock_gettime(CLOCK_REALTIME, &ts) catch {};
3352 const UInt = @IntType(false, @TypeOf(ts.tv_nsec).bit_count);
3352 const UInt = std.meta.IntType(false, @TypeOf(ts.tv_nsec).bit_count);
33533353 const unsec = @bitCast(UInt, ts.tv_nsec);
33543354 const id = @truncate(u32, unsec + unsec / 65536);
33553355 q[0] = @truncate(u8, id / 256);
lib/std/os/bits/linux.zig+1-1
......@@ -1004,7 +1004,7 @@ pub const dl_phdr_info = extern struct {
10041004
10051005pub const CPU_SETSIZE = 128;
10061006pub const cpu_set_t = [CPU_SETSIZE / @sizeOf(usize)]usize;
1007pub const cpu_count_t = @IntType(false, std.math.log2(CPU_SETSIZE * 8));
1007pub const cpu_count_t = std.meta.IntType(false, std.math.log2(CPU_SETSIZE * 8));
10081008
10091009pub fn CPU_COUNT(set: cpu_set_t) cpu_count_t {
10101010 var sum: cpu_count_t = 0;
lib/std/packed_int_array.zig+6-6
......@@ -34,13 +34,13 @@ pub fn PackedIntIo(comptime Int: type, comptime endian: builtin.Endian) type {
3434
3535 //we bitcast the desired Int type to an unsigned version of itself
3636 // to avoid issues with shifting signed ints.
37 const UnInt = @IntType(false, int_bits);
37 const UnInt = std.meta.IntType(false, int_bits);
3838
3939 //The maximum container int type
40 const MinIo = @IntType(false, min_io_bits);
40 const MinIo = std.meta.IntType(false, min_io_bits);
4141
4242 //The minimum container int type
43 const MaxIo = @IntType(false, max_io_bits);
43 const MaxIo = std.meta.IntType(false, max_io_bits);
4444
4545 return struct {
4646 pub fn get(bytes: []const u8, index: usize, bit_offset: u7) Int {
......@@ -322,7 +322,7 @@ test "PackedIntArray" {
322322 inline while (bits <= 256) : (bits += 1) {
323323 //alternate unsigned and signed
324324 const even = bits % 2 == 0;
325 const I = @IntType(even, bits);
325 const I = std.meta.IntType(even, bits);
326326
327327 const PackedArray = PackedIntArray(I, int_count);
328328 const expected_bytes = ((bits * int_count) + 7) / 8;
......@@ -369,7 +369,7 @@ test "PackedIntSlice" {
369369 inline while (bits <= 256) : (bits += 1) {
370370 //alternate unsigned and signed
371371 const even = bits % 2 == 0;
372 const I = @IntType(even, bits);
372 const I = std.meta.IntType(even, bits);
373373 const P = PackedIntSlice(I);
374374
375375 var data = P.init(&buffer, int_count);
......@@ -399,7 +399,7 @@ test "PackedIntSlice of PackedInt(Array/Slice)" {
399399
400400 comptime var bits = 0;
401401 inline while (bits <= max_bits) : (bits += 1) {
402 const Int = @IntType(false, bits);
402 const Int = std.meta.IntType(false, bits);
403403
404404 const PackedArray = PackedIntArray(Int, int_count);
405405 var packed_array = @as(PackedArray, undefined);
lib/std/rand.zig+10-10
......@@ -45,8 +45,8 @@ pub const Random = struct {
4545 /// Returns a random int `i` such that `0 <= i <= maxInt(T)`.
4646 /// `i` is evenly distributed.
4747 pub fn int(r: *Random, comptime T: type) T {
48 const UnsignedT = @IntType(false, T.bit_count);
49 const ByteAlignedT = @IntType(false, @divTrunc(T.bit_count + 7, 8) * 8);
48 const UnsignedT = std.meta.IntType(false, T.bit_count);
49 const ByteAlignedT = std.meta.IntType(false, @divTrunc(T.bit_count + 7, 8) * 8);
5050
5151 var rand_bytes: [@sizeOf(ByteAlignedT)]u8 = undefined;
5252 r.bytes(rand_bytes[0..]);
......@@ -85,9 +85,9 @@ pub const Random = struct {
8585 comptime assert(T.bit_count <= 64); // TODO: workaround: LLVM ERROR: Unsupported library call operation!
8686 assert(0 < less_than);
8787 // Small is typically u32
88 const Small = @IntType(false, @divTrunc(T.bit_count + 31, 32) * 32);
88 const Small = std.meta.IntType(false, @divTrunc(T.bit_count + 31, 32) * 32);
8989 // Large is typically u64
90 const Large = @IntType(false, Small.bit_count * 2);
90 const Large = std.meta.IntType(false, Small.bit_count * 2);
9191
9292 // adapted from:
9393 // http://www.pcg-random.org/posts/bounded-rands.html
......@@ -99,7 +99,7 @@ pub const Random = struct {
9999 // TODO: workaround for https://github.com/ziglang/zig/issues/1770
100100 // should be:
101101 // var t: Small = -%less_than;
102 var t: Small = @bitCast(Small, -%@bitCast(@IntType(true, Small.bit_count), @as(Small, less_than)));
102 var t: Small = @bitCast(Small, -%@bitCast(std.meta.IntType(true, Small.bit_count), @as(Small, less_than)));
103103
104104 if (t >= less_than) {
105105 t -= less_than;
......@@ -145,7 +145,7 @@ pub const Random = struct {
145145 assert(at_least < less_than);
146146 if (T.is_signed) {
147147 // Two's complement makes this math pretty easy.
148 const UnsignedT = @IntType(false, T.bit_count);
148 const UnsignedT = std.meta.IntType(false, T.bit_count);
149149 const lo = @bitCast(UnsignedT, at_least);
150150 const hi = @bitCast(UnsignedT, less_than);
151151 const result = lo +% r.uintLessThanBiased(UnsignedT, hi -% lo);
......@@ -163,7 +163,7 @@ pub const Random = struct {
163163 assert(at_least < less_than);
164164 if (T.is_signed) {
165165 // Two's complement makes this math pretty easy.
166 const UnsignedT = @IntType(false, T.bit_count);
166 const UnsignedT = std.meta.IntType(false, T.bit_count);
167167 const lo = @bitCast(UnsignedT, at_least);
168168 const hi = @bitCast(UnsignedT, less_than);
169169 const result = lo +% r.uintLessThan(UnsignedT, hi -% lo);
......@@ -180,7 +180,7 @@ pub const Random = struct {
180180 assert(at_least <= at_most);
181181 if (T.is_signed) {
182182 // Two's complement makes this math pretty easy.
183 const UnsignedT = @IntType(false, T.bit_count);
183 const UnsignedT = std.meta.IntType(false, T.bit_count);
184184 const lo = @bitCast(UnsignedT, at_least);
185185 const hi = @bitCast(UnsignedT, at_most);
186186 const result = lo +% r.uintAtMostBiased(UnsignedT, hi -% lo);
......@@ -198,7 +198,7 @@ pub const Random = struct {
198198 assert(at_least <= at_most);
199199 if (T.is_signed) {
200200 // Two's complement makes this math pretty easy.
201 const UnsignedT = @IntType(false, T.bit_count);
201 const UnsignedT = std.meta.IntType(false, T.bit_count);
202202 const lo = @bitCast(UnsignedT, at_least);
203203 const hi = @bitCast(UnsignedT, at_most);
204204 const result = lo +% r.uintAtMost(UnsignedT, hi -% lo);
......@@ -281,7 +281,7 @@ pub const Random = struct {
281281/// This function introduces a minor bias.
282282pub fn limitRangeBiased(comptime T: type, random_int: T, less_than: T) T {
283283 comptime assert(T.is_signed == false);
284 const T2 = @IntType(false, T.bit_count * 2);
284 const T2 = std.meta.IntType(false, T.bit_count * 2);
285285
286286 // adapted from:
287287 // http://www.pcg-random.org/posts/bounded-rands.html
lib/std/special/c.zig+1-1
......@@ -511,7 +511,7 @@ export fn roundf(a: f32) f32 {
511511fn generic_fmod(comptime T: type, x: T, y: T) T {
512512 @setRuntimeSafety(false);
513513
514 const uint = @IntType(false, T.bit_count);
514 const uint = std.meta.IntType(false, T.bit_count);
515515 const log2uint = math.Log2Int(uint);
516516 const digits = if (T == f32) 23 else 52;
517517 const exp_bits = if (T == f32) 9 else 12;
lib/std/special/compiler_rt/addXf3.zig+7-7
......@@ -54,21 +54,21 @@ pub fn __aeabi_dsub(a: f64, b: f64) callconv(.AAPCS) f64 {
5454}
5555
5656// TODO: restore inline keyword, see: https://github.com/ziglang/zig/issues/2154
57fn normalize(comptime T: type, significand: *@IntType(false, T.bit_count)) i32 {
58 const Z = @IntType(false, T.bit_count);
59 const S = @IntType(false, T.bit_count - @clz(Z, @as(Z, T.bit_count) - 1));
57fn normalize(comptime T: type, significand: *std.meta.IntType(false, T.bit_count)) i32 {
58 const Z = std.meta.IntType(false, T.bit_count);
59 const S = std.meta.IntType(false, T.bit_count - @clz(Z, @as(Z, T.bit_count) - 1));
6060 const significandBits = std.math.floatMantissaBits(T);
6161 const implicitBit = @as(Z, 1) << significandBits;
6262
63 const shift = @clz(@IntType(false, T.bit_count), significand.*) - @clz(Z, implicitBit);
63 const shift = @clz(std.meta.IntType(false, T.bit_count), significand.*) - @clz(Z, implicitBit);
6464 significand.* <<= @intCast(S, shift);
6565 return 1 - shift;
6666}
6767
6868// TODO: restore inline keyword, see: https://github.com/ziglang/zig/issues/2154
6969fn addXf3(comptime T: type, a: T, b: T) T {
70 const Z = @IntType(false, T.bit_count);
71 const S = @IntType(false, T.bit_count - @clz(Z, @as(Z, T.bit_count) - 1));
70 const Z = std.meta.IntType(false, T.bit_count);
71 const S = std.meta.IntType(false, T.bit_count - @clz(Z, @as(Z, T.bit_count) - 1));
7272
7373 const typeWidth = T.bit_count;
7474 const significandBits = std.math.floatMantissaBits(T);
......@@ -182,7 +182,7 @@ fn addXf3(comptime T: type, a: T, b: T) T {
182182 // If partial cancellation occured, we need to left-shift the result
183183 // and adjust the exponent:
184184 if (aSignificand < implicitBit << 3) {
185 const shift = @intCast(i32, @clz(Z, aSignificand)) - @intCast(i32, @clz(@IntType(false, T.bit_count), implicitBit << 3));
185 const shift = @intCast(i32, @clz(Z, aSignificand)) - @intCast(i32, @clz(std.meta.IntType(false, T.bit_count), implicitBit << 3));
186186 aSignificand <<= @intCast(S, shift);
187187 aExponent -= shift;
188188 }
lib/std/special/compiler_rt/compareXf2.zig+3-3
......@@ -22,8 +22,8 @@ const GE = extern enum(i32) {
2222pub fn cmp(comptime T: type, comptime RT: type, a: T, b: T) RT {
2323 @setRuntimeSafety(builtin.is_test);
2424
25 const srep_t = @IntType(true, T.bit_count);
26 const rep_t = @IntType(false, T.bit_count);
25 const srep_t = std.meta.IntType(true, T.bit_count);
26 const rep_t = std.meta.IntType(false, T.bit_count);
2727
2828 const significandBits = std.math.floatMantissaBits(T);
2929 const exponentBits = std.math.floatExponentBits(T);
......@@ -68,7 +68,7 @@ pub fn cmp(comptime T: type, comptime RT: type, a: T, b: T) RT {
6868pub fn unordcmp(comptime T: type, a: T, b: T) i32 {
6969 @setRuntimeSafety(builtin.is_test);
7070
71 const rep_t = @IntType(false, T.bit_count);
71 const rep_t = std.meta.IntType(false, T.bit_count);
7272
7373 const significandBits = std.math.floatMantissaBits(T);
7474 const exponentBits = std.math.floatExponentBits(T);
lib/std/special/compiler_rt/divdf3.zig+4-4
......@@ -7,8 +7,8 @@ const builtin = @import("builtin");
77
88pub fn __divdf3(a: f64, b: f64) callconv(.C) f64 {
99 @setRuntimeSafety(builtin.is_test);
10 const Z = @IntType(false, f64.bit_count);
11 const SignedZ = @IntType(true, f64.bit_count);
10 const Z = std.meta.IntType(false, f64.bit_count);
11 const SignedZ = std.meta.IntType(true, f64.bit_count);
1212
1313 const typeWidth = f64.bit_count;
1414 const significandBits = std.math.floatMantissaBits(f64);
......@@ -312,9 +312,9 @@ fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void {
312312 }
313313}
314314
315fn normalize(comptime T: type, significand: *@IntType(false, T.bit_count)) i32 {
315fn normalize(comptime T: type, significand: *std.meta.IntType(false, T.bit_count)) i32 {
316316 @setRuntimeSafety(builtin.is_test);
317 const Z = @IntType(false, T.bit_count);
317 const Z = std.meta.IntType(false, T.bit_count);
318318 const significandBits = std.math.floatMantissaBits(T);
319319 const implicitBit = @as(Z, 1) << significandBits;
320320
lib/std/special/compiler_rt/divsf3.zig+3-3
......@@ -7,7 +7,7 @@ const builtin = @import("builtin");
77
88pub fn __divsf3(a: f32, b: f32) callconv(.C) f32 {
99 @setRuntimeSafety(builtin.is_test);
10 const Z = @IntType(false, f32.bit_count);
10 const Z = std.meta.IntType(false, f32.bit_count);
1111
1212 const typeWidth = f32.bit_count;
1313 const significandBits = std.math.floatMantissaBits(f32);
......@@ -185,9 +185,9 @@ pub fn __divsf3(a: f32, b: f32) callconv(.C) f32 {
185185 }
186186}
187187
188fn normalize(comptime T: type, significand: *@IntType(false, T.bit_count)) i32 {
188fn normalize(comptime T: type, significand: *std.meta.IntType(false, T.bit_count)) i32 {
189189 @setRuntimeSafety(builtin.is_test);
190 const Z = @IntType(false, T.bit_count);
190 const Z = std.meta.IntType(false, T.bit_count);
191191 const significandBits = std.math.floatMantissaBits(T);
192192 const implicitBit = @as(Z, 1) << significandBits;
193193
lib/std/special/compiler_rt/extendXfYf2.zig+3-3
......@@ -30,11 +30,11 @@ pub fn __aeabi_f2d(arg: f32) callconv(.AAPCS) f64 {
3030
3131const CHAR_BIT = 8;
3232
33fn extendXfYf2(comptime dst_t: type, comptime src_t: type, a: @IntType(false, @typeInfo(src_t).Float.bits)) dst_t {
33fn extendXfYf2(comptime dst_t: type, comptime src_t: type, a: std.meta.IntType(false, @typeInfo(src_t).Float.bits)) dst_t {
3434 @setRuntimeSafety(builtin.is_test);
3535
36 const src_rep_t = @IntType(false, @typeInfo(src_t).Float.bits);
37 const dst_rep_t = @IntType(false, @typeInfo(dst_t).Float.bits);
36 const src_rep_t = std.meta.IntType(false, @typeInfo(src_t).Float.bits);
37 const dst_rep_t = std.meta.IntType(false, @typeInfo(dst_t).Float.bits);
3838 const srcSigBits = std.math.floatMantissaBits(src_t);
3939 const dstSigBits = std.math.floatMantissaBits(dst_t);
4040 const SrcShift = std.math.Log2Int(src_rep_t);
lib/std/special/compiler_rt/fixint.zig+1-1
......@@ -45,7 +45,7 @@ pub fn fixint(comptime fp_t: type, comptime fixint_t: type, a: fp_t) fixint_t {
4545 if (exponent < 0) return 0;
4646
4747 // The unsigned result needs to be large enough to handle an fixint_t or rep_t
48 const fixuint_t = @IntType(false, fixint_t.bit_count);
48 const fixuint_t = std.meta.IntType(false, fixint_t.bit_count);
4949 const UintResultType = if (fixint_t.bit_count > rep_t.bit_count) fixuint_t else rep_t;
5050 var uint_result: UintResultType = undefined;
5151
lib/std/special/compiler_rt/fixuint.zig+1-1
......@@ -10,7 +10,7 @@ pub fn fixuint(comptime fp_t: type, comptime fixuint_t: type, a: fp_t) fixuint_t
1010 f128 => u128,
1111 else => unreachable,
1212 };
13 const srep_t = @IntType(true, rep_t.bit_count);
13 const srep_t = @import("std").meta.IntType(true, rep_t.bit_count);
1414 const significandBits = switch (fp_t) {
1515 f32 => 23,
1616 f64 => 52,
lib/std/special/compiler_rt/floatsiXf.zig+2-2
......@@ -5,8 +5,8 @@ const maxInt = std.math.maxInt;
55fn floatsiXf(comptime T: type, a: i32) T {
66 @setRuntimeSafety(builtin.is_test);
77
8 const Z = @IntType(false, T.bit_count);
9 const S = @IntType(false, T.bit_count - @clz(Z, @as(Z, T.bit_count) - 1));
8 const Z = std.meta.IntType(false, T.bit_count);
9 const S = std.meta.IntType(false, T.bit_count - @clz(Z, @as(Z, T.bit_count) - 1));
1010
1111 if (a == 0) {
1212 return @as(T, 0.0);
lib/std/special/compiler_rt/mulXf3.zig+3-3
......@@ -28,7 +28,7 @@ pub fn __aeabi_dmul(a: f64, b: f64) callconv(.C) f64 {
2828
2929fn mulXf3(comptime T: type, a: T, b: T) T {
3030 @setRuntimeSafety(builtin.is_test);
31 const Z = @IntType(false, T.bit_count);
31 const Z = std.meta.IntType(false, T.bit_count);
3232
3333 const typeWidth = T.bit_count;
3434 const significandBits = std.math.floatMantissaBits(T);
......@@ -264,9 +264,9 @@ fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void {
264264 }
265265}
266266
267fn normalize(comptime T: type, significand: *@IntType(false, T.bit_count)) i32 {
267fn normalize(comptime T: type, significand: *std.meta.IntType(false, T.bit_count)) i32 {
268268 @setRuntimeSafety(builtin.is_test);
269 const Z = @IntType(false, T.bit_count);
269 const Z = std.meta.IntType(false, T.bit_count);
270270 const significandBits = std.math.floatMantissaBits(T);
271271 const implicitBit = @as(Z, 1) << significandBits;
272272
lib/std/special/compiler_rt/negXf2.zig+1-1
......@@ -19,7 +19,7 @@ pub fn __aeabi_dneg(arg: f64) callconv(.AAPCS) f64 {
1919}
2020
2121fn negXf2(comptime T: type, a: T) T {
22 const Z = @IntType(false, T.bit_count);
22 const Z = std.meta.IntType(false, T.bit_count);
2323
2424 const typeWidth = T.bit_count;
2525 const significandBits = std.math.floatMantissaBits(T);
lib/std/special/compiler_rt/truncXfYf2.zig+2-2
......@@ -36,8 +36,8 @@ pub fn __aeabi_f2h(a: f32) callconv(.AAPCS) u16 {
3636}
3737
3838inline fn truncXfYf2(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t {
39 const src_rep_t = @IntType(false, @typeInfo(src_t).Float.bits);
40 const dst_rep_t = @IntType(false, @typeInfo(dst_t).Float.bits);
39 const src_rep_t = std.meta.IntType(false, @typeInfo(src_t).Float.bits);
40 const dst_rep_t = std.meta.IntType(false, @typeInfo(dst_t).Float.bits);
4141 const srcSigBits = std.math.floatMantissaBits(src_t);
4242 const dstSigBits = std.math.floatMantissaBits(dst_t);
4343 const SrcShift = std.math.Log2Int(src_rep_t);
lib/std/special/compiler_rt/udivmod.zig+2-2
......@@ -10,8 +10,8 @@ const high = 1 - low;
1010pub fn udivmod(comptime DoubleInt: type, a: DoubleInt, b: DoubleInt, maybe_rem: ?*DoubleInt) DoubleInt {
1111 @setRuntimeSafety(is_test);
1212
13 const SingleInt = @IntType(false, @divExact(DoubleInt.bit_count, 2));
14 const SignedDoubleInt = @IntType(true, DoubleInt.bit_count);
13 const SingleInt = @import("std").meta.IntType(false, @divExact(DoubleInt.bit_count, 2));
14 const SignedDoubleInt = @import("std").meta.IntType(true, DoubleInt.bit_count);
1515 const Log2SingleInt = @import("std").math.Log2Int(SingleInt);
1616
1717 const n = @ptrCast(*const [2]SingleInt, &a).*; // TODO issue #421
lib/std/target.zig+1-1
......@@ -222,7 +222,7 @@ pub const Target = union(enum) {
222222 pub const needed_bit_count = 154;
223223 pub const byte_count = (needed_bit_count + 7) / 8;
224224 pub const usize_count = (byte_count + (@sizeOf(usize) - 1)) / @sizeOf(usize);
225 pub const Index = std.math.Log2Int(@IntType(false, usize_count * @bitSizeOf(usize)));
225 pub const Index = std.math.Log2Int(std.meta.IntType(false, usize_count * @bitSizeOf(usize)));
226226 pub const ShiftInt = std.math.Log2Int(usize);
227227
228228 pub const empty = Set{ .ints = [1]usize{0} ** usize_count };
lib/std/thread.zig+1-1
......@@ -148,7 +148,7 @@ pub const Thread = struct {
148148 const default_stack_size = 16 * 1024 * 1024;
149149
150150 const Context = @TypeOf(context);
151 comptime assert(@ArgType(@TypeOf(startFn), 0) == Context);
151 comptime assert(@typeInfo(@TypeOf(startFn)).Fn.args[0].arg_type.? == Context);
152152
153153 if (builtin.os == builtin.Os.windows) {
154154 const WinThread = struct {
src-self-hosted/type.zig+1-1
......@@ -1042,7 +1042,7 @@ fn hashAny(x: var, comptime seed: u64) u32 {
10421042 switch (@typeInfo(@TypeOf(x))) {
10431043 .Int => |info| {
10441044 comptime var rng = comptime std.rand.DefaultPrng.init(seed);
1045 const unsigned_x = @bitCast(@IntType(false, info.bits), x);
1045 const unsigned_x = @bitCast(std.meta.IntType(false, info.bits), x);
10461046 if (info.bits <= 32) {
10471047 return @as(u32, unsigned_x) *% comptime rng.random.scalar(u32);
10481048 } else {
test/compile_errors.zig+3-29
......@@ -1657,7 +1657,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
16571657 \\ var ptr: [*c]u8 = (1 << 64) + 1;
16581658 \\}
16591659 \\export fn b() void {
1660 \\ var x: @IntType(false, 65) = 0x1234;
1660 \\ var x: u65 = 0x1234;
16611661 \\ var ptr: [*c]u8 = x;
16621662 \\}
16631663 , &[_][]const u8{
......@@ -1896,7 +1896,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
18961896
18971897 cases.add("exceeded maximum bit width of integer",
18981898 \\export fn entry1() void {
1899 \\ const T = @IntType(false, 65536);
1899 \\ const T = u65536;
19001900 \\}
19011901 \\export fn entry2() void {
19021902 \\ var x: i65536 = 1;
......@@ -5598,7 +5598,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
55985598 });
55995599
56005600 cases.add("globally shadowing a primitive type",
5601 \\const u16 = @intType(false, 8);
5601 \\const u16 = u8;
56025602 \\export fn entry() void {
56035603 \\ const a: u16 = 300;
56045604 \\}
......@@ -5939,23 +5939,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
59395939 "tmp.zig:2:1: error: invalid character: '\\t'",
59405940 });
59415941
5942 cases.add("@ArgType given non function parameter",
5943 \\comptime {
5944 \\ _ = @ArgType(i32, 3);
5945 \\}
5946 , &[_][]const u8{
5947 "tmp.zig:2:18: error: expected function, found 'i32'",
5948 });
5949
5950 cases.add("@ArgType arg index out of bounds",
5951 \\comptime {
5952 \\ _ = @ArgType(@TypeOf(add), 2);
5953 \\}
5954 \\fn add(a: i32, b: i32) i32 { return a + b; }
5955 , &[_][]const u8{
5956 "tmp.zig:2:32: error: arg index 2 out of bounds; 'fn(i32, i32) i32' has 2 arguments",
5957 });
5958
59595942 cases.add("calling var args extern function, passing array instead of pointer",
59605943 \\export fn entry() void {
59615944 \\ foo("hello".*,);
......@@ -6379,15 +6362,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
63796362 "tmp.zig:3:25: error: ReturnType has not been resolved because 'fn(var) var' is generic",
63806363 });
63816364
6382 cases.add("getting @ArgType of generic function",
6383 \\fn generic(a: var) void {}
6384 \\comptime {
6385 \\ _ = @ArgType(@TypeOf(generic), 0);
6386 \\}
6387 , &[_][]const u8{
6388 "tmp.zig:3:36: error: @ArgType could not resolve the type of arg 0 because 'fn(var) var' is generic",
6389 });
6390
63916365 cases.add("unsupported modifier at start of asm output constraint",
63926366 \\export fn foo() void {
63936367 \\ var bar: u32 = 3;
test/stage1/behavior/bit_shifting.zig+2-2
......@@ -2,9 +2,9 @@ const std = @import("std");
22const expect = std.testing.expect;
33
44fn ShardedTable(comptime Key: type, comptime mask_bit_count: comptime_int, comptime V: type) type {
5 expect(Key == @IntType(false, Key.bit_count));
5 expect(Key == std.meta.IntType(false, Key.bit_count));
66 expect(Key.bit_count >= mask_bit_count);
7 const ShardKey = @IntType(false, mask_bit_count);
7 const ShardKey = std.meta.IntType(false, mask_bit_count);
88 const shift_amount = Key.bit_count - ShardKey.bit_count;
99 return struct {
1010 const Self = @This();
test/stage1/behavior/math.zig+1-1
......@@ -270,7 +270,7 @@ fn testBinaryNot(x: u16) void {
270270}
271271
272272test "small int addition" {
273 var x: @IntType(false, 2) = 0;
273 var x: u2 = 0;
274274 expect(x == 0);
275275
276276 x += 1;
test/stage1/behavior/misc.zig-29
......@@ -24,35 +24,6 @@ test "call disabled extern fn" {
2424 disabledExternFn();
2525}
2626
27test "@IntType builtin" {
28 expect(@IntType(true, 8) == i8);
29 expect(@IntType(true, 16) == i16);
30 expect(@IntType(true, 32) == i32);
31 expect(@IntType(true, 64) == i64);
32
33 expect(@IntType(false, 8) == u8);
34 expect(@IntType(false, 16) == u16);
35 expect(@IntType(false, 32) == u32);
36 expect(@IntType(false, 64) == u64);
37
38 expect(i8.bit_count == 8);
39 expect(i16.bit_count == 16);
40 expect(i32.bit_count == 32);
41 expect(i64.bit_count == 64);
42
43 expect(i8.is_signed);
44 expect(i16.is_signed);
45 expect(i32.is_signed);
46 expect(i64.is_signed);
47 expect(isize.is_signed);
48
49 expect(!u8.is_signed);
50 expect(!u16.is_signed);
51 expect(!u32.is_signed);
52 expect(!u64.is_signed);
53 expect(!usize.is_signed);
54}
55
5627test "floating point primitive bit counts" {
5728 expect(f16.bit_count == 16);
5829 expect(f32.bit_count == 32);
test/stage1/behavior/reflection.zig+3-3
......@@ -16,9 +16,9 @@ test "reflection: function return type, var args, and param types" {
1616 expect(@TypeOf(dummy).ReturnType == i32);
1717 expect(!@TypeOf(dummy).is_var_args);
1818 expect(@TypeOf(dummy).arg_count == 3);
19 expect(@ArgType(@TypeOf(dummy), 0) == bool);
20 expect(@ArgType(@TypeOf(dummy), 1) == i32);
21 expect(@ArgType(@TypeOf(dummy), 2) == f32);
19 expect(@typeInfo(@TypeOf(dummy)).Fn.args[0].arg_type.? == bool);
20 expect(@typeInfo(@TypeOf(dummy)).Fn.args[1].arg_type.? == i32);
21 expect(@typeInfo(@TypeOf(dummy)).Fn.args[2].arg_type.? == f32);
2222 }
2323}
2424