Skip to content

Commit

Permalink
Rollup merge of #65859 - iwikal:pretty-const-pointers, r=cramertj
Browse files Browse the repository at this point in the history
Better pretty printing for const raw pointers

closes #65349, hopefully.
  • Loading branch information
Centril authored Oct 29, 2019
2 parents cb5f9e2 + 6a6ed12 commit 8a6462f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/librustc/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,10 @@ pub trait PrettyPrinter<'tcx>:
},
(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::Raw { data, size }), ty::RawPtr(_)) => {
p!(write("0x{:01$x} : ", data, size as usize * 2));
p!(print(ct.ty));
}
(ConstValue::Scalar(Scalar::Ptr(ptr)), ty::FnPtr(_)) => {
let instance = {
let alloc_map = self.tcx().alloc_map.lock();
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/const-generics/raw-ptr-const-param.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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 `{pointer}`, found `{pointer}`
| ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `0x000000000000000f : *const u32`, found `0x000000000000000a : *const u32`
|
= note: expected type `Const<{pointer}>`
found type `Const<{pointer}>`
= note: expected type `Const<0x000000000000000f : *const u32>`
found type `Const<0x000000000000000a : *const u32>`

error: aborting due to previous error

Expand Down

0 comments on commit 8a6462f

Please sign in to comment.