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 {...@@ -550,7 +550,7 @@ pub fn main() void {
550 {#syntax#}i7{#endsyntax#} refers to a signed 7-bit integer. The maximum allowed bit-width of an550 {#syntax#}i7{#endsyntax#} refers to a signed 7-bit integer. The maximum allowed bit-width of an
551 integer type is {#syntax#}65535{#endsyntax#}.551 integer type is {#syntax#}65535{#endsyntax#}.
552 </p>552 </p>
553 {#see_also|Integers|Floats|void|Errors|@IntType#}553 {#see_also|Integers|Floats|void|Errors|@Type#}
554 {#header_close#}554 {#header_close#}
555 {#header_open|Primitive Values#}555 {#header_open|Primitive Values#}
556 <div class="table-wrapper">556 <div class="table-wrapper">
...@@ -6667,18 +6667,6 @@ comptime {...@@ -6667,18 +6667,6 @@ comptime {
6667 </p>6667 </p>
6668 {#see_also|Alignment#}6668 {#see_also|Alignment#}
6669 {#header_close#}6669 {#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
6683 {#header_open|@as#}6671 {#header_open|@as#}
6684 <pre>{#syntax#}@as(comptime T: type, expression) T{#endsyntax#}</pre>6672 <pre>{#syntax#}@as(comptime T: type, expression) T{#endsyntax#}</pre>
...@@ -7337,7 +7325,7 @@ test "main" {...@@ -7337,7 +7325,7 @@ test "main" {
7337 {#header_close#}7325 {#header_close#}
73387326
7339 {#header_open|@errorToInt#}7327 {#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>
7341 <p>7329 <p>
7342 Supports the following types:7330 Supports the following types:
7343 </p>7331 </p>
...@@ -7631,7 +7619,7 @@ test "@hasDecl" {...@@ -7631,7 +7619,7 @@ test "@hasDecl" {
7631 {#header_close#}7619 {#header_close#}
76327620
7633 {#header_open|@intToError#}7621 {#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>
7635 <p>7623 <p>
7636 Converts from the integer representation of an error into {#link|The Global Error Set#} type.7624 Converts from the integer representation of an error into {#link|The Global Error Set#} type.
7637 </p>7625 </p>
...@@ -7664,17 +7652,6 @@ test "@hasDecl" {...@@ -7664,17 +7652,6 @@ test "@hasDecl" {
7664 </p>7652 </p>
7665 {#header_close#}7653 {#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
7678 {#header_open|@memcpy#}7655 {#header_open|@memcpy#}
7679 <pre>{#syntax#}@memcpy(noalias dest: [*]u8, noalias source: [*]const u8, byte_count: usize){#endsyntax#}</pre>7656 <pre>{#syntax#}@memcpy(noalias dest: [*]u8, noalias source: [*]const u8, byte_count: usize){#endsyntax#}</pre>
7680 <p>7657 <p>
lib/std/child_process.zig+1-1
...@@ -851,7 +851,7 @@ fn forkChildErrReport(fd: i32, err: ChildProcess.SpawnError) noreturn {...@@ -851,7 +851,7 @@ fn forkChildErrReport(fd: i32, err: ChildProcess.SpawnError) noreturn {
851 os.exit(1);851 os.exit(1);
852}852}
853853
854const ErrInt = @IntType(false, @sizeOf(anyerror) * 8);854const ErrInt = std.meta.IntType(false, @sizeOf(anyerror) * 8);
855855
856fn writeIntFd(fd: i32, value: ErrInt) !void {856fn writeIntFd(fd: i32, value: ErrInt) !void {
857 const file = File{857 const file = File{
lib/std/debug/leb128.zig+6-6
...@@ -2,7 +2,7 @@ const std = @import("std");...@@ -2,7 +2,7 @@ const std = @import("std");
2const testing = std.testing;2const testing = std.testing;
33
4pub fn readULEB128(comptime T: type, in_stream: var) !T {4pub 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
7 var result: T = 0;7 var result: T = 0;
8 var shift: usize = 0;8 var shift: usize = 0;
...@@ -27,7 +27,7 @@ pub fn readULEB128(comptime T: type, in_stream: var) !T {...@@ -27,7 +27,7 @@ pub fn readULEB128(comptime T: type, in_stream: var) !T {
27}27}
2828
29pub fn readULEB128Mem(comptime T: type, ptr: *[*]const u8) !T {29pub 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
32 var result: T = 0;32 var result: T = 0;
33 var shift: usize = 0;33 var shift: usize = 0;
...@@ -55,8 +55,8 @@ pub fn readULEB128Mem(comptime T: type, ptr: *[*]const u8) !T {...@@ -55,8 +55,8 @@ pub fn readULEB128Mem(comptime T: type, ptr: *[*]const u8) !T {
55}55}
5656
57pub fn readILEB128(comptime T: type, in_stream: var) !T {57pub fn readILEB128(comptime T: type, in_stream: var) !T {
58 const UT = @IntType(false, T.bit_count);58 const UT = std.meta.IntType(false, T.bit_count);
59 const ShiftT = @IntType(false, std.math.log2(T.bit_count));59 const ShiftT = std.meta.IntType(false, std.math.log2(T.bit_count));
6060
61 var result: UT = 0;61 var result: UT = 0;
62 var shift: usize = 0;62 var shift: usize = 0;
...@@ -87,8 +87,8 @@ pub fn readILEB128(comptime T: type, in_stream: var) !T {...@@ -87,8 +87,8 @@ pub fn readILEB128(comptime T: type, in_stream: var) !T {
87}87}
8888
89pub fn readILEB128Mem(comptime T: type, ptr: *[*]const u8) !T {89pub fn readILEB128Mem(comptime T: type, ptr: *[*]const u8) !T {
90 const UT = @IntType(false, T.bit_count);90 const UT = std.meta.IntType(false, T.bit_count);
91 const ShiftT = @IntType(false, std.math.log2(T.bit_count));91 const ShiftT = std.meta.IntType(false, std.math.log2(T.bit_count));
9292
93 var result: UT = 0;93 var result: UT = 0;
94 var shift: usize = 0;94 var shift: usize = 0;
lib/std/fmt.zig+3-3
...@@ -82,7 +82,7 @@ pub fn format(...@@ -82,7 +82,7 @@ pub fn format(
82 comptime fmt: []const u8,82 comptime fmt: []const u8,
83 args: var,83 args: var,
84) Errors!void {84) Errors!void {
85 const ArgSetType = @IntType(false, 32);85 const ArgSetType = u32;
86 if (@typeInfo(@TypeOf(args)) != .Struct) {86 if (@typeInfo(@TypeOf(args)) != .Struct) {
87 @compileError("Expected tuple or struct argument, found " ++ @typeName(@TypeOf(args)));87 @compileError("Expected tuple or struct argument, found " ++ @typeName(@TypeOf(args)));
88 }88 }
...@@ -944,7 +944,7 @@ fn formatIntSigned(...@@ -944,7 +944,7 @@ fn formatIntSigned(
944 .fill = options.fill,944 .fill = options.fill,
945 };945 };
946946
947 const uint = @IntType(false, @TypeOf(value).bit_count);947 const uint = std.meta.IntType(false, @TypeOf(value).bit_count);
948 if (value < 0) {948 if (value < 0) {
949 const minus_sign: u8 = '-';949 const minus_sign: u8 = '-';
950 try output(context, @as(*const [1]u8, &minus_sign)[0..]);950 try output(context, @as(*const [1]u8, &minus_sign)[0..]);
...@@ -972,7 +972,7 @@ fn formatIntUnsigned(...@@ -972,7 +972,7 @@ fn formatIntUnsigned(
972 assert(base >= 2);972 assert(base >= 2);
973 var buf: [math.max(@TypeOf(value).bit_count, 1)]u8 = undefined;973 var buf: [math.max(@TypeOf(value).bit_count, 1)]u8 = undefined;
974 const min_int_bits = comptime math.max(@TypeOf(value).bit_count, @TypeOf(base).bit_count);974 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);
976 var a: MinInt = value;976 var a: MinInt = value;
977 var index: usize = buf.len;977 var index: usize = buf.len;
978978
lib/std/fmt/parse_float.zig+1-1
...@@ -393,7 +393,7 @@ test "fmt.parseFloat" {...@@ -393,7 +393,7 @@ test "fmt.parseFloat" {
393 const epsilon = 1e-7;393 const epsilon = 1e-7;
394394
395 inline for ([_]type{ f16, f32, f64, f128 }) |T| {395 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
398 testing.expectError(error.InvalidCharacter, parseFloat(T, ""));398 testing.expectError(error.InvalidCharacter, parseFloat(T, ""));
399 testing.expectError(error.InvalidCharacter, parseFloat(T, " 1"));399 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 {...@@ -93,7 +93,7 @@ pub fn hash(hasher: var, key: var, comptime strat: HashStrategy) void {
93 // TODO Check if the situation is better after #561 is resolved.93 // TODO Check if the situation is better after #561 is resolved.
94 .Int => @call(.{ .modifier = .always_inline }, hasher.update, .{std.mem.asBytes(&key)}),94 .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
98 .Bool => hash(hasher, @boolToInt(key), strat),98 .Bool => hash(hasher, @boolToInt(key), strat),
99 .Enum => hash(hasher, @enumToInt(key), strat),99 .Enum => hash(hasher, @enumToInt(key), strat),
lib/std/hash/wyhash.zig+1-1
...@@ -10,7 +10,7 @@ const primes = [_]u64{...@@ -10,7 +10,7 @@ const primes = [_]u64{
10};10};
1111
12fn read_bytes(comptime bytes: u8, data: []const u8) u64 {12fn 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);
14 return mem.readIntSliceLittle(T, data[0..bytes]);14 return mem.readIntSliceLittle(T, data[0..bytes]);
15}15}
1616
lib/std/heap.zig+1-1
...@@ -1015,7 +1015,7 @@ fn testAllocatorLargeAlignment(allocator: *mem.Allocator) mem.Allocator.Error!vo...@@ -1015,7 +1015,7 @@ fn testAllocatorLargeAlignment(allocator: *mem.Allocator) mem.Allocator.Error!vo
1015 // very near usize?1015 // very near usize?
1016 if (mem.page_size << 2 > maxInt(usize)) return;1016 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));
1019 const large_align = @as(u29, mem.page_size << 2);1019 const large_align = @as(u29, mem.page_size << 2);
10201020
1021 var align_mask: usize = undefined;1021 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 {...@@ -337,7 +337,7 @@ pub fn BitInStream(endian: builtin.Endian, comptime Error: type) type {
337 assert(u_bit_count >= bits);337 assert(u_bit_count >= bits);
338 break :bc if (u_bit_count <= u8_bit_count) u8_bit_count else u_bit_count;338 break :bc if (u_bit_count <= u8_bit_count) u8_bit_count else u_bit_count;
339 };339 };
340 const Buf = @IntType(false, buf_bit_count);340 const Buf = std.meta.IntType(false, buf_bit_count);
341 const BufShift = math.Log2Int(Buf);341 const BufShift = math.Log2Int(Buf);
342342
343 out_bits.* = @as(usize, 0);343 out_bits.* = @as(usize, 0);
...@@ -659,7 +659,7 @@ pub fn BitOutStream(endian: builtin.Endian, comptime Error: type) type {...@@ -659,7 +659,7 @@ pub fn BitOutStream(endian: builtin.Endian, comptime Error: type) type {
659 assert(u_bit_count >= bits);659 assert(u_bit_count >= bits);
660 break :bc if (u_bit_count <= u8_bit_count) u8_bit_count else u_bit_count;660 break :bc if (u_bit_count <= u8_bit_count) u8_bit_count else u_bit_count;
661 };661 };
662 const Buf = @IntType(false, buf_bit_count);662 const Buf = std.meta.IntType(false, buf_bit_count);
663 const BufShift = math.Log2Int(Buf);663 const BufShift = math.Log2Int(Buf);
664664
665 const buf_value = @intCast(Buf, value);665 const buf_value = @intCast(Buf, value);
...@@ -836,7 +836,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,...@@ -836,7 +836,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,
836 const u8_bit_count = 8;836 const u8_bit_count = 8;
837 const t_bit_count = comptime meta.bitCount(T);837 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);
840 const Log2U = math.Log2Int(U);840 const Log2U = math.Log2Int(U);
841 const int_size = (U.bit_count + 7) / 8;841 const int_size = (U.bit_count + 7) / 8;
842842
...@@ -851,7 +851,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,...@@ -851,7 +851,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,
851851
852 if (int_size == 1) {852 if (int_size == 1) {
853 if (t_bit_count == 8) return @bitCast(T, buffer[0]);853 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);
855 return @truncate(T, @bitCast(PossiblySignedByte, buffer[0]));855 return @truncate(T, @bitCast(PossiblySignedByte, buffer[0]));
856 }856 }
857857
...@@ -1014,7 +1014,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co...@@ -1014,7 +1014,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co
1014 const t_bit_count = comptime meta.bitCount(T);1014 const t_bit_count = comptime meta.bitCount(T);
1015 const u8_bit_count = comptime meta.bitCount(u8);1015 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);
1018 const Log2U = math.Log2Int(U);1018 const Log2U = math.Log2Int(U);
1019 const int_size = (U.bit_count + 7) / 8;1019 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" {...@@ -318,6 +318,7 @@ test "BitStreams with File Stream" {
318}318}
319319
320fn testIntSerializerDeserializer(comptime endian: builtin.Endian, comptime packing: io.Packing) !void {320fn testIntSerializerDeserializer(comptime endian: builtin.Endian, comptime packing: io.Packing) !void {
321 @setEvalBranchQuota(1500);
321 //@NOTE: if this test is taking too long, reduce the maximum tested bitsize322 //@NOTE: if this test is taking too long, reduce the maximum tested bitsize
322 const max_test_bitsize = 128;323 const max_test_bitsize = 128;
323324
...@@ -341,8 +342,8 @@ fn testIntSerializerDeserializer(comptime endian: builtin.Endian, comptime packi...@@ -341,8 +342,8 @@ fn testIntSerializerDeserializer(comptime endian: builtin.Endian, comptime packi
341342
342 comptime var i = 0;343 comptime var i = 0;
343 inline while (i <= max_test_bitsize) : (i += 1) {344 inline while (i <= max_test_bitsize) : (i += 1) {
344 const U = @IntType(false, i);345 const U = std.meta.IntType(false, i);
345 const S = @IntType(true, i);346 const S = std.meta.IntType(true, i);
346 try serializer.serializeInt(@as(U, i));347 try serializer.serializeInt(@as(U, i));
347 if (i != 0) try serializer.serializeInt(@as(S, -1)) else try serializer.serialize(@as(S, 0));348 if (i != 0) try serializer.serializeInt(@as(S, -1)) else try serializer.serialize(@as(S, 0));
348 }349 }
...@@ -350,8 +351,8 @@ fn testIntSerializerDeserializer(comptime endian: builtin.Endian, comptime packi...@@ -350,8 +351,8 @@ fn testIntSerializerDeserializer(comptime endian: builtin.Endian, comptime packi
350351
351 i = 0;352 i = 0;
352 inline while (i <= max_test_bitsize) : (i += 1) {353 inline while (i <= max_test_bitsize) : (i += 1) {
353 const U = @IntType(false, i);354 const U = std.meta.IntType(false, i);
354 const S = @IntType(true, i);355 const S = std.meta.IntType(true, i);
355 const x = try deserializer.deserializeInt(U);356 const x = try deserializer.deserializeInt(U);
356 const y = try deserializer.deserializeInt(S);357 const y = try deserializer.deserializeInt(S);
357 expect(x == @as(U, i));358 expect(x == @as(U, i));
lib/std/math.zig+11-11
...@@ -444,7 +444,7 @@ pub fn Log2Int(comptime T: type) type {...@@ -444,7 +444,7 @@ pub fn Log2Int(comptime T: type) type {
444 count += 1;444 count += 1;
445 }445 }
446446
447 return @IntType(false, count);447 return std.meta.IntType(false, count);
448}448}
449449
450pub fn IntFittingRange(comptime from: comptime_int, comptime to: comptime_int) type {450pub 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...@@ -460,7 +460,7 @@ pub fn IntFittingRange(comptime from: comptime_int, comptime to: comptime_int) t
460 if (is_signed) {460 if (is_signed) {
461 magnitude_bits += 1;461 magnitude_bits += 1;
462 }462 }
463 return @IntType(is_signed, magnitude_bits);463 return std.meta.IntType(is_signed, magnitude_bits);
464}464}
465465
466test "math.IntFittingRange" {466test "math.IntFittingRange" {
...@@ -674,13 +674,13 @@ pub fn absCast(x: var) t: {...@@ -674,13 +674,13 @@ pub fn absCast(x: var) t: {
674 if (@TypeOf(x) == comptime_int) {674 if (@TypeOf(x) == comptime_int) {
675 break :t comptime_int;675 break :t comptime_int;
676 } else {676 } else {
677 break :t @IntType(false, @TypeOf(x).bit_count);677 break :t std.meta.IntType(false, @TypeOf(x).bit_count);
678 }678 }
679} {679} {
680 if (@TypeOf(x) == comptime_int) {680 if (@TypeOf(x) == comptime_int) {
681 return if (x < 0) -x else x;681 return if (x < 0) -x else x;
682 }682 }
683 const uint = @IntType(false, @TypeOf(x).bit_count);683 const uint = std.meta.IntType(false, @TypeOf(x).bit_count);
684 if (x >= 0) return @intCast(uint, x);684 if (x >= 0) return @intCast(uint, x);
685685
686 return @intCast(uint, -(x + 1)) + 1;686 return @intCast(uint, -(x + 1)) + 1;
...@@ -701,10 +701,10 @@ test "math.absCast" {...@@ -701,10 +701,10 @@ test "math.absCast" {
701701
702/// Returns the negation of the integer parameter.702/// Returns the negation of the integer parameter.
703/// Result is a signed integer.703/// 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) {
705 if (@TypeOf(x).is_signed) return negate(x);705 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);
708 if (x > -minInt(int)) return error.Overflow;708 if (x > -minInt(int)) return error.Overflow;
709709
710 if (x == -minInt(int)) return minInt(int);710 if (x == -minInt(int)) return minInt(int);
...@@ -790,11 +790,11 @@ fn testFloorPowerOfTwo() void {...@@ -790,11 +790,11 @@ fn testFloorPowerOfTwo() void {
790/// Returns the next power of two (if the value is not already a power of two).790/// Returns the next power of two (if the value is not already a power of two).
791/// Only unsigned integers can be used. Zero is not an allowed input.791/// Only unsigned integers can be used. Zero is not an allowed input.
792/// Result is a type with 1 more bit than the input type.792/// 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) {
794 comptime assert(@typeInfo(T) == .Int);794 comptime assert(@typeInfo(T) == .Int);
795 comptime assert(!T.is_signed);795 comptime assert(!T.is_signed);
796 assert(value != 0);796 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);
798 comptime const shiftType = std.math.Log2Int(PromotedType);798 comptime const shiftType = std.math.Log2Int(PromotedType);
799 return @as(PromotedType, 1) << @intCast(shiftType, T.bit_count - @clz(T, value - 1));799 return @as(PromotedType, 1) << @intCast(shiftType, T.bit_count - @clz(T, value - 1));
800}800}
...@@ -805,7 +805,7 @@ pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) @IntType(T.is_signed, T...@@ -805,7 +805,7 @@ pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) @IntType(T.is_signed, T
805pub fn ceilPowerOfTwo(comptime T: type, value: T) (error{Overflow}!T) {805pub fn ceilPowerOfTwo(comptime T: type, value: T) (error{Overflow}!T) {
806 comptime assert(@typeInfo(T) == .Int);806 comptime assert(@typeInfo(T) == .Int);
807 comptime assert(!T.is_signed);807 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);
809 comptime const overflowBit = @as(PromotedType, 1) << T.bit_count;809 comptime const overflowBit = @as(PromotedType, 1) << T.bit_count;
810 var x = ceilPowerOfTwoPromote(T, value);810 var x = ceilPowerOfTwoPromote(T, value);
811 if (overflowBit & x != 0) {811 if (overflowBit & x != 0) {
...@@ -947,8 +947,8 @@ test "max value type" {...@@ -947,8 +947,8 @@ test "max value type" {
947 testing.expect(x == 2147483647);947 testing.expect(x == 2147483647);
948}948}
949949
950pub fn mulWide(comptime T: type, a: T, b: T) @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 = @IntType(T.is_signed, T.bit_count * 2);951 const ResultInt = std.meta.IntType(T.is_signed, T.bit_count * 2);
952 return @as(ResultInt, a) * @as(ResultInt, b);952 return @as(ResultInt, a) * @as(ResultInt, b);
953}953}
954954
lib/std/math/big/int.zig+3-3
...@@ -9,7 +9,7 @@ const maxInt = std.math.maxInt;...@@ -9,7 +9,7 @@ const maxInt = std.math.maxInt;
9const minInt = std.math.minInt;9const minInt = std.math.minInt;
1010
11pub const Limb = usize;11pub const Limb = usize;
12pub const DoubleLimb = @IntType(false, 2 * Limb.bit_count);12pub const DoubleLimb = std.meta.IntType(false, 2 * Limb.bit_count);
13pub const Log2Limb = math.Log2Int(Limb);13pub const Log2Limb = math.Log2Int(Limb);
1414
15comptime {15comptime {
...@@ -268,7 +268,7 @@ pub const Int = struct {...@@ -268,7 +268,7 @@ pub const Int = struct {
268268
269 switch (@typeInfo(T)) {269 switch (@typeInfo(T)) {
270 .Int => |info| {270 .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
273 try self.ensureCapacity(@sizeOf(UT) / @sizeOf(Limb));273 try self.ensureCapacity(@sizeOf(UT) / @sizeOf(Limb));
274 self.metadata = 0;274 self.metadata = 0;
...@@ -331,7 +331,7 @@ pub const Int = struct {...@@ -331,7 +331,7 @@ pub const Int = struct {
331 pub fn to(self: Int, comptime T: type) ConvertError!T {331 pub fn to(self: Int, comptime T: type) ConvertError!T {
332 switch (@typeInfo(T)) {332 switch (@typeInfo(T)) {
333 .Int => {333 .Int => {
334 const UT = @IntType(false, T.bit_count);334 const UT = std.meta.IntType(false, T.bit_count);
335335
336 if (self.bitCountTwosComp() > T.bit_count) {336 if (self.bitCountTwosComp() > T.bit_count) {
337 return error.TargetTooSmall;337 return error.TargetTooSmall;
lib/std/math/big/rational.zig+3-3
...@@ -128,7 +128,7 @@ pub const Rational = struct {...@@ -128,7 +128,7 @@ pub const Rational = struct {
128 // Translated from golang.go/src/math/big/rat.go.128 // Translated from golang.go/src/math/big/rat.go.
129 debug.assert(@typeInfo(T) == .Float);129 debug.assert(@typeInfo(T) == .Float);
130130
131 const UnsignedIntType = @IntType(false, T.bit_count);131 const UnsignedIntType = std.meta.IntType(false, T.bit_count);
132 const f_bits = @bitCast(UnsignedIntType, f);132 const f_bits = @bitCast(UnsignedIntType, f);
133133
134 const exponent_bits = math.floatExponentBits(T);134 const exponent_bits = math.floatExponentBits(T);
...@@ -187,7 +187,7 @@ pub const Rational = struct {...@@ -187,7 +187,7 @@ pub const Rational = struct {
187 debug.assert(@typeInfo(T) == .Float);187 debug.assert(@typeInfo(T) == .Float);
188188
189 const fsize = T.bit_count;189 const fsize = T.bit_count;
190 const BitReprType = @IntType(false, T.bit_count);190 const BitReprType = std.meta.IntType(false, T.bit_count);
191191
192 const msize = math.floatMantissaBits(T);192 const msize = math.floatMantissaBits(T);
193 const msize1 = msize + 1;193 const msize1 = msize + 1;
...@@ -462,7 +462,7 @@ pub const Rational = struct {...@@ -462,7 +462,7 @@ pub const Rational = struct {
462 }462 }
463};463};
464464
465const SignedDoubleLimb = @IntType(true, DoubleLimb.bit_count);465const SignedDoubleLimb = std.meta.IntType(true, DoubleLimb.bit_count);
466466
467fn gcd(rma: *Int, x: Int, y: Int) !void {467fn gcd(rma: *Int, x: Int, y: Int) !void {
468 rma.assertWritable();468 rma.assertWritable();
lib/std/math/cos.zig+1-1
...@@ -44,7 +44,7 @@ const pi4c = 2.69515142907905952645E-15;...@@ -44,7 +44,7 @@ const pi4c = 2.69515142907905952645E-15;
44const m4pi = 1.273239544735162542821171882678754627704620361328125;44const m4pi = 1.273239544735162542821171882678754627704620361328125;
4545
46fn cos_(comptime T: type, x_: T) T {46fn 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
49 var x = x_;49 var x = x_;
50 if (math.isNan(x) or math.isInf(x)) {50 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 {...@@ -145,7 +145,7 @@ pub fn pow(comptime T: type, x: T, y: T) T {
145 var xe = r2.exponent;145 var xe = r2.exponent;
146 var x1 = r2.significand;146 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);
149 while (i != 0) : (i >>= 1) {149 while (i != 0) : (i >>= 1) {
150 const overflow_shift = math.floatExponentBits(T) + 1;150 const overflow_shift = math.floatExponentBits(T) + 1;
151 if (xe < -(1 << overflow_shift) or (1 << overflow_shift) < xe) {151 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;...@@ -45,7 +45,7 @@ const pi4c = 2.69515142907905952645E-15;
45const m4pi = 1.273239544735162542821171882678754627704620361328125;45const m4pi = 1.273239544735162542821171882678754627704620361328125;
4646
47fn sin_(comptime T: type, x_: T) T {47fn 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
50 var x = x_;50 var x = x_;
51 if (x == 0 or math.isNan(x)) {51 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)) {...@@ -31,7 +31,7 @@ pub fn sqrt(x: var) Sqrt(@TypeOf(x)) {
31 }31 }
32}32}
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) {
35 var op = value;35 var op = value;
36 var res: T = 0;36 var res: T = 0;
37 var one: T = 1 << (T.bit_count - 2);37 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) {...@@ -50,7 +50,7 @@ fn sqrt_int(comptime T: type, value: T) @IntType(false, T.bit_count / 2) {
50 one >>= 2;50 one >>= 2;
51 }51 }
5252
53 const ResultType = @IntType(false, T.bit_count / 2);53 const ResultType = std.meta.IntType(false, T.bit_count / 2);
54 return @intCast(ResultType, res);54 return @intCast(ResultType, res);
55}55}
5656
...@@ -66,7 +66,7 @@ test "math.sqrt_int" {...@@ -66,7 +66,7 @@ test "math.sqrt_int" {
66/// Returns the return type `sqrt` will return given an operand of type `T`.66/// Returns the return type `sqrt` will return given an operand of type `T`.
67pub fn Sqrt(comptime T: type) type {67pub fn Sqrt(comptime T: type) type {
68 return switch (@typeInfo(T)) {68 return switch (@typeInfo(T)) {
69 .Int => |int| @IntType(false, int.bits / 2),69 .Int => |int| std.meta.IntType(false, int.bits / 2),
70 else => T,70 else => T,
71 };71 };
72}72}
lib/std/math/tan.zig+1-1
...@@ -38,7 +38,7 @@ const pi4c = 2.69515142907905952645E-15;...@@ -38,7 +38,7 @@ const pi4c = 2.69515142907905952645E-15;
38const m4pi = 1.273239544735162542821171882678754627704620361328125;38const m4pi = 1.273239544735162542821171882678754627704620361328125;
3939
40fn tan_(comptime T: type, x_: T) T {40fn 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
43 var x = x_;43 var x = x_;
44 if (x == 0 or math.isNan(x)) {44 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 {...@@ -708,7 +708,7 @@ pub fn writeIntSliceLittle(comptime T: type, buffer: []u8, value: T) void {
708 assert(buffer.len >= @divExact(T.bit_count, 8));708 assert(buffer.len >= @divExact(T.bit_count, 8));
709709
710 // TODO I want to call writeIntLittle here but comptime eval facilities aren't good enough710 // 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);
712 var bits = @truncate(uint, value);712 var bits = @truncate(uint, value);
713 for (buffer) |*b| {713 for (buffer) |*b| {
714 b.* = @truncate(u8, bits);714 b.* = @truncate(u8, bits);
...@@ -725,7 +725,7 @@ pub fn writeIntSliceBig(comptime T: type, buffer: []u8, value: T) void {...@@ -725,7 +725,7 @@ pub fn writeIntSliceBig(comptime T: type, buffer: []u8, value: T) void {
725 assert(buffer.len >= @divExact(T.bit_count, 8));725 assert(buffer.len >= @divExact(T.bit_count, 8));
726726
727 // TODO I want to call writeIntBig here but comptime eval facilities aren't good enough727 // 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);
729 var bits = @truncate(uint, value);729 var bits = @truncate(uint, value);
730 var index: usize = buffer.len;730 var index: usize = buffer.len;
731 while (index != 0) {731 while (index != 0) {
lib/std/meta.zig+9
...@@ -580,3 +580,12 @@ pub fn declList(comptime Namespace: type, comptime Decl: type) []const *const De...@@ -580,3 +580,12 @@ pub fn declList(comptime Namespace: type, comptime Decl: type) []const *const De
580 return &array;580 return &array;
581 }581 }
582}582}
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(...@@ -3349,7 +3349,7 @@ pub fn res_mkquery(
3349 // Make a reasonably unpredictable id3349 // Make a reasonably unpredictable id
3350 var ts: timespec = undefined;3350 var ts: timespec = undefined;
3351 clock_gettime(CLOCK_REALTIME, &ts) catch {};3351 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);
3353 const unsec = @bitCast(UInt, ts.tv_nsec);3353 const unsec = @bitCast(UInt, ts.tv_nsec);
3354 const id = @truncate(u32, unsec + unsec / 65536);3354 const id = @truncate(u32, unsec + unsec / 65536);
3355 q[0] = @truncate(u8, id / 256);3355 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 {...@@ -1004,7 +1004,7 @@ pub const dl_phdr_info = extern struct {
10041004
1005pub const CPU_SETSIZE = 128;1005pub const CPU_SETSIZE = 128;
1006pub const cpu_set_t = [CPU_SETSIZE / @sizeOf(usize)]usize;1006pub 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
1009pub fn CPU_COUNT(set: cpu_set_t) cpu_count_t {1009pub fn CPU_COUNT(set: cpu_set_t) cpu_count_t {
1010 var sum: cpu_count_t = 0;1010 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 {...@@ -34,13 +34,13 @@ pub fn PackedIntIo(comptime Int: type, comptime endian: builtin.Endian) type {
3434
35 //we bitcast the desired Int type to an unsigned version of itself35 //we bitcast the desired Int type to an unsigned version of itself
36 // to avoid issues with shifting signed ints.36 // to avoid issues with shifting signed ints.
37 const UnInt = @IntType(false, int_bits);37 const UnInt = std.meta.IntType(false, int_bits);
3838
39 //The maximum container int type39 //The maximum container int type
40 const MinIo = @IntType(false, min_io_bits);40 const MinIo = std.meta.IntType(false, min_io_bits);
4141
42 //The minimum container int type42 //The minimum container int type
43 const MaxIo = @IntType(false, max_io_bits);43 const MaxIo = std.meta.IntType(false, max_io_bits);
4444
45 return struct {45 return struct {
46 pub fn get(bytes: []const u8, index: usize, bit_offset: u7) Int {46 pub fn get(bytes: []const u8, index: usize, bit_offset: u7) Int {
...@@ -322,7 +322,7 @@ test "PackedIntArray" {...@@ -322,7 +322,7 @@ test "PackedIntArray" {
322 inline while (bits <= 256) : (bits += 1) {322 inline while (bits <= 256) : (bits += 1) {
323 //alternate unsigned and signed323 //alternate unsigned and signed
324 const even = bits % 2 == 0;324 const even = bits % 2 == 0;
325 const I = @IntType(even, bits);325 const I = std.meta.IntType(even, bits);
326326
327 const PackedArray = PackedIntArray(I, int_count);327 const PackedArray = PackedIntArray(I, int_count);
328 const expected_bytes = ((bits * int_count) + 7) / 8;328 const expected_bytes = ((bits * int_count) + 7) / 8;
...@@ -369,7 +369,7 @@ test "PackedIntSlice" {...@@ -369,7 +369,7 @@ test "PackedIntSlice" {
369 inline while (bits <= 256) : (bits += 1) {369 inline while (bits <= 256) : (bits += 1) {
370 //alternate unsigned and signed370 //alternate unsigned and signed
371 const even = bits % 2 == 0;371 const even = bits % 2 == 0;
372 const I = @IntType(even, bits);372 const I = std.meta.IntType(even, bits);
373 const P = PackedIntSlice(I);373 const P = PackedIntSlice(I);
374374
375 var data = P.init(&buffer, int_count);375 var data = P.init(&buffer, int_count);
...@@ -399,7 +399,7 @@ test "PackedIntSlice of PackedInt(Array/Slice)" {...@@ -399,7 +399,7 @@ test "PackedIntSlice of PackedInt(Array/Slice)" {
399399
400 comptime var bits = 0;400 comptime var bits = 0;
401 inline while (bits <= max_bits) : (bits += 1) {401 inline while (bits <= max_bits) : (bits += 1) {
402 const Int = @IntType(false, bits);402 const Int = std.meta.IntType(false, bits);
403403
404 const PackedArray = PackedIntArray(Int, int_count);404 const PackedArray = PackedIntArray(Int, int_count);
405 var packed_array = @as(PackedArray, undefined);405 var packed_array = @as(PackedArray, undefined);
lib/std/rand.zig+10-10
...@@ -45,8 +45,8 @@ pub const Random = struct {...@@ -45,8 +45,8 @@ pub const Random = struct {
45 /// Returns a random int `i` such that `0 <= i <= maxInt(T)`.45 /// Returns a random int `i` such that `0 <= i <= maxInt(T)`.
46 /// `i` is evenly distributed.46 /// `i` is evenly distributed.
47 pub fn int(r: *Random, comptime T: type) T {47 pub fn int(r: *Random, comptime T: type) T {
48 const UnsignedT = @IntType(false, T.bit_count);48 const UnsignedT = std.meta.IntType(false, T.bit_count);
49 const ByteAlignedT = @IntType(false, @divTrunc(T.bit_count + 7, 8) * 8);49 const ByteAlignedT = std.meta.IntType(false, @divTrunc(T.bit_count + 7, 8) * 8);
5050
51 var rand_bytes: [@sizeOf(ByteAlignedT)]u8 = undefined;51 var rand_bytes: [@sizeOf(ByteAlignedT)]u8 = undefined;
52 r.bytes(rand_bytes[0..]);52 r.bytes(rand_bytes[0..]);
...@@ -85,9 +85,9 @@ pub const Random = struct {...@@ -85,9 +85,9 @@ pub const Random = struct {
85 comptime assert(T.bit_count <= 64); // TODO: workaround: LLVM ERROR: Unsupported library call operation!85 comptime assert(T.bit_count <= 64); // TODO: workaround: LLVM ERROR: Unsupported library call operation!
86 assert(0 < less_than);86 assert(0 < less_than);
87 // Small is typically u3287 // 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);
89 // Large is typically u6489 // 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
92 // adapted from:92 // adapted from:
93 // http://www.pcg-random.org/posts/bounded-rands.html93 // http://www.pcg-random.org/posts/bounded-rands.html
...@@ -99,7 +99,7 @@ pub const Random = struct {...@@ -99,7 +99,7 @@ pub const Random = struct {
99 // TODO: workaround for https://github.com/ziglang/zig/issues/177099 // TODO: workaround for https://github.com/ziglang/zig/issues/1770
100 // should be:100 // should be:
101 // var t: Small = -%less_than;101 // 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
104 if (t >= less_than) {104 if (t >= less_than) {
105 t -= less_than;105 t -= less_than;
...@@ -145,7 +145,7 @@ pub const Random = struct {...@@ -145,7 +145,7 @@ pub const Random = struct {
145 assert(at_least < less_than);145 assert(at_least < less_than);
146 if (T.is_signed) {146 if (T.is_signed) {
147 // Two's complement makes this math pretty easy.147 // 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);
149 const lo = @bitCast(UnsignedT, at_least);149 const lo = @bitCast(UnsignedT, at_least);
150 const hi = @bitCast(UnsignedT, less_than);150 const hi = @bitCast(UnsignedT, less_than);
151 const result = lo +% r.uintLessThanBiased(UnsignedT, hi -% lo);151 const result = lo +% r.uintLessThanBiased(UnsignedT, hi -% lo);
...@@ -163,7 +163,7 @@ pub const Random = struct {...@@ -163,7 +163,7 @@ pub const Random = struct {
163 assert(at_least < less_than);163 assert(at_least < less_than);
164 if (T.is_signed) {164 if (T.is_signed) {
165 // Two's complement makes this math pretty easy.165 // 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);
167 const lo = @bitCast(UnsignedT, at_least);167 const lo = @bitCast(UnsignedT, at_least);
168 const hi = @bitCast(UnsignedT, less_than);168 const hi = @bitCast(UnsignedT, less_than);
169 const result = lo +% r.uintLessThan(UnsignedT, hi -% lo);169 const result = lo +% r.uintLessThan(UnsignedT, hi -% lo);
...@@ -180,7 +180,7 @@ pub const Random = struct {...@@ -180,7 +180,7 @@ pub const Random = struct {
180 assert(at_least <= at_most);180 assert(at_least <= at_most);
181 if (T.is_signed) {181 if (T.is_signed) {
182 // Two's complement makes this math pretty easy.182 // 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);
184 const lo = @bitCast(UnsignedT, at_least);184 const lo = @bitCast(UnsignedT, at_least);
185 const hi = @bitCast(UnsignedT, at_most);185 const hi = @bitCast(UnsignedT, at_most);
186 const result = lo +% r.uintAtMostBiased(UnsignedT, hi -% lo);186 const result = lo +% r.uintAtMostBiased(UnsignedT, hi -% lo);
...@@ -198,7 +198,7 @@ pub const Random = struct {...@@ -198,7 +198,7 @@ pub const Random = struct {
198 assert(at_least <= at_most);198 assert(at_least <= at_most);
199 if (T.is_signed) {199 if (T.is_signed) {
200 // Two's complement makes this math pretty easy.200 // 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);
202 const lo = @bitCast(UnsignedT, at_least);202 const lo = @bitCast(UnsignedT, at_least);
203 const hi = @bitCast(UnsignedT, at_most);203 const hi = @bitCast(UnsignedT, at_most);
204 const result = lo +% r.uintAtMost(UnsignedT, hi -% lo);204 const result = lo +% r.uintAtMost(UnsignedT, hi -% lo);
...@@ -281,7 +281,7 @@ pub const Random = struct {...@@ -281,7 +281,7 @@ pub const Random = struct {
281/// This function introduces a minor bias.281/// This function introduces a minor bias.
282pub fn limitRangeBiased(comptime T: type, random_int: T, less_than: T) T {282pub fn limitRangeBiased(comptime T: type, random_int: T, less_than: T) T {
283 comptime assert(T.is_signed == false);283 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
286 // adapted from:286 // adapted from:
287 // http://www.pcg-random.org/posts/bounded-rands.html287 // 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 {...@@ -511,7 +511,7 @@ export fn roundf(a: f32) f32 {
511fn generic_fmod(comptime T: type, x: T, y: T) T {511fn generic_fmod(comptime T: type, x: T, y: T) T {
512 @setRuntimeSafety(false);512 @setRuntimeSafety(false);
513513
514 const uint = @IntType(false, T.bit_count);514 const uint = std.meta.IntType(false, T.bit_count);
515 const log2uint = math.Log2Int(uint);515 const log2uint = math.Log2Int(uint);
516 const digits = if (T == f32) 23 else 52;516 const digits = if (T == f32) 23 else 52;
517 const exp_bits = if (T == f32) 9 else 12;517 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 {...@@ -54,21 +54,21 @@ pub fn __aeabi_dsub(a: f64, b: f64) callconv(.AAPCS) f64 {
54}54}
5555
56// TODO: restore inline keyword, see: https://github.com/ziglang/zig/issues/215456// TODO: restore inline keyword, see: https://github.com/ziglang/zig/issues/2154
57fn normalize(comptime T: type, significand: *@IntType(false, T.bit_count)) i32 {57fn normalize(comptime T: type, significand: *std.meta.IntType(false, T.bit_count)) i32 {
58 const Z = @IntType(false, T.bit_count);58 const Z = std.meta.IntType(false, T.bit_count);
59 const S = @IntType(false, T.bit_count - @clz(Z, @as(Z, T.bit_count) - 1));59 const S = std.meta.IntType(false, T.bit_count - @clz(Z, @as(Z, T.bit_count) - 1));
60 const significandBits = std.math.floatMantissaBits(T);60 const significandBits = std.math.floatMantissaBits(T);
61 const implicitBit = @as(Z, 1) << significandBits;61 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);
64 significand.* <<= @intCast(S, shift);64 significand.* <<= @intCast(S, shift);
65 return 1 - shift;65 return 1 - shift;
66}66}
6767
68// TODO: restore inline keyword, see: https://github.com/ziglang/zig/issues/215468// TODO: restore inline keyword, see: https://github.com/ziglang/zig/issues/2154
69fn addXf3(comptime T: type, a: T, b: T) T {69fn addXf3(comptime T: type, a: T, b: T) T {
70 const Z = @IntType(false, T.bit_count);70 const Z = std.meta.IntType(false, T.bit_count);
71 const S = @IntType(false, T.bit_count - @clz(Z, @as(Z, T.bit_count) - 1));71 const S = std.meta.IntType(false, T.bit_count - @clz(Z, @as(Z, T.bit_count) - 1));
7272
73 const typeWidth = T.bit_count;73 const typeWidth = T.bit_count;
74 const significandBits = std.math.floatMantissaBits(T);74 const significandBits = std.math.floatMantissaBits(T);
...@@ -182,7 +182,7 @@ fn addXf3(comptime T: type, a: T, b: T) T {...@@ -182,7 +182,7 @@ fn addXf3(comptime T: type, a: T, b: T) T {
182 // If partial cancellation occured, we need to left-shift the result182 // If partial cancellation occured, we need to left-shift the result
183 // and adjust the exponent:183 // and adjust the exponent:
184 if (aSignificand < implicitBit << 3) {184 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));
186 aSignificand <<= @intCast(S, shift);186 aSignificand <<= @intCast(S, shift);
187 aExponent -= shift;187 aExponent -= shift;
188 }188 }
lib/std/special/compiler_rt/compareXf2.zig+3-3
...@@ -22,8 +22,8 @@ const GE = extern enum(i32) {...@@ -22,8 +22,8 @@ const GE = extern enum(i32) {
22pub fn cmp(comptime T: type, comptime RT: type, a: T, b: T) RT {22pub fn cmp(comptime T: type, comptime RT: type, a: T, b: T) RT {
23 @setRuntimeSafety(builtin.is_test);23 @setRuntimeSafety(builtin.is_test);
2424
25 const srep_t = @IntType(true, T.bit_count);25 const srep_t = std.meta.IntType(true, T.bit_count);
26 const rep_t = @IntType(false, T.bit_count);26 const rep_t = std.meta.IntType(false, T.bit_count);
2727
28 const significandBits = std.math.floatMantissaBits(T);28 const significandBits = std.math.floatMantissaBits(T);
29 const exponentBits = std.math.floatExponentBits(T);29 const exponentBits = std.math.floatExponentBits(T);
...@@ -68,7 +68,7 @@ pub fn cmp(comptime T: type, comptime RT: type, a: T, b: T) RT {...@@ -68,7 +68,7 @@ pub fn cmp(comptime T: type, comptime RT: type, a: T, b: T) RT {
68pub fn unordcmp(comptime T: type, a: T, b: T) i32 {68pub fn unordcmp(comptime T: type, a: T, b: T) i32 {
69 @setRuntimeSafety(builtin.is_test);69 @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
73 const significandBits = std.math.floatMantissaBits(T);73 const significandBits = std.math.floatMantissaBits(T);
74 const exponentBits = std.math.floatExponentBits(T);74 const exponentBits = std.math.floatExponentBits(T);
lib/std/special/compiler_rt/divdf3.zig+4-4
...@@ -7,8 +7,8 @@ const builtin = @import("builtin");...@@ -7,8 +7,8 @@ const builtin = @import("builtin");
77
8pub fn __divdf3(a: f64, b: f64) callconv(.C) f64 {8pub fn __divdf3(a: f64, b: f64) callconv(.C) f64 {
9 @setRuntimeSafety(builtin.is_test);9 @setRuntimeSafety(builtin.is_test);
10 const Z = @IntType(false, f64.bit_count);10 const Z = std.meta.IntType(false, f64.bit_count);
11 const SignedZ = @IntType(true, f64.bit_count);11 const SignedZ = std.meta.IntType(true, f64.bit_count);
1212
13 const typeWidth = f64.bit_count;13 const typeWidth = f64.bit_count;
14 const significandBits = std.math.floatMantissaBits(f64);14 const significandBits = std.math.floatMantissaBits(f64);
...@@ -312,9 +312,9 @@ fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void {...@@ -312,9 +312,9 @@ fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void {
312 }312 }
313}313}
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 {
316 @setRuntimeSafety(builtin.is_test);316 @setRuntimeSafety(builtin.is_test);
317 const Z = @IntType(false, T.bit_count);317 const Z = std.meta.IntType(false, T.bit_count);
318 const significandBits = std.math.floatMantissaBits(T);318 const significandBits = std.math.floatMantissaBits(T);
319 const implicitBit = @as(Z, 1) << significandBits;319 const implicitBit = @as(Z, 1) << significandBits;
320320
lib/std/special/compiler_rt/divsf3.zig+3-3
...@@ -7,7 +7,7 @@ const builtin = @import("builtin");...@@ -7,7 +7,7 @@ const builtin = @import("builtin");
77
8pub fn __divsf3(a: f32, b: f32) callconv(.C) f32 {8pub fn __divsf3(a: f32, b: f32) callconv(.C) f32 {
9 @setRuntimeSafety(builtin.is_test);9 @setRuntimeSafety(builtin.is_test);
10 const Z = @IntType(false, f32.bit_count);10 const Z = std.meta.IntType(false, f32.bit_count);
1111
12 const typeWidth = f32.bit_count;12 const typeWidth = f32.bit_count;
13 const significandBits = std.math.floatMantissaBits(f32);13 const significandBits = std.math.floatMantissaBits(f32);
...@@ -185,9 +185,9 @@ pub fn __divsf3(a: f32, b: f32) callconv(.C) f32 {...@@ -185,9 +185,9 @@ pub fn __divsf3(a: f32, b: f32) callconv(.C) f32 {
185 }185 }
186}186}
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 {
189 @setRuntimeSafety(builtin.is_test);189 @setRuntimeSafety(builtin.is_test);
190 const Z = @IntType(false, T.bit_count);190 const Z = std.meta.IntType(false, T.bit_count);
191 const significandBits = std.math.floatMantissaBits(T);191 const significandBits = std.math.floatMantissaBits(T);
192 const implicitBit = @as(Z, 1) << significandBits;192 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 {...@@ -30,11 +30,11 @@ pub fn __aeabi_f2d(arg: f32) callconv(.AAPCS) f64 {
3030
31const CHAR_BIT = 8;31const 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 {
34 @setRuntimeSafety(builtin.is_test);34 @setRuntimeSafety(builtin.is_test);
3535
36 const src_rep_t = @IntType(false, @typeInfo(src_t).Float.bits);36 const src_rep_t = std.meta.IntType(false, @typeInfo(src_t).Float.bits);
37 const dst_rep_t = @IntType(false, @typeInfo(dst_t).Float.bits);37 const dst_rep_t = std.meta.IntType(false, @typeInfo(dst_t).Float.bits);
38 const srcSigBits = std.math.floatMantissaBits(src_t);38 const srcSigBits = std.math.floatMantissaBits(src_t);
39 const dstSigBits = std.math.floatMantissaBits(dst_t);39 const dstSigBits = std.math.floatMantissaBits(dst_t);
40 const SrcShift = std.math.Log2Int(src_rep_t);40 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 {...@@ -45,7 +45,7 @@ pub fn fixint(comptime fp_t: type, comptime fixint_t: type, a: fp_t) fixint_t {
45 if (exponent < 0) return 0;45 if (exponent < 0) return 0;
4646
47 // The unsigned result needs to be large enough to handle an fixint_t or rep_t47 // 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);
49 const UintResultType = if (fixint_t.bit_count > rep_t.bit_count) fixuint_t else rep_t;49 const UintResultType = if (fixint_t.bit_count > rep_t.bit_count) fixuint_t else rep_t;
50 var uint_result: UintResultType = undefined;50 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...@@ -10,7 +10,7 @@ pub fn fixuint(comptime fp_t: type, comptime fixuint_t: type, a: fp_t) fixuint_t
10 f128 => u128,10 f128 => u128,
11 else => unreachable,11 else => unreachable,
12 };12 };
13 const srep_t = @IntType(true, rep_t.bit_count);13 const srep_t = @import("std").meta.IntType(true, rep_t.bit_count);
14 const significandBits = switch (fp_t) {14 const significandBits = switch (fp_t) {
15 f32 => 23,15 f32 => 23,
16 f64 => 52,16 f64 => 52,
lib/std/special/compiler_rt/floatsiXf.zig+2-2
...@@ -5,8 +5,8 @@ const maxInt = std.math.maxInt;...@@ -5,8 +5,8 @@ const maxInt = std.math.maxInt;
5fn floatsiXf(comptime T: type, a: i32) T {5fn floatsiXf(comptime T: type, a: i32) T {
6 @setRuntimeSafety(builtin.is_test);6 @setRuntimeSafety(builtin.is_test);
77
8 const Z = @IntType(false, T.bit_count);8 const Z = std.meta.IntType(false, T.bit_count);
9 const S = @IntType(false, T.bit_count - @clz(Z, @as(Z, T.bit_count) - 1));9 const S = std.meta.IntType(false, T.bit_count - @clz(Z, @as(Z, T.bit_count) - 1));
1010
11 if (a == 0) {11 if (a == 0) {
12 return @as(T, 0.0);12 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 {...@@ -28,7 +28,7 @@ pub fn __aeabi_dmul(a: f64, b: f64) callconv(.C) f64 {
2828
29fn mulXf3(comptime T: type, a: T, b: T) T {29fn mulXf3(comptime T: type, a: T, b: T) T {
30 @setRuntimeSafety(builtin.is_test);30 @setRuntimeSafety(builtin.is_test);
31 const Z = @IntType(false, T.bit_count);31 const Z = std.meta.IntType(false, T.bit_count);
3232
33 const typeWidth = T.bit_count;33 const typeWidth = T.bit_count;
34 const significandBits = std.math.floatMantissaBits(T);34 const significandBits = std.math.floatMantissaBits(T);
...@@ -264,9 +264,9 @@ fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void {...@@ -264,9 +264,9 @@ fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void {
264 }264 }
265}265}
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 {
268 @setRuntimeSafety(builtin.is_test);268 @setRuntimeSafety(builtin.is_test);
269 const Z = @IntType(false, T.bit_count);269 const Z = std.meta.IntType(false, T.bit_count);
270 const significandBits = std.math.floatMantissaBits(T);270 const significandBits = std.math.floatMantissaBits(T);
271 const implicitBit = @as(Z, 1) << significandBits;271 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 {...@@ -19,7 +19,7 @@ pub fn __aeabi_dneg(arg: f64) callconv(.AAPCS) f64 {
19}19}
2020
21fn negXf2(comptime T: type, a: T) T {21fn 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
24 const typeWidth = T.bit_count;24 const typeWidth = T.bit_count;
25 const significandBits = std.math.floatMantissaBits(T);25 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 {...@@ -36,8 +36,8 @@ pub fn __aeabi_f2h(a: f32) callconv(.AAPCS) u16 {
36}36}
3737
38inline fn truncXfYf2(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t {38inline 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);39 const src_rep_t = std.meta.IntType(false, @typeInfo(src_t).Float.bits);
40 const dst_rep_t = @IntType(false, @typeInfo(dst_t).Float.bits);40 const dst_rep_t = std.meta.IntType(false, @typeInfo(dst_t).Float.bits);
41 const srcSigBits = std.math.floatMantissaBits(src_t);41 const srcSigBits = std.math.floatMantissaBits(src_t);
42 const dstSigBits = std.math.floatMantissaBits(dst_t);42 const dstSigBits = std.math.floatMantissaBits(dst_t);
43 const SrcShift = std.math.Log2Int(src_rep_t);43 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;...@@ -10,8 +10,8 @@ const high = 1 - low;
10pub fn udivmod(comptime DoubleInt: type, a: DoubleInt, b: DoubleInt, maybe_rem: ?*DoubleInt) DoubleInt {10pub fn udivmod(comptime DoubleInt: type, a: DoubleInt, b: DoubleInt, maybe_rem: ?*DoubleInt) DoubleInt {
11 @setRuntimeSafety(is_test);11 @setRuntimeSafety(is_test);
1212
13 const SingleInt = @IntType(false, @divExact(DoubleInt.bit_count, 2));13 const SingleInt = @import("std").meta.IntType(false, @divExact(DoubleInt.bit_count, 2));
14 const SignedDoubleInt = @IntType(true, DoubleInt.bit_count);14 const SignedDoubleInt = @import("std").meta.IntType(true, DoubleInt.bit_count);
15 const Log2SingleInt = @import("std").math.Log2Int(SingleInt);15 const Log2SingleInt = @import("std").math.Log2Int(SingleInt);
1616
17 const n = @ptrCast(*const [2]SingleInt, &a).*; // TODO issue #42117 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) {...@@ -222,7 +222,7 @@ pub const Target = union(enum) {
222 pub const needed_bit_count = 154;222 pub const needed_bit_count = 154;
223 pub const byte_count = (needed_bit_count + 7) / 8;223 pub const byte_count = (needed_bit_count + 7) / 8;
224 pub const usize_count = (byte_count + (@sizeOf(usize) - 1)) / @sizeOf(usize);224 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)));
226 pub const ShiftInt = std.math.Log2Int(usize);226 pub const ShiftInt = std.math.Log2Int(usize);
227227
228 pub const empty = Set{ .ints = [1]usize{0} ** usize_count };228 pub const empty = Set{ .ints = [1]usize{0} ** usize_count };
lib/std/thread.zig+1-1
...@@ -148,7 +148,7 @@ pub const Thread = struct {...@@ -148,7 +148,7 @@ pub const Thread = struct {
148 const default_stack_size = 16 * 1024 * 1024;148 const default_stack_size = 16 * 1024 * 1024;
149149
150 const Context = @TypeOf(context);150 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
153 if (builtin.os == builtin.Os.windows) {153 if (builtin.os == builtin.Os.windows) {
154 const WinThread = struct {154 const WinThread = struct {
src-self-hosted/type.zig+1-1
...@@ -1042,7 +1042,7 @@ fn hashAny(x: var, comptime seed: u64) u32 {...@@ -1042,7 +1042,7 @@ fn hashAny(x: var, comptime seed: u64) u32 {
1042 switch (@typeInfo(@TypeOf(x))) {1042 switch (@typeInfo(@TypeOf(x))) {
1043 .Int => |info| {1043 .Int => |info| {
1044 comptime var rng = comptime std.rand.DefaultPrng.init(seed);1044 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);
1046 if (info.bits <= 32) {1046 if (info.bits <= 32) {
1047 return @as(u32, unsigned_x) *% comptime rng.random.scalar(u32);1047 return @as(u32, unsigned_x) *% comptime rng.random.scalar(u32);
1048 } else {1048 } else {
test/compile_errors.zig+3-29
...@@ -1657,7 +1657,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -1657,7 +1657,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1657 \\ var ptr: [*c]u8 = (1 << 64) + 1;1657 \\ var ptr: [*c]u8 = (1 << 64) + 1;
1658 \\}1658 \\}
1659 \\export fn b() void {1659 \\export fn b() void {
1660 \\ var x: @IntType(false, 65) = 0x1234;1660 \\ var x: u65 = 0x1234;
1661 \\ var ptr: [*c]u8 = x;1661 \\ var ptr: [*c]u8 = x;
1662 \\}1662 \\}
1663 , &[_][]const u8{1663 , &[_][]const u8{
...@@ -1896,7 +1896,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -1896,7 +1896,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
18961896
1897 cases.add("exceeded maximum bit width of integer",1897 cases.add("exceeded maximum bit width of integer",
1898 \\export fn entry1() void {1898 \\export fn entry1() void {
1899 \\ const T = @IntType(false, 65536);1899 \\ const T = u65536;
1900 \\}1900 \\}
1901 \\export fn entry2() void {1901 \\export fn entry2() void {
1902 \\ var x: i65536 = 1;1902 \\ var x: i65536 = 1;
...@@ -5598,7 +5598,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -5598,7 +5598,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
5598 });5598 });
55995599
5600 cases.add("globally shadowing a primitive type",5600 cases.add("globally shadowing a primitive type",
5601 \\const u16 = @intType(false, 8);5601 \\const u16 = u8;
5602 \\export fn entry() void {5602 \\export fn entry() void {
5603 \\ const a: u16 = 300;5603 \\ const a: u16 = 300;
5604 \\}5604 \\}
...@@ -5939,23 +5939,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -5939,23 +5939,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
5939 "tmp.zig:2:1: error: invalid character: '\\t'",5939 "tmp.zig:2:1: error: invalid character: '\\t'",
5940 });5940 });
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
5959 cases.add("calling var args extern function, passing array instead of pointer",5942 cases.add("calling var args extern function, passing array instead of pointer",
5960 \\export fn entry() void {5943 \\export fn entry() void {
5961 \\ foo("hello".*,);5944 \\ foo("hello".*,);
...@@ -6379,15 +6362,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -6379,15 +6362,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
6379 "tmp.zig:3:25: error: ReturnType has not been resolved because 'fn(var) var' is generic",6362 "tmp.zig:3:25: error: ReturnType has not been resolved because 'fn(var) var' is generic",
6380 });6363 });
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
6391 cases.add("unsupported modifier at start of asm output constraint",6365 cases.add("unsupported modifier at start of asm output constraint",
6392 \\export fn foo() void {6366 \\export fn foo() void {
6393 \\ var bar: u32 = 3;6367 \\ var bar: u32 = 3;
test/stage1/behavior/bit_shifting.zig+2-2
...@@ -2,9 +2,9 @@ const std = @import("std");...@@ -2,9 +2,9 @@ const std = @import("std");
2const expect = std.testing.expect;2const expect = std.testing.expect;
33
4fn ShardedTable(comptime Key: type, comptime mask_bit_count: comptime_int, comptime V: type) type {4fn 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));
6 expect(Key.bit_count >= mask_bit_count);6 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);
8 const shift_amount = Key.bit_count - ShardKey.bit_count;8 const shift_amount = Key.bit_count - ShardKey.bit_count;
9 return struct {9 return struct {
10 const Self = @This();10 const Self = @This();
test/stage1/behavior/math.zig+1-1
...@@ -270,7 +270,7 @@ fn testBinaryNot(x: u16) void {...@@ -270,7 +270,7 @@ fn testBinaryNot(x: u16) void {
270}270}
271271
272test "small int addition" {272test "small int addition" {
273 var x: @IntType(false, 2) = 0;273 var x: u2 = 0;
274 expect(x == 0);274 expect(x == 0);
275275
276 x += 1;276 x += 1;
test/stage1/behavior/misc.zig-29
...@@ -24,35 +24,6 @@ test "call disabled extern fn" {...@@ -24,35 +24,6 @@ test "call disabled extern fn" {
24 disabledExternFn();24 disabledExternFn();
25}25}
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
56test "floating point primitive bit counts" {27test "floating point primitive bit counts" {
57 expect(f16.bit_count == 16);28 expect(f16.bit_count == 16);
58 expect(f32.bit_count == 32);29 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" {...@@ -16,9 +16,9 @@ test "reflection: function return type, var args, and param types" {
16 expect(@TypeOf(dummy).ReturnType == i32);16 expect(@TypeOf(dummy).ReturnType == i32);
17 expect(!@TypeOf(dummy).is_var_args);17 expect(!@TypeOf(dummy).is_var_args);
18 expect(@TypeOf(dummy).arg_count == 3);18 expect(@TypeOf(dummy).arg_count == 3);
19 expect(@ArgType(@TypeOf(dummy), 0) == bool);19 expect(@typeInfo(@TypeOf(dummy)).Fn.args[0].arg_type.? == bool);
20 expect(@ArgType(@TypeOf(dummy), 1) == i32);20 expect(@typeInfo(@TypeOf(dummy)).Fn.args[1].arg_type.? == i32);
21 expect(@ArgType(@TypeOf(dummy), 2) == f32);21 expect(@typeInfo(@TypeOf(dummy)).Fn.args[2].arg_type.? == f32);
22 }22 }
23}23}
2424