mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
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:
commit
76bd7d62d6
@ -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");
|
||||
}
|
||||
|
6
src/test/ui/c-variadic/variadic-ffi-no-fixed-args.rs
Normal file
6
src/test/ui/c-variadic/variadic-ffi-no-fixed-args.rs
Normal file
@ -0,0 +1,6 @@
|
||||
extern {
|
||||
fn foo(...);
|
||||
//~^ ERROR C-variadic function must be declared with at least one named argument
|
||||
}
|
||||
|
||||
fn main() {}
|
8
src/test/ui/c-variadic/variadic-ffi-no-fixed-args.stderr
Normal file
8
src/test/ui/c-variadic/variadic-ffi-no-fixed-args.stderr
Normal 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
|
||||
|
Loading…
Reference in New Issue
Block a user