Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print TypeId as hex for debugging #127179

Merged
merged 1 commit into from
Jul 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/core/src/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ impl hash::Hash for TypeId {
#[stable(feature = "rust1", since = "1.0.0")]
impl fmt::Debug for TypeId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
f.debug_tuple("TypeId").field(&self.as_u128()).finish()
write!(f, "TypeId({:#034x})", self.as_u128())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be 32 instead of 34?

Copy link
Contributor Author

@tgross35 tgross35 Jun 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The number has to include the leading 0x when used with #. Which always feels pretty weird to me because it pads the number after the 0x, but is apparently correct (e.g. the example in the top post)

}
}

Expand Down
Loading