Skip to content

Commit f659a93

Browse files
committed
Update panic_handler.
- Address review comments. - Some minor formatting adjustments.
1 parent bd744e2 commit f659a93

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

src/attributes.md

+2
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ which can be used to control type layout.
204204
object file that this item's contents will be placed into.
205205
- `no_mangle` - on any item, do not apply the standard name mangling. Set the
206206
symbol for this item to its identifier.
207+
- [`panic_handler`] — sets the function to handle panics.
207208

208209
### Deprecation
209210

@@ -629,3 +630,4 @@ pub fn f() {}
629630
[trait or lifetime bounds]: trait-bounds.html
630631
[Expression Attributes]: expressions.html#expression-attributes
631632
[`meta` macro fragment specifier]: macros-by-example.html
633+
[`panic_handler`]: runtime.html#the-panic_handler-attribute

src/runtime.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
# The Rust runtime
22

3-
This section documents features that define some aspects of the Rust runtime. A list of such
4-
features is shown below:
3+
This section documents features that define some aspects of the Rust runtime.
54

6-
- `#[panic_handler]`, the panicking behavior
5+
## The `panic_handler` attribute
76

8-
## `#[panic_handler]`
9-
10-
The `panic_handler` attribute can only be applied to a function with signature
11-
`fn(&PanicInfo) -> !`. The function marked with this attribute defines the behavior of panics. The
7+
The *`panic_handler` attribute* can only be applied to a function with signature
8+
`fn(&PanicInfo) -> !`. The function marked with this [attribute] defines the behavior of panics. The
129
[`PanicInfo`] struct contains information about the location of the panic. There must be a single
1310
`panic_handler` function in the dependency graph of a binary, dylib or cdylib crate.
1411

15-
[`PanicInfo`]: https://doc.rust-lang.org/nightly/core/panic/struct.PanicInfo.html
16-
1712
Below is shown a `panic_handler` function that logs the panic message and then halts the
1813
thread.
1914

@@ -51,7 +46,12 @@ fn panic(info: &PanicInfo) -> ! {
5146

5247
### Standard behavior
5348

54-
The standard library provides an implementation of `panic_handler` than defaults
55-
to unwinding the stack but that can be [changed to abort the process][abort].
49+
The standard library provides an implementation of `panic_handler` that
50+
defaults to unwinding the stack but that can be [changed to abort the
51+
process][abort]. The standard library's panic behavior can be modified at
52+
runtime with the [set_hook] function.
5653

57-
[abort]: ../book/2018-edition/ch09-01-unrecoverable-errors-with-panic.html
54+
[`PanicInfo`]: ../core/panic/struct.PanicInfo.html
55+
[abort]: ../book/ch09-01-unrecoverable-errors-with-panic.html
56+
[attribute]: attributes.html
57+
[set_hook]: ../std/panic/fn.set_hook.html

0 commit comments

Comments
 (0)