@@ -239,7 +239,13 @@ fn rewrite_tuple_lit(context: &RewriteContext,
239
239
width : usize ,
240
240
offset : usize )
241
241
-> Option < String > {
242
+ debug ! ( "rewrite_tuple_lit: width: {}, offset: {}" , width, offset) ;
242
243
let indent = offset + 1 ;
244
+ // In case of length 1, need a trailing comma
245
+ if items. len ( ) == 1 {
246
+ // 3 = "(" + ",)"
247
+ return items[ 0 ] . rewrite ( context, width - 3 , indent) . map ( |s| format ! ( "({},)" , s) ) ;
248
+ }
243
249
244
250
let items = itemize_list ( context. codemap ,
245
251
Vec :: new ( ) ,
@@ -249,23 +255,16 @@ fn rewrite_tuple_lit(context: &RewriteContext,
249
255
|item| item. span . lo ,
250
256
|item| item. span . hi ,
251
257
|item| item. rewrite ( context,
252
- context. config . max_width - indent - 2 ,
258
+ context. config . max_width - indent - 1 ,
253
259
indent)
254
260
. unwrap_or ( context. codemap . span_to_snippet ( item. span )
255
261
. unwrap ( ) ) ,
256
262
span. lo + BytePos ( 1 ) , // Remove parens
257
263
span. hi - BytePos ( 1 ) ) ;
258
264
259
- // In case of length 1, need a trailing comma
260
- let trailing_separator_tactic = if items. len ( ) == 1 {
261
- SeparatorTactic :: Always
262
- } else {
263
- SeparatorTactic :: Never
264
- } ;
265
-
266
265
let fmt = ListFormatting { tactic : ListTactic :: HorizontalVertical ,
267
266
separator : "," ,
268
- trailing_separator : trailing_separator_tactic ,
267
+ trailing_separator : SeparatorTactic :: Never ,
269
268
indent : indent,
270
269
h_width : width - 2 ,
271
270
v_width : width - 2 ,
0 commit comments