Skip to content

Commit 2dad4f3

Browse files
Rollup merge of rust-lang#44396 - joshlf:tls-comment, r=alexcrichton
std::thread::LocalKey: Document limitation with initializers Document that if a `LocalKey`'s initializer recursively depends on itself, initialization will result in infinite recursion.
2 parents 6f7c75e + ddb072b commit 2dad4f3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/libstd/thread/local.rs

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ use mem;
3131
/// within a thread, and values that implement [`Drop`] get destructed when a
3232
/// thread exits. Some caveats apply, which are explained below.
3333
///
34+
/// A `LocalKey`'s initializer cannot recursively depend on itself, and using
35+
/// a `LocalKey` in this way will cause the initializer to infinitely recurse
36+
/// on the first call to `with`.
37+
///
3438
/// # Examples
3539
///
3640
/// ```

0 commit comments

Comments
 (0)