From 75cf06c187d9d0288c2ea31f34b18c3a7da4bd1d Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 5 May 2023 13:26:01 -0700 Subject: [PATCH] std.mem.alignForwardGeneric: manually inline the assertions This matches more directly the documentation comments, and makes it more obvious what went wrong when an assertion fails. --- lib/std/mem.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/std/mem.zig b/lib/std/mem.zig index 212d09a1a8..d6ca4a9ea1 100644 --- a/lib/std/mem.zig +++ b/lib/std/mem.zig @@ -4226,7 +4226,8 @@ pub fn alignForwardLog2(addr: usize, log2_alignment: u8) usize { /// The alignment must be a power of 2 and greater than 0. /// Asserts that rounding up the address does not cause integer overflow. pub fn alignForwardGeneric(comptime T: type, addr: T, alignment: T) T { - assert(isValidAlignGeneric(T, alignment)); + assert(alignment > 0); + assert(std.math.isPowerOfTwo(alignment)); return alignBackwardGeneric(T, addr + (alignment - 1), alignment); }