Skip to content

Commit 49966fe

Browse files
authored
Rollup merge of rust-lang#153295 - biscuitrescue:fix-panicking-docs, r=tgross35
update panicking() docs for panic=abort fixes rust-lang#151458 The documentation for `std::thread::panicking()` has not been changed since v1.0, even though panic hooks were added in v1.10. Current documentation is misleading for `panic=abort` `panicking()` can return `true` in 2 different cases: 1. Thread unwinds due to panic 2. Panic hook is executing with `panic=abort` r? @SpriteOvO
2 parents b5f3ca1 + 014344b commit 49966fe

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

library/std/src/thread/functions.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,11 @@ pub fn yield_now() {
168168
imp::yield_now()
169169
}
170170

171-
/// Determines whether the current thread is unwinding because of panic.
171+
/// Determines whether the current thread is panicking.
172+
///
173+
/// This returns `true` both when the thread is unwinding due to a panic,
174+
/// or executing a panic hook. Note that the latter case will still happen
175+
/// when `panic=abort` is set.
172176
///
173177
/// A common use of this feature is to poison shared resources when writing
174178
/// unsafe code, by checking `panicking` when the `drop` is called.
@@ -309,14 +313,14 @@ pub fn sleep(dur: Duration) {
309313
///
310314
/// | Platform | System call |
311315
/// |-----------|----------------------------------------------------------------------|
312-
/// | Linux | [clock_nanosleep] (Monotonic clock) |
313-
/// | BSD except OpenBSD | [clock_nanosleep] (Monotonic Clock)] |
314-
/// | Android | [clock_nanosleep] (Monotonic Clock)] |
315-
/// | Solaris | [clock_nanosleep] (Monotonic Clock)] |
316-
/// | Illumos | [clock_nanosleep] (Monotonic Clock)] |
317-
/// | Dragonfly | [clock_nanosleep] (Monotonic Clock)] |
318-
/// | Hurd | [clock_nanosleep] (Monotonic Clock)] |
319-
/// | Vxworks | [clock_nanosleep] (Monotonic Clock)] |
316+
/// | Linux | [clock_nanosleep] (Monotonic Clock) |
317+
/// | BSD except OpenBSD | [clock_nanosleep] (Monotonic Clock) |
318+
/// | Android | [clock_nanosleep] (Monotonic Clock) |
319+
/// | Solaris | [clock_nanosleep] (Monotonic Clock) |
320+
/// | Illumos | [clock_nanosleep] (Monotonic Clock) |
321+
/// | Dragonfly | [clock_nanosleep] (Monotonic Clock) |
322+
/// | Hurd | [clock_nanosleep] (Monotonic Clock) |
323+
/// | Vxworks | [clock_nanosleep] (Monotonic Clock) |
320324
/// | Apple | `mach_wait_until` |
321325
/// | Other | `sleep_until` uses [`sleep`] and does not issue a syscall itself |
322326
///

0 commit comments

Comments
 (0)