]> git.lizzy.rs Git - rust.git/commitdiff
Implement Debug for PlaceBase
authorSantiago Pastorino <spastorino@gmail.com>
Thu, 20 Jun 2019 01:02:53 +0000 (03:02 +0200)
committerSantiago Pastorino <spastorino@gmail.com>
Thu, 20 Jun 2019 12:25:58 +0000 (14:25 +0200)
src/librustc/mir/mod.rs

index 9dfd8d959a3c4d29f3a3e2564f161ac8caffd3e3..6e09cc045282806cdf89801bd051f3180fda47ae 100644 (file)
@@ -2184,29 +2184,7 @@ fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
         });
 
         self.iterate(|place_base, place_projections| {
-            match place_base {
-                PlaceBase::Local(id) => {
-                    write!(fmt, "{:?}", id)?;
-                }
-                PlaceBase::Static(box self::Static { ty, kind: StaticKind::Static(def_id) }) => {
-                    write!(
-                        fmt,
-                        "({}: {:?})",
-                        ty::tls::with(|tcx| tcx.def_path_str(*def_id)),
-                        ty
-                    )?;
-                },
-                PlaceBase::Static(
-                    box self::Static { ty, kind: StaticKind::Promoted(promoted) }
-                ) => {
-                    write!(
-                        fmt,
-                        "({:?}: {:?})",
-                        promoted,
-                        ty
-                    )?;
-                },
-            }
+            write!(fmt, "{:?}", place_base)?;
 
             for projection in place_projections {
                 match projection.elem {
@@ -2256,6 +2234,30 @@ fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
     }
 }
 
+impl Debug for PlaceBase<'_> {
+    fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
+        match *self {
+            PlaceBase::Local(id) => write!(fmt, "{:?}", id),
+            PlaceBase::Static(box self::Static { ty, kind: StaticKind::Static(def_id) }) => {
+                write!(
+                    fmt,
+                    "({}: {:?})",
+                    ty::tls::with(|tcx| tcx.def_path_str(def_id)),
+                    ty
+                )
+            },
+            PlaceBase::Static(box self::Static { ty, kind: StaticKind::Promoted(promoted) }) => {
+                write!(
+                    fmt,
+                    "({:?}: {:?})",
+                    promoted,
+                    ty
+                )
+            },
+        }
+    }
+}
+
 ///////////////////////////////////////////////////////////////////////////
 // Scopes