Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions src/libsyntax/print/pprust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down
10 changes: 10 additions & 0 deletions src/test/pretty/struct-tuple.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// pp-exact
struct Foo;
struct Bar(int, int);

fn main() {
struct Foo2;
struct Bar2(int, int, int);
let a = Bar(5, 5);
let b = Foo;
}