You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We specifically talk about `abort` and `unwind` already. Let's just go
ahead and up-front define that there are two, and not be so hand-wavey
about it.
In theory the standard library could introduce additional runtimes, and
it doesn't have a specific impact on the language per se. However, this
is a blurred line where I think it is better to be clear about what
there is. We can always revisit this later and adjust if things change.
Copy file name to clipboardExpand all lines: src/panic.md
+11-3
Original file line number
Diff line number
Diff line change
@@ -19,10 +19,18 @@ There are also language features that provide a level of control over panic beha
19
19
r[panic.runtime]
20
20
## Panic runtimes
21
21
22
+
r[panic.runtime.intro]
22
23
The actual behavior and implementation of a panic is controlled by the _panic runtime_. The panic runtime is a handler linked into the output which provides the necessary implementation for panicking.
23
24
24
-
> [!NOTE]
25
-
> The Rust standard library provides two panic runtimes: `panic_unwind` (which unwinds the stack and is potentially recoverable) and `panic_abort` (which aborts the process and is non-recoverable). The default runtime depends on the target platform, but is generally `panic_unwind` on platforms with native support for C++ exceptions.
25
+
r[panic.runtime.kinds]
26
+
The following panic runtimes are provided by the standard library:
27
+
28
+
*`unwind` --- unwinds the stack and is potentially recoverable.
29
+
*`abort` ---- aborts the process and is non-recoverable.
30
+
31
+
Not all targets may provide the `unwind` runtime.
32
+
33
+
The default runtime depends on the target platform, but is generally `unwind` on platforms with native support for C++ exceptions.
26
34
27
35
> [!NOTE]
28
36
> The panic runtime can be chosen in `rustc` with the [`-C panic`] CLI flag when building any crate type except an rlib.
@@ -39,7 +47,7 @@ The _panic strategy_ defines the kind of panic runtime that a crate is built to
39
47
> The panic strategy can be chosen in `rustc` with the [`-C panic`] CLI flag.
40
48
41
49
> [!NOTE]
42
-
> When compiling code with a non-recoverable panic strategy, the optimizer may assume that unwinding across Rust frames is impossible, which can result in both code-size and runtime speed improvements.
50
+
> When compiling code with the `abort` panic strategy, the optimizer may assume that unwinding across Rust frames is impossible, which can result in both code-size and runtime speed improvements.
43
51
44
52
r[panic.strategy.mixed]
45
53
When linking with the `unwind` runtime, all crates must be built with the `unwind` strategy.
0 commit comments