Skip to content

Commit 8d82263

Browse files
committed
Normatively define the abort and unwind runtimes
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.
1 parent 04222f9 commit 8d82263

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/panic.md

+11-3
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,18 @@ There are also language features that provide a level of control over panic beha
1919
r[panic.runtime]
2020
## Panic runtimes
2121

22+
r[panic.runtime.intro]
2223
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.
2324

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.
2634

2735
> [!NOTE]
2836
> 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
3947
> The panic strategy can be chosen in `rustc` with the [`-C panic`] CLI flag.
4048
4149
> [!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.
4351
4452
r[panic.strategy.mixed]
4553
When linking with the `unwind` runtime, all crates must be built with the `unwind` strategy.

0 commit comments

Comments
 (0)