authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-09-25 13:24:47-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-09-26 12:35:14-07:00
log76f0b6e7d8dfa527f8776a4ffe61400fd84d871a
tree429048371c8ff50151ec3aca30df7b9d5d12ad22
parent9ccf8d3332dd9c1e4d967e3b8af2b98128d360ca

delete the old panic stuff again

now that we have a zig1.wasm update it's not needed

1 files changed, 2 insertions(+), 75 deletions(-)

lib/std/builtin.zig+2-75
......@@ -761,91 +761,18 @@ pub const TestFn = struct {
761761 func: *const fn () anyerror!void,
762762};
763763
764const old_version = std.SemanticVersion.parse("0.14.0-dev.1659+4ceefca14") catch unreachable;
765const is_old = @import("builtin").zig_version.order(old_version) != .gt;
766
767764/// This function type is used by the Zig language code generation and
768765/// therefore must be kept in sync with the compiler implementation.
769pub const PanicFn = if (is_old)
770 fn ([]const u8, ?*StackTrace, ?usize) noreturn
771else
772 fn (PanicCause, ?*StackTrace, ?usize) noreturn;
766pub const PanicFn = fn (PanicCause, ?*StackTrace, ?usize) noreturn;
773767
774768/// The entry point for auto-generated calls by the compiler.
775pub const panic: PanicFn = if (is_old)
776 defaultPanicOld
777else if (@hasDecl(root, "panic"))
769pub const panic: PanicFn = if (@hasDecl(root, "panic"))
778770 root.panic
779771else if (@hasDecl(root, "os") and @hasDecl(root.os, "panic"))
780772 root.os.panic
781773else
782774 std.debug.defaultPanic;
783775
784pub fn defaultPanicOld(
785 msg: []const u8,
786 trace: ?*const std.builtin.StackTrace,
787 first_trace_addr: ?usize,
788) noreturn {
789 @branchHint(.cold);
790 std.debug.print("old panic: {s}\n", .{msg});
791 _ = trace;
792 _ = first_trace_addr;
793 @trap();
794}
795
796pub fn panicSentinelMismatch(expected: anytype, actual: @TypeOf(expected)) noreturn {
797 @branchHint(.cold);
798 std.debug.panicExtra(null, @returnAddress(), "sentinel mismatch: expected {any}, found {any}", .{ expected, actual });
799}
800
801pub fn panicUnwrapError(st: ?*StackTrace, err: anyerror) noreturn {
802 @branchHint(.cold);
803 std.debug.panicExtra(st, @returnAddress(), "attempt to unwrap error: {s}", .{@errorName(err)});
804}
805
806pub fn panicOutOfBounds(index: usize, len: usize) noreturn {
807 @branchHint(.cold);
808 std.debug.panicExtra(null, @returnAddress(), "index out of bounds: index {d}, len {d}", .{ index, len });
809}
810
811pub fn panicStartGreaterThanEnd(start: usize, end: usize) noreturn {
812 @branchHint(.cold);
813 std.debug.panicExtra(null, @returnAddress(), "start index {d} is larger than end index {d}", .{ start, end });
814}
815
816pub fn panicInactiveUnionField(active: anytype, wanted: @TypeOf(active)) noreturn {
817 @branchHint(.cold);
818 std.debug.panicExtra(null, @returnAddress(), "access of union field '{s}' while field '{s}' is active", .{ @tagName(wanted), @tagName(active) });
819}
820
821pub const panic_messages = struct {
822 pub const unreach = "reached unreachable code";
823 pub const unwrap_null = "attempt to use null value";
824 pub const cast_to_null = "cast causes pointer to be null";
825 pub const incorrect_alignment = "incorrect alignment";
826 pub const invalid_error_code = "invalid error code";
827 pub const cast_truncated_data = "integer cast truncated bits";
828 pub const negative_to_unsigned = "attempt to cast negative value to unsigned integer";
829 pub const integer_overflow = "integer overflow";
830 pub const shl_overflow = "left shift overflowed bits";
831 pub const shr_overflow = "right shift overflowed bits";
832 pub const divide_by_zero = "division by zero";
833 pub const exact_division_remainder = "exact division produced remainder";
834 pub const inactive_union_field = "access of inactive union field";
835 pub const integer_part_out_of_bounds = "integer part of floating point value out of bounds";
836 pub const corrupt_switch = "switch on corrupt value";
837 pub const shift_rhs_too_big = "shift amount is greater than the type size";
838 pub const invalid_enum_value = "invalid enum value";
839 pub const sentinel_mismatch = "sentinel mismatch";
840 pub const unwrap_error = "attempt to unwrap error";
841 pub const index_out_of_bounds = "index out of bounds";
842 pub const start_index_greater_than_end = "start index is larger than end index";
843 pub const for_len_mismatch = "for loop over objects with non-equal lengths";
844 pub const memcpy_len_mismatch = "@memcpy arguments have non-equal lengths";
845 pub const memcpy_alias = "@memcpy arguments alias";
846 pub const noreturn_returned = "'noreturn' function returned";
847};
848
849776/// This data structure is used by the Zig language code generation and
850777/// therefore must be kept in sync with the compiler implementation.
851778pub const PanicCause = union(enum) {