Fix HIR pretty-printing of fns with just a variadic arg.

Avoid the extraneous comma.
This commit is contained in:
Nicholas Nethercote 2025-04-15 10:17:32 +10:00
parent f8edc831ca
commit 16670e1676
2 changed files with 7 additions and 5 deletions

View file

@ -2165,7 +2165,9 @@ impl<'a> State<'a> {
s.end(); s.end();
}); });
if decl.c_variadic { if decl.c_variadic {
if !decl.inputs.is_empty() {
self.word(", "); self.word(", ");
}
print_arg(self, None); print_arg(self, None);
self.word("..."); self.word("...");
} }

View file

@ -20,8 +20,8 @@ fn main() {
fn g3(_: extern "C" fn(u8, va: ...)) { } fn g3(_: extern "C" fn(u8, va: ...)) { }
fn g4(_: extern "C" fn(u8, ...)) { } fn g4(_: extern "C" fn(u8, ...)) { }
fn g5(_: extern "C" fn(, va: ...)) { } fn g5(_: extern "C" fn(va: ...)) { }
fn g6(_: extern "C" fn(, ...)) { } fn g6(_: extern "C" fn(...)) { }
{ {
let _ = let _ =
@ -39,13 +39,13 @@ fn main() {
{ {
let _ = let _ =
{ {
unsafe extern "C" fn f5(, va: ...) { } unsafe extern "C" fn f5(va: ...) { }
}; };
}; };
{ {
let _ = let _ =
{ {
unsafe extern "C" fn f6(, _: ...) { } unsafe extern "C" fn f6(_: ...) { }
}; };
}; };
} }