Skip to content

Commit 218bca3

Browse files
committed
Update rules to be with headers
1 parent d8ad6a8 commit 218bca3

File tree

4 files changed

+8
-15
lines changed

4 files changed

+8
-15
lines changed

src/destructors.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,19 +426,18 @@ let x = (&temp()).use_temp(); // ERROR
426426
r[destructors.forget]
427427
## Not running destructors
428428

429+
r[destructors.manually-preventing]
429430
### Manually preventing destructors
430431

431-
r[destructors.manually-preventing]
432432
[`std::mem::forget`] can be used to prevent the destructor of a variable from being run,
433433
and [`std::mem::ManuallyDrop`] provides a wrapper to prevent a
434434
variable or field from being dropped automatically.
435435

436436
> Note: Preventing a destructor from being run via [`std::mem::forget`] or other means is safe even if it has a type that isn't `'static`.
437437
> Besides the places where destructors are guaranteed to run as defined by this document, types may *not* safely rely on a destructor being run for soundness.
438438
439-
### Process termination without unwinding
440-
441439
r[destructors.process-termination]
440+
### Process termination without unwinding
442441

443442
There are some ways to terminate the process without [unwinding], in which case
444443
destructors will not be run.

src/items/functions.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,8 @@ extern "C" fn new_i32() -> i32 { 0 }
253253
let fptr: extern "C" fn() -> i32 = new_i32;
254254
```
255255

256-
### Unwinding
257-
258256
r[items.fn.extern.unwind]
257+
### Unwinding
259258

260259
r[items.fn.extern.unwind.intro]
261260
Most ABI strings come in two variants, one with an `-unwind` suffix and one without.

src/linkage.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,8 @@ Passing `rlib`s directly into your foreign linker is currently unsupported.
275275
> Rust code compiled or linked with a different instance of the Rust runtime counts as a
276276
> "foreign code" for the purpose of this section.
277277
278-
### Prohibited linkage and unwinding
279-
280278
r[link.unwinding]
279+
### Prohibited linkage and unwinding
281280

282281
r[link.unwinding.consistency]
283282
If you are *not* using `rustc` to link Rust files, you must take care to ensure that unwinding is

src/panic.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
# Panic
2-
31
r[panic]
2+
# Panic
43

54
r[panic.intro]
65
Rust provides a mechanism to prevent a function from returning normally, and instead "panic," which is a response to an error condition that is typically not expected to be recoverable within the context in which the error is encountered.
@@ -17,9 +16,8 @@ There are also language features that provide a level of control over panic beha
1716
> [!NOTE]
1817
> The standard library provides the capability to explicitly panic via the [`panic!` macro][panic!].
1918
20-
## Unwinding
21-
2219
r[panic.unwind]
20+
## Unwinding
2321

2422
r[panic.unwind.intro]
2523
Panicking may either be recoverable or non-recoverable, though it can be configured (via `panic=abort`) to always be non-recoverable. (The converse is not true: `panic=unwind` does not guarantee that all panics are recoverable, only that panicking via the `panic!` macro and similar standard library mechanisms is recoverable.)
@@ -33,9 +31,8 @@ When panic recovery occurs, the runtime "unwinds" Rust frames, just as C++'s `th
3331
> [!NOTE]
3432
> The standard library provides two mechanisms for recovering from a panic, [`std::panic::catch_unwind`] (which enables recovery within the panicking thread) and [`std::thread::spawn`] (which automatically sets up panic recovery for the spawned thread so that other threads may continue running).
3533
36-
### Unwinding across FFI boundaries
37-
3834
r[panic.unwind.ffi]
35+
### Unwinding across FFI boundaries
3936

4037
r[panic.unwind.ffi.intro]
4138
It is possible to unwind across FFI boundaries using an [appropriate ABI declaration][unwind-abi]. While useful in certain cases, this creates unique opportunities for undefined behavior, especially when multiple language runtimes are involved.
@@ -58,9 +55,8 @@ Catching a foreign unwinding operation (such as a C++ exception) using [`std::pa
5855
r[panic.unwind.ffi.dispose-panic]
5956
There are currently no guarantees about the behavior that occurs when a foreign runtime attempts to dispose of, or rethrow, a Rust `panic` payload. In other words, an unwind originated from a Rust runtime must either lead to termination of the process or be caught by the same runtime.
6057

61-
## Panic runtimes
62-
6358
r[panic.runtime]
59+
## Panic runtimes
6460

6561
The actual behavior and implementation of `panic!` is controlled by the _panic runtime_.
6662

0 commit comments

Comments
 (0)