Skip to content

Commit 791f545

Browse files
committed
Pretty print empty structs properly
1 parent 480374a commit 791f545

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
@@ -1537,6 +1537,9 @@ impl<'a> State<'a> {
15371537

15381538
ast::ExprStruct(ref path, ref fields, ref wth) => {
15391539
try!(self.print_path(path, true));
1540+
if fields.is_empty() && wth.is_none() {
1541+
return;
1542+
}
15401543
try!(word(&mut self.s, "{"));
15411544
try!(self.commasep_cmnt(
15421545
Consistent,
@@ -1560,7 +1563,7 @@ impl<'a> State<'a> {
15601563
try!(self.print_expr(&**expr));
15611564
try!(self.end());
15621565
}
1563-
_ => try!(word(&mut self.s, ","))
1566+
_ => try!(word(&mut self.s, ",")),
15641567
}
15651568
try!(word(&mut self.s, "}"));
15661569
}

0 commit comments

Comments
 (0)