diff options
Diffstat (limited to 'src/libstd/thread')
| -rw-r--r-- | src/libstd/thread/local.rs | 18 | ||||
| -rw-r--r-- | src/libstd/thread/mod.rs | 15 |
2 files changed, 32 insertions, 1 deletions
diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs index f74dd592495..01584979aab 100644 --- a/src/libstd/thread/local.rs +++ b/src/libstd/thread/local.rs @@ -13,6 +13,7 @@ #![unstable(feature = "thread_local_internals", issue = "0")] use cell::UnsafeCell; +use fmt; use mem; /// A thread local storage key which owns its contents. @@ -98,6 +99,13 @@ pub struct LocalKey<T: 'static> { init: fn() -> T, } +#[stable(feature = "std_debug", since = "1.15.0")] +impl<T: 'static> fmt::Debug for LocalKey<T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("LocalKey { .. }") + } +} + /// Declare a new thread local storage key of type `std::thread::LocalKey`. /// /// # Syntax @@ -184,7 +192,7 @@ macro_rules! __thread_local_inner { #[unstable(feature = "thread_local_state", reason = "state querying was recently added", issue = "27716")] -#[derive(Eq, PartialEq, Copy, Clone)] +#[derive(Debug, Eq, PartialEq, Copy, Clone)] pub enum LocalKeyState { /// All keys are in this state whenever a thread starts. Keys will /// transition to the `Valid` state once the first call to `with` happens @@ -313,6 +321,7 @@ impl<T: 'static> LocalKey<T> { #[doc(hidden)] pub mod os { use cell::{Cell, UnsafeCell}; + use fmt; use marker; use ptr; use sys_common::thread_local::StaticKey as OsStaticKey; @@ -323,6 +332,13 @@ pub mod os { marker: marker::PhantomData<Cell<T>>, } + #[stable(feature = "std_debug", since = "1.15.0")] + impl<T> fmt::Debug for Key<T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Key { .. }") + } + } + unsafe impl<T> ::marker::Sync for Key<T> { } struct Value<T: 'static> { diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 255cd2a9bc0..8cfa0200bf8 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -203,6 +203,7 @@ pub use self::local::{LocalKey, LocalKeyState}; /// Thread configuration. Provides detailed control over the properties /// and behavior of new threads. #[stable(feature = "rust1", since = "1.0.0")] +#[derive(Debug)] pub struct Builder { // A name for the thread-to-be, for identification in panic messages name: Option<String>, @@ -573,6 +574,13 @@ impl ThreadId { } } +#[stable(feature = "std_debug", since = "1.15.0")] +impl fmt::Debug for ThreadId { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("ThreadId { .. }") + } +} + //////////////////////////////////////////////////////////////////////////////// // Thread //////////////////////////////////////////////////////////////////////////////// @@ -788,6 +796,13 @@ impl<T> IntoInner<imp::Thread> for JoinHandle<T> { fn into_inner(self) -> imp::Thread { self.0.native.unwrap() } } +#[stable(feature = "std_debug", since = "1.15.0")] +impl<T> fmt::Debug for JoinHandle<T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("JoinHandle { .. }") + } +} + fn _assert_sync_and_send() { fn _assert_both<T: Send + Sync>() {} _assert_both::<JoinHandle<()>>(); |
