diff --git a/src/libstd/repr.rs b/src/libstd/repr.rs index cc7d08847da..3e2c5773acc 100644 --- a/src/libstd/repr.rs +++ b/src/libstd/repr.rs @@ -412,10 +412,12 @@ impl<'self> TyVisitor for ReprVisitor<'self> { true } - fn visit_enter_class(&mut self, name: &str, _n_fields: uint, + fn visit_enter_class(&mut self, name: &str, n_fields: uint, _sz: uint, _align: uint) -> bool { self.writer.write(name.as_bytes()); - self.writer.write(['{' as u8]); + if n_fields != 0 { + self.writer.write(['{' as u8]); + } true } @@ -431,9 +433,11 @@ impl<'self> TyVisitor for ReprVisitor<'self> { true } - fn visit_leave_class(&mut self, _name: &str, _n_fields: uint, + fn visit_leave_class(&mut self, _name: &str, n_fields: uint, _sz: uint, _align: uint) -> bool { - self.writer.write(['}' as u8]); + if n_fields != 0 { + self.writer.write(['}' as u8]); + } true } @@ -650,5 +654,5 @@ fn test_repr() { "(10u64, ~\"hello\")"); struct Foo; - exact_test(&(~[Foo, Foo]), "~[repr::test_repr::Foo{}, repr::test_repr::Foo{}]"); + exact_test(&(~[Foo, Foo]), "~[repr::test_repr::Foo, repr::test_repr::Foo]"); } diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index f596520ba95..22c64c6b39c 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -3682,11 +3682,11 @@ mod tests { let xs = ~[Foo, Foo, Foo]; assert_eq!(fmt!("%?", xs.slice(0, 2).to_owned()), - ~"~[vec::tests::Foo{}, vec::tests::Foo{}]"); + ~"~[vec::tests::Foo, vec::tests::Foo]"); let xs: [Foo, ..3] = [Foo, Foo, Foo]; assert_eq!(fmt!("%?", xs.slice(0, 2).to_owned()), - ~"~[vec::tests::Foo{}, vec::tests::Foo{}]"); + ~"~[vec::tests::Foo, vec::tests::Foo]"); cnt = 0; for f in xs.iter() { assert!(*f == Foo); diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs index 32bb30720c5..c60c97552fa 100644 --- a/src/test/run-pass/ifmt.rs +++ b/src/test/run-pass/ifmt.rs @@ -29,7 +29,7 @@ pub fn main() { // Make sure there's a poly formatter that takes anything t!(format!("{:?}", 1), "1"); - t!(format!("{:?}", A), "A{}"); + t!(format!("{:?}", A), "A"); t!(format!("{:?}", ()), "()"); t!(format!("{:?}", @(~1, "foo")), "@(~1, \"foo\")");