From 231783f2078bca02a8b861f2d750a61db0c4d581 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 25 Sep 2024 20:17:21 -0700 Subject: [PATCH] update test cases to new panic API --- .../compile_errors/panic_has_source_location.zig | 7 +++++-- test/cases/safety/@alignCast misaligned.zig | 4 ++-- .../safety/@enumFromInt - no matching tag value.zig | 4 ++-- .../@errorCast error not present in destination.zig | 4 ++-- ...errorCast error union casted to disjoint set.zig | 4 ++-- test/cases/safety/@intCast to u0.zig | 4 ++-- ...FromFloat cannot fit - negative out of range.zig | 4 ++-- ...tFromFloat cannot fit - negative to unsigned.zig | 4 ++-- ...FromFloat cannot fit - positive out of range.zig | 4 ++-- ...ss zero to non-optional byte-aligned pointer.zig | 4 ++-- ...FromInt address zero to non-optional pointer.zig | 4 ++-- .../safety/@ptrFromInt with misaligned address.zig | 4 ++-- .../safety/@tagName on corrupted enum value.zig | 4 ++-- .../safety/@tagName on corrupted union value.zig | 4 ++-- .../safety/array slice sentinel mismatch vector.zig | 4 ++-- test/cases/safety/array slice sentinel mismatch.zig | 11 ++++++++--- test/cases/safety/bad union field access.zig | 13 ++++++++++--- test/cases/safety/calling panic.zig | 11 ++++++++--- .../cast []u8 to bigger slice of wrong size.zig | 4 ++-- ... integer to global error and no code matches.zig | 4 ++-- .../empty slice with sentinel out of bounds.zig | 11 ++++++++--- .../safety/exact division failure - vectors.zig | 4 ++-- test/cases/safety/exact division failure.zig | 4 ++-- test/cases/safety/for_len_mismatch.zig | 4 ++-- test/cases/safety/for_len_mismatch_three.zig | 4 ++-- .../safety/ignored expression integer overflow.zig | 4 ++-- test/cases/safety/integer addition overflow.zig | 4 ++-- .../safety/integer division by zero - vectors.zig | 4 ++-- test/cases/safety/integer division by zero.zig | 4 ++-- .../safety/integer multiplication overflow.zig | 4 ++-- test/cases/safety/integer negation overflow.zig | 4 ++-- test/cases/safety/integer subtraction overflow.zig | 4 ++-- test/cases/safety/memcpy_alias.zig | 4 ++-- test/cases/safety/memcpy_len_mismatch.zig | 4 ++-- test/cases/safety/memset_array_undefined_bytes.zig | 4 ++-- test/cases/safety/memset_array_undefined_large.zig | 4 ++-- test/cases/safety/memset_slice_undefined_bytes.zig | 4 ++-- test/cases/safety/memset_slice_undefined_large.zig | 4 ++-- test/cases/safety/modrem by zero.zig | 4 ++-- test/cases/safety/modulus by zero.zig | 4 ++-- test/cases/safety/noreturn returned.zig | 4 ++-- .../optional unwrap operator on C pointer.zig | 4 ++-- .../optional unwrap operator on null pointer.zig | 4 ++-- .../safety/out of bounds array slice by length.zig | 11 ++++++++--- test/cases/safety/out of bounds slice access.zig | 11 ++++++++--- ...pointer casting null to non-optional pointer.zig | 4 ++-- .../pointer casting to null function pointer.zig | 4 ++-- .../safety/pointer slice sentinel mismatch.zig | 11 ++++++++--- test/cases/safety/remainder division by zero.zig | 4 ++-- test/cases/safety/shift left by huge amount.zig | 4 ++-- test/cases/safety/shift right by huge amount.zig | 4 ++-- .../signed integer division overflow - vectors.zig | 4 ++-- .../safety/signed integer division overflow.zig | 4 ++-- ...tting in cast to unsigned integer - widening.zig | 4 ++-- ...eger not fitting in cast to unsigned integer.zig | 4 ++-- test/cases/safety/signed shift left overflow.zig | 4 ++-- test/cases/safety/signed shift right overflow.zig | 4 ++-- test/cases/safety/signed-unsigned vector cast.zig | 4 ++-- .../safety/slice sentinel mismatch - floats.zig | 4 ++-- .../slice sentinel mismatch - optional pointers.zig | 4 ++-- test/cases/safety/slice slice sentinel mismatch.zig | 11 ++++++++--- .../slice start index greater than end index.zig | 11 ++++++++--- ...ce with sentinel out of bounds - runtime len.zig | 11 ++++++++--- .../safety/slice with sentinel out of bounds.zig | 11 ++++++++--- .../safety/slicing null C pointer - runtime len.zig | 4 ++-- test/cases/safety/slicing null C pointer.zig | 4 ++-- ...witch else on corrupt enum value - one prong.zig | 4 ++-- .../switch else on corrupt enum value - union.zig | 4 ++-- .../safety/switch else on corrupt enum value.zig | 4 ++-- .../cases/safety/switch on corrupted enum value.zig | 4 ++-- .../safety/switch on corrupted union value.zig | 4 ++-- test/cases/safety/truncating vector cast.zig | 4 ++-- test/cases/safety/unreachable.zig | 5 ++--- ...g in cast to signed integer - same bit count.zig | 4 ++-- test/cases/safety/unsigned shift left overflow.zig | 4 ++-- test/cases/safety/unsigned shift right overflow.zig | 4 ++-- test/cases/safety/unsigned-signed vector cast.zig | 4 ++-- test/cases/safety/unwrap error switch.zig | 11 ++++++++--- test/cases/safety/unwrap error.zig | 11 ++++++++--- .../value does not fit in shortening cast - u0.zig | 4 ++-- .../value does not fit in shortening cast.zig | 4 ++-- .../safety/vector integer addition overflow.zig | 4 ++-- .../vector integer multiplication overflow.zig | 4 ++-- .../safety/vector integer negation overflow.zig | 4 ++-- .../safety/vector integer subtraction overflow.zig | 4 ++-- test/cases/safety/zero casted to error.zig | 4 ++-- 86 files changed, 255 insertions(+), 186 deletions(-) diff --git a/test/cases/compile_errors/panic_has_source_location.zig b/test/cases/compile_errors/panic_has_source_location.zig index 6e9d16d76d..c29f126c9f 100644 --- a/test/cases/compile_errors/panic_has_source_location.zig +++ b/test/cases/compile_errors/panic_has_source_location.zig @@ -6,7 +6,10 @@ export fn foo() void { @panic("oh no"); } -pub fn panic(_: []const u8, _: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, ert: ?*std.builtin.StackTrace, ra: ?usize) noreturn { + _ = cause; + _ = ert; + _ = ra; @compileError("panic"); } @@ -14,4 +17,4 @@ pub fn panic(_: []const u8, _: ?*std.builtin.StackTrace, _: ?usize) noreturn { // backend=stage2 // target=native // -// :10:5: error: panic +// :13:5: error: panic diff --git a/test/cases/safety/@alignCast misaligned.zig b/test/cases/safety/@alignCast misaligned.zig index ade27c2747..b514810730 100644 --- a/test/cases/safety/@alignCast misaligned.zig +++ b/test/cases/safety/@alignCast misaligned.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "incorrect alignment")) { + if (cause == .incorrect_alignment) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/@enumFromInt - no matching tag value.zig b/test/cases/safety/@enumFromInt - no matching tag value.zig index 5051869cc0..10f5267702 100644 --- a/test/cases/safety/@enumFromInt - no matching tag value.zig +++ b/test/cases/safety/@enumFromInt - no matching tag value.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "invalid enum value")) { + if (cause == .invalid_enum_value) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/@errorCast error not present in destination.zig b/test/cases/safety/@errorCast error not present in destination.zig index ff86e1f783..73b87ad20e 100644 --- a/test/cases/safety/@errorCast error not present in destination.zig +++ b/test/cases/safety/@errorCast error not present in destination.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "invalid error code")) { + if (cause == .invalid_error_code) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/@errorCast error union casted to disjoint set.zig b/test/cases/safety/@errorCast error union casted to disjoint set.zig index c9da2fc636..bdb2d80760 100644 --- a/test/cases/safety/@errorCast error union casted to disjoint set.zig +++ b/test/cases/safety/@errorCast error union casted to disjoint set.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "invalid error code")) { + if (cause == .invalid_error_code) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/@intCast to u0.zig b/test/cases/safety/@intCast to u0.zig index a33da87f0f..daf5069e61 100644 --- a/test/cases/safety/@intCast to u0.zig +++ b/test/cases/safety/@intCast to u0.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "integer cast truncated bits")) { + if (cause == .cast_truncated_data) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/@intFromFloat cannot fit - negative out of range.zig b/test/cases/safety/@intFromFloat cannot fit - negative out of range.zig index a5a8d831b3..d029f90343 100644 --- a/test/cases/safety/@intFromFloat cannot fit - negative out of range.zig +++ b/test/cases/safety/@intFromFloat cannot fit - negative out of range.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "integer part of floating point value out of bounds")) { + if (cause == .integer_part_out_of_bounds) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/@intFromFloat cannot fit - negative to unsigned.zig b/test/cases/safety/@intFromFloat cannot fit - negative to unsigned.zig index 1bf1a66765..ea2365ea6d 100644 --- a/test/cases/safety/@intFromFloat cannot fit - negative to unsigned.zig +++ b/test/cases/safety/@intFromFloat cannot fit - negative to unsigned.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "integer part of floating point value out of bounds")) { + if (cause == .integer_part_out_of_bounds) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/@intFromFloat cannot fit - positive out of range.zig b/test/cases/safety/@intFromFloat cannot fit - positive out of range.zig index 15a9fa7ad1..1bdc23982a 100644 --- a/test/cases/safety/@intFromFloat cannot fit - positive out of range.zig +++ b/test/cases/safety/@intFromFloat cannot fit - positive out of range.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "integer part of floating point value out of bounds")) { + if (cause == .integer_part_out_of_bounds) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/@ptrFromInt address zero to non-optional byte-aligned pointer.zig b/test/cases/safety/@ptrFromInt address zero to non-optional byte-aligned pointer.zig index f8c448855e..2788a31fd9 100644 --- a/test/cases/safety/@ptrFromInt address zero to non-optional byte-aligned pointer.zig +++ b/test/cases/safety/@ptrFromInt address zero to non-optional byte-aligned pointer.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "cast causes pointer to be null")) { + if (cause == .cast_to_null) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/@ptrFromInt address zero to non-optional pointer.zig b/test/cases/safety/@ptrFromInt address zero to non-optional pointer.zig index c9ae253df7..81e4500115 100644 --- a/test/cases/safety/@ptrFromInt address zero to non-optional pointer.zig +++ b/test/cases/safety/@ptrFromInt address zero to non-optional pointer.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "cast causes pointer to be null")) { + if (cause == .cast_to_null) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/@ptrFromInt with misaligned address.zig b/test/cases/safety/@ptrFromInt with misaligned address.zig index 3952ab9baa..2c291f9ad3 100644 --- a/test/cases/safety/@ptrFromInt with misaligned address.zig +++ b/test/cases/safety/@ptrFromInt with misaligned address.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "incorrect alignment")) { + if (cause == .incorrect_alignment) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/@tagName on corrupted enum value.zig b/test/cases/safety/@tagName on corrupted enum value.zig index e23cd1fcf6..a89dc72a97 100644 --- a/test/cases/safety/@tagName on corrupted enum value.zig +++ b/test/cases/safety/@tagName on corrupted enum value.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "invalid enum value")) { + if (cause == .invalid_enum_value) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/@tagName on corrupted union value.zig b/test/cases/safety/@tagName on corrupted union value.zig index 09d8276d23..799a9c6a17 100644 --- a/test/cases/safety/@tagName on corrupted union value.zig +++ b/test/cases/safety/@tagName on corrupted union value.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "invalid enum value")) { + if (cause == .invalid_enum_value) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/array slice sentinel mismatch vector.zig b/test/cases/safety/array slice sentinel mismatch vector.zig index da20d98869..aea05a6b41 100644 --- a/test/cases/safety/array slice sentinel mismatch vector.zig +++ b/test/cases/safety/array slice sentinel mismatch vector.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "sentinel mismatch: expected { 0, 0 }, found { 4, 4 }")) { + if (cause == .sentinel_mismatch_other) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/array slice sentinel mismatch.zig b/test/cases/safety/array slice sentinel mismatch.zig index fc19618673..2e9bcf9366 100644 --- a/test/cases/safety/array slice sentinel mismatch.zig +++ b/test/cases/safety/array slice sentinel mismatch.zig @@ -1,9 +1,14 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "sentinel mismatch: expected 0, found 4")) { - std.process.exit(0); + switch (cause) { + .sentinel_mismatch_usize => |info| { + if (info.expected == 0 and info.found == 4) { + std.process.exit(0); + } + }, + else => {}, } std.process.exit(1); } diff --git a/test/cases/safety/bad union field access.zig b/test/cases/safety/bad union field access.zig index c6706d4176..d73897f0f3 100644 --- a/test/cases/safety/bad union field access.zig +++ b/test/cases/safety/bad union field access.zig @@ -1,9 +1,16 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "access of union field 'float' while field 'int' is active")) { - std.process.exit(0); + switch (cause) { + .inactive_union_field => |info| { + if (std.mem.eql(u8, info.active, "int") and + std.mem.eql(u8, info.accessed, "float")) + { + std.process.exit(0); + } + }, + else => {}, } std.process.exit(1); } diff --git a/test/cases/safety/calling panic.zig b/test/cases/safety/calling panic.zig index 832bc5f19a..d77f0dd911 100644 --- a/test/cases/safety/calling panic.zig +++ b/test/cases/safety/calling panic.zig @@ -1,9 +1,14 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "oh no")) { - std.process.exit(0); + switch (cause) { + .explicit_call => |message| { + if (std.mem.eql(u8, message, "oh no")) { + std.process.exit(0); + } + }, + else => {}, } std.process.exit(1); } diff --git a/test/cases/safety/cast []u8 to bigger slice of wrong size.zig b/test/cases/safety/cast []u8 to bigger slice of wrong size.zig index a72b2fcca2..50dac0411c 100644 --- a/test/cases/safety/cast []u8 to bigger slice of wrong size.zig +++ b/test/cases/safety/cast []u8 to bigger slice of wrong size.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "exact division produced remainder")) { + if (cause == .exact_division_remainder) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/cast integer to global error and no code matches.zig b/test/cases/safety/cast integer to global error and no code matches.zig index 61daf07a2b..f6c5410a7b 100644 --- a/test/cases/safety/cast integer to global error and no code matches.zig +++ b/test/cases/safety/cast integer to global error and no code matches.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "invalid error code")) { + if (cause == .invalid_error_code) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/empty slice with sentinel out of bounds.zig b/test/cases/safety/empty slice with sentinel out of bounds.zig index 69201fde30..2c0a4ebb40 100644 --- a/test/cases/safety/empty slice with sentinel out of bounds.zig +++ b/test/cases/safety/empty slice with sentinel out of bounds.zig @@ -1,9 +1,14 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "index out of bounds: index 1, len 0")) { - std.process.exit(0); + switch (cause) { + .index_out_of_bounds => |info| { + if (info.index == 1 and info.len == 0) { + std.process.exit(0); + } + }, + else => {}, } std.process.exit(1); } diff --git a/test/cases/safety/exact division failure - vectors.zig b/test/cases/safety/exact division failure - vectors.zig index c5df2b276f..8d65d833e1 100644 --- a/test/cases/safety/exact division failure - vectors.zig +++ b/test/cases/safety/exact division failure - vectors.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "exact division produced remainder")) { + if (cause == .exact_division_remainder) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/exact division failure.zig b/test/cases/safety/exact division failure.zig index cdf1b1fb8d..8fa31d6ee0 100644 --- a/test/cases/safety/exact division failure.zig +++ b/test/cases/safety/exact division failure.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "exact division produced remainder")) { + if (cause == .exact_division_remainder) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/for_len_mismatch.zig b/test/cases/safety/for_len_mismatch.zig index ee21b947d7..37a0761ee9 100644 --- a/test/cases/safety/for_len_mismatch.zig +++ b/test/cases/safety/for_len_mismatch.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "for loop over objects with non-equal lengths")) { + if (cause == .for_len_mismatch) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/for_len_mismatch_three.zig b/test/cases/safety/for_len_mismatch_three.zig index 70f854def5..3f1f1ac230 100644 --- a/test/cases/safety/for_len_mismatch_three.zig +++ b/test/cases/safety/for_len_mismatch_three.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "for loop over objects with non-equal lengths")) { + if (cause == .for_len_mismatch) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/ignored expression integer overflow.zig b/test/cases/safety/ignored expression integer overflow.zig index f8e3f0bf0a..1ddb3588bc 100644 --- a/test/cases/safety/ignored expression integer overflow.zig +++ b/test/cases/safety/ignored expression integer overflow.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "integer overflow")) { + if (cause == .integer_overflow) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/integer addition overflow.zig b/test/cases/safety/integer addition overflow.zig index 4f7c5b2cb3..8aea6c7616 100644 --- a/test/cases/safety/integer addition overflow.zig +++ b/test/cases/safety/integer addition overflow.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "integer overflow")) { + if (cause == .integer_overflow) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/integer division by zero - vectors.zig b/test/cases/safety/integer division by zero - vectors.zig index 6e2af616b9..3ac58efd31 100644 --- a/test/cases/safety/integer division by zero - vectors.zig +++ b/test/cases/safety/integer division by zero - vectors.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "division by zero")) { + if (cause == .divide_by_zero) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/integer division by zero.zig b/test/cases/safety/integer division by zero.zig index 0d1b79d26d..7f14acc9a4 100644 --- a/test/cases/safety/integer division by zero.zig +++ b/test/cases/safety/integer division by zero.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "division by zero")) { + if (cause == .divide_by_zero) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/integer multiplication overflow.zig b/test/cases/safety/integer multiplication overflow.zig index 641801277d..d90d65ed86 100644 --- a/test/cases/safety/integer multiplication overflow.zig +++ b/test/cases/safety/integer multiplication overflow.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "integer overflow")) { + if (cause == .integer_overflow) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/integer negation overflow.zig b/test/cases/safety/integer negation overflow.zig index 3d4c134c4a..9a569b5338 100644 --- a/test/cases/safety/integer negation overflow.zig +++ b/test/cases/safety/integer negation overflow.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "integer overflow")) { + if (cause == .integer_overflow) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/integer subtraction overflow.zig b/test/cases/safety/integer subtraction overflow.zig index 84a16f55b8..a6591dd9ec 100644 --- a/test/cases/safety/integer subtraction overflow.zig +++ b/test/cases/safety/integer subtraction overflow.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "integer overflow")) { + if (cause == .integer_overflow) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/memcpy_alias.zig b/test/cases/safety/memcpy_alias.zig index d87a7bf6aa..191a37f8eb 100644 --- a/test/cases/safety/memcpy_alias.zig +++ b/test/cases/safety/memcpy_alias.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "@memcpy arguments alias")) { + if (cause == .memcpy_alias) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/memcpy_len_mismatch.zig b/test/cases/safety/memcpy_len_mismatch.zig index 6ca36abccb..aa5bb92732 100644 --- a/test/cases/safety/memcpy_len_mismatch.zig +++ b/test/cases/safety/memcpy_len_mismatch.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "@memcpy arguments have non-equal lengths")) { + if (cause == .memcpy_len_mismatch) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/memset_array_undefined_bytes.zig b/test/cases/safety/memset_array_undefined_bytes.zig index e0ce2dac04..c1c86df1aa 100644 --- a/test/cases/safety/memset_array_undefined_bytes.zig +++ b/test/cases/safety/memset_array_undefined_bytes.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "integer overflow")) { + if (cause == .integer_overflow) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/memset_array_undefined_large.zig b/test/cases/safety/memset_array_undefined_large.zig index dbc1cf4420..3cab2f4c5f 100644 --- a/test/cases/safety/memset_array_undefined_large.zig +++ b/test/cases/safety/memset_array_undefined_large.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "integer overflow")) { + if (cause == .integer_overflow) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/memset_slice_undefined_bytes.zig b/test/cases/safety/memset_slice_undefined_bytes.zig index 4214b5db4b..d6a7e3e5cd 100644 --- a/test/cases/safety/memset_slice_undefined_bytes.zig +++ b/test/cases/safety/memset_slice_undefined_bytes.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "integer overflow")) { + if (cause == .integer_overflow) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/memset_slice_undefined_large.zig b/test/cases/safety/memset_slice_undefined_large.zig index d1f4f651d3..a5e572eefd 100644 --- a/test/cases/safety/memset_slice_undefined_large.zig +++ b/test/cases/safety/memset_slice_undefined_large.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "integer overflow")) { + if (cause == .integer_overflow) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/modrem by zero.zig b/test/cases/safety/modrem by zero.zig index f201062c0e..16616f4801 100644 --- a/test/cases/safety/modrem by zero.zig +++ b/test/cases/safety/modrem by zero.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "division by zero")) { + if (cause == .divide_by_zero) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/modulus by zero.zig b/test/cases/safety/modulus by zero.zig index 6714458979..454b1cd432 100644 --- a/test/cases/safety/modulus by zero.zig +++ b/test/cases/safety/modulus by zero.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "division by zero")) { + if (cause == .divide_by_zero) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/noreturn returned.zig b/test/cases/safety/noreturn returned.zig index c3c30af37e..ac413089e7 100644 --- a/test/cases/safety/noreturn returned.zig +++ b/test/cases/safety/noreturn returned.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "'noreturn' function returned")) { + if (cause == .noreturn_returned) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/optional unwrap operator on C pointer.zig b/test/cases/safety/optional unwrap operator on C pointer.zig index bd3313265a..59ffe381a4 100644 --- a/test/cases/safety/optional unwrap operator on C pointer.zig +++ b/test/cases/safety/optional unwrap operator on C pointer.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "attempt to use null value")) { + if (cause == .unwrap_null) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/optional unwrap operator on null pointer.zig b/test/cases/safety/optional unwrap operator on null pointer.zig index 9dda4d0a9e..9b09d63f7b 100644 --- a/test/cases/safety/optional unwrap operator on null pointer.zig +++ b/test/cases/safety/optional unwrap operator on null pointer.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "attempt to use null value")) { + if (cause == .unwrap_null) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/out of bounds array slice by length.zig b/test/cases/safety/out of bounds array slice by length.zig index 62768abebf..9ad18972f8 100644 --- a/test/cases/safety/out of bounds array slice by length.zig +++ b/test/cases/safety/out of bounds array slice by length.zig @@ -1,9 +1,14 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "index out of bounds: index 16, len 5")) { - std.process.exit(0); + switch (cause) { + .index_out_of_bounds => |info| { + if (info.index == 16 and info.len == 5) { + std.process.exit(0); + } + }, + else => {}, } std.process.exit(1); } diff --git a/test/cases/safety/out of bounds slice access.zig b/test/cases/safety/out of bounds slice access.zig index b4c87948a5..7b7ac0f8fa 100644 --- a/test/cases/safety/out of bounds slice access.zig +++ b/test/cases/safety/out of bounds slice access.zig @@ -1,9 +1,14 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "index out of bounds: index 4, len 4")) { - std.process.exit(0); + switch (cause) { + .index_out_of_bounds => |info| { + if (info.index == 4 and info.len == 4) { + std.process.exit(0); + } + }, + else => {}, } std.process.exit(1); } diff --git a/test/cases/safety/pointer casting null to non-optional pointer.zig b/test/cases/safety/pointer casting null to non-optional pointer.zig index fdf8dc17ce..ad8921ae92 100644 --- a/test/cases/safety/pointer casting null to non-optional pointer.zig +++ b/test/cases/safety/pointer casting null to non-optional pointer.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "cast causes pointer to be null")) { + if (cause == .cast_to_null) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/pointer casting to null function pointer.zig b/test/cases/safety/pointer casting to null function pointer.zig index 8f399b66dc..364f66ab19 100644 --- a/test/cases/safety/pointer casting to null function pointer.zig +++ b/test/cases/safety/pointer casting to null function pointer.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "cast causes pointer to be null")) { + if (cause == .cast_to_null) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/pointer slice sentinel mismatch.zig b/test/cases/safety/pointer slice sentinel mismatch.zig index 3972528edf..7d79144fcf 100644 --- a/test/cases/safety/pointer slice sentinel mismatch.zig +++ b/test/cases/safety/pointer slice sentinel mismatch.zig @@ -1,9 +1,14 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "sentinel mismatch: expected 0, found 4")) { - std.process.exit(0); + switch (cause) { + .sentinel_mismatch_usize => |info| { + if (info.expected == 0 and info.found == 4) { + std.process.exit(0); + } + }, + else => {}, } std.process.exit(1); } diff --git a/test/cases/safety/remainder division by zero.zig b/test/cases/safety/remainder division by zero.zig index 3dc97f6e16..9fee0aa13a 100644 --- a/test/cases/safety/remainder division by zero.zig +++ b/test/cases/safety/remainder division by zero.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "division by zero")) { + if (cause == .divide_by_zero) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/shift left by huge amount.zig b/test/cases/safety/shift left by huge amount.zig index a038c0ee44..09425b2cc1 100644 --- a/test/cases/safety/shift left by huge amount.zig +++ b/test/cases/safety/shift left by huge amount.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "shift amount is greater than the type size")) { + if (cause == .shift_rhs_too_big) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/shift right by huge amount.zig b/test/cases/safety/shift right by huge amount.zig index ced81d948d..b02e2a01af 100644 --- a/test/cases/safety/shift right by huge amount.zig +++ b/test/cases/safety/shift right by huge amount.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "shift amount is greater than the type size")) { + if (cause == .shift_rhs_too_big) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/signed integer division overflow - vectors.zig b/test/cases/safety/signed integer division overflow - vectors.zig index 6346d9f1a1..0da140b8f2 100644 --- a/test/cases/safety/signed integer division overflow - vectors.zig +++ b/test/cases/safety/signed integer division overflow - vectors.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "integer overflow")) { + if (cause == .integer_overflow) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/signed integer division overflow.zig b/test/cases/safety/signed integer division overflow.zig index 9d1014ceec..576e3ef7aa 100644 --- a/test/cases/safety/signed integer division overflow.zig +++ b/test/cases/safety/signed integer division overflow.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "integer overflow")) { + if (cause == .integer_overflow) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/signed integer not fitting in cast to unsigned integer - widening.zig b/test/cases/safety/signed integer not fitting in cast to unsigned integer - widening.zig index 87c812eddc..762719df81 100644 --- a/test/cases/safety/signed integer not fitting in cast to unsigned integer - widening.zig +++ b/test/cases/safety/signed integer not fitting in cast to unsigned integer - widening.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "attempt to cast negative value to unsigned integer")) { + if (cause == .negative_to_unsigned) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/signed integer not fitting in cast to unsigned integer.zig b/test/cases/safety/signed integer not fitting in cast to unsigned integer.zig index 5d8c3f88c8..765a50d5a5 100644 --- a/test/cases/safety/signed integer not fitting in cast to unsigned integer.zig +++ b/test/cases/safety/signed integer not fitting in cast to unsigned integer.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "attempt to cast negative value to unsigned integer")) { + if (cause == .negative_to_unsigned) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/signed shift left overflow.zig b/test/cases/safety/signed shift left overflow.zig index f9a4db81ce..148d79ca4d 100644 --- a/test/cases/safety/signed shift left overflow.zig +++ b/test/cases/safety/signed shift left overflow.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "left shift overflowed bits")) { + if (cause == .shl_overflow) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/signed shift right overflow.zig b/test/cases/safety/signed shift right overflow.zig index 7d71b9ffbd..f89f57a132 100644 --- a/test/cases/safety/signed shift right overflow.zig +++ b/test/cases/safety/signed shift right overflow.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "right shift overflowed bits")) { + if (cause == .shr_overflow) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/signed-unsigned vector cast.zig b/test/cases/safety/signed-unsigned vector cast.zig index 2e3b4d25d5..2dee04d1bf 100644 --- a/test/cases/safety/signed-unsigned vector cast.zig +++ b/test/cases/safety/signed-unsigned vector cast.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "attempt to cast negative value to unsigned integer")) { + if (cause == .negative_to_unsigned) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/slice sentinel mismatch - floats.zig b/test/cases/safety/slice sentinel mismatch - floats.zig index 19b9b86c3b..71b32e0c8a 100644 --- a/test/cases/safety/slice sentinel mismatch - floats.zig +++ b/test/cases/safety/slice sentinel mismatch - floats.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "sentinel mismatch: expected 1.2e0, found 4e0")) { + if (cause == .sentinel_mismatch_other) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/slice sentinel mismatch - optional pointers.zig b/test/cases/safety/slice sentinel mismatch - optional pointers.zig index a3b4a98575..5e69a1d350 100644 --- a/test/cases/safety/slice sentinel mismatch - optional pointers.zig +++ b/test/cases/safety/slice sentinel mismatch - optional pointers.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "sentinel mismatch: expected null, found i32@10")) { + if (cause == .sentinel_mismatch_other) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/slice slice sentinel mismatch.zig b/test/cases/safety/slice slice sentinel mismatch.zig index 635706b2c5..7f90b9edbf 100644 --- a/test/cases/safety/slice slice sentinel mismatch.zig +++ b/test/cases/safety/slice slice sentinel mismatch.zig @@ -1,9 +1,14 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "sentinel mismatch: expected 0, found 4")) { - std.process.exit(0); + switch (cause) { + .sentinel_mismatch_usize => |info| { + if (info.expected == 0 and info.found == 4) { + std.process.exit(0); + } + }, + else => {}, } std.process.exit(1); } diff --git a/test/cases/safety/slice start index greater than end index.zig b/test/cases/safety/slice start index greater than end index.zig index 83d489ab56..5cdf1e46e9 100644 --- a/test/cases/safety/slice start index greater than end index.zig +++ b/test/cases/safety/slice start index greater than end index.zig @@ -1,9 +1,14 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "start index 10 is larger than end index 1")) { - std.process.exit(0); + switch (cause) { + .start_index_greater_than_end => |info| { + if (info.start == 10 and info.end == 1) { + std.process.exit(0); + } + }, + else => {}, } std.process.exit(1); } diff --git a/test/cases/safety/slice with sentinel out of bounds - runtime len.zig b/test/cases/safety/slice with sentinel out of bounds - runtime len.zig index abb3cc42f0..09d8fa32a5 100644 --- a/test/cases/safety/slice with sentinel out of bounds - runtime len.zig +++ b/test/cases/safety/slice with sentinel out of bounds - runtime len.zig @@ -1,9 +1,14 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "index out of bounds: index 5, len 4")) { - std.process.exit(0); + switch (cause) { + .index_out_of_bounds => |info| { + if (info.index == 5 and info.len == 4) { + std.process.exit(0); + } + }, + else => {}, } std.process.exit(1); } diff --git a/test/cases/safety/slice with sentinel out of bounds.zig b/test/cases/safety/slice with sentinel out of bounds.zig index 1683dc9d3f..1ec0698657 100644 --- a/test/cases/safety/slice with sentinel out of bounds.zig +++ b/test/cases/safety/slice with sentinel out of bounds.zig @@ -1,9 +1,14 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "index out of bounds: index 5, len 4")) { - std.process.exit(0); + switch (cause) { + .index_out_of_bounds => |info| { + if (info.index == 5 and info.len == 4) { + std.process.exit(0); + } + }, + else => {}, } std.process.exit(1); } diff --git a/test/cases/safety/slicing null C pointer - runtime len.zig b/test/cases/safety/slicing null C pointer - runtime len.zig index dd73a50112..d4ebbdff18 100644 --- a/test/cases/safety/slicing null C pointer - runtime len.zig +++ b/test/cases/safety/slicing null C pointer - runtime len.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "attempt to use null value")) { + if (cause == .unwrap_null) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/slicing null C pointer.zig b/test/cases/safety/slicing null C pointer.zig index 862f2dcfdb..b3e50b0ebf 100644 --- a/test/cases/safety/slicing null C pointer.zig +++ b/test/cases/safety/slicing null C pointer.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "attempt to use null value")) { + if (cause == .unwrap_null) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/switch else on corrupt enum value - one prong.zig b/test/cases/safety/switch else on corrupt enum value - one prong.zig index c11227c3be..bc8321a346 100644 --- a/test/cases/safety/switch else on corrupt enum value - one prong.zig +++ b/test/cases/safety/switch else on corrupt enum value - one prong.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "switch on corrupt value")) { + if (cause == .corrupt_switch) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/switch else on corrupt enum value - union.zig b/test/cases/safety/switch else on corrupt enum value - union.zig index a63c78597e..4f6e00c85a 100644 --- a/test/cases/safety/switch else on corrupt enum value - union.zig +++ b/test/cases/safety/switch else on corrupt enum value - union.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "switch on corrupt value")) { + if (cause == .corrupt_switch) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/switch else on corrupt enum value.zig b/test/cases/safety/switch else on corrupt enum value.zig index 7e050838c0..1d38217399 100644 --- a/test/cases/safety/switch else on corrupt enum value.zig +++ b/test/cases/safety/switch else on corrupt enum value.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "switch on corrupt value")) { + if (cause == .corrupt_switch) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/switch on corrupted enum value.zig b/test/cases/safety/switch on corrupted enum value.zig index f890761911..1591401808 100644 --- a/test/cases/safety/switch on corrupted enum value.zig +++ b/test/cases/safety/switch on corrupted enum value.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "switch on corrupt value")) { + if (cause == .corrupt_switch) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/switch on corrupted union value.zig b/test/cases/safety/switch on corrupted union value.zig index fc93c9d6e7..1ae72fcbfb 100644 --- a/test/cases/safety/switch on corrupted union value.zig +++ b/test/cases/safety/switch on corrupted union value.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "switch on corrupt value")) { + if (cause == .corrupt_switch) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/truncating vector cast.zig b/test/cases/safety/truncating vector cast.zig index ae76d4dec1..32fb407555 100644 --- a/test/cases/safety/truncating vector cast.zig +++ b/test/cases/safety/truncating vector cast.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "integer cast truncated bits")) { + if (cause == .cast_truncated_data) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/unreachable.zig b/test/cases/safety/unreachable.zig index 818d7e31a5..b12b1a722f 100644 --- a/test/cases/safety/unreachable.zig +++ b/test/cases/safety/unreachable.zig @@ -1,9 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, ret_addr: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - _ = ret_addr; - if (std.mem.eql(u8, message, "reached unreachable code")) { + if (cause == .reached_unreachable) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/unsigned integer not fitting in cast to signed integer - same bit count.zig b/test/cases/safety/unsigned integer not fitting in cast to signed integer - same bit count.zig index 9bd4c42007..937d522569 100644 --- a/test/cases/safety/unsigned integer not fitting in cast to signed integer - same bit count.zig +++ b/test/cases/safety/unsigned integer not fitting in cast to signed integer - same bit count.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "integer cast truncated bits")) { + if (cause == .cast_truncated_data) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/unsigned shift left overflow.zig b/test/cases/safety/unsigned shift left overflow.zig index d38d8f6ecf..53fe91c9fb 100644 --- a/test/cases/safety/unsigned shift left overflow.zig +++ b/test/cases/safety/unsigned shift left overflow.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "left shift overflowed bits")) { + if (cause == .shl_overflow) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/unsigned shift right overflow.zig b/test/cases/safety/unsigned shift right overflow.zig index 121797a17d..a5389797fc 100644 --- a/test/cases/safety/unsigned shift right overflow.zig +++ b/test/cases/safety/unsigned shift right overflow.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "right shift overflowed bits")) { + if (cause == .shr_overflow) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/unsigned-signed vector cast.zig b/test/cases/safety/unsigned-signed vector cast.zig index 32676f7c1c..aab2f5ae16 100644 --- a/test/cases/safety/unsigned-signed vector cast.zig +++ b/test/cases/safety/unsigned-signed vector cast.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "integer cast truncated bits")) { + if (cause == .cast_truncated_data) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/unwrap error switch.zig b/test/cases/safety/unwrap error switch.zig index 0723a9fb24..dd587c4865 100644 --- a/test/cases/safety/unwrap error switch.zig +++ b/test/cases/safety/unwrap error switch.zig @@ -1,9 +1,14 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "attempt to unwrap error: Whatever")) { - std.process.exit(0); + switch (cause) { + .unwrap_error => |err| { + if (err == error.Whatever) { + std.process.exit(0); + } + }, + else => {}, } std.process.exit(1); } diff --git a/test/cases/safety/unwrap error.zig b/test/cases/safety/unwrap error.zig index e2d7ea725b..a2ac8f5046 100644 --- a/test/cases/safety/unwrap error.zig +++ b/test/cases/safety/unwrap error.zig @@ -1,9 +1,14 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "attempt to unwrap error: Whatever")) { - std.process.exit(0); + switch (cause) { + .unwrap_error => |err| { + if (err == error.Whatever) { + std.process.exit(0); + } + }, + else => {}, } std.process.exit(1); } diff --git a/test/cases/safety/value does not fit in shortening cast - u0.zig b/test/cases/safety/value does not fit in shortening cast - u0.zig index ec111a2cae..d06d1cf440 100644 --- a/test/cases/safety/value does not fit in shortening cast - u0.zig +++ b/test/cases/safety/value does not fit in shortening cast - u0.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "integer cast truncated bits")) { + if (cause == .cast_truncated_data) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/value does not fit in shortening cast.zig b/test/cases/safety/value does not fit in shortening cast.zig index a5ea41659e..3f55f40f96 100644 --- a/test/cases/safety/value does not fit in shortening cast.zig +++ b/test/cases/safety/value does not fit in shortening cast.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "integer cast truncated bits")) { + if (cause == .cast_truncated_data) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/vector integer addition overflow.zig b/test/cases/safety/vector integer addition overflow.zig index 21c26eeb4e..3e3145db86 100644 --- a/test/cases/safety/vector integer addition overflow.zig +++ b/test/cases/safety/vector integer addition overflow.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "integer overflow")) { + if (cause == .integer_overflow) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/vector integer multiplication overflow.zig b/test/cases/safety/vector integer multiplication overflow.zig index 8678eccec6..eceb507efa 100644 --- a/test/cases/safety/vector integer multiplication overflow.zig +++ b/test/cases/safety/vector integer multiplication overflow.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "integer overflow")) { + if (cause == .integer_overflow) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/vector integer negation overflow.zig b/test/cases/safety/vector integer negation overflow.zig index 5f8becad17..5f408dab8b 100644 --- a/test/cases/safety/vector integer negation overflow.zig +++ b/test/cases/safety/vector integer negation overflow.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "integer overflow")) { + if (cause == .integer_overflow) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/vector integer subtraction overflow.zig b/test/cases/safety/vector integer subtraction overflow.zig index 82c0342121..c858ac5e34 100644 --- a/test/cases/safety/vector integer subtraction overflow.zig +++ b/test/cases/safety/vector integer subtraction overflow.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "integer overflow")) { + if (cause == .integer_overflow) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/zero casted to error.zig b/test/cases/safety/zero casted to error.zig index 78340db316..591e4b62ef 100644 --- a/test/cases/safety/zero casted to error.zig +++ b/test/cases/safety/zero casted to error.zig @@ -1,8 +1,8 @@ const std = @import("std"); -pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { +pub fn panic(cause: std.builtin.PanicCause, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "invalid error code")) { + if (cause == .invalid_error_code) { std.process.exit(0); } std.process.exit(1);