diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index 9cae080aeb3..ff4385c3bcc 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -2165,7 +2165,9 @@ impl<'a> State<'a> { s.end(); }); if decl.c_variadic { - self.word(", "); + if !decl.inputs.is_empty() { + self.word(", "); + } print_arg(self, None); self.word("..."); } diff --git a/tests/pretty/hir-fn-variadic.pp b/tests/pretty/hir-fn-variadic.pp index 136e8b44ec2..b6bc8e95127 100644 --- a/tests/pretty/hir-fn-variadic.pp +++ b/tests/pretty/hir-fn-variadic.pp @@ -20,8 +20,8 @@ fn main() { fn g3(_: extern "C" fn(u8, va: ...)) { } fn g4(_: extern "C" fn(u8, ...)) { } - fn g5(_: extern "C" fn(, va: ...)) { } - fn g6(_: extern "C" fn(, ...)) { } + fn g5(_: extern "C" fn(va: ...)) { } + fn g6(_: extern "C" fn(...)) { } { let _ = @@ -39,13 +39,13 @@ fn main() { { let _ = { - unsafe extern "C" fn f5(, va: ...) { } + unsafe extern "C" fn f5(va: ...) { } }; }; { let _ = { - unsafe extern "C" fn f6(, _: ...) { } + unsafe extern "C" fn f6(_: ...) { } }; }; }