Don't print leading zeros on hex dumps constants
This commit is contained in:
parent
4ddb4bdaad
commit
e22ddfd80d
@ -982,8 +982,7 @@ pub trait PrettyPrinter<'tcx>:
|
|||||||
p!(write("{{null reference to "), print(ty), write("}}"))
|
p!(write("{{null reference to "), print(ty), write("}}"))
|
||||||
}
|
}
|
||||||
(Scalar::Raw { data, .. }, ty::Ref(..)) | (Scalar::Raw { data, .. }, ty::RawPtr(_)) => {
|
(Scalar::Raw { data, .. }, ty::Ref(..)) | (Scalar::Raw { data, .. }, ty::RawPtr(_)) => {
|
||||||
let pointer_width = self.tcx().data_layout.pointer_size.bytes();
|
p!(write("0x{:x}", data))
|
||||||
p!(write("0x{:01$x}", data, pointer_width as usize * 2))
|
|
||||||
}
|
}
|
||||||
(Scalar::Ptr(ptr), ty::FnPtr(_)) => {
|
(Scalar::Ptr(ptr), ty::FnPtr(_)) => {
|
||||||
let instance = {
|
let instance = {
|
||||||
@ -995,9 +994,9 @@ pub trait PrettyPrinter<'tcx>:
|
|||||||
// For zsts just print their type as their value gives no extra information
|
// For zsts just print their type as their value gives no extra information
|
||||||
(Scalar::Raw { size: 0, .. }, _) => p!(print(ty)),
|
(Scalar::Raw { size: 0, .. }, _) => p!(print(ty)),
|
||||||
// Nontrivial types with scalar bit representation
|
// Nontrivial types with scalar bit representation
|
||||||
(Scalar::Raw { data, size }, _) => {
|
(Scalar::Raw { data, .. }, _) => {
|
||||||
let print = |mut this: Self| {
|
let print = |mut this: Self| {
|
||||||
write!(this, "0x{:01$x}", data, size as usize * 2)?;
|
write!(this, "transmute(0x{:x})", data)?;
|
||||||
Ok(this)
|
Ok(this)
|
||||||
};
|
};
|
||||||
self = if print_ty {
|
self = if print_ty {
|
||||||
|
@ -31,7 +31,7 @@ fn main() {
|
|||||||
// START rustc.main.ConstProp.after.mir
|
// START rustc.main.ConstProp.after.mir
|
||||||
// bb0: {
|
// bb0: {
|
||||||
// ...
|
// ...
|
||||||
// _3 = const {0x01: std::option::Option<bool>};
|
// _3 = const {transmute(0x1): std::option::Option<bool>};
|
||||||
// _4 = const 1isize;
|
// _4 = const 1isize;
|
||||||
// switchInt(const 1isize) -> [1isize: bb2, otherwise: bb1];
|
// switchInt(const 1isize) -> [1isize: bb2, otherwise: bb1];
|
||||||
// }
|
// }
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
fn use_zst(_: ((), ())) {}
|
fn use_zst(_: ((), ())) {}
|
||||||
|
|
||||||
struct Temp {
|
struct Temp {
|
||||||
x: u8
|
x: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn use_u8(_: u8) {}
|
fn use_u8(_: u8) {}
|
||||||
@ -56,7 +56,7 @@ fn main() {
|
|||||||
// StorageLive(_8);
|
// StorageLive(_8);
|
||||||
// StorageLive(_10);
|
// StorageLive(_10);
|
||||||
// StorageLive(_11);
|
// StorageLive(_11);
|
||||||
// _11 = const {0x28 : Temp};
|
// _11 = const {transmute(0x28) : Temp};
|
||||||
// _10 = const 40u8;
|
// _10 = const 40u8;
|
||||||
// StorageDead(_10);
|
// StorageDead(_10);
|
||||||
// _8 = const use_u8(const 42u8) -> bb2;
|
// _8 = const use_u8(const 42u8) -> bb2;
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
// normalize-stderr-64bit "0x00000000" -> "0x[PREFIX]"
|
|
||||||
// normalize-stderr-32bit "0x" -> "0x[PREFIX]"
|
|
||||||
|
|
||||||
#![feature(const_generics, const_compare_raw_pointers)]
|
#![feature(const_generics, const_compare_raw_pointers)]
|
||||||
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
|
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
|
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
|
||||||
--> $DIR/raw-ptr-const-param.rs:4:12
|
--> $DIR/raw-ptr-const-param.rs:1:12
|
||||||
|
|
|
|
||||||
LL | #![feature(const_generics, const_compare_raw_pointers)]
|
LL | #![feature(const_generics, const_compare_raw_pointers)]
|
||||||
| ^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^
|
||||||
@ -7,15 +7,15 @@ LL | #![feature(const_generics, const_compare_raw_pointers)]
|
|||||||
= note: `#[warn(incomplete_features)]` on by default
|
= note: `#[warn(incomplete_features)]` on by default
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/raw-ptr-const-param.rs:10:38
|
--> $DIR/raw-ptr-const-param.rs:7:40
|
||||||
|
|
|
|
||||||
LL | let _: Const<{ 15 as *const _ }> = Const::<{ 10 as *const _ }>;
|
LL | let _: Const<{ 15 as *const _ }> = Const::<{ 10 as *const _ }>;
|
||||||
| ----------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `0x[PREFIX]0000000f`, found `0x[PREFIX]0000000a`
|
| ------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `0xf`, found `0xa`
|
||||||
| |
|
| |
|
||||||
| expected due to this
|
| expected due to this
|
||||||
|
|
|
|
||||||
= note: expected struct `Const<0x[PREFIX]0000000f>`
|
= note: expected struct `Const<0xf>`
|
||||||
found struct `Const<0x[PREFIX]0000000a>`
|
found struct `Const<0xa>`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user