Skip to content

Commit 22586d7

Browse files
committed
Better pretty printing for const raw pointers
1 parent 89e645a commit 22586d7

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/librustc/ty/print/pretty.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,10 @@ pub trait PrettyPrinter<'tcx>:
919919
},
920920
(ConstValue::Scalar(Scalar::Raw { data, .. }), ty::Char) =>
921921
p!(write("{:?}", ::std::char::from_u32(data as u32).unwrap())),
922-
(ConstValue::Scalar(_), ty::RawPtr(_)) => p!(write("{{pointer}}")),
922+
(ConstValue::Scalar(Scalar::Raw { data, size }), ty::RawPtr(_)) => {
923+
p!(write("{:#01$x} ", data, size as usize * 2));
924+
self = self.pretty_print_type(&ct.ty)?;
925+
}
923926
(ConstValue::Scalar(Scalar::Ptr(ptr)), ty::FnPtr(_)) => {
924927
let instance = {
925928
let alloc_map = self.tcx().alloc_map.lock();

src/test/ui/const-generics/raw-ptr-const-param.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ error[E0308]: mismatched types
1010
--> $DIR/raw-ptr-const-param.rs:7:38
1111
|
1212
LL | let _: Const<{15 as *const _}> = Const::<{10 as *const _}>;
13-
| ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `{pointer}`, found `{pointer}`
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `0x0000000000000f *const u32`, found `0x0000000000000a *const u32`
1414
|
15-
= note: expected type `Const<{pointer}>`
16-
found type `Const<{pointer}>`
15+
= note: expected type `Const<0x0000000000000f *const u32>`
16+
found type `Const<0x0000000000000a *const u32>`
1717

1818
error: aborting due to previous error
1919

0 commit comments

Comments
 (0)