diff options
| author | Jacob G-W <jacoblevgw@gmail.com> | 2023-07-25 11:15:59 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-07-25 16:19:08 -0700 |
| commit | 3c08fe931a10618950c6af9e89226d1d9b20bbb9 (patch) | |
| tree | e745ce6e163c0af808adc8322a6c83e5ba426641 /lib/std/testing.zig | |
| parent | 972e70b7941561b10f9b3062dcd7b7a91016c546 (diff) | |
| download | zig-3c08fe931a10618950c6af9e89226d1d9b20bbb9.tar.gz zig-3c08fe931a10618950c6af9e89226d1d9b20bbb9.zip | |
make `@typeInfo` not return private decls
fixes #10731
Thanks @nektro for previous work in #14878
This change creates a small breaking change:
It removes the `is_pub` field of a decl in `@typeInfo`
Diffstat (limited to 'lib/std/testing.zig')
| -rw-r--r-- | lib/std/testing.zig | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/std/testing.zig b/lib/std/testing.zig index 6c3952cfd6..0590d76e57 100644 --- a/lib/std/testing.zig +++ b/lib/std/testing.zig @@ -1122,7 +1122,7 @@ pub fn checkAllAllocationFailures(backing_allocator: std.mem.Allocator, comptime pub fn refAllDecls(comptime T: type) void { if (!builtin.is_test) return; inline for (comptime std.meta.declarations(T)) |decl| { - if (decl.is_pub) _ = &@field(T, decl.name); + _ = &@field(T, decl.name); } } @@ -1131,14 +1131,12 @@ pub fn refAllDecls(comptime T: type) void { pub fn refAllDeclsRecursive(comptime T: type) void { if (!builtin.is_test) return; inline for (comptime std.meta.declarations(T)) |decl| { - if (decl.is_pub) { - if (@TypeOf(@field(T, decl.name)) == type) { - switch (@typeInfo(@field(T, decl.name))) { - .Struct, .Enum, .Union, .Opaque => refAllDeclsRecursive(@field(T, decl.name)), - else => {}, - } + if (@TypeOf(@field(T, decl.name)) == type) { + switch (@typeInfo(@field(T, decl.name))) { + .Struct, .Enum, .Union, .Opaque => refAllDeclsRecursive(@field(T, decl.name)), + else => {}, } - _ = &@field(T, decl.name); } + _ = &@field(T, decl.name); } } |
