about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-10-15 21:29:06 +0200
committerGitHub <noreply@github.com>2023-10-15 21:29:06 +0200
commite063d8a59129109405d8af7e6ef97cde801196fa (patch)
treebb9bd994ae4fe72e2d32ec7f30c9ae6d32b4f32b
parent64368d0279c41699fffd7980304488d65a42ba32 (diff)
parent559ec69e4106bd257ec4474c93b7d9066467ad38 (diff)
downloadrust-e063d8a59129109405d8af7e6ef97cde801196fa.tar.gz
rust-e063d8a59129109405d8af7e6ef97cde801196fa.zip
Rollup merge of #116172 - joboet:recursive_tls_initialization, r=dtolnay
Broaden the consequences of recursive TLS initialization

This PR updates the documentation of `LocalKey` to clearly disallow the behaviour described in [this comment](https://github.com/rust-lang/rust/issues/110897#issuecomment-1525738849). This allows using `OnceCell` for the lazy initialization of TLS variables, which panics on reentrant initialization instead of updating the value like TLS variables currently do.

``@rustbot`` label +T-libs-api
r? ``@m-ou-se``
-rw-r--r--library/std/src/thread/local.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/library/std/src/thread/local.rs b/library/std/src/thread/local.rs
index 09994e47f0a..def94acd457 100644
--- a/library/std/src/thread/local.rs
+++ b/library/std/src/thread/local.rs
@@ -29,9 +29,9 @@ use crate::fmt;
 /// within a thread, and values that implement [`Drop`] get destructed when a
 /// thread exits. Some caveats apply, which are explained below.
 ///
-/// A `LocalKey`'s initializer cannot recursively depend on itself, and using
-/// a `LocalKey` in this way will cause the initializer to infinitely recurse
-/// on the first call to `with`.
+/// A `LocalKey`'s initializer cannot recursively depend on itself. Using a
+/// `LocalKey` in this way may cause panics, aborts or infinite recursion on
+/// the first call to `with`.
 ///
 /// # Examples
 ///