about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2014-02-07 14:51:18 -0500
committerNiko Matsakis <niko@alum.mit.edu>2014-02-11 16:55:23 -0500
commit42cd820c62c531f20d763281c7cc2bdaa1e0a89a (patch)
tree9a4415d3393c5ab79e590215a7bca96c060f86a2 /src
parent95c53c049c9ced13c325c9aade22affbf5d97fa3 (diff)
ppaux -- add Repr implementations
Diffstat (limited to 'src')
-rw-r--r--src/librustc/util/ppaux.rs46
1 files changed, 45 insertions, 1 deletions
diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs
index 5a9c3fd031d..afac501835d 100644
--- a/src/librustc/util/ppaux.rs
+++ b/src/librustc/util/ppaux.rs
@@ -565,11 +565,26 @@ impl<T:Repr> Repr for Option<T> {
     fn repr(&self, tcx: ctxt) -> ~str {
         match self {
             &None => ~"None",
-            &Some(ref t) => format!("Some({})", t.repr(tcx))
+            &Some(ref t) => t.repr(tcx),
         }
     }
 }
 
+impl<T:Repr,U:Repr> Repr for Result<T,U> {
+    fn repr(&self, tcx: ctxt) -> ~str {
+        match self {
+            &Ok(ref t) => t.repr(tcx),
+            &Err(ref u) => format!("Err({})", u.repr(tcx))
+        }
+    }
+}
+
+impl Repr for () {
+    fn repr(&self, _tcx: ctxt) -> ~str {
+        ~"()"
+    }
+}
+
 impl<T:Repr> Repr for @T {
     fn repr(&self, tcx: ctxt) -> ~str {
         (&**self).repr(tcx)
@@ -1021,3 +1036,32 @@ impl UserString for AbiSet {
         self.to_str()
     }
 }
+
+impl Repr for ty::UpvarId {
+    fn repr(&self, tcx: ctxt) -> ~str {
+        format!("UpvarId({};`{}`;{})",
+             self.var_id,
+             ty::local_var_name_str(tcx, self.var_id),
+             self.closure_expr_id)
+    }
+}
+
+impl Repr for ast::Mutability {
+    fn repr(&self, _tcx: ctxt) -> ~str {
+        format!("{:?}", *self)
+    }
+}
+
+impl Repr for ty::BorrowKind {
+    fn repr(&self, _tcx: ctxt) -> ~str {
+        format!("{:?}", *self)
+    }
+}
+
+impl Repr for ty::UpvarBorrow {
+    fn repr(&self, tcx: ctxt) -> ~str {
+        format!("UpvarBorrow({}, {})",
+             self.kind.repr(tcx),
+             self.region.repr(tcx))
+    }
+}