Skip to content
/ rust Public
forked from rust-lang/rust

Commit 16670e1

Browse files
committed
Fix HIR pretty-printing of fns with just a variadic arg.
Avoid the extraneous comma.
1 parent f8edc83 commit 16670e1

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

compiler/rustc_hir_pretty/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -2165,7 +2165,9 @@ impl<'a> State<'a> {
21652165
s.end();
21662166
});
21672167
if decl.c_variadic {
2168-
self.word(", ");
2168+
if !decl.inputs.is_empty() {
2169+
self.word(", ");
2170+
}
21692171
print_arg(self, None);
21702172
self.word("...");
21712173
}

tests/pretty/hir-fn-variadic.pp

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
fn g3(_: extern "C" fn(u8, va: ...)) { }
2121
fn g4(_: extern "C" fn(u8, ...)) { }
2222

23-
fn g5(_: extern "C" fn(, va: ...)) { }
24-
fn g6(_: extern "C" fn(, ...)) { }
23+
fn g5(_: extern "C" fn(va: ...)) { }
24+
fn g6(_: extern "C" fn(...)) { }
2525

2626
{
2727
let _ =
@@ -39,13 +39,13 @@
3939
{
4040
let _ =
4141
{
42-
unsafe extern "C" fn f5(, va: ...) { }
42+
unsafe extern "C" fn f5(va: ...) { }
4343
};
4444
};
4545
{
4646
let _ =
4747
{
48-
unsafe extern "C" fn f6(, _: ...) { }
48+
unsafe extern "C" fn f6(_: ...) { }
4949
};
5050
};
5151
}

0 commit comments

Comments
 (0)