Skip to content

Commit 0a2fe66

Browse files
authored
Merge pull request rust-lang#1157 from cchiw/issue-77443-fix
Documentation PR for cfg_panic
2 parents 8e462e9 + 267f815 commit 0a2fe66

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/conditional-compilation.md

+16
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,15 @@ production. For example, it controls the behavior of the standard library's
208208
Set when the crate being compiled is being compiled with the `proc_macro`
209209
[crate type].
210210

211+
### `panic`
212+
213+
Key-value option set depending on the panic strategy. Note that more values may be added in the future.
214+
215+
Example values:
216+
217+
* `"abort"`
218+
* `"unwind"`
219+
211220
## Forms of conditional compilation
212221

213222
### The `cfg` attribute
@@ -253,6 +262,13 @@ fn on_32bit_unix() {
253262
fn needs_not_foo() {
254263
// ...
255264
}
265+
266+
// This function is only included when the panic strategy is set to unwind
267+
#[cfg(panic = "unwind")]
268+
fn when_unwinding() {
269+
// ...
270+
}
271+
256272
```
257273

258274
The `cfg` attribute is allowed anywhere attributes are allowed.

0 commit comments

Comments
 (0)