Skip to content

Commit 8f5e8de

Browse files
committed
---
yaml --- r: 40223 b: refs/heads/dist-snap c: c7ec183 h: refs/heads/master i: 40221: f8635d9 40219: 32f3d87 40215: 5fa8bd7 40207: 18e6898 40191: 367ab00 v: v3
1 parent c0c1350 commit 8f5e8de

File tree

2 files changed

+52
-27
lines changed

2 files changed

+52
-27
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278
99
refs/heads/incoming: e90142e536c150df0d9b4b2f11352152177509b5
10-
refs/heads/dist-snap: c851d2a1bc7683d0eb662ac1fcf6aecfe90cce4f
10+
refs/heads/dist-snap: c7ec183b34805ba6af0c49581639b16dbd33e47a
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/libsyntax/print/pprust.rs

Lines changed: 51 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -672,36 +672,61 @@ fn print_struct(s: ps, struct_def: @ast::struct_def, tps: ~[ast::ty_param],
672672
commasep(s, inconsistent, struct_def.traits, |s, p|
673673
print_path(s, p.path, false));
674674
}
675-
bopen(s);
676-
hardbreak_if_not_bol(s);
677-
do struct_def.dtor.iter |dtor| {
678-
hardbreak_if_not_bol(s);
679-
maybe_print_comment(s, dtor.span.lo);
680-
print_outer_attributes(s, dtor.node.attrs);
681-
head(s, ~"drop");
682-
print_block(s, dtor.node.body);
683-
}
684-
for struct_def.fields.each |field| {
685-
match field.node.kind {
686-
ast::unnamed_field => {} // We don't print here.
687-
ast::named_field(ident, mutability, visibility) => {
688-
hardbreak_if_not_bol(s);
689-
maybe_print_comment(s, field.span.lo);
690-
print_visibility(s, visibility);
691-
if mutability == ast::class_mutable {
692-
word_nbsp(s, ~"mut");
675+
if ast_util::struct_def_is_tuple_like(struct_def) {
676+
popen(s);
677+
let mut first = true;
678+
for struct_def.fields.each |field| {
679+
if first {
680+
first = false;
681+
} else {
682+
word_space(s, ~",");
683+
}
684+
685+
match field.node.kind {
686+
ast::named_field(*) => fail ~"unexpected named field",
687+
ast::unnamed_field => {
688+
maybe_print_comment(s, field.span.lo);
689+
print_type(s, field.node.ty);
693690
}
694-
print_ident(s, ident);
695-
word_nbsp(s, ~":");
696-
print_type(s, field.node.ty);
697-
word(s.s, ~",");
698691
}
699692
}
693+
pclose(s);
694+
word(s.s, ~";");
695+
end(s); // close the outer-box
696+
} else {
697+
bopen(s);
698+
hardbreak_if_not_bol(s);
699+
do struct_def.dtor.iter |dtor| {
700+
hardbreak_if_not_bol(s);
701+
maybe_print_comment(s, dtor.span.lo);
702+
print_outer_attributes(s, dtor.node.attrs);
703+
head(s, ~"drop");
704+
print_block(s, dtor.node.body);
705+
}
706+
707+
for struct_def.fields.each |field| {
708+
match field.node.kind {
709+
ast::unnamed_field => fail ~"unexpected unnamed field",
710+
ast::named_field(ident, mutability, visibility) => {
711+
hardbreak_if_not_bol(s);
712+
maybe_print_comment(s, field.span.lo);
713+
print_visibility(s, visibility);
714+
if mutability == ast::class_mutable {
715+
word_nbsp(s, ~"mut");
716+
}
717+
print_ident(s, ident);
718+
word_nbsp(s, ~":");
719+
print_type(s, field.node.ty);
720+
word(s.s, ~",");
721+
}
722+
}
723+
}
724+
725+
for struct_def.methods.each |method| {
726+
print_method(s, *method);
727+
}
728+
bclose(s, span);
700729
}
701-
for struct_def.methods.each |method| {
702-
print_method(s, *method);
703-
}
704-
bclose(s, span);
705730
}
706731
707732
/// This doesn't deserve to be called "pretty" printing, but it should be

0 commit comments

Comments
 (0)