diff options
| author | bors <bors@rust-lang.org> | 2013-03-02 03:06:38 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-03-02 03:06:38 -0800 |
| commit | d3b94f6f341e935910aff59ea187af7b34055be8 (patch) | |
| tree | 4ebc50df64b0587a2b2216e8a4e7f8154f08924d /src/libsyntax | |
| parent | 2f901126d4c2c19334842e539561b15e7e74159d (diff) | |
| parent | dcd2f735606ea952425760edce2ac55a32850341 (diff) | |
| download | rust-d3b94f6f341e935910aff59ea187af7b34055be8.tar.gz rust-d3b94f6f341e935910aff59ea187af7b34055be8.zip | |
auto merge of #5193 : sethpink/rust/struct-tup-pp, r=catamorphism
- 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')
| -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| { |
