Skip to content

Commit df408f5

Browse files
Boshenclaude
andauthored
feat: improve Debug output for index types (#92)
Changes the Debug output format for types created with `define_nonmax_u32_index_type!` from just the raw number (e.g., `42`) to include the type name (e.g., `ScopeId(42)`). This makes debug output and error messages much clearer, especially when displaying multiple different index types together. For example, in semantic analysis snapshots, scope and symbol IDs are now clearly distinguished: Before: ``` Scope children mismatch: after transform: 0: [1] rebuilt : 0: [1, 2, 4] ``` After: ``` Scope children mismatch: after transform: ScopeId(0): [ScopeId(1)] rebuilt : ScopeId(0): [ScopeId(1), ScopeId(2), ScopeId(4)] ``` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <[email protected]>
1 parent 29d406c commit df408f5

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ macro_rules! define_nonmax_u32_index_type {
328328

329329
impl core::fmt::Debug for $type {
330330
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
331-
write!(f, "{}", self.index())
331+
write!(f, "{}({})", stringify!($type), self.index())
332332
}
333333
}
334334

tests/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,9 +611,9 @@ fn test_nonmax_with_attrs() {
611611
// Test that custom attributes work with define_nonmax_u32_index_type!
612612
let idx = IdxNonMaxWithAttrs::new(42);
613613

614-
// Verify Debug derive works
614+
// Verify Debug impl works
615615
let debug_str = format!("{:?}", idx);
616-
assert_eq!(debug_str, "42");
616+
assert_eq!(debug_str, "IdxNonMaxWithAttrs(42)");
617617

618618
// Verify all standard functionality works
619619
assert_eq!(idx.index(), 42);

0 commit comments

Comments
 (0)