Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix C-variadic function printing #58865

Merged
merged 2 commits into from
Mar 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/libsyntax/print/pprust.rs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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() { }
Copy link
Contributor Author

@dlrobertson dlrobertson Mar 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexreg looks like this has to be formatted as fn main() { }. I amended the last commit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh really? Sorry, my bad. I'm so used to {} in other files, I thought it was actually standard.