f91b5ceaf2
Trying to use C-variadics in a const function would previously fail with an error like "destructor of `VaListImpl<'_>` cannot be evaluated at compile-time". Add an explicit check for const C-variadics to provide a clearer error: "functions cannot be both `const` and C-variadic".
248 lines
7.9 KiB
Plaintext
248 lines
7.9 KiB
Plaintext
error: only foreign or `unsafe extern "C"` functions may be C-variadic
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:6:19
|
|
|
|
|
LL | fn f1_1(x: isize, ...) {}
|
|
| ^^^
|
|
|
|
error: C-variadic function must be declared with at least one named argument
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:9:9
|
|
|
|
|
LL | fn f1_2(...) {}
|
|
| ^^^
|
|
|
|
error: only foreign or `unsafe extern "C"` functions may be C-variadic
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:9:9
|
|
|
|
|
LL | fn f1_2(...) {}
|
|
| ^^^
|
|
|
|
error: only foreign or `unsafe extern "C"` functions may be C-variadic
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:13:30
|
|
|
|
|
LL | extern "C" fn f2_1(x: isize, ...) {}
|
|
| ^^^
|
|
|
|
error: C-variadic function must be declared with at least one named argument
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:16:20
|
|
|
|
|
LL | extern "C" fn f2_2(...) {}
|
|
| ^^^
|
|
|
|
error: only foreign or `unsafe extern "C"` functions may be C-variadic
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:16:20
|
|
|
|
|
LL | extern "C" fn f2_2(...) {}
|
|
| ^^^
|
|
|
|
error: `...` must be the last argument of a C-variadic function
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:20:20
|
|
|
|
|
LL | extern "C" fn f2_3(..., x: isize) {}
|
|
| ^^^
|
|
|
|
error: only foreign or `unsafe extern "C"` functions may be C-variadic
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:20:20
|
|
|
|
|
LL | extern "C" fn f2_3(..., x: isize) {}
|
|
| ^^^
|
|
|
|
error: only foreign or `unsafe extern "C"` functions may be C-variadic
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:24:30
|
|
|
|
|
LL | extern "C" fn f3_1(x: isize, ...) {}
|
|
| ^^^
|
|
|
|
error: C-variadic function must be declared with at least one named argument
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:27:20
|
|
|
|
|
LL | extern "C" fn f3_2(...) {}
|
|
| ^^^
|
|
|
|
error: only foreign or `unsafe extern "C"` functions may be C-variadic
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:27:20
|
|
|
|
|
LL | extern "C" fn f3_2(...) {}
|
|
| ^^^
|
|
|
|
error: `...` must be the last argument of a C-variadic function
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:31:20
|
|
|
|
|
LL | extern "C" fn f3_3(..., x: isize) {}
|
|
| ^^^
|
|
|
|
error: only foreign or `unsafe extern "C"` functions may be C-variadic
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:31:20
|
|
|
|
|
LL | extern "C" fn f3_3(..., x: isize) {}
|
|
| ^^^
|
|
|
|
error: functions cannot be both `const` and C-variadic
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:35:1
|
|
|
|
|
LL | const unsafe extern "C" fn f4_1(x: isize, ...) {}
|
|
| ^^^^^ `const` because of this ^^^ C-variadic because of this
|
|
|
|
error: functions cannot be both `const` and C-variadic
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:38:1
|
|
|
|
|
LL | const extern "C" fn f4_2(x: isize, ...) {}
|
|
| ^^^^^ `const` because of this ^^^ C-variadic because of this
|
|
|
|
error: only foreign or `unsafe extern "C"` functions may be C-variadic
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:38:36
|
|
|
|
|
LL | const extern "C" fn f4_2(x: isize, ...) {}
|
|
| ^^^
|
|
|
|
error: `...` must be the last argument of a C-variadic function
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:42:26
|
|
|
|
|
LL | const extern "C" fn f4_3(..., x: isize, ...) {}
|
|
| ^^^
|
|
|
|
error: functions cannot be both `const` and C-variadic
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:42:1
|
|
|
|
|
LL | const extern "C" fn f4_3(..., x: isize, ...) {}
|
|
| ^^^^^ ^^^ ^^^ C-variadic because of this
|
|
| | |
|
|
| | C-variadic because of this
|
|
| `const` because of this
|
|
|
|
error: only foreign or `unsafe extern "C"` functions may be C-variadic
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:42:26
|
|
|
|
|
LL | const extern "C" fn f4_3(..., x: isize, ...) {}
|
|
| ^^^ ^^^
|
|
|
|
error: C-variadic function must be declared with at least one named argument
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:48:13
|
|
|
|
|
LL | fn e_f1(...);
|
|
| ^^^
|
|
|
|
error: `...` must be the last argument of a C-variadic function
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:50:13
|
|
|
|
|
LL | fn e_f2(..., x: isize);
|
|
| ^^^
|
|
|
|
error: only foreign or `unsafe extern "C"` functions may be C-variadic
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:57:23
|
|
|
|
|
LL | fn i_f1(x: isize, ...) {}
|
|
| ^^^
|
|
|
|
error: C-variadic function must be declared with at least one named argument
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:59:13
|
|
|
|
|
LL | fn i_f2(...) {}
|
|
| ^^^
|
|
|
|
error: only foreign or `unsafe extern "C"` functions may be C-variadic
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:59:13
|
|
|
|
|
LL | fn i_f2(...) {}
|
|
| ^^^
|
|
|
|
error: `...` must be the last argument of a C-variadic function
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:62:13
|
|
|
|
|
LL | fn i_f3(..., x: isize, ...) {}
|
|
| ^^^
|
|
|
|
error: only foreign or `unsafe extern "C"` functions may be C-variadic
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:62:13
|
|
|
|
|
LL | fn i_f3(..., x: isize, ...) {}
|
|
| ^^^ ^^^
|
|
|
|
error: `...` must be the last argument of a C-variadic function
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:65:13
|
|
|
|
|
LL | fn i_f4(..., x: isize, ...) {}
|
|
| ^^^
|
|
|
|
error: only foreign or `unsafe extern "C"` functions may be C-variadic
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:65:13
|
|
|
|
|
LL | fn i_f4(..., x: isize, ...) {}
|
|
| ^^^ ^^^
|
|
|
|
error: functions cannot be both `const` and C-variadic
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:68:5
|
|
|
|
|
LL | const fn i_f5(x: isize, ...) {}
|
|
| ^^^^^ ^^^ C-variadic because of this
|
|
| |
|
|
| `const` because of this
|
|
|
|
error: only foreign or `unsafe extern "C"` functions may be C-variadic
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:68:29
|
|
|
|
|
LL | const fn i_f5(x: isize, ...) {}
|
|
| ^^^
|
|
|
|
error: only foreign or `unsafe extern "C"` functions may be C-variadic
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:74:23
|
|
|
|
|
LL | fn t_f1(x: isize, ...) {}
|
|
| ^^^
|
|
|
|
error: only foreign or `unsafe extern "C"` functions may be C-variadic
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:76:23
|
|
|
|
|
LL | fn t_f2(x: isize, ...);
|
|
| ^^^
|
|
|
|
error: C-variadic function must be declared with at least one named argument
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:78:13
|
|
|
|
|
LL | fn t_f3(...) {}
|
|
| ^^^
|
|
|
|
error: only foreign or `unsafe extern "C"` functions may be C-variadic
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:78:13
|
|
|
|
|
LL | fn t_f3(...) {}
|
|
| ^^^
|
|
|
|
error: C-variadic function must be declared with at least one named argument
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:81:13
|
|
|
|
|
LL | fn t_f4(...);
|
|
| ^^^
|
|
|
|
error: only foreign or `unsafe extern "C"` functions may be C-variadic
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:81:13
|
|
|
|
|
LL | fn t_f4(...);
|
|
| ^^^
|
|
|
|
error: `...` must be the last argument of a C-variadic function
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:84:13
|
|
|
|
|
LL | fn t_f5(..., x: isize) {}
|
|
| ^^^
|
|
|
|
error: only foreign or `unsafe extern "C"` functions may be C-variadic
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:84:13
|
|
|
|
|
LL | fn t_f5(..., x: isize) {}
|
|
| ^^^
|
|
|
|
error: `...` must be the last argument of a C-variadic function
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:87:13
|
|
|
|
|
LL | fn t_f6(..., x: isize);
|
|
| ^^^
|
|
|
|
error: only foreign or `unsafe extern "C"` functions may be C-variadic
|
|
--> $DIR/variadic-ffi-semantic-restrictions.rs:87:13
|
|
|
|
|
LL | fn t_f6(..., x: isize);
|
|
| ^^^
|
|
|
|
error: aborting due to 40 previous errors
|
|
|