Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ci/azure/pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
vmImage: 'windows-2019'
variables:
TARGET: 'x86_64-windows-gnu'
ZIG_LLVM_CLANG_LLD_NAME: 'zig+llvm+lld+clang-${{ variables.TARGET }}-0.10.0-dev.61+9be8396b7'
ZIG_LLVM_CLANG_LLD_NAME: 'zig+llvm+lld+clang-${{ variables.TARGET }}-0.10.0-dev.4138+3f5ee6f03'
ZIG_LLVM_CLANG_LLD_URL: 'https://ziglang.org/deps/${{ variables.ZIG_LLVM_CLANG_LLD_NAME }}.zip'
steps:
- pwsh: |
Expand Down
2 changes: 1 addition & 1 deletion lib/c.zig
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ comptime {

// Avoid dragging in the runtime safety mechanisms into this .o file,
// unless we're trying to test this file.
pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace) noreturn {
pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
@setCold(true);
_ = error_return_trace;
if (builtin.is_test) {
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler_rt/common.zig
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub const want_sparc_abi = builtin.cpu.arch.isSPARC();

// Avoid dragging in the runtime safety mechanisms into this .o file,
// unless we're trying to test compiler-rt.
pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace) noreturn {
pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
_ = error_return_trace;
if (builtin.is_test) {
@setCold(true);
Expand Down
2 changes: 1 addition & 1 deletion lib/ssp.zig
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extern fn memcpy(noalias dest: ?[*]u8, noalias src: ?[*]const u8, n: usize) call
extern fn memmove(dest: ?[*]u8, src: ?[*]const u8, n: usize) callconv(.C) ?[*]u8;

// Avoid dragging in the runtime safety mechanisms into this .o file.
pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace) noreturn {
pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
_ = msg;
_ = error_return_trace;
@setCold(true);
Expand Down
12 changes: 6 additions & 6 deletions lib/std/builtin.zig
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ const testFnProto = switch (builtin.zig_backend) {

/// This function type is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const PanicFn = fn ([]const u8, ?*StackTrace) noreturn;
pub const PanicFn = fn ([]const u8, ?*StackTrace, ?usize) noreturn;

/// This function is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
Expand All @@ -761,7 +761,7 @@ else

/// This function is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace) noreturn {
pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace, ret_addr: ?usize) noreturn {
@setCold(true);

// Until self-hosted catches up with stage1 language features, we have a simpler
Expand Down Expand Up @@ -839,7 +839,7 @@ pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace) noreturn
std.os.abort();
},
else => {
const first_trace_addr = @returnAddress();
const first_trace_addr = ret_addr orelse @returnAddress();
std.debug.panicImpl(error_return_trace, first_trace_addr, msg);
},
}
Expand All @@ -853,17 +853,17 @@ pub fn checkNonScalarSentinel(expected: anytype, actual: @TypeOf(expected)) void

pub fn panicSentinelMismatch(expected: anytype, actual: @TypeOf(expected)) noreturn {
@setCold(true);
std.debug.panic("sentinel mismatch: expected {any}, found {any}", .{ expected, actual });
std.debug.panicExtra(null, @returnAddress(), "sentinel mismatch: expected {any}, found {any}", .{ expected, actual });
}

pub fn panicUnwrapError(st: ?*StackTrace, err: anyerror) noreturn {
@setCold(true);
std.debug.panicExtra(st, "attempt to unwrap error: {s}", .{@errorName(err)});
std.debug.panicExtra(st, @returnAddress(), "attempt to unwrap error: {s}", .{@errorName(err)});
}

pub fn panicOutOfBounds(index: usize, len: usize) noreturn {
@setCold(true);
std.debug.panic("index out of bounds: index {d}, len {d}", .{ index, len });
std.debug.panicExtra(null, @returnAddress(), "index out of bounds: index {d}, len {d}", .{ index, len });
}

pub noinline fn returnError(st: *StackTrace) void {
Expand Down
5 changes: 3 additions & 2 deletions lib/std/debug.zig
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,14 @@ pub fn assert(ok: bool) void {
pub fn panic(comptime format: []const u8, args: anytype) noreturn {
@setCold(true);

panicExtra(null, format, args);
panicExtra(null, null, format, args);
}

/// `panicExtra` is useful when you want to print out an `@errorReturnTrace`
/// and also print out some values.
pub fn panicExtra(
trace: ?*std.builtin.StackTrace,
ret_addr: ?usize,
comptime format: []const u8,
args: anytype,
) noreturn {
Expand All @@ -308,7 +309,7 @@ pub fn panicExtra(
break :blk &buf;
},
};
std.builtin.panic(msg, trace);
std.builtin.panic(msg, trace, ret_addr);
}

/// Non-zero whenever the program triggered a panic.
Expand Down
29 changes: 0 additions & 29 deletions src/AstGen.zig
Original file line number Diff line number Diff line change
Expand Up @@ -884,33 +884,6 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: Ast.Node.Index) InnerEr
catch_token + 2
else
null;

var rhs = node_datas[node].rhs;
while (true) switch (node_tags[rhs]) {
.grouped_expression => rhs = node_datas[rhs].lhs,
.unreachable_literal => {
if (payload_token != null and mem.eql(u8, tree.tokenSlice(payload_token.?), "_")) {
return astgen.failTok(payload_token.?, "discard of error capture; omit it instead", .{});
} else if (payload_token != null) {
return astgen.failTok(payload_token.?, "unused capture", .{});
}
const lhs = node_datas[node].lhs;

const operand = try reachableExpr(gz, scope, switch (rl) {
.ref => .ref,
else => .none,
}, lhs, lhs);
const result = try gz.addUnNode(switch (rl) {
.ref => .err_union_payload_safe_ptr,
else => .err_union_payload_safe,
}, operand, node);
switch (rl) {
.none, .coerced_ty, .discard, .ref => return result,
else => return rvalue(gz, rl, result, lhs),
}
},
else => break,
};
switch (rl) {
.ref => return orelseCatchExpr(
gz,
Expand Down Expand Up @@ -2375,9 +2348,7 @@ fn addEnsureResult(gz: *GenZir, maybe_unused_result: Zir.Inst.Ref, statement: As
.optional_payload_unsafe,
.optional_payload_safe_ptr,
.optional_payload_unsafe_ptr,
.err_union_payload_safe,
.err_union_payload_unsafe,
.err_union_payload_safe_ptr,
.err_union_payload_unsafe_ptr,
.err_union_code,
.err_union_code_ptr,
Expand Down
Loading