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