Skip to content

Commit

Permalink
Rollup merge of rust-lang#110049 - SkiFire13:localkey-with-docs-fix, …
Browse files Browse the repository at this point in the history
…r=workingjubilee

Don't claim `LocalKey::with` prevents a reference to be sent across threads

The documentation for `LocalKey` claims that `with` yields a reference that cannot be sent across threads, but this is false since you can easily do that with scoped threads. What it actually prevents is the reference from outliving the current thread.
  • Loading branch information
matthiaskrgr authored May 15, 2023
2 parents 1063548 + 2563fbe commit c93c298
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions library/std/src/thread/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ use crate::fmt;
/// target platform. It is instantiated with the [`thread_local!`] macro and the
/// primary method is the [`with`] method.
///
/// The [`with`] method yields a reference to the contained value which cannot be
/// sent across threads or escape the given closure.
/// The [`with`] method yields a reference to the contained value which cannot
/// outlive the current thread or escape the given closure.
///
/// [`thread_local!`]: crate::thread_local
///
Expand Down

0 comments on commit c93c298

Please sign in to comment.