@@ -533,8 +533,8 @@ impl<'a> FmtVisitor<'a> {
533
533
}
534
534
535
535
let context = self . get_context ( ) ;
536
- let indent = self . block_indent ;
537
- let shape = self . shape ( ) ;
536
+ // 1 = ','
537
+ let shape = self . shape ( ) . sub_width ( 1 ) ? ;
538
538
let attrs_str = field. node . attrs . rewrite ( & context, shape) ?;
539
539
let lo = field
540
540
. node
@@ -544,19 +544,15 @@ impl<'a> FmtVisitor<'a> {
544
544
let span = mk_sp ( lo, field. span . lo ( ) ) ;
545
545
546
546
let variant_body = match field. node . data {
547
- ast:: VariantData :: Tuple ( ..) | ast:: VariantData :: Struct ( ..) => {
548
- // FIXME: Should limit the width, as we have a trailing comma
549
- format_struct (
550
- & context,
551
- & StructParts :: from_variant ( field) ,
552
- indent,
553
- Some ( one_line_width) ,
554
- ) ?
555
- }
547
+ ast:: VariantData :: Tuple ( ..) | ast:: VariantData :: Struct ( ..) => format_struct (
548
+ & context,
549
+ & StructParts :: from_variant ( field) ,
550
+ self . block_indent ,
551
+ Some ( one_line_width) ,
552
+ ) ?,
556
553
ast:: VariantData :: Unit ( ..) => if let Some ( ref expr) = field. node . disr_expr {
557
554
let lhs = format ! ( "{} =" , field. node. name) ;
558
- // 1 = ','
559
- rewrite_assign_rhs ( & context, lhs, & * * expr, shape. sub_width ( 1 ) ?) ?
555
+ rewrite_assign_rhs ( & context, lhs, & * * expr, shape) ?
560
556
} else {
561
557
field. node . name . to_string ( )
562
558
} ,
@@ -1312,7 +1308,7 @@ fn format_tuple_struct(
1312
1308
}
1313
1309
result. push ( ')' ) ;
1314
1310
} else {
1315
- let shape = Shape :: indented ( offset, context. config ) ;
1311
+ let shape = Shape :: indented ( offset, context. config ) . sub_width ( 1 ) ? ;
1316
1312
let fields = & fields. iter ( ) . map ( |field| field) . collect :: < Vec < _ > > ( ) [ ..] ;
1317
1313
let one_line_width = context. config . width_heuristics ( ) . fn_call_width ;
1318
1314
result = rewrite_call_inner ( context, & result, fields, span, shape, one_line_width, false ) ?;
0 commit comments