std: Reorganize thread::local a bit
Make the structure more amenable to what rustdoc is expecting to ensure that everything renders all nice and pretty in the output. Closes #23705 Closes #23910
This commit is contained in:
parent
61d0365aac
commit
f651bea822
@ -95,7 +95,7 @@ macro_rules! thread_local {
|
|||||||
(static $name:ident: $t:ty = $init:expr) => (
|
(static $name:ident: $t:ty = $init:expr) => (
|
||||||
static $name: ::std::thread::LocalKey<$t> = {
|
static $name: ::std::thread::LocalKey<$t> = {
|
||||||
use std::cell::UnsafeCell as __UnsafeCell;
|
use std::cell::UnsafeCell as __UnsafeCell;
|
||||||
use std::thread::__local::__impl::KeyInner as __KeyInner;
|
use std::thread::__local::KeyInner as __KeyInner;
|
||||||
use std::option::Option as __Option;
|
use std::option::Option as __Option;
|
||||||
use std::option::Option::None as __None;
|
use std::option::Option::None as __None;
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ macro_rules! thread_local {
|
|||||||
(pub static $name:ident: $t:ty = $init:expr) => (
|
(pub static $name:ident: $t:ty = $init:expr) => (
|
||||||
pub static $name: ::std::thread::LocalKey<$t> = {
|
pub static $name: ::std::thread::LocalKey<$t> = {
|
||||||
use std::cell::UnsafeCell as __UnsafeCell;
|
use std::cell::UnsafeCell as __UnsafeCell;
|
||||||
use std::thread::__local::__impl::KeyInner as __KeyInner;
|
use std::thread::__local::KeyInner as __KeyInner;
|
||||||
use std::option::Option as __Option;
|
use std::option::Option as __Option;
|
||||||
use std::option::Option::None as __None;
|
use std::option::Option::None as __None;
|
||||||
|
|
||||||
@ -156,20 +156,20 @@ macro_rules! __thread_local_inner {
|
|||||||
#[cfg_attr(all(any(target_os = "macos", target_os = "linux"),
|
#[cfg_attr(all(any(target_os = "macos", target_os = "linux"),
|
||||||
not(target_arch = "aarch64")),
|
not(target_arch = "aarch64")),
|
||||||
thread_local)]
|
thread_local)]
|
||||||
static $name: ::std::thread::__local::__impl::KeyInner<$t> =
|
static $name: ::std::thread::__local::KeyInner<$t> =
|
||||||
__thread_local_inner!($init, $t);
|
__thread_local_inner!($init, $t);
|
||||||
);
|
);
|
||||||
(pub static $name:ident: $t:ty = $init:expr) => (
|
(pub static $name:ident: $t:ty = $init:expr) => (
|
||||||
#[cfg_attr(all(any(target_os = "macos", target_os = "linux"),
|
#[cfg_attr(all(any(target_os = "macos", target_os = "linux"),
|
||||||
not(target_arch = "aarch64")),
|
not(target_arch = "aarch64")),
|
||||||
thread_local)]
|
thread_local)]
|
||||||
pub static $name: ::std::thread::__local::__impl::KeyInner<$t> =
|
pub static $name: ::std::thread::__local::KeyInner<$t> =
|
||||||
__thread_local_inner!($init, $t);
|
__thread_local_inner!($init, $t);
|
||||||
);
|
);
|
||||||
($init:expr, $t:ty) => ({
|
($init:expr, $t:ty) => ({
|
||||||
#[cfg(all(any(target_os = "macos", target_os = "linux"), not(target_arch = "aarch64")))]
|
#[cfg(all(any(target_os = "macos", target_os = "linux"), not(target_arch = "aarch64")))]
|
||||||
const _INIT: ::std::thread::__local::__impl::KeyInner<$t> = {
|
const _INIT: ::std::thread::__local::KeyInner<$t> = {
|
||||||
::std::thread::__local::__impl::KeyInner {
|
::std::thread::__local::KeyInner {
|
||||||
inner: ::std::cell::UnsafeCell { value: $init },
|
inner: ::std::cell::UnsafeCell { value: $init },
|
||||||
dtor_registered: ::std::cell::UnsafeCell { value: false },
|
dtor_registered: ::std::cell::UnsafeCell { value: false },
|
||||||
dtor_running: ::std::cell::UnsafeCell { value: false },
|
dtor_running: ::std::cell::UnsafeCell { value: false },
|
||||||
@ -178,13 +178,13 @@ macro_rules! __thread_local_inner {
|
|||||||
|
|
||||||
#[allow(trivial_casts)]
|
#[allow(trivial_casts)]
|
||||||
#[cfg(any(not(any(target_os = "macos", target_os = "linux")), target_arch = "aarch64"))]
|
#[cfg(any(not(any(target_os = "macos", target_os = "linux")), target_arch = "aarch64"))]
|
||||||
const _INIT: ::std::thread::__local::__impl::KeyInner<$t> = {
|
const _INIT: ::std::thread::__local::KeyInner<$t> = {
|
||||||
::std::thread::__local::__impl::KeyInner {
|
::std::thread::__local::KeyInner {
|
||||||
inner: ::std::cell::UnsafeCell { value: $init },
|
inner: ::std::cell::UnsafeCell { value: $init },
|
||||||
os: ::std::thread::__local::__impl::OsStaticKey {
|
os: ::std::thread::__local::OsStaticKey {
|
||||||
inner: ::std::thread::__local::__impl::OS_INIT_INNER,
|
inner: ::std::thread::__local::OS_INIT_INNER,
|
||||||
dtor: ::std::option::Option::Some(
|
dtor: ::std::option::Option::Some(
|
||||||
::std::thread::__local::__impl::destroy_value::<$t>
|
::std::thread::__local::destroy_value::<$t>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -168,14 +168,6 @@
|
|||||||
|
|
||||||
#![stable(feature = "rust1", since = "1.0.0")]
|
#![stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
|
||||||
pub use self::__local::{LocalKey, LocalKeyState};
|
|
||||||
|
|
||||||
#[unstable(feature = "scoped_tls",
|
|
||||||
reason = "scoped TLS has yet to have wide enough use to fully consider \
|
|
||||||
stabilizing its interface")]
|
|
||||||
pub use self::__scoped::ScopedKey;
|
|
||||||
|
|
||||||
use prelude::v1::*;
|
use prelude::v1::*;
|
||||||
|
|
||||||
use any::Any;
|
use any::Any;
|
||||||
@ -194,13 +186,19 @@ use time::Duration;
|
|||||||
// Thread-local storage
|
// Thread-local storage
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use] mod local;
|
||||||
#[doc(hidden)]
|
#[macro_use] mod scoped;
|
||||||
#[path = "local.rs"] pub mod __local;
|
|
||||||
|
|
||||||
#[macro_use]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[doc(hidden)]
|
pub use self::local::{LocalKey, LocalKeyState};
|
||||||
#[path = "scoped.rs"] pub mod __scoped;
|
|
||||||
|
#[unstable(feature = "scoped_tls",
|
||||||
|
reason = "scoped TLS has yet to have wide enough use to fully \
|
||||||
|
consider stabilizing its interface")]
|
||||||
|
pub use self::scoped::ScopedKey;
|
||||||
|
|
||||||
|
#[doc(hidden)] pub use self::local::__impl as __local;
|
||||||
|
#[doc(hidden)] pub use self::scoped::__impl as __scoped;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Builder
|
// Builder
|
||||||
|
@ -110,7 +110,7 @@ macro_rules! __scoped_thread_local_inner {
|
|||||||
target_os = "openbsd",
|
target_os = "openbsd",
|
||||||
target_arch = "aarch64")))]
|
target_arch = "aarch64")))]
|
||||||
const _INIT: __Key<$t> = __Key {
|
const _INIT: __Key<$t> = __Key {
|
||||||
inner: ::std::thread::__scoped::__impl::KeyInner {
|
inner: ::std::thread::__scoped::KeyInner {
|
||||||
inner: ::std::cell::UnsafeCell { value: 0 as *mut _ },
|
inner: ::std::cell::UnsafeCell { value: 0 as *mut _ },
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -121,8 +121,8 @@ macro_rules! __scoped_thread_local_inner {
|
|||||||
target_os = "openbsd",
|
target_os = "openbsd",
|
||||||
target_arch = "aarch64"))]
|
target_arch = "aarch64"))]
|
||||||
const _INIT: __Key<$t> = __Key {
|
const _INIT: __Key<$t> = __Key {
|
||||||
inner: ::std::thread::__scoped::__impl::KeyInner {
|
inner: ::std::thread::__scoped::KeyInner {
|
||||||
inner: ::std::thread::__scoped::__impl::OS_INIT,
|
inner: ::std::thread::__scoped::OS_INIT,
|
||||||
marker: ::std::marker::PhantomData::<::std::cell::Cell<$t>>,
|
marker: ::std::marker::PhantomData::<::std::cell::Cell<$t>>,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user