about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDan Robertson <dan@dlrobertson.com>2019-03-02 03:14:29 +0000
committerDan Robertson <dan@dlrobertson.com>2019-03-02 15:03:09 +0000
commit04d0a8cb83e713f71848c4afeba72d7e776acc6a (patch)
treef0571ff8bd2149a42d3b5d9890dc7fc255e2c646
parentc1d2d83ca3b5155468ab96b09a7c54568449b137 (diff)
downloadrust-04d0a8cb83e713f71848c4afeba72d7e776acc6a.tar.gz
rust-04d0a8cb83e713f71848c4afeba72d7e776acc6a.zip
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.
-rw-r--r--src/libsyntax/print/pprust.rs3
-rw-r--r--src/test/pretty/fn-variadic.rs15
2 files changed, 15 insertions, 3 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index 942bd969391..49e3fad4af0 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -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)
diff --git a/src/test/pretty/fn-variadic.rs b/src/test/pretty/fn-variadic.rs
new file mode 100644
index 00000000000..d3b193a3e18
--- /dev/null
+++ b/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() { }