Skip to content

Commit ef73a9b

Browse files
authored
Rollup merge of rust-lang#63459 - eddyb:issue-63430, r=petrochenkov
syntax: account for CVarArgs being in the argument list. Fixes rust-lang#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 rust-lang#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
2 parents f16924a + 34dcca2 commit ef73a9b

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/libsyntax/parse/parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1236,7 +1236,7 @@ impl<'a> Parser<'a> {
12361236

12371237
let args: Vec<_> = args.into_iter().filter_map(|x| x).collect();
12381238

1239-
if c_variadic && args.is_empty() {
1239+
if c_variadic && args.len() <= 1 {
12401240
self.span_err(sp,
12411241
"C-variadic function must be declared with at least one named argument");
12421242
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
extern {
2+
fn foo(...);
3+
//~^ ERROR C-variadic function must be declared with at least one named argument
4+
}
5+
6+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: C-variadic function must be declared with at least one named argument
2+
--> $DIR/variadic-ffi-no-fixed-args.rs:2:11
3+
|
4+
LL | fn foo(...);
5+
| ^
6+
7+
error: aborting due to previous error
8+

0 commit comments

Comments
 (0)