diff options
| author | bors <bors@rust-lang.org> | 2024-10-18 11:11:43 +0000 | 
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-10-18 11:11:43 +0000 | 
| commit | 1350eead10c46b9d3c2007fe0ea7892b7d7337ab (patch) | |
| tree | cb64b35fbe218b685fd687977266e5205562d645 /library/std/src/sys/thread_local/native/mod.rs | |
| parent | acfdb8dd1fd4913ea004f43f73e7346e125491ed (diff) | |
| parent | 80a8f7b0419cc8cbe987a5f68715a435b1654a18 (diff) | |
| download | rust-1350eead10c46b9d3c2007fe0ea7892b7d7337ab.tar.gz rust-1350eead10c46b9d3c2007fe0ea7892b7d7337ab.zip | |
Auto merge of #131887 - jieyouxu:rollup-ftik4ni, r=jieyouxu
Rollup of 9 pull requests Successful merges: - #130136 (Partially stabilize const_pin) - #131755 (Regression test for AVR `rjmp` offset) - #131774 (Add getentropy for RTEMS) - #131802 (Dont ICE when computing coverage of synthetic async closure body) - #131809 (Fix predicate signatures in retain_mut docs) - #131858 (Remove outdated documentation for `repeat_n`) - #131866 (Avoid use imports in `thread_local_inner!`) - #131874 (Default to the medium code model on OpenHarmony LoongArch target) - #131877 (checktools.sh: add link to issue for more context about disabled Miri tests) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'library/std/src/sys/thread_local/native/mod.rs')
| -rw-r--r-- | library/std/src/sys/thread_local/native/mod.rs | 31 | 
1 files changed, 15 insertions, 16 deletions
| diff --git a/library/std/src/sys/thread_local/native/mod.rs b/library/std/src/sys/thread_local/native/mod.rs index f498dee0899..a5dffe3c458 100644 --- a/library/std/src/sys/thread_local/native/mod.rs +++ b/library/std/src/sys/thread_local/native/mod.rs @@ -49,20 +49,21 @@ pub use lazy::Storage as LazyStorage; #[unstable(feature = "thread_local_internals", issue = "none")] #[rustc_macro_transparency = "semitransparent"] pub macro thread_local_inner { - // used to generate the `LocalKey` value for const-initialized thread locals + // NOTE: we cannot import `LocalKey`, `LazyStorage` or `EagerStorage` with a `use` because that + // can shadow user provided type or type alias with a matching name. Please update the shadowing + // test in `tests/thread.rs` if these types are renamed. + + // Used to generate the `LocalKey` value for const-initialized thread locals. (@key $t:ty, const $init:expr) => {{ const __INIT: $t = $init; unsafe { - use $crate::mem::needs_drop; - use $crate::thread::LocalKey; - use $crate::thread::local_impl::EagerStorage; - - LocalKey::new(const { - if needs_drop::<$t>() { + $crate::thread::LocalKey::new(const { + if $crate::mem::needs_drop::<$t>() { |_| { #[thread_local] - static VAL: EagerStorage<$t> = EagerStorage::new(__INIT); + static VAL: $crate::thread::local_impl::EagerStorage<$t> + = $crate::thread::local_impl::EagerStorage::new(__INIT); VAL.get() } } else { @@ -84,21 +85,19 @@ pub macro thread_local_inner { } unsafe { - use $crate::mem::needs_drop; - use $crate::thread::LocalKey; - use $crate::thread::local_impl::LazyStorage; - - LocalKey::new(const { - if needs_drop::<$t>() { + $crate::thread::LocalKey::new(const { + if $crate::mem::needs_drop::<$t>() { |init| { #[thread_local] - static VAL: LazyStorage<$t, ()> = LazyStorage::new(); + static VAL: $crate::thread::local_impl::LazyStorage<$t, ()> + = $crate::thread::local_impl::LazyStorage::new(); VAL.get_or_init(init, __init) } } else { |init| { #[thread_local] - static VAL: LazyStorage<$t, !> = LazyStorage::new(); + static VAL: $crate::thread::local_impl::LazyStorage<$t, !> + = $crate::thread::local_impl::LazyStorage::new(); VAL.get_or_init(init, __init) } } | 
