]> git.lizzy.rs Git - rust.git/commitdiff
Pretty print empty structs properly
authorNick Cameron <ncameron@mozilla.com>
Sun, 4 Jan 2015 23:02:47 +0000 (12:02 +1300)
committerNick Cameron <ncameron@mozilla.com>
Tue, 6 Jan 2015 21:49:00 +0000 (10:49 +1300)
src/libsyntax/print/pprust.rs

index 9a38f6c8ac325d0dc928912989b10004f859c8a5..721769be7a461c19b28b2b3fb42140ea45b356fe 100644 (file)
@@ -1537,6 +1537,9 @@ pub fn print_expr(&mut self, expr: &ast::Expr) -> IoResult<()> {
 
             ast::ExprStruct(ref path, ref fields, ref wth) => {
                 try!(self.print_path(path, true));
+                if fields.is_empty() && wth.is_none() {
+                    return;
+                }
                 try!(word(&mut self.s, "{"));
                 try!(self.commasep_cmnt(
                     Consistent,
@@ -1560,7 +1563,7 @@ pub fn print_expr(&mut self, expr: &ast::Expr) -> IoResult<()> {
                         try!(self.print_expr(&**expr));
                         try!(self.end());
                     }
-                    _ => try!(word(&mut self.s, ","))
+                    _ => try!(word(&mut self.s, ",")),
                 }
                 try!(word(&mut self.s, "}"));
             }