Skip to content

Commit

Permalink
Auto merge of rust-lang#99099 - Stargateur:phantomdata_debug, r=josht…
Browse files Browse the repository at this point in the history
…riplett

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
  • Loading branch information
bors committed Oct 4, 2022
2 parents f83e026 + eac1e30 commit 1f1defc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion library/core/src/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>())
}
}

Expand Down

0 comments on commit 1f1defc

Please sign in to comment.