From 7ba2d16623e74f6b75196df494cfc8433b36bda2 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 22 Jan 2023 22:54:45 -0800 Subject: [PATCH] Document panic from std::thread::current --- library/std/src/thread/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index 692ff0cbca68b..6630b9d380a20 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -717,6 +717,13 @@ where /// Gets a handle to the thread that invokes it. /// +/// # Panics +/// +/// Panics if called beyond the end of `main`, when the Rust standard library's +/// thread state has been torn down. For example, use of `libc::atexit` on some +/// platforms can hit this. In general much of the standard library is not okay +/// to use before or after `main`. +/// /// # Examples /// /// Getting a handle to the current thread with `thread::current()`: