From ddb072b8d77dbb4708ffa89b361375d761debc9f Mon Sep 17 00:00:00 2001 From: Joshua Liebow-Feeser Date: Thu, 7 Sep 2017 12:57:08 -0700 Subject: [PATCH] std::thread::LocalKey: Document limitation with initializers --- src/libstd/thread/local.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs index 4ee8132f55c..a53c76a333a 100644 --- a/src/libstd/thread/local.rs +++ b/src/libstd/thread/local.rs @@ -31,6 +31,10 @@ use mem; /// 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`. +/// /// # Examples /// /// ```