Rollup merge of #63459 - eddyb:issue-63430, r=petrochenkov

syntax: account for CVarArgs being in the argument list.

Fixes #63430 by testing for `1` argument (the `CVarArgs` itself) instead of `0`.

Note that the error has basically been impossible to trigger since the change that caused #63430, so perhaps we need an audit of untested errors.

Also, this check probably belongs in AST validation/HIR lowering, but I'd rather fix it in place for now.

r? @petrochenkov cc @dlrobertson
This commit is contained in:
Mazdak Farrokhzad 2019-08-14 04:18:40 +02:00 committed by GitHub
commit 76bd7d62d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 1 deletions

View File

@ -1236,7 +1236,7 @@ impl<'a> Parser<'a> {
let args: Vec<_> = args.into_iter().filter_map(|x| x).collect();
if c_variadic && args.is_empty() {
if c_variadic && args.len() <= 1 {
self.span_err(sp,
"C-variadic function must be declared with at least one named argument");
}

View File

@ -0,0 +1,6 @@
extern {
fn foo(...);
//~^ ERROR C-variadic function must be declared with at least one named argument
}
fn main() {}

View File

@ -0,0 +1,8 @@
error: C-variadic function must be declared with at least one named argument
--> $DIR/variadic-ffi-no-fixed-args.rs:2:11
|
LL | fn foo(...);
| ^
error: aborting due to previous error