From e0845eb589c69ebc5f4c572cc7d43b1d9bbc4b9c Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Thu, 13 Sep 2012 11:10:05 -0700 Subject: [PATCH] repr: emit closing `)` for enum variants, test that nullary variants names print --- src/libcore/repr.rs | 2 +- src/test/run-pass/log-knows-the-names-of-variants.rs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) 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); }