Skip to content

Commit a7ea5db

Browse files
committed
Update panic_handler to use the attribute template
1 parent 5005272 commit a7ea5db

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/panic.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ r[panic.panic_handler]
2020
## The `panic_handler` attribute
2121

2222
r[panic.panic_handler.intro]
23-
The *`panic_handler` attribute* can be applied to a function to define the behavior of panics.
23+
The *`panic_handler` [attribute][attributes]* can be applied to a function to define the behavior of panics.
2424

2525
> [!EXAMPLE]
2626
> Below is shown a `panic_handler` function that logs the panic message and then halts the thread.
@@ -58,8 +58,17 @@ The *`panic_handler` attribute* can be applied to a function to define the behav
5858
> [!NOTE]
5959
> The [`PanicInfo`] struct contains information about the location of the panic.
6060
61+
r[panic.panic_handler.syntax]
62+
The `panic_handler` attribute uses the [MetaWord] syntax and thus does not take any inputs.
63+
6164
r[panic.panic_handler.allowed-positions]
62-
The `panic_handler` attribute can only be applied to a function with signature `fn(&PanicInfo) -> !`.
65+
The `panic_handler` attribute may only be applied to a function with signature `fn(&PanicInfo) -> !`.
66+
67+
r[panic.panic_handler.duplicates]
68+
Duplicate instances of the `panic_handler` attribute on a function are ignored.
69+
70+
> [!NOTE]
71+
> `rustc` currently warns about unused duplicate `panic_handler` attributes.
6372
6473
r[panic.panic_handler.unique]
6574
There must be a single `panic_handler` function in the dependency graph.

0 commit comments

Comments
 (0)