Skip to content

Commit

Permalink
Merge pull request #1444 from Fancyflame/master
Browse files Browse the repository at this point in the history
fixed the case when `TypeTuple::to_tokens` will result in `TypeParen`
  • Loading branch information
dtolnay committed Apr 13, 2023
2 parents 0f78bdf + 03e4f21 commit 2b7ba23
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/ty.rs
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 2b7ba23

Please sign in to comment.