mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
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("}}"))
|
||||
}
|
||||
(Scalar::Raw { data, .. }, ty::Ref(..)) | (Scalar::Raw { data, .. }, ty::RawPtr(_)) => {
|
||||
let pointer_width = self.tcx().data_layout.pointer_size.bytes();
|
||||
p!(write("0x{:01$x}", data, pointer_width as usize * 2))
|
||||
p!(write("0x{:x}", data))
|
||||
}
|
||||
(Scalar::Ptr(ptr), ty::FnPtr(_)) => {
|
||||
let instance = {
|
||||
@ -995,9 +994,9 @@ pub trait PrettyPrinter<'tcx>:
|
||||
// For zsts just print their type as their value gives no extra information
|
||||
(Scalar::Raw { size: 0, .. }, _) => p!(print(ty)),
|
||||
// Nontrivial types with scalar bit representation
|
||||
(Scalar::Raw { data, size }, _) => {
|
||||
(Scalar::Raw { data, .. }, _) => {
|
||||
let print = |mut this: Self| {
|
||||
write!(this, "0x{:01$x}", data, size as usize * 2)?;
|
||||
write!(this, "transmute(0x{:x})", data)?;
|
||||
Ok(this)
|
||||
};
|
||||
self = if print_ty {
|
||||
|
@ -31,7 +31,7 @@ fn main() {
|
||||
// START rustc.main.ConstProp.after.mir
|
||||
// bb0: {
|
||||
// ...
|
||||
// _3 = const {0x01: std::option::Option<bool>};
|
||||
// _3 = const {transmute(0x1): std::option::Option<bool>};
|
||||
// _4 = const 1isize;
|
||||
// switchInt(const 1isize) -> [1isize: bb2, otherwise: bb1];
|
||||
// }
|
||||
|
@ -3,7 +3,7 @@
|
||||
fn use_zst(_: ((), ())) {}
|
||||
|
||||
struct Temp {
|
||||
x: u8
|
||||
x: u8,
|
||||
}
|
||||
|
||||
fn use_u8(_: u8) {}
|
||||
@ -56,7 +56,7 @@ fn main() {
|
||||
// StorageLive(_8);
|
||||
// StorageLive(_10);
|
||||
// StorageLive(_11);
|
||||
// _11 = const {0x28 : Temp};
|
||||
// _11 = const {transmute(0x28) : Temp};
|
||||
// _10 = const 40u8;
|
||||
// StorageDead(_10);
|
||||
// _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)]
|
||||
//~^ 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
|
||||
--> $DIR/raw-ptr-const-param.rs:4:12
|
||||
--> $DIR/raw-ptr-const-param.rs:1:12
|
||||
|
|
||||
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
|
||||
|
||||
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 _ }>;
|
||||
| ----------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `0x[PREFIX]0000000f`, found `0x[PREFIX]0000000a`
|
||||
| ------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `0xf`, found `0xa`
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected struct `Const<0x[PREFIX]0000000f>`
|
||||
found struct `Const<0x[PREFIX]0000000a>`
|
||||
= note: expected struct `Const<0xf>`
|
||||
found struct `Const<0xa>`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user