@@ -672,36 +672,61 @@ fn print_struct(s: ps, struct_def: @ast::struct_def, tps: ~[ast::ty_param],
672
672
commasep ( s, inconsistent, struct_def. traits , |s, p|
673
673
print_path ( s, p. path , false ) ) ;
674
674
}
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 ) ;
693
690
}
694
- print_ident(s, ident);
695
- word_nbsp(s, ~" : ") ;
696
- print_type( s, field. node. ty) ;
697
- word( s. s, ~", ");
698
691
}
699
692
}
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);
700
729
}
701
- for struct_def.methods.each |method| {
702
- print_method(s, *method);
703
- }
704
- bclose(s, span);
705
730
}
706
731
707
732
/// This doesn't deserve to be called " pretty" printing, but it should be
0 commit comments