-
Notifications
You must be signed in to change notification settings - Fork 155
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
Manual Debug
impl for salsa::Id
#508
Manual Debug
impl for salsa::Id
#508
Conversation
✅ Deploy Preview for salsa-rs canceled.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts?
src/id.rs
Outdated
@@ -40,6 +40,12 @@ impl Id { | |||
} | |||
} | |||
|
|||
impl std::fmt::Debug for Id { | |||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | |||
self.as_u32().fmt(f) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. I think it would be better to print something other than just a number -- e.g., Id(N)
. I've usually found there is value in having some more "grep-able".
I think yes :)
I like that it uses the debug impl, keep that I think. |
ff0bcd6
to
662c58f
Compare
tests/tracked_with_struct_db.rs
Outdated
[salsa id]: Id( | ||
0, | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, the fact that debug_tuple
splits the ID across multiple lines in alternate mode is too verbose. I'm just gonna use a regular write call.
53c3cf7
to
94f36f0
Compare
94f36f0
to
5751cb3
Compare
I updated the Debug implementation to write |
@nikomatsakis I addressed the feedback. Would you mind taking another look? |
Ha, I probably need to start over. @nikomatsakis I don't mind rebasing (re-doing) if this is something we want to merge. |
I'm in favor of this but needs a rebase |
fc3d39d
to
ff23927
Compare
Done |
ff23927
to
6975a47
Compare
I've often been confused by the fact that the IDs printed by
DebugWithDb
don't match with the ids printed when dumping asalsa::Id
withDebug
.This PR replaces the derived
Debug
implementation ofsalsa::Id
with a manualDebug
implementation that ensures that the IDs printed byDebug
andDebugWithdb
are consistent.Open Questions
Id
usef.debug_tuple
to preserve the name in theDebug
output?DebugWithDb
continue to useas_u32
directly or should it just call theId
'sDebug
implementation (It would change the output if we decide thatDebug
should outputId(num)
.