Skip to content

Commit 89cc046

Browse files
committed
Pretty print raw pointers in consts as '{pointer}'.
1 parent 5986fe2 commit 89cc046

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/librustc/ty/print/pretty.rs

+1
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,7 @@ 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}}")),
922923
(ConstValue::Scalar(Scalar::Ptr(ptr)), ty::FnPtr(_)) => {
923924
let instance = {
924925
let alloc_map = self.tcx().alloc_map.lock();

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

+3-3
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 `Scalar(0x000000000000000f) : *const u32`, found `Scalar(0x000000000000000a) : *const u32`
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `{pointer}`, found `{pointer}`
1414
|
15-
= note: expected type `Const<Scalar(0x000000000000000f) : *const u32>`
16-
found type `Const<Scalar(0x000000000000000a) : *const u32>`
15+
= note: expected type `Const<{pointer}>`
16+
found type `Const<{pointer}>`
1717

1818
error: aborting due to previous error
1919

0 commit comments

Comments
 (0)