diff --git a/lib/std/build.zig b/lib/std/build.zig index 4cbf6ea67aae7732c65db9296d34ff4a14eec979..0a12b10db47e8108aaddbb634fe1206991309463 100644 --- a/lib/std/build.zig +++ b/lib/std/build.zig @@ -2702,5 +2702,5 @@ test "" { // The only purpose of this test is to get all these untested functions // to be referenced to avoid regression so it is okay to skip some targets. if (comptime std.Target.current.cpu.arch.ptrBitWidth() == 64) - std.meta.refAllDecls(@This()); + std.testing.refAllDecls(@This()); } diff --git a/lib/std/build/emit_raw.zig b/lib/std/build/emit_raw.zig index d499df1817f9d71c93bf5a10554a9d78688d4042..75fd7be613da9625ee80f410f725c1c7143e3901 100644 --- a/lib/std/build/emit_raw.zig +++ b/lib/std/build/emit_raw.zig @@ -224,5 +224,5 @@ pub const InstallRawStep = struct { }; test "" { - std.meta.refAllDecls(InstallRawStep); + std.testing.refAllDecls(InstallRawStep); } diff --git a/lib/std/crypto.zig b/lib/std/crypto.zig index 8c225aa719d8ed3defa897ffd419388ec58295e5..858869e5e33f2256ba38a23c997920e8bb13cea8 100644 --- a/lib/std/crypto.zig +++ b/lib/std/crypto.zig @@ -110,7 +110,7 @@ test "crypto" { inline for (std.meta.declarations(@This())) |decl| { switch (decl.data) { .Type => |t| { - std.meta.refAllDecls(t); + std.testing.refAllDecls(t); }, .Var => |v| { _ = v; diff --git a/lib/std/math.zig b/lib/std/math.zig index a1db1309c930180abf95d1ee7c2316fa6fff25ea..efd70fe049d9f8f70bf09ebcf8f2cdd3f233efa9 100644 --- a/lib/std/math.zig +++ b/lib/std/math.zig @@ -194,7 +194,7 @@ pub const Complex = complex.Complex; pub const big = @import("math/big.zig"); test "" { - std.meta.refAllDecls(@This()); + std.testing.refAllDecls(@This()); } pub fn floatMantissaBits(comptime T: type) comptime_int { diff --git a/lib/std/meta.zig b/lib/std/meta.zig index 79b0424e96b028a3f7045bc2abdeb699ad427c08..ca13ba8a284551398723f5bf30f96fe528688c48 100644 --- a/lib/std/meta.zig +++ b/lib/std/meta.zig @@ -655,13 +655,7 @@ pub fn fieldIndex(comptime T: type, comptime name: []const u8) ?comptime_int { return null; } -/// Given a type, reference all the declarations inside, so that the semantic analyzer sees them. -pub fn refAllDecls(comptime T: type) void { - if (!builtin.is_test) return; - inline for (declarations(T)) |decl| { - _ = decl; - } -} +pub const refAllDecls = @compileError("refAllDecls has been moved from std.meta to std.testing"); /// Returns a slice of pointers to public declarations of a namespace. pub fn declList(comptime Namespace: type, comptime Decl: type) []const *const Decl { diff --git a/lib/std/rand.zig b/lib/std/rand.zig index 7e055928698ac37716b53599ddfd792007f9e5fc..cad76f2da5ef52c6c8806e59c25421987279b5ef 100644 --- a/lib/std/rand.zig +++ b/lib/std/rand.zig @@ -1140,5 +1140,5 @@ fn testRangeBias(r: *Random, start: i8, end: i8, biased: bool) void { } test "" { - std.meta.refAllDecls(@This()); + std.testing.refAllDecls(@This()); } diff --git a/lib/std/std.zig b/lib/std/std.zig index f4cca0f9f461ec280e6f4a291edfc2ab51082428..c499f7a5cc2a7975255d955f5be57dbdb6e1f065 100644 --- a/lib/std/std.zig +++ b/lib/std/std.zig @@ -92,5 +92,5 @@ comptime { } test "" { - meta.refAllDecls(@This()); + testing.refAllDecls(@This()); } diff --git a/lib/std/target.zig b/lib/std/target.zig index 1b93c82a76f1a7063e9d804ab90a3f1de8465656..01fffb68e5bcac8bb69e764fc688e9262c481948 100644 --- a/lib/std/target.zig +++ b/lib/std/target.zig @@ -1516,5 +1516,5 @@ pub const Target = struct { }; test "" { - std.meta.refAllDecls(Target.Cpu.Arch); + std.testing.refAllDecls(Target.Cpu.Arch); } diff --git a/lib/std/testing.zig b/lib/std/testing.zig index ccbd1d6324fa8d0fd43b1db1e9aa682db6b595fd..4b388adb679d5b081fa8655db302d9bb7b8a3fdf 100644 --- a/lib/std/testing.zig +++ b/lib/std/testing.zig @@ -389,3 +389,11 @@ fn printLine(line: []const u8) void { test "" { expectEqualStrings("foo", "foo"); } + +/// Given a type, reference all the declarations inside, so that the semantic analyzer sees them. +pub fn refAllDecls(comptime T: type) void { + if (!@import("builtin").is_test) return; + inline for (std.meta.declarations(T)) |decl| { + _ = decl; + } +} diff --git a/lib/std/zig.zig b/lib/std/zig.zig index cc1815e8e50f827c7417117097606de92111aee5..c28b9b3e353be0a49198f55605753d0d97591d7a 100644 --- a/lib/std/zig.zig +++ b/lib/std/zig.zig @@ -255,5 +255,5 @@ test "parseCharLiteral" { } test "" { - @import("std").meta.refAllDecls(@This()); + @import("std").testing.refAllDecls(@This()); }