Skip to content

Commit

Permalink
Rollup merge of rust-lang#58865 - dlrobertson:fix-varargs, r=alexreg
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Mark-Simulacrum committed Mar 2, 2019
2 parents 0dfd28e + 72f0ca5 commit 8f8f70e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 0 additions & 3 deletions src/libsyntax/print/pprust.rs
Expand Up @@ -2814,9 +2814,6 @@ impl<'a> State<'a> {
-> io::Result<()> {
self.popen()?;
self.commasep(Inconsistent, &decl.inputs, |s, arg| s.print_arg(arg, false))?;
if decl.c_variadic {
self.s.word(", ...")?;
}
self.pclose()?;

self.print_fn_output(decl)
Expand Down
15 changes: 15 additions & 0 deletions src/test/pretty/fn-variadic.rs
@@ -0,0 +1,15 @@
// Check that `fn foo(x: i32, ...)` does not print as `fn foo(x: i32, ..., ...)`.
// See issue #58853.

// pp-exact
#![feature(c_variadic)]

extern "C" {
pub fn foo(x: i32, ...);
}

pub unsafe extern "C" fn bar(_: i32, mut ap: ...) -> usize {
ap.arg::<usize>()
}

fn main() {}

0 comments on commit 8f8f70e

Please sign in to comment.