diff --git a/src/librustc/ty/print/pretty.rs b/src/librustc/ty/print/pretty.rs index d750fcdef89..86791ece5fc 100644 --- a/src/librustc/ty/print/pretty.rs +++ b/src/librustc/ty/print/pretty.rs @@ -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 { diff --git a/src/test/mir-opt/const_prop/discriminant.rs b/src/test/mir-opt/const_prop/discriminant.rs index b308d06999c..587f81f7f87 100644 --- a/src/test/mir-opt/const_prop/discriminant.rs +++ b/src/test/mir-opt/const_prop/discriminant.rs @@ -31,7 +31,7 @@ fn main() { // START rustc.main.ConstProp.after.mir // bb0: { // ... -// _3 = const {0x01: std::option::Option}; +// _3 = const {transmute(0x1): std::option::Option}; // _4 = const 1isize; // switchInt(const 1isize) -> [1isize: bb2, otherwise: bb1]; // } diff --git a/src/test/mir-opt/simplify-locals-removes-unused-consts.rs b/src/test/mir-opt/simplify-locals-removes-unused-consts.rs index ca8e60b9e39..730314a7888 100644 --- a/src/test/mir-opt/simplify-locals-removes-unused-consts.rs +++ b/src/test/mir-opt/simplify-locals-removes-unused-consts.rs @@ -1,18 +1,18 @@ // compile-flags: -C overflow-checks=no -fn use_zst(_: ((), ())) { } +fn use_zst(_: ((), ())) {} struct Temp { - x: u8 + x: u8, } -fn use_u8(_: u8) { } +fn use_u8(_: u8) {} fn main() { let ((), ()) = ((), ()); use_zst(((), ())); - use_u8((Temp { x : 40 }).x + 2); + use_u8((Temp { x: 40 }).x + 2); } // END RUST SOURCE @@ -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; diff --git a/src/test/ui/const-generics/raw-ptr-const-param.rs b/src/test/ui/const-generics/raw-ptr-const-param.rs index f8ae1b3fdc9..f0349f46962 100644 --- a/src/test/ui/const-generics/raw-ptr-const-param.rs +++ b/src/test/ui/const-generics/raw-ptr-const-param.rs @@ -1,12 +1,9 @@ -// 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 struct Const; fn main() { - let _: Const<{15 as *const _}> = Const::<{10 as *const _}>; //~ mismatched types - let _: Const<{10 as *const _}> = Const::<{10 as *const _}>; + let _: Const<{ 15 as *const _ }> = Const::<{ 10 as *const _ }>; //~ mismatched types + let _: Const<{ 10 as *const _ }> = Const::<{ 10 as *const _ }>; } diff --git a/src/test/ui/const-generics/raw-ptr-const-param.stderr b/src/test/ui/const-generics/raw-ptr-const-param.stderr index 850bb89e956..7bf2616fea2 100644 --- a/src/test/ui/const-generics/raw-ptr-const-param.stderr +++ b/src/test/ui/const-generics/raw-ptr-const-param.stderr @@ -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` +LL | let _: Const<{ 15 as *const _ }> = Const::<{ 10 as *const _ }>; + | ------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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