Skip to content

Conversation

tgross35
Copy link
Contributor

In #127134, the Debug impl for TypeId was changed to print a single integer rather than a tuple. Change this again to print as hex for more concise and consistent formatting, as was suggested.

Result:

TypeId(0x1378bb1c0a0202683eb65e7c11f2e4d7)

r? @Nilstrieb

In <rust-lang#127134>, the `Debug` impl for
`TypeId` was changed to print a single integer rather than a tuple.
Change this again to print as hex for more concise and consistent
formatting, as was suggested.

Result:

    TypeId(0x1378bb1c0a0202683eb65e7c11f2e4d7)
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jun 30, 2024
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)

@Noratrieb
Copy link
Member

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Jul 7, 2024

📌 Commit 69446e3 has been approved by Nilstrieb

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 7, 2024
@bors bors merged commit 35a1ca0 into rust-lang:master Jul 7, 2024
@rustbot rustbot added this to the 1.81.0 milestone Jul 7, 2024
@tgross35 tgross35 deleted the typeid-debug-hex branch July 7, 2024 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants