| author | |
| committer | |
| log | bf953c4d6af5225d27cdfade564814a92321befb |
| tree | 4e305f301c6758dc6f2d5650b13b74f147923fda |
| parent | 991f56fd6b23db0e6a6c78cac8ad62e869a39711 |
3 files changed, 9 insertions(+), 36 deletions(-)
lib/std/json/static_test.zig+2-2| ... | @@ -663,7 +663,7 @@ test "parse into tuple" { | ... | @@ -663,7 +663,7 @@ test "parse into tuple" { |
| 663 | float: f64, | 663 | float: f64, |
| 664 | string: []const u8, | 664 | string: []const u8, |
| 665 | }; | 665 | }; |
| 666 | const T = std.meta.Tuple(&.{ | 666 | const T = @Tuple(&.{ |
| 667 | i64, | 667 | i64, |
| 668 | f64, | 668 | f64, |
| 669 | bool, | 669 | bool, |
| ... | @@ -673,7 +673,7 @@ test "parse into tuple" { | ... | @@ -673,7 +673,7 @@ test "parse into tuple" { |
| 673 | foo: i32, | 673 | foo: i32, |
| 674 | bar: []const u8, | 674 | bar: []const u8, |
| 675 | }, | 675 | }, |
| 676 | std.meta.Tuple(&.{ u8, []const u8, u8 }), | 676 | @Tuple(&.{ u8, []const u8, u8 }), |
| 677 | Union, | 677 | Union, |
| 678 | }); | 678 | }); |
| 679 | const str = | 679 | const str = |
lib/std/meta.zig+3-30| ... | @@ -791,14 +791,7 @@ pub fn ArgsTuple(comptime Function: type) type { | ... | @@ -791,14 +791,7 @@ pub fn ArgsTuple(comptime Function: type) type { |
| 791 | argument_field_list[i] = T; | 791 | argument_field_list[i] = T; |
| 792 | } | 792 | } |
| 793 | 793 | ||
| 794 | return Tuple(&argument_field_list); | 794 | return @Tuple(&argument_field_list); |
| 795 | } | ||
| 796 | |||
| 797 | /// Deprecated; use `@Tuple` instead. | ||
| 798 | /// | ||
| 799 | /// To be removed after Zig 0.16.0 releases. | ||
| 800 | pub fn Tuple(comptime types: []const type) type { | ||
| 801 | return @Tuple(types); | ||
| 802 | } | 795 | } |
| 803 | 796 | ||
| 804 | const TupleTester = struct { | 797 | const TupleTester = struct { |
| ... | @@ -834,33 +827,13 @@ test ArgsTuple { | ... | @@ -834,33 +827,13 @@ test ArgsTuple { |
| 834 | TupleTester.assertTuple(.{u32}, ArgsTuple(fn (comptime a: u32) []const u8)); | 827 | TupleTester.assertTuple(.{u32}, ArgsTuple(fn (comptime a: u32) []const u8)); |
| 835 | } | 828 | } |
| 836 | 829 | ||
| 837 | test Tuple { | ||
| 838 | TupleTester.assertTuple(.{}, Tuple(&[_]type{})); | ||
| 839 | TupleTester.assertTuple(.{u32}, Tuple(&[_]type{u32})); | ||
| 840 | TupleTester.assertTuple(.{ u32, f16 }, Tuple(&[_]type{ u32, f16 })); | ||
| 841 | TupleTester.assertTuple(.{ u32, f16, []const u8, void }, Tuple(&[_]type{ u32, f16, []const u8, void })); | ||
| 842 | } | ||
| 843 | |||
| 844 | test "Tuple deduplication" { | ||
| 845 | const T1 = std.meta.Tuple(&.{ u32, f32, i8 }); | ||
| 846 | const T2 = std.meta.Tuple(&.{ u32, f32, i8 }); | ||
| 847 | const T3 = std.meta.Tuple(&.{ u32, f32, i7 }); | ||
| 848 | |||
| 849 | if (T1 != T2) { | ||
| 850 | @compileError("std.meta.Tuple doesn't deduplicate tuple types."); | ||
| 851 | } | ||
| 852 | if (T1 == T3) { | ||
| 853 | @compileError("std.meta.Tuple fails to generate different types."); | ||
| 854 | } | ||
| 855 | } | ||
| 856 | |||
| 857 | test "ArgsTuple forwarding" { | 830 | test "ArgsTuple forwarding" { |
| 858 | const T1 = std.meta.Tuple(&.{ u32, f32, i8 }); | 831 | const T1 = @Tuple(&.{ u32, f32, i8 }); |
| 859 | const T2 = std.meta.ArgsTuple(fn (u32, f32, i8) void); | 832 | const T2 = std.meta.ArgsTuple(fn (u32, f32, i8) void); |
| 860 | const T3 = std.meta.ArgsTuple(fn (u32, f32, i8) callconv(.c) noreturn); | 833 | const T3 = std.meta.ArgsTuple(fn (u32, f32, i8) callconv(.c) noreturn); |
| 861 | 834 | ||
| 862 | if (T1 != T2) { | 835 | if (T1 != T2) { |
| 863 | @compileError("std.meta.ArgsTuple produces different types than std.meta.Tuple"); | 836 | @compileError("std.meta.ArgsTuple produces different types than @Tuple"); |
| 864 | } | 837 | } |
| 865 | if (T1 != T3) { | 838 | if (T1 != T3) { |
| 866 | @compileError("std.meta.ArgsTuple produces different types for the same argument lists."); | 839 | @compileError("std.meta.ArgsTuple produces different types for the same argument lists."); |
test/behavior/tuple.zig+4-4| ... | @@ -233,7 +233,7 @@ test "tuple in tuple passed to generic function" { | ... | @@ -233,7 +233,7 @@ test "tuple in tuple passed to generic function" { |
| 233 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; | 233 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 234 | 234 | ||
| 235 | const S = struct { | 235 | const S = struct { |
| 236 | fn pair(x: f32, y: f32) std.meta.Tuple(&.{ f32, f32 }) { | 236 | fn pair(x: f32, y: f32) @Tuple(&.{ f32, f32 }) { |
| 237 | return .{ x, y }; | 237 | return .{ x, y }; |
| 238 | } | 238 | } |
| 239 | 239 | ||
| ... | @@ -251,7 +251,7 @@ test "coerce tuple to tuple" { | ... | @@ -251,7 +251,7 @@ test "coerce tuple to tuple" { |
| 251 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | 251 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 252 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; | 252 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 253 | 253 | ||
| 254 | const T = std.meta.Tuple(&.{u8}); | 254 | const T = @Tuple(&.{u8}); |
| 255 | const S = struct { | 255 | const S = struct { |
| 256 | fn foo(x: T) !void { | 256 | fn foo(x: T) !void { |
| 257 | try expect(x[0] == 123); | 257 | try expect(x[0] == 123); |
| ... | @@ -265,7 +265,7 @@ test "tuple type with void field" { | ... | @@ -265,7 +265,7 @@ test "tuple type with void field" { |
| 265 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | 265 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 266 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; | 266 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 267 | 267 | ||
| 268 | const T = std.meta.Tuple(&[_]type{void}); | 268 | const T = @Tuple(&.{void}); |
| 269 | const x = T{{}}; | 269 | const x = T{{}}; |
| 270 | try expect(@TypeOf(x[0]) == void); | 270 | try expect(@TypeOf(x[0]) == void); |
| 271 | } | 271 | } |
| ... | @@ -290,7 +290,7 @@ test "tuple type with void field and a runtime field" { | ... | @@ -290,7 +290,7 @@ test "tuple type with void field and a runtime field" { |
| 290 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | 290 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 291 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; | 291 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 292 | 292 | ||
| 293 | const T = std.meta.Tuple(&[_]type{ usize, void }); | 293 | const T = @Tuple(&.{ usize, void }); |
| 294 | var t: T = .{ 5, {} }; | 294 | var t: T = .{ 5, {} }; |
| 295 | _ = &t; | 295 | _ = &t; |
| 296 | try expect(t[0] == 5); | 296 | try expect(t[0] == 5); |