Rollup merge of #132101 - youknowone:thread_local-gyneiene, r=tgross35

Avoid using imports in thread_local_inner! in static

Fixes #131863 for wasm targets

All other macros were done in #131866, but this sub module is missed.

r? `@jieyouxu`
This commit is contained in:
Jubilee 2024-10-24 15:53:35 -07:00 committed by GitHub
commit abfad21c97
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -14,12 +14,11 @@ pub macro thread_local_inner {
(@key $t:ty, const $init:expr) => {{ (@key $t:ty, const $init:expr) => {{
const __INIT: $t = $init; const __INIT: $t = $init;
// NOTE: Please update the shadowing test in `tests/thread.rs` if these types are renamed.
unsafe { unsafe {
use $crate::thread::LocalKey; $crate::thread::LocalKey::new(|_| {
use $crate::thread::local_impl::EagerStorage; static VAL: $crate::thread::local_impl::EagerStorage<$t> =
$crate::thread::local_impl::EagerStorage { value: __INIT };
LocalKey::new(|_| {
static VAL: EagerStorage<$t> = EagerStorage { value: __INIT };
&VAL.value &VAL.value
}) })
} }