diff options
| author | Seth Pink <sethpink@gmail.com> | 2013-03-02 12:42:02 +1000 |
|---|---|---|
| committer | Seth Pink <sethpink@gmail.com> | 2013-03-02 13:32:40 +1000 |
| commit | dcd2f735606ea952425760edce2ac55a32850341 (patch) | |
| tree | c32024bd5237bf7ad11a112a35a48e8565aeb6d8 /src/libsyntax/print | |
| parent | 0fd1b58f236b4fe653d164836e94feebb2972931 (diff) | |
| download | rust-dcd2f735606ea952425760edce2ac55a32850341.tar.gz rust-dcd2f735606ea952425760edce2ac55a32850341.zip | |
Fix some struct-tuple def prettyprint issues
- Removed space between struct name and parentheses - Fixed indentation of the rest of the file (missing end) - Don't print parentheses for structs with no fields - Added test
Diffstat (limited to 'src/libsyntax/print')
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 0f161a444bd..9bbed28b388 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -713,30 +713,26 @@ pub fn print_struct(s: @ps, ident: ast::ident, span: codemap::span) { print_ident(s, ident); - nbsp(s); print_generics(s, generics); if ast_util::struct_def_is_tuple_like(struct_def) { - popen(s); - let mut first = true; - for struct_def.fields.each |field| { - if first { - first = false; - } else { - word_space(s, ~","); - } - - match field.node.kind { - ast::named_field(*) => fail!(~"unexpected named field"), - ast::unnamed_field => { - maybe_print_comment(s, field.span.lo); - print_type(s, field.node.ty); + if !struct_def.fields.is_empty() { + popen(s); + do commasep(s, inconsistent, struct_def.fields) |s, field| { + match field.node.kind { + ast::named_field(*) => fail!(~"unexpected named field"), + ast::unnamed_field => { + maybe_print_comment(s, field.span.lo); + print_type(s, field.node.ty); + } } } + pclose(s); } - pclose(s); word(s.s, ~";"); + end(s); end(s); // close the outer-box } else { + nbsp(s); bopen(s); hardbreak_if_not_bol(s); do struct_def.dtor.iter |dtor| { |
