about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorOliver Scherer <github35764891676564198441@oli-obk.de>2020-02-10 15:36:14 +0100
committerOliver Scherer <github35764891676564198441@oli-obk.de>2020-03-11 09:10:49 +0100
commitb837e7173236b27ba76660864cd160aacbe66c57 (patch)
treeadae746393df59412febbb2332b25606ebac65ef /src
parente22ddfd80d840f310d00fc756ab298caa181a326 (diff)
downloadrust-b837e7173236b27ba76660864cd160aacbe66c57.tar.gz
rust-b837e7173236b27ba76660864cd160aacbe66c57.zip
Reduce special casing in the const pretty printer
Diffstat (limited to 'src')
-rw-r--r--src/librustc/ty/print/pretty.rs12
-rw-r--r--src/test/ui/const-generics/raw-ptr-const-param.stderr6
2 files changed, 6 insertions, 12 deletions
diff --git a/src/librustc/ty/print/pretty.rs b/src/librustc/ty/print/pretty.rs
index 86791ece5fc..446bb3db004 100644
--- a/src/librustc/ty/print/pretty.rs
+++ b/src/librustc/ty/print/pretty.rs
@@ -937,7 +937,6 @@ pub trait PrettyPrinter<'tcx>:
             // Bool
             (Scalar::Raw { data: 0, .. }, ty::Bool) => p!(write("false")),
             (Scalar::Raw { data: 1, .. }, ty::Bool) => p!(write("true")),
-            (Scalar::Raw { data, .. }, ty::Bool) => p!(write("{}_bool", data)),
             // Float
             (Scalar::Raw { data, .. }, ty::Float(ast::FloatTy::F32)) => {
                 p!(write("{}f32", Single::from_bits(data)))
@@ -975,14 +974,9 @@ pub trait PrettyPrinter<'tcx>:
                 Some(c) => p!(write("{:?}", c)),
                 None => p!(write("{}_char", data)),
             },
-            // References and pointers
-            (Scalar::Raw { data: 0, .. }, ty::RawPtr(_)) => p!(write("{{null pointer}}")),
-            // This is UB, but we still print it
-            (Scalar::Raw { data: 0, .. }, ty::Ref(_, ty, _)) => {
-                p!(write("{{null reference to "), print(ty), write("}}"))
-            }
-            (Scalar::Raw { data, .. }, ty::Ref(..)) | (Scalar::Raw { data, .. }, ty::RawPtr(_)) => {
-                p!(write("0x{:x}", data))
+            // Raw pointers
+            (Scalar::Raw { data, .. }, ty::RawPtr(_)) => {
+                p!(write("{{0x{:x} as ", data), print(ty), write("}}"))
             }
             (Scalar::Ptr(ptr), ty::FnPtr(_)) => {
                 let instance = {
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 7bf2616fea2..d9794f60a19 100644
--- a/src/test/ui/const-generics/raw-ptr-const-param.stderr
+++ b/src/test/ui/const-generics/raw-ptr-const-param.stderr
@@ -10,12 +10,12 @@ error[E0308]: mismatched types
   --> $DIR/raw-ptr-const-param.rs:7:40
    |
 LL |     let _: Const<{ 15 as *const _ }> = Const::<{ 10 as *const _ }>;
-   |            -------------------------   ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `0xf`, found `0xa`
+   |            -------------------------   ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `{0xf as *const u32}`, found `{0xa as *const u32}`
    |            |
    |            expected due to this
    |
-   = note: expected struct `Const<0xf>`
-              found struct `Const<0xa>`
+   = note: expected struct `Const<{0xf as *const u32}>`
+              found struct `Const<{0xa as *const u32}>`
 
 error: aborting due to previous error