aboutsummaryrefslogtreecommitdiff
path: root/lib/std/debug/FormattedPanic.zig
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2025-01-24 02:19:28 +0000
committermlugg <mlugg@mlugg.co.uk>2025-01-24 19:29:51 +0000
commit83991efe10d92c4b920d7b7fc75be98ed7854ad7 (patch)
tree7137ee5eb01517aede1c5503c29a2003fca71f80 /lib/std/debug/FormattedPanic.zig
parentb3d9b0e3f6bab5d662ec385cf754872f8a90607f (diff)
downloadzig-83991efe10d92c4b920d7b7fc75be98ed7854ad7.tar.gz
zig-83991efe10d92c4b920d7b7fc75be98ed7854ad7.zip
compiler: yet more panic handler changes
* `std.builtin.Panic` -> `std.builtin.panic`, because it is a namespace. * `root.Panic` -> `root.panic` for the same reason. There are type checks so that we still allow the legacy `pub fn panic` strategy in the 0.14.0 release. * `std.debug.SimplePanic` -> `std.debug.simple_panic`, same reason. * `std.debug.NoPanic` -> `std.debug.no_panic`, same reason. * `std.debug.FormattedPanic` is now a function `std.debug.FullPanic` which takes as input a `panicFn` and returns a namespace with all the panic functions. This handles the incredibly common case of just wanting to override how the message is printed, whilst keeping nice formatted panics. * Remove `std.builtin.panic.messages`; now, every safety panic has its own function. This reduces binary bloat, as calls to these functions no longer need to prepare any arguments (aside from the error return trace). * Remove some legacy declarations, since a zig1.wasm update has happened. Most of these were related to the panic handler, but a quick grep for "zig1" brought up a couple more results too. Also, add some missing type checks to Sema. Resolves: #22584 formatted -> full
Diffstat (limited to 'lib/std/debug/FormattedPanic.zig')
-rw-r--r--lib/std/debug/FormattedPanic.zig45
1 files changed, 0 insertions, 45 deletions
diff --git a/lib/std/debug/FormattedPanic.zig b/lib/std/debug/FormattedPanic.zig
deleted file mode 100644
index 0ad6ea696c..0000000000
--- a/lib/std/debug/FormattedPanic.zig
+++ /dev/null
@@ -1,45 +0,0 @@
-//! This namespace is the default one used by the Zig compiler to emit various
-//! kinds of safety panics, due to the logic in `std.builtin.Panic`.
-//!
-//! Since Zig does not have interfaces, this file serves as an example template
-//! for users to provide their own alternative panic handling.
-//!
-//! As an alternative, see `std.debug.SimplePanic`.
-
-const std = @import("../std.zig");
-
-/// Dumps a stack trace to standard error, then aborts.
-///
-/// Explicit calls to `@panic` lower to calling this function.
-pub const call: fn ([]const u8, ?*std.builtin.StackTrace, ?usize) noreturn = std.debug.defaultPanic;
-
-pub fn sentinelMismatch(expected: anytype, found: @TypeOf(expected)) noreturn {
- @branchHint(.cold);
- std.debug.panicExtra(null, @returnAddress(), "sentinel mismatch: expected {any}, found {any}", .{
- expected, found,
- });
-}
-
-pub fn unwrapError(ert: ?*std.builtin.StackTrace, err: anyerror) noreturn {
- @branchHint(.cold);
- std.debug.panicExtra(ert, @returnAddress(), "attempt to unwrap error: {s}", .{@errorName(err)});
-}
-
-pub fn outOfBounds(index: usize, len: usize) noreturn {
- @branchHint(.cold);
- std.debug.panicExtra(null, @returnAddress(), "index out of bounds: index {d}, len {d}", .{ index, len });
-}
-
-pub fn startGreaterThanEnd(start: usize, end: usize) noreturn {
- @branchHint(.cold);
- std.debug.panicExtra(null, @returnAddress(), "start index {d} is larger than end index {d}", .{ start, end });
-}
-
-pub fn inactiveUnionField(active: anytype, accessed: @TypeOf(active)) noreturn {
- @branchHint(.cold);
- std.debug.panicExtra(null, @returnAddress(), "access of union field '{s}' while field '{s}' is active", .{
- @tagName(accessed), @tagName(active),
- });
-}
-
-pub const messages = std.debug.SimplePanic.messages;