repr: emit closing `)` for enum variants, test that nullary variants names print

This commit is contained in:
Niko Matsakis 2012-09-13 11:10:05 -07:00
parent e21b48c0ce
commit e0845eb589
2 changed files with 6 additions and 1 deletions

View File

@ -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

View File

@ -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);
}