about summary refs log tree commit diff
path: root/src/librustc/mir
diff options
context:
space:
mode:
authorOliver Scherer <github35764891676564198441@oli-obk.de>2019-12-23 17:41:06 +0100
committerOliver Scherer <github35764891676564198441@oli-obk.de>2020-03-11 09:10:48 +0100
commit02dbb35b2b6ed869f14a8aecaf9dad5c72d5cb0b (patch)
tree39810e0ae552bae3763abcf960d7ea2e19826f80 /src/librustc/mir
parent15812785344d913d779d9738fe3cca8de56f71d5 (diff)
downloadrust-02dbb35b2b6ed869f14a8aecaf9dad5c72d5cb0b.tar.gz
rust-02dbb35b2b6ed869f14a8aecaf9dad5c72d5cb0b.zip
Deduplicate and clean up pretty printing logic
Diffstat (limited to 'src/librustc/mir')
-rw-r--r--src/librustc/mir/mod.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs
index b2413f5a2c8..d9f49b6784e 100644
--- a/src/librustc/mir/mod.rs
+++ b/src/librustc/mir/mod.rs
@@ -2562,15 +2562,15 @@ impl<'tcx> Debug for Constant<'tcx> {
 
 impl<'tcx> Display for Constant<'tcx> {
     fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
+        use crate::ty::print::PrettyPrinter;
         write!(fmt, "const ")?;
-        // FIXME make the default pretty printing of raw pointers more detailed. Here we output the
-        // debug representation of raw pointers, so that the raw pointers in the mir dump output are
-        // detailed and just not '{pointer}'.
-        if let ty::RawPtr(_) = self.literal.ty.kind {
-            write!(fmt, "{:?} : {}", self.literal.val, self.literal.ty)
-        } else {
-            write!(fmt, "{}", self.literal)
-        }
+        ty::tls::with(|tcx| {
+            let literal = tcx.lift(&self.literal).unwrap();
+            let mut cx = FmtPrinter::new(tcx, fmt, Namespace::ValueNS);
+            cx.print_alloc_ids = true;
+            cx.pretty_print_const(literal, true)?;
+            Ok(())
+        })
     }
 }