Skip to content

Commit 9b6939b

Browse files
committed
alloc: Fix the fmt::Pointer impl for Box
1 parent a3e70c7 commit 9b6939b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/liballoc/boxed.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,10 @@ impl<T: fmt::Debug + ?Sized> fmt::Debug for Box<T> {
278278
#[stable(feature = "rust1", since = "1.0.0")]
279279
impl<T> fmt::Pointer for Box<T> {
280280
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
281-
fmt::Pointer::fmt(&*self, f)
281+
// It's not possible to extract the inner Uniq directly from the Box,
282+
// instead we cast it to a *const which aliases the Unique
283+
let ptr: *const T = &**self;
284+
fmt::Pointer::fmt(&ptr, f)
282285
}
283286
}
284287

0 commit comments

Comments
 (0)