Skip to content

Conversation

@MarijnS95
Copy link
Member

We typically see errors formatted as -0x80004005, because we tell pad_integral() that the number is negative while we format-printed it as unsigned integer which cannot be negative as represented by the highest 0x80000000 bit being set - appearing as a double negation of sorts? Either we remove the misleading - or print the number as integer with the sign bit removed (which makes it harder to look up online).

The end result is that we can and should just remove this strange override of LowerHex, and rely purely on our Display implementation of HRESULT that format-prints the inner i32 as hexadecimal with 0x prefix, which automatically prints it as unsigned.

The end result is that we found one more case where {:#x} was overridden to just {:x} because LowerHex is no longer implemented for HRESULT, which was accidentally dropping the 0x prefix in the format string too.

Copy link

@maxded maxded left a comment

Choose a reason for hiding this comment

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

Fine by me

@MarijnS95 MarijnS95 enabled auto-merge (squash) October 27, 2025 09:14
We typically see errors formatted as `-0x80004005`, because we tell
`pad_integral()` that the number is negative while we format-printed
it as **unsigned** integer which cannot be negative as represented by
the highest `0x80000000` bit being set - appearing as a double negation
of sorts?  Either we remove the misleading `-` or print the number as
integer with the sign bit removed (which makes it harder to look up
online).

The end result is that we can and should just remove this strange
override of `LowerHex`, and rely purely on our `Display` implementation
of `HRESULT` that format-prints the inner `i32` as hexadecimal with `0x`
prefix, which automatically prints it as unsigned.

The end result is that we found one more case where `{:#x}` was
overridden to just `{:x}` because `LowerHex` is no longer implemented
for `HRESULT`, which was accidentally dropping the `0x` prefix in the
format string too.
@MarijnS95 MarijnS95 removed the request for review from EmilioLaiso November 17, 2025 10:29
@MarijnS95 MarijnS95 merged commit 74295da into main Nov 17, 2025
4 checks passed
@MarijnS95 MarijnS95 deleted the formatting-oopsies branch November 17, 2025 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants