Skip to content

Commit 65f189a

Browse files
nrcnikomatsakis
authored andcommitted
Pretty print empty structs properly
1 parent a60f9ca commit 65f189a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/libsyntax/print/pprust.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1553,6 +1553,9 @@ impl<'a> State<'a> {
15531553

15541554
ast::ExprStruct(ref path, ref fields, ref wth) => {
15551555
try!(self.print_path(path, true));
1556+
if fields.is_empty() && wth.is_none() {
1557+
return;
1558+
}
15561559
try!(word(&mut self.s, "{"));
15571560
try!(self.commasep_cmnt(
15581561
Consistent,
@@ -1576,7 +1579,7 @@ impl<'a> State<'a> {
15761579
try!(self.print_expr(&**expr));
15771580
try!(self.end());
15781581
}
1579-
_ => try!(word(&mut self.s, ","))
1582+
_ => try!(word(&mut self.s, ",")),
15801583
}
15811584
try!(word(&mut self.s, "}"));
15821585
}

0 commit comments

Comments
 (0)