Pretty print raw pointers in consts as '{pointer}'.

This commit is contained in:
ben
2019-10-10 08:11:31 +13:00
parent 5986fe24bd
commit 89cc0467a2
2 changed files with 4 additions and 3 deletions
+1
View File
@@ -919,6 +919,7 @@ fn pretty_print_const(
},
(ConstValue::Scalar(Scalar::Raw { data, .. }), ty::Char) =>
p!(write("{:?}", ::std::char::from_u32(data as u32).unwrap())),
(ConstValue::Scalar(_), ty::RawPtr(_)) => p!(write("{{pointer}}")),
(ConstValue::Scalar(Scalar::Ptr(ptr)), ty::FnPtr(_)) => {
let instance = {
let alloc_map = self.tcx().alloc_map.lock();
@@ -10,10 +10,10 @@ error[E0308]: mismatched types
--> $DIR/raw-ptr-const-param.rs:7:38
|
LL | let _: Const<{15 as *const _}> = Const::<{10 as *const _}>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Scalar(0x000000000000000f) : *const u32`, found `Scalar(0x000000000000000a) : *const u32`
| ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `{pointer}`, found `{pointer}`
|
= note: expected type `Const<Scalar(0x000000000000000f) : *const u32>`
found type `Const<Scalar(0x000000000000000a) : *const u32>`
= note: expected type `Const<{pointer}>`
found type `Const<{pointer}>`
error: aborting due to previous error