Skip to content

Commit c7c0b85

Browse files
committed
Make tagged pointers debug impls print the pointer
Does not really matter, but may be nicer in case the pointer has some specific debug impl.
1 parent c6acd5c commit c7c0b85

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

compiler/rustc_data_structures/src/tagged_ptr/copy.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,13 @@ where
163163

164164
impl<P, T, const COMPARE_PACKED: bool> fmt::Debug for CopyTaggedPtr<P, T, COMPARE_PACKED>
165165
where
166-
P: Pointer,
167-
P::Target: fmt::Debug,
166+
P: Pointer + fmt::Debug,
168167
T: Tag + fmt::Debug,
169168
{
170169
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
171-
f.debug_struct("CopyTaggedPtr")
172-
.field("pointer", &self.pointer_ref())
173-
.field("tag", &self.tag())
174-
.finish()
170+
self.with_pointer_ref(|ptr| {
171+
f.debug_struct("CopyTaggedPtr").field("pointer", ptr).field("tag", &self.tag()).finish()
172+
})
175173
}
176174
}
177175

compiler/rustc_data_structures/src/tagged_ptr/drop.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,13 @@ where
8585

8686
impl<P, T, const COMPARE_PACKED: bool> fmt::Debug for TaggedPtr<P, T, COMPARE_PACKED>
8787
where
88-
P: Pointer,
89-
P::Target: fmt::Debug,
88+
P: Pointer + fmt::Debug,
9089
T: Tag + fmt::Debug,
9190
{
9291
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
93-
f.debug_struct("TaggedPtr")
94-
.field("pointer", &self.pointer_ref())
95-
.field("tag", &self.tag())
96-
.finish()
92+
self.raw.with_pointer_ref(|ptr| {
93+
f.debug_struct("TaggedPtr").field("pointer", ptr).field("tag", &self.tag()).finish()
94+
})
9795
}
9896
}
9997

0 commit comments

Comments
 (0)