Skip to content

Commit 8f8f70e

Browse files
Rollup merge of rust-lang#58865 - dlrobertson:fix-varargs, r=alexreg
Fix C-variadic function printing There is no longer a need to append the string `", ..."` to a functions args as `...` is parsed as an argument and will appear in the functions arguments. r? @alexreg cc @alexcrichton Fixes: rust-lang#58853
2 parents 0dfd28e + 72f0ca5 commit 8f8f70e

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/libsyntax/print/pprust.rs

-3
Original file line numberDiff line numberDiff line change
@@ -2814,9 +2814,6 @@ impl<'a> State<'a> {
28142814
-> io::Result<()> {
28152815
self.popen()?;
28162816
self.commasep(Inconsistent, &decl.inputs, |s, arg| s.print_arg(arg, false))?;
2817-
if decl.c_variadic {
2818-
self.s.word(", ...")?;
2819-
}
28202817
self.pclose()?;
28212818

28222819
self.print_fn_output(decl)

src/test/pretty/fn-variadic.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Check that `fn foo(x: i32, ...)` does not print as `fn foo(x: i32, ..., ...)`.
2+
// See issue #58853.
3+
4+
// pp-exact
5+
#![feature(c_variadic)]
6+
7+
extern "C" {
8+
pub fn foo(x: i32, ...);
9+
}
10+
11+
pub unsafe extern "C" fn bar(_: i32, mut ap: ...) -> usize {
12+
ap.arg::<usize>()
13+
}
14+
15+
fn main() {}

0 commit comments

Comments
 (0)