mirror of
https://github.com/rust-lang/rust
synced 2024-10-14 12:33:57 +00:00
Rollup merge of #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. Fixes: #58853
This commit is contained in:
commit
946e670bce
|
@ -2814,9 +2814,6 @@ pub fn print_fn_args_and_ret(&mut self, decl: &ast::FnDecl)
|
|||
-> 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)
|
||||
|
|
15
src/test/pretty/fn-variadic.rs
Normal file
15
src/test/pretty/fn-variadic.rs
Normal file
|
@ -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() { }
|
Loading…
Reference in a new issue