aboutsummaryrefslogtreecommitdiff
path: root/lib/std/debug.zig
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2025-02-01 07:37:27 +0000
committerMatthew Lugg <mlugg@mlugg.co.uk>2025-02-23 08:28:58 +0000
commit5e20e9b4491dead0c56d9b0351677d5832058673 (patch)
tree1b397bf48ac85822b52895439015f79b2372cadc /lib/std/debug.zig
parentd6f8200294689b318e3a4f75be0ae4d05cfea9c0 (diff)
downloadzig-5e20e9b4491dead0c56d9b0351677d5832058673.tar.gz
zig-5e20e9b4491dead0c56d9b0351677d5832058673.zip
Sema: allow `@ptrCast` of slices changing the length
Also, refactor `Sema.ptrCastFull` to not be a horrifying hellscape.
Diffstat (limited to 'lib/std/debug.zig')
-rw-r--r--lib/std/debug.zig4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/std/debug.zig b/lib/std/debug.zig
index 56d978626a..77b619a056 100644
--- a/lib/std/debug.zig
+++ b/lib/std/debug.zig
@@ -54,6 +54,10 @@ pub fn FullPanic(comptime panicFn: fn ([]const u8, ?usize) noreturn) type {
@tagName(accessed), @tagName(active),
});
}
+ pub fn sliceCastLenRemainder(src_len: usize) noreturn {
+ @branchHint(.cold);
+ std.debug.panicExtra(@returnAddress(), "slice length '{d}' does not divide exactly into destination elements", .{src_len});
+ }
pub fn reachedUnreachable() noreturn {
@branchHint(.cold);
call("reached unreachable code", @returnAddress());