Skip to content

Commit 90c2a62

Browse files
committed
Rollup merge of rust-lang#45714 - sdroege:thread-panic-docs, r=dtolnay
Update the std::thread docs and clarify that panics can nowadays be caught
2 parents d40ee40 + b86bba5 commit 90c2a62

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/libstd/thread/mod.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,15 @@
2525
//!
2626
//! Fatal logic errors in Rust cause *thread panic*, during which
2727
//! a thread will unwind the stack, running destructors and freeing
28-
//! owned resources. Thread panic is unrecoverable from within
29-
//! the panicking thread (i.e. there is no 'try/catch' in Rust), but
30-
//! the panic may optionally be detected from a different thread. If
31-
//! the main thread panics, the application will exit with a non-zero
32-
//! exit code.
28+
//! owned resources. While not meant as a 'try/catch' mechanism, panics
29+
//! in Rust can nonetheless be caught (unless compiling with `panic=abort`) with
30+
//! [`catch_unwind`](../../std/panic/fn.catch_unwind.html) and recovered
31+
//! from, or alternatively be resumed with
32+
//! [`resume_unwind`](../../std/panic/fn.resume_unwind.html). If the panic
33+
//! is not caught the thread will exit, but the panic may optionally be
34+
//! detected from a different thread with [`join`]. If the main thread panics
35+
//! without the panic being caught, the application will exit with a
36+
//! non-zero exit code.
3337
//!
3438
//! When the main thread of a Rust program terminates, the entire program shuts
3539
//! down, even if other threads are still running. However, this module provides

0 commit comments

Comments
 (0)