authorgravatar for mail@linusgroh.deLinus Groh <mail@linusgroh.de> 2026-05-03 20:54:44+01:00
committergravatar for mail@linusgroh.deLinus Groh <mail@linusgroh.de> 2026-05-03 21:42:06+01:00
logbf953c4d6af5225d27cdfade564814a92321befb
tree4e305f301c6758dc6f2d5650b13b74f147923fda
parent991f56fd6b23db0e6a6c78cac8ad62e869a39711

std.meta: Remove Tuple in favor of @Tuple


3 files changed, 9 insertions(+), 36 deletions(-)

lib/std/json/static_test.zig+2-2
......@@ -663,7 +663,7 @@ test "parse into tuple" {
663663 float: f64,
664664 string: []const u8,
665665 };
666 const T = std.meta.Tuple(&.{
666 const T = @Tuple(&.{
667667 i64,
668668 f64,
669669 bool,
......@@ -673,7 +673,7 @@ test "parse into tuple" {
673673 foo: i32,
674674 bar: []const u8,
675675 },
676 std.meta.Tuple(&.{ u8, []const u8, u8 }),
676 @Tuple(&.{ u8, []const u8, u8 }),
677677 Union,
678678 });
679679 const str =
lib/std/meta.zig+3-30
......@@ -791,14 +791,7 @@ pub fn ArgsTuple(comptime Function: type) type {
791791 argument_field_list[i] = T;
792792 }
793793
794 return Tuple(&argument_field_list);
795}
796
797/// Deprecated; use `@Tuple` instead.
798///
799/// To be removed after Zig 0.16.0 releases.
800pub fn Tuple(comptime types: []const type) type {
801 return @Tuple(types);
794 return @Tuple(&argument_field_list);
802795}
803796
804797const TupleTester = struct {
......@@ -834,33 +827,13 @@ test ArgsTuple {
834827 TupleTester.assertTuple(.{u32}, ArgsTuple(fn (comptime a: u32) []const u8));
835828}
836829
837test 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
844test "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
857830test "ArgsTuple forwarding" {
858 const T1 = std.meta.Tuple(&.{ u32, f32, i8 });
831 const T1 = @Tuple(&.{ u32, f32, i8 });
859832 const T2 = std.meta.ArgsTuple(fn (u32, f32, i8) void);
860833 const T3 = std.meta.ArgsTuple(fn (u32, f32, i8) callconv(.c) noreturn);
861834
862835 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");
864837 }
865838 if (T1 != T3) {
866839 @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" {
233233 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
234234
235235 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 }) {
237237 return .{ x, y };
238238 }
239239
......@@ -251,7 +251,7 @@ test "coerce tuple to tuple" {
251251 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
252252 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
253253
254 const T = std.meta.Tuple(&.{u8});
254 const T = @Tuple(&.{u8});
255255 const S = struct {
256256 fn foo(x: T) !void {
257257 try expect(x[0] == 123);
......@@ -265,7 +265,7 @@ test "tuple type with void field" {
265265 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
266266 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
267267
268 const T = std.meta.Tuple(&[_]type{void});
268 const T = @Tuple(&.{void});
269269 const x = T{{}};
270270 try expect(@TypeOf(x[0]) == void);
271271}
......@@ -290,7 +290,7 @@ test "tuple type with void field and a runtime field" {
290290 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
291291 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
292292
293 const T = std.meta.Tuple(&[_]type{ usize, void });
293 const T = @Tuple(&.{ usize, void });
294294 var t: T = .{ 5, {} };
295295 _ = &t;
296296 try expect(t[0] == 5);