about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-10-04 00:56:14 +0000
committerbors <bors@rust-lang.org>2022-10-04 00:56:14 +0000
commit1f1defc2f6f5c828e287845d04076cd22e90671e (patch)
tree6c121dea6c7320c634bb4b57abf3dcb0a26ea777
parentf83e0266cf7aaa4b41505c49a5fd9c2363166522 (diff)
parenteac1e30bd8620446c123b4f0d2c0ea054acdee56 (diff)
downloadrust-1f1defc2f6f5c828e287845d04076cd22e90671e.tar.gz
rust-1f1defc2f6f5c828e287845d04076cd22e90671e.zip
Auto merge of #99099 - Stargateur:phantomdata_debug, r=joshtriplett
Add T to PhantomData impl Debug

This add debug information for `PhantomData`, I believe it's make sense to add this to debug impl of `PhantomData` since `T` is what define what is the `PhantomData` just write `"PhantomData"` is not very useful for debugging.

Alternative:

* `PhantomData::<{}>`
* `PhantomData { t: "str_type" }`

`@rustbot` label +T-libs-api -T-libs
-rw-r--r--library/core/src/fmt/mod.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs
index 372439f14ec..c8d28550567 100644
--- a/library/core/src/fmt/mod.rs
+++ b/library/core/src/fmt/mod.rs
@@ -2610,7 +2610,7 @@ impl Debug for () {
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: ?Sized> Debug for PhantomData<T> {
     fn fmt(&self, f: &mut Formatter<'_>) -> Result {
-        f.debug_struct("PhantomData").finish()
+        write!(f, "PhantomData<{}>", crate::any::type_name::<T>())
     }
 }