authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-16 12:30:24-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-16 12:34:42-08:00
log790d28d6cd9029805af857d56645a6ce191bfe91
treec382578db89fed7fde266d1b7ecf43d72d1c6ace
parent081888286bcee495c4b9c3a9e45db6485c6bd367

std.testing: delete refAllDeclsRecursive

suggested alternatives: - actual tests - explicitly list the decls - compile an example application that uses the API - stop worrying about dead code - refAllDecls (non recursive) in each file Don't fight the laziness, embrace it. closes #23608 closes #30813

3 files changed, 2 insertions(+), 18 deletions(-)

lib/std/os/uefi/protocol.zig+1-2
......@@ -53,6 +53,5 @@ pub const HiiDatabase = @import("protocol/hii_database.zig").HiiDatabase;
5353pub const HiiPopup = @import("protocol/hii_popup.zig").HiiPopup;
5454
5555test {
56 @setEvalBranchQuota(2000);
57 @import("std").testing.refAllDeclsRecursive(@This());
56 std.testing.refAllDecls(@This());
5857}
lib/std/os/uefi/tables.zig+1-1
......@@ -305,5 +305,5 @@ pub const global_variable = Guid{
305305};
306306
307307test {
308 std.testing.refAllDeclsRecursive(@This());
308 std.testing.refAllDecls(@This());
309309}
lib/std/testing.zig-15
......@@ -1200,21 +1200,6 @@ pub fn refAllDecls(comptime T: type) void {
12001200 }
12011201}
12021202
1203/// Given a type, recursively references all the declarations inside, so that the semantic analyzer sees them.
1204/// For deep types, you may use `@setEvalBranchQuota`.
1205pub fn refAllDeclsRecursive(comptime T: type) void {
1206 if (!builtin.is_test) return;
1207 inline for (comptime std.meta.declarations(T)) |decl| {
1208 if (@TypeOf(@field(T, decl.name)) == type) {
1209 switch (@typeInfo(@field(T, decl.name))) {
1210 .@"struct", .@"enum", .@"union", .@"opaque" => refAllDeclsRecursive(@field(T, decl.name)),
1211 else => {},
1212 }
1213 }
1214 _ = &@field(T, decl.name);
1215 }
1216}
1217
12181203pub const FuzzInputOptions = struct {
12191204 corpus: []const []const u8 = &.{},
12201205};