diff --git a/library/core/src/any.rs b/library/core/src/any.rs index eef8f2046d33e..c9882d5350e2c 100644 --- a/library/core/src/any.rs +++ b/library/core/src/any.rs @@ -435,7 +435,7 @@ impl dyn Any + Send + Sync { /// While `TypeId` implements `Hash`, `PartialOrd`, and `Ord`, it is worth /// noting that the hashes and ordering will vary between Rust releases. Beware /// of relying on them inside of your code! -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[stable(feature = "rust1", since = "1.0.0")] pub struct TypeId { t: u64, @@ -464,6 +464,13 @@ impl TypeId { } } +#[stable(feature = "rust1", since = "1.0.0")] +impl fmt::Debug for TypeId { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.pad("TypeId(_)") + } +} + /// Returns the name of a type as a string slice. /// /// # Note diff --git a/library/core/src/mem/mod.rs b/library/core/src/mem/mod.rs index 778e34e634f64..abfa657f76bbc 100644 --- a/library/core/src/mem/mod.rs +++ b/library/core/src/mem/mod.rs @@ -988,7 +988,7 @@ impl hash::Hash for Discriminant { #[stable(feature = "discriminant_value", since = "1.21.0")] impl fmt::Debug for Discriminant { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt.debug_tuple("Discriminant").field(&self.0).finish() + fmt.pad("Discriminant(_)") } } diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index 0ef848ff0c4c1..2493dd1dc44dd 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -985,7 +985,7 @@ pub fn park_timeout(dur: Duration) { /// /// [`id`]: Thread::id #[stable(feature = "thread_id", since = "1.19.0")] -#[derive(Eq, PartialEq, Clone, Copy, Hash, Debug)] +#[derive(Eq, PartialEq, Clone, Copy, Hash)] pub struct ThreadId(NonZeroU64); impl ThreadId { @@ -1025,6 +1025,13 @@ impl ThreadId { } } +#[stable(feature = "thread_id", since = "1.19.0")] +impl fmt::Debug for ThreadId { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.pad("ThreadId(_)") + } +} + //////////////////////////////////////////////////////////////////////////////// // Thread //////////////////////////////////////////////////////////////////////////////// diff --git a/library/std/src/time.rs b/library/std/src/time.rs index 89addae078948..3c9cc5614bf16 100644 --- a/library/std/src/time.rs +++ b/library/std/src/time.rs @@ -410,7 +410,9 @@ impl Sub for Instant { #[stable(feature = "time2", since = "1.8.0")] impl fmt::Debug for Instant { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - self.0.fmt(f) + // Instant is an opaque type and only useful with `Duration`. So it + // would be misleading to show implementation detail in the output. + f.pad("Instant(_)") } }