mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-07 14:24:43 +00:00
* `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
160 lines
3.2 KiB
Zig
160 lines
3.2 KiB
Zig
//! This namespace can be used with `pub const panic = std.debug.no_panic;` in the root file.
|
|
//! It emits as little code as possible, for testing purposes.
|
|
//!
|
|
//! For a functional alternative, see `std.debug.FullPanic`.
|
|
|
|
const std = @import("../std.zig");
|
|
|
|
pub fn call(_: []const u8, _: ?*std.builtin.StackTrace, _: ?usize) noreturn {
|
|
@branchHint(.cold);
|
|
@trap();
|
|
}
|
|
|
|
pub fn sentinelMismatch(_: anytype, _: anytype) noreturn {
|
|
@branchHint(.cold);
|
|
@trap();
|
|
}
|
|
|
|
pub fn unwrapError(_: ?*std.builtin.StackTrace, _: anyerror) noreturn {
|
|
@branchHint(.cold);
|
|
@trap();
|
|
}
|
|
|
|
pub fn outOfBounds(_: usize, _: usize) noreturn {
|
|
@branchHint(.cold);
|
|
@trap();
|
|
}
|
|
|
|
pub fn startGreaterThanEnd(_: usize, _: usize) noreturn {
|
|
@branchHint(.cold);
|
|
@trap();
|
|
}
|
|
|
|
pub fn inactiveUnionField(_: anytype, _: anytype) noreturn {
|
|
@branchHint(.cold);
|
|
@trap();
|
|
}
|
|
|
|
pub fn reachedUnreachable() noreturn {
|
|
@branchHint(.cold);
|
|
@trap();
|
|
}
|
|
|
|
pub fn unwrapNull() noreturn {
|
|
@branchHint(.cold);
|
|
@trap();
|
|
}
|
|
|
|
pub fn castToNull() noreturn {
|
|
@branchHint(.cold);
|
|
@trap();
|
|
}
|
|
|
|
pub fn incorrectAlignment() noreturn {
|
|
@branchHint(.cold);
|
|
@trap();
|
|
}
|
|
|
|
pub fn invalidErrorCode() noreturn {
|
|
@branchHint(.cold);
|
|
@trap();
|
|
}
|
|
|
|
pub fn castTruncatedData() noreturn {
|
|
@branchHint(.cold);
|
|
@trap();
|
|
}
|
|
|
|
pub fn negativeToUnsigned() noreturn {
|
|
@branchHint(.cold);
|
|
@trap();
|
|
}
|
|
|
|
pub fn integerOverflow() noreturn {
|
|
@branchHint(.cold);
|
|
@trap();
|
|
}
|
|
|
|
pub fn shlOverflow() noreturn {
|
|
@branchHint(.cold);
|
|
@trap();
|
|
}
|
|
|
|
pub fn shrOverflow() noreturn {
|
|
@branchHint(.cold);
|
|
@trap();
|
|
}
|
|
|
|
pub fn divideByZero() noreturn {
|
|
@branchHint(.cold);
|
|
@trap();
|
|
}
|
|
|
|
pub fn exactDivisionRemainder() noreturn {
|
|
@branchHint(.cold);
|
|
@trap();
|
|
}
|
|
|
|
pub fn integerPartOutOfBounds() noreturn {
|
|
@branchHint(.cold);
|
|
@trap();
|
|
}
|
|
|
|
pub fn corruptSwitch() noreturn {
|
|
@branchHint(.cold);
|
|
@trap();
|
|
}
|
|
|
|
pub fn shiftRhsTooBig() noreturn {
|
|
@branchHint(.cold);
|
|
@trap();
|
|
}
|
|
|
|
pub fn invalidEnumValue() noreturn {
|
|
@branchHint(.cold);
|
|
@trap();
|
|
}
|
|
|
|
pub fn forLenMismatch() noreturn {
|
|
@branchHint(.cold);
|
|
@trap();
|
|
}
|
|
|
|
pub fn memcpyLenMismatch() noreturn {
|
|
@branchHint(.cold);
|
|
@trap();
|
|
}
|
|
|
|
pub fn memcpyAlias() noreturn {
|
|
@branchHint(.cold);
|
|
@trap();
|
|
}
|
|
|
|
pub fn noreturnReturned() noreturn {
|
|
@branchHint(.cold);
|
|
@trap();
|
|
}
|
|
|
|
/// To be deleted after zig1.wasm update.
|
|
pub const messages = struct {
|
|
pub const reached_unreachable = "";
|
|
pub const unwrap_null = "";
|
|
pub const cast_to_null = "";
|
|
pub const incorrect_alignment = "";
|
|
pub const invalid_error_code = "";
|
|
pub const cast_truncated_data = "";
|
|
pub const negative_to_unsigned = "";
|
|
pub const integer_overflow = "";
|
|
pub const shl_overflow = "";
|
|
pub const shr_overflow = "";
|
|
pub const divide_by_zero = "";
|
|
pub const exact_division_remainder = "";
|
|
pub const integer_part_out_of_bounds = "";
|
|
pub const corrupt_switch = "";
|
|
pub const shift_rhs_too_big = "";
|
|
pub const invalid_enum_value = "";
|
|
pub const for_len_mismatch = "";
|
|
pub const memcpy_len_mismatch = "";
|
|
pub const memcpy_alias = "";
|
|
pub const noreturn_returned = "";
|
|
};
|