summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2012-09-13 11:10:05 -0700
committerNiko Matsakis <niko@alum.mit.edu>2012-09-13 11:10:05 -0700
commite0845eb589c69ebc5f4c572cc7d43b1d9bbc4b9c (patch)
tree3e0fb4ae5dfda4d5ddf8bdce391ee684d8ce3630 /src
parente21b48c0ce07cc70116dd7f3f7b4231e97769c11 (diff)
downloadrust-e0845eb589c69ebc5f4c572cc7d43b1d9bbc4b9c.tar.gz
rust-e0845eb589c69ebc5f4c572cc7d43b1d9bbc4b9c.zip
repr: emit closing `)` for enum variants, test that nullary variants names print
Diffstat (limited to 'src')
-rw-r--r--src/libcore/repr.rs2
-rw-r--r--src/test/run-pass/log-knows-the-names-of-variants.rs5
2 files changed, 6 insertions, 1 deletions
diff --git a/src/libcore/repr.rs b/src/libcore/repr.rs
index f052016ed6c..f36bc5367f7 100644
--- a/src/libcore/repr.rs
+++ b/src/libcore/repr.rs
@@ -508,7 +508,7 @@ impl ReprPrinterWrapper : TyVisitor {
                                 _disr_val: int,
                                 n_fields: uint,
                                 _name: &str) -> bool {
-        if !self.printer.skip && n_fields > 1 {
+        if !self.printer.skip && n_fields >= 1 {
             self.printer.writer.write_char(')');
         }
         true
diff --git a/src/test/run-pass/log-knows-the-names-of-variants.rs b/src/test/run-pass/log-knows-the-names-of-variants.rs
index eaba075793b..7c1eea3dd32 100644
--- a/src/test/run-pass/log-knows-the-names-of-variants.rs
+++ b/src/test/run-pass/log-knows-the-names-of-variants.rs
@@ -4,8 +4,13 @@ enum foo {
   c,
 }
 
+enum bar {
+  d, e, f
+}
+
 fn main() {
     assert ~"a(22)" == fmt!("%?", a(22u));
     assert ~"b(~\"hi\")" == fmt!("%?", b(~"hi"));
     assert ~"c" == fmt!("%?", c);
+    assert ~"d" == fmt!("%?", d);
 }