From 03e4f217bdf7f3bbeff9a96919106abde2bebd03 Mon Sep 17 00:00:00 2001 From: FancyFlame Date: Thu, 13 Apr 2023 20:54:50 +0800 Subject: [PATCH] fix TypeTuple::to_tokens may result in TypeParen --- src/ty.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ty.rs b/src/ty.rs index 9b341dafaf..9282ba4e61 100644 --- a/src/ty.rs +++ b/src/ty.rs @@ -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() { + ::default().to_tokens(tokens); + } }); } }