Skip to content

Commit 19e4f7b

Browse files
Kyle StrandBatmanAoD
Kyle Strand
authored andcommitted
PR revision
1 parent d0b5b1f commit 19e4f7b

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/panic.md

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
# Panic
22

3-
Rust provides the ability to "panic" upon encountering a runtime error that is
4-
not part of a function's signature; such an error is typically not expected to
5-
be recoverable within the context in which the error is encountered.
3+
Rust provides the ability to "panic" upon encountering an error that is not
4+
part of a function's signature; such an error is typically not expected to be
5+
recoverable within the context in which the error is encountered.
66

7-
> **Note**: The Standard Library provides this capability via the [`panic!` macro][macro-panic].
7+
Some language constructs, such as out-of-bounds [array indexing], panic
8+
automatically. There are also language features that provide a level of control
9+
over panic behavior:
10+
* A [_panic runtime_](#panic-runtimes) defined how a panic is handled during
11+
runtime.
12+
* [FFI ABIs](items/functions.md#unwinding) may alter how panics behave.
813

9-
Although it is not part of the core language, panics interact with several core
10-
language features; for instance, out-of-bounds array indexing using the
11-
`array[index]` syntax will automatically panic.
14+
> **Note**: The Standard Library provides the capability to explicitly panic
15+
> via the [`panic!` macro][macro-panic].
1216
1317
## Unwinding
1418

1519
Panicking may either be recoverable or non-recoverable, though its behavior
16-
must be homogenous throughout program execution. A recoverable panic "unwinds"
20+
must be uniform throughout program execution. A recoverable panic "unwinds"
1721
Rust frames, just as C++'s `throw` unwinds C++ frames. This means that as the
1822
panic traverses Rust frames, live objects in those frames that [implement
1923
`Drop`][destructors] will have their `drop` methods called. Thus, if panic
@@ -46,6 +50,7 @@ impossible, which can result in both code-size and runtime speed improvements.
4650

4751
See also ["The Rust runtime"][runtime].
4852

53+
[array-indexing]: expressions/array-expr.md#array-and-slice-indexing-expressions
4954
[destructors]: destructors.md
5055
[fn-catch-unwind]: ../std/panic/fn.catch_unwind.html
5156
[macro-panic]: ../std/macro.panic.html

0 commit comments

Comments
 (0)