]> git.lizzy.rs Git - rust.git/commitdiff
Print leading zeros for non pointers
authorOliver Scherer <github35764891676564198441@oli-obk.de>
Mon, 10 Feb 2020 16:05:18 +0000 (17:05 +0100)
committerOliver Scherer <github35764891676564198441@oli-obk.de>
Wed, 11 Mar 2020 08:10:49 +0000 (09:10 +0100)
src/librustc/ty/print/pretty.rs
src/test/mir-opt/const_prop/discriminant.rs

index 446bb3db0046485517e97fe4e513a5dbcb1c9d40..76503eb10fcf38c995f05a1f994fba14c21f447f 100644 (file)
@@ -988,9 +988,9 @@ fn pretty_print_const_scalar(
             // 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, .. }, _) => {
+            (Scalar::Raw { data, size }, _) => {
                 let print = |mut this: Self| {
-                    write!(this, "transmute(0x{:x})", data)?;
+                    write!(this, "transmute(0x{:01$x})", data, size as usize * 2)?;
                     Ok(this)
                 };
                 self = if print_ty {
index 587f81f7f879ee4e23f14eaccb37b125a9f523d4..636aa1af6533341513200eb57adda716331d6488 100644 (file)
@@ -31,7 +31,7 @@ fn main() {
 // START rustc.main.ConstProp.after.mir
 //  bb0: {
 //      ...
-//      _3 = const {transmute(0x1): std::option::Option<bool>};
+//      _3 = const {transmute(0x01): std::option::Option<bool>};
 //      _4 = const 1isize;
 //      switchInt(const 1isize) -> [1isize: bb2, otherwise: bb1];
 //  }