Skip to content

Commit 7a6b4db

Browse files
committed
Handle tuples of length 1
1 parent 38f421b commit 7a6b4db

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/expr.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,10 @@ impl<'a> FmtVisitor<'a> {
198198
-> String {
199199
// opening paren
200200
let indent = offset + 1;
201+
// In case of length 1, need a trailing comma
202+
if items.len() == 1 {
203+
return format!("({},)", self.rewrite_expr(&*items[0], width - 3, indent));
204+
}
201205
// Only last line has width-1 as budget, other may take max_width
202206
let item_strs: Vec<_> =
203207
items.iter()

tests/idem/tuple.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ fn foo() {
77
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
88
aaaaaaaaaaaaaaaaaaaaaaaaa,
99
aaaa);
10+
let a = (a,);
1011
}

0 commit comments

Comments
 (0)