Skip to content

Commit d17ef56

Browse files
committed
Update panic_handler.
- Address review comments. - Some minor formatting adjustments.
1 parent 1985db0 commit d17ef56

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
@@ -206,6 +206,7 @@ which can be used to control type layout.
206206
symbol for this item to its identifier.
207207
- [`used`] - on statics, this forces the compiler to keep the variable in the
208208
output object file.
209+
- [`panic_handler`] — sets the function to handle panics.
209210

210211
### Deprecation
211212

@@ -632,3 +633,4 @@ pub fn f() {}
632633
[Expression Attributes]: expressions.html#expression-attributes
633634
[`meta` macro fragment specifier]: macros-by-example.html
634635
[`used`]: abi.html#the-used-attribute
636+
[`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)