Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions library/std/src/sys/thread_local/native/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,12 @@ pub macro thread_local_inner {

// used to generate the `LocalKey` value for `thread_local!`
(@key $t:ty, $(#[$align_attr:meta])*, $init:expr) => {{
// We intentionally have an argument-position `'static` lifetime so that elided lifetimes in `$t`
// become `'static` like they do for `const`s and `static`s, including in the other two
// `thread_local!` implementations.
#[allow(mismatched_lifetime_syntaxes)]
#[inline]
fn __rust_std_internal_init_fn() -> $t {
fn __rust_std_internal_init_fn(_lifetime_elision: $crate::marker::PhantomData<&'static ()>) -> $t {
$init
}

Expand All @@ -94,15 +98,15 @@ pub macro thread_local_inner {
$(#[$align_attr])*
static __RUST_STD_INTERNAL_VAL: $crate::thread::local_impl::LazyStorage<$t, ()>
= $crate::thread::local_impl::LazyStorage::new();
__RUST_STD_INTERNAL_VAL.get_or_init(__rust_std_internal_init, __rust_std_internal_init_fn)
__RUST_STD_INTERNAL_VAL.get_or_init(__rust_std_internal_init, || __rust_std_internal_init_fn($crate::marker::PhantomData))
}
} else {
|__rust_std_internal_init| {
#[thread_local]
$(#[$align_attr])*
static __RUST_STD_INTERNAL_VAL: $crate::thread::local_impl::LazyStorage<$t, !>
= $crate::thread::local_impl::LazyStorage::new();
__RUST_STD_INTERNAL_VAL.get_or_init(__rust_std_internal_init, __rust_std_internal_init_fn)
__RUST_STD_INTERNAL_VAL.get_or_init(__rust_std_internal_init, || __rust_std_internal_init_fn($crate::marker::PhantomData))
}
}
})
Expand Down
8 changes: 6 additions & 2 deletions library/std/src/sys/thread_local/no_threads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,18 @@ pub macro thread_local_inner {

// used to generate the `LocalKey` value for `thread_local!`
(@key $t:ty, $(#[$align_attr:meta])*, $init:expr) => {{
// We intentionally have an argument-position `'static` lifetime so that elided lifetimes in `$t`
// become `'static` like they do for `const`s and `static`s, including in the other two
// `thread_local!` implementations.
#[allow(mismatched_lifetime_syntaxes)]
#[inline]
fn __rust_std_internal_init_fn() -> $t { $init }
fn __rust_std_internal_init_fn(_lifetime_elision: $crate::marker::PhantomData<&'static ()>) -> $t { $init }

unsafe {
$crate::thread::LocalKey::new(|__rust_std_internal_init| {
$(#[$align_attr])*
static __RUST_STD_INTERNAL_VAL: $crate::thread::local_impl::LazyStorage<$t> = $crate::thread::local_impl::LazyStorage::new();
__RUST_STD_INTERNAL_VAL.get(__rust_std_internal_init, __rust_std_internal_init_fn)
__RUST_STD_INTERNAL_VAL.get(__rust_std_internal_init, || __rust_std_internal_init_fn($crate::marker::PhantomData))
})
}
}},
Expand Down
8 changes: 6 additions & 2 deletions library/std/src/sys/thread_local/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ pub macro thread_local_inner {

// used to generate the `LocalKey` value for `thread_local!`.
(@key $t:ty, $($(#[$($align_attr:tt)*])+)?, $init:expr) => {{
// We intentionally have an argument-position `'static` lifetime so that elided lifetimes in `$t`
// become `'static` like they do for `const`s and `static`s, including in the other two
// `thread_local!` implementations.
#[allow(mismatched_lifetime_syntaxes)]
#[inline]
fn __rust_std_internal_init_fn() -> $t { $init }
fn __rust_std_internal_init_fn(_lifetime_elision: $crate::marker::PhantomData<&'static ()>) -> $t { $init }

// NOTE: this cannot import `LocalKey` or `Storage` with a `use` because that can shadow
// user provided type or type alias with a matching name. Please update the shadowing test
Expand All @@ -43,7 +47,7 @@ pub macro thread_local_inner {
final_align
}>
= $crate::thread::local_impl::Storage::new();
__RUST_STD_INTERNAL_VAL.get(__rust_std_internal_init, __rust_std_internal_init_fn)
__RUST_STD_INTERNAL_VAL.get(__rust_std_internal_init, || __rust_std_internal_init_fn($crate::marker::PhantomData))
})
}
}},
Expand Down
54 changes: 0 additions & 54 deletions tests/ui/suggestions/missing-lifetime-specifier.rs

This file was deleted.

109 changes: 0 additions & 109 deletions tests/ui/suggestions/missing-lifetime-specifier.stderr

This file was deleted.

Loading