Skip to content

Commit f80c01f

Browse files
committed
ref more math decls for better docs
1 parent 7598a57 commit f80c01f

File tree

3 files changed

+10
-113
lines changed

3 files changed

+10
-113
lines changed

lib/std/math.zig

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -202,54 +202,8 @@ pub const Complex = complex.Complex;
202202

203203
pub const big = @import("math/big.zig");
204204

205-
test "math" {
206-
_ = @import("math/nan.zig");
207-
_ = @import("math/isnan.zig");
208-
_ = @import("math/fabs.zig");
209-
_ = @import("math/ceil.zig");
210-
_ = @import("math/floor.zig");
211-
_ = @import("math/trunc.zig");
212-
_ = @import("math/round.zig");
213-
_ = @import("math/frexp.zig");
214-
_ = @import("math/modf.zig");
215-
_ = @import("math/copysign.zig");
216-
_ = @import("math/isfinite.zig");
217-
_ = @import("math/isinf.zig");
218-
_ = @import("math/isnormal.zig");
219-
_ = @import("math/signbit.zig");
220-
_ = @import("math/scalbn.zig");
221-
_ = @import("math/pow.zig");
222-
_ = @import("math/powi.zig");
223-
_ = @import("math/sqrt.zig");
224-
_ = @import("math/cbrt.zig");
225-
_ = @import("math/acos.zig");
226-
_ = @import("math/asin.zig");
227-
_ = @import("math/atan.zig");
228-
_ = @import("math/atan2.zig");
229-
_ = @import("math/hypot.zig");
230-
_ = @import("math/exp.zig");
231-
_ = @import("math/exp2.zig");
232-
_ = @import("math/expm1.zig");
233-
_ = @import("math/ilogb.zig");
234-
_ = @import("math/ln.zig");
235-
_ = @import("math/log.zig");
236-
_ = @import("math/log2.zig");
237-
_ = @import("math/log10.zig");
238-
_ = @import("math/log1p.zig");
239-
_ = @import("math/fma.zig");
240-
_ = @import("math/asinh.zig");
241-
_ = @import("math/acosh.zig");
242-
_ = @import("math/atanh.zig");
243-
_ = @import("math/sinh.zig");
244-
_ = @import("math/cosh.zig");
245-
_ = @import("math/tanh.zig");
246-
_ = @import("math/sin.zig");
247-
_ = @import("math/cos.zig");
248-
_ = @import("math/tan.zig");
249-
250-
_ = @import("math/complex.zig");
251-
252-
_ = @import("math/big.zig");
205+
comptime {
206+
std.meta.refAllDecls(@This());
253207
}
254208

255209
pub fn floatMantissaBits(comptime T: type) comptime_int {

lib/std/meta.zig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,3 +552,9 @@ pub fn fieldIndex(comptime T: type, comptime name: []const u8) ?comptime_int {
552552
}
553553
return null;
554554
}
555+
556+
/// Given a type, reference all the declarations inside, so that the semantic analyzer sees them.
557+
pub fn refAllDecls(comptime T: type) void {
558+
if (!builtin.is_test) return;
559+
_ = declarations(T);
560+
}

lib/std/std.zig

Lines changed: 2 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -62,69 +62,6 @@ pub const unicode = @import("unicode.zig");
6262
pub const valgrind = @import("valgrind.zig");
6363
pub const zig = @import("zig.zig");
6464

65-
// Reference everything so it gets tested.
66-
test "" {
67-
_ = AlignedArrayList;
68-
_ = ArrayList;
69-
_ = AutoHashMap;
70-
_ = BloomFilter;
71-
_ = BufMap;
72-
_ = BufSet;
73-
_ = Buffer;
74-
_ = BufferOutStream;
75-
_ = DynLib;
76-
_ = HashMap;
77-
_ = Mutex;
78-
_ = PackedIntArrayEndian;
79-
_ = PackedIntArray;
80-
_ = PackedIntSliceEndian;
81-
_ = PackedIntSlice;
82-
_ = PriorityQueue;
83-
_ = SinglyLinkedList;
84-
_ = StaticallyInitializedMutex;
85-
_ = SegmentedList;
86-
_ = SpinLock;
87-
_ = StringHashMap;
88-
_ = ChildProcess;
89-
_ = TailQueue;
90-
_ = Thread;
91-
92-
_ = atomic;
93-
_ = base64;
94-
_ = build;
95-
_ = c;
96-
_ = coff;
97-
_ = crypto;
98-
_ = cstr;
99-
_ = debug;
100-
_ = dwarf;
101-
_ = elf;
102-
_ = event;
103-
_ = fmt;
104-
_ = fs;
105-
_ = hash;
106-
_ = hash_map;
107-
_ = heap;
108-
_ = http;
109-
_ = io;
110-
_ = json;
111-
_ = lazyInit;
112-
_ = macho;
113-
_ = math;
114-
_ = mem;
115-
_ = meta;
116-
_ = net;
117-
_ = os;
118-
_ = packed_int_array;
119-
_ = pdb;
120-
_ = process;
121-
_ = rand;
122-
_ = rb;
123-
_ = sort;
124-
_ = ascii;
125-
_ = testing;
126-
_ = time;
127-
_ = unicode;
128-
_ = valgrind;
129-
_ = zig;
65+
comptime {
66+
meta.refAllDecls(@This());
13067
}

0 commit comments

Comments
 (0)