aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-08-08 19:16:21 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-08-08 19:16:21 -0700
commit1a500b969943dc6a4c549fdcbd72659702e867a2 (patch)
treeb65d3f11b30e1c43f0a63636fe908929e83b0c27 /lib/std
parent50b36e84fab023ec418eb794d6a5b4510ac6b984 (diff)
downloadzig-1a500b969943dc6a4c549fdcbd72659702e867a2.tar.gz
zig-1a500b969943dc6a4c549fdcbd72659702e867a2.zip
Sema: avoid error return traces when possible
stage2 was adding bogus error return trace frames when an error was not being returned. This commit makes several improvements: * Make a runtime check if necessary to only emit a frame into the error return trace when an actual error is returned. * Use the `analyzeIsNonErrComptimeOnly` machinery to avoid runtime checks when it is compile-time-known that the value is an error, or a non-error. * Make std.builtin.returnError take a non-optional stack trace pointer. closes #12174
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/builtin.zig3
1 files changed, 1 insertions, 2 deletions
diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig
index 047c65439c..ef716c6972 100644
--- a/lib/std/builtin.zig
+++ b/lib/std/builtin.zig
@@ -867,10 +867,9 @@ pub fn panicOutOfBounds(index: usize, len: usize) noreturn {
std.debug.panic("attempt to index out of bound: index {d}, len {d}", .{ index, len });
}
-pub noinline fn returnError(maybe_st: ?*StackTrace) void {
+pub noinline fn returnError(st: *StackTrace) void {
@setCold(true);
@setRuntimeSafety(false);
- const st = maybe_st orelse return;
addErrRetTraceAddr(st, @returnAddress());
}