Skip to content

Commit

Permalink
fix TypeTuple::to_tokens may result in TypeParen
Browse files Browse the repository at this point in the history
  • Loading branch information
Fancyflame committed Apr 13, 2023
1 parent 0f78bdf commit 03e4f21
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,11 @@ mod printing {
fn to_tokens(&self, tokens: &mut TokenStream) {
self.paren_token.surround(tokens, |tokens| {
self.elems.to_tokens(tokens);
// If we only have one argument, we need a trailing comma to
// distinguish TypeTuple from TypeParen.
if self.elems.len() == 1 && !self.elems.trailing_punct() {
<Token![,]>::default().to_tokens(tokens);
}
});
}
}
Expand Down

0 comments on commit 03e4f21

Please sign in to comment.