Fix printing of variadic extern fn with trailing comma

This commit is contained in:
David Tolnay 2022-09-18 17:11:28 -07:00
parent 42e9942cc6
commit 9b589ba216
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 3 additions and 14 deletions

View File

@ -2765,7 +2765,6 @@ mod printing {
use super::*;
use crate::attr::FilterAttrs;
use crate::print::TokensOrDefault;
use crate::punctuated::Pair;
use proc_macro2::TokenStream;
use quote::{ToTokens, TokenStreamExt};
@ -3283,16 +3282,9 @@ mod printing {
self.generics.to_tokens(tokens);
self.paren_token.surround(tokens, |tokens| {
let mut last_is_variadic = false;
for input in self.inputs.pairs() {
match input {
Pair::Punctuated(input, comma) => {
maybe_variadic_to_tokens(input, tokens);
comma.to_tokens(tokens);
}
Pair::End(input) => {
last_is_variadic = maybe_variadic_to_tokens(input, tokens);
}
}
for pair in self.inputs.pairs() {
last_is_variadic = maybe_variadic_to_tokens(pair.value(), tokens);
pair.punct().to_tokens(tokens);
}
if self.variadic.is_some() && !last_is_variadic {
if !self.inputs.empty_or_trailing() {

View File

@ -14,9 +14,6 @@ const REVISION: &str = "98ad6a5519651af36e246c0335c964dd52c554ba";
#[rustfmt::skip]
static EXCLUDE_FILES: &[&str] = &[
// TODO: trailing comma after variadic in extern fn signature
"src/tools/rust-analyzer/crates/parser/test_data/parser/ok/0063_variadic_fun.rs",
// TODO: impl ~const T {}
// https://github.com/dtolnay/syn/issues/1051
"src/test/ui/rfc-2632-const-trait-impl/syntax.rs",