diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-12-02 03:16:12 +0100 |
|---|---|---|
| committer | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-12-12 18:01:33 +0100 |
| commit | 35e9e097e7c7e977f36795c0febceb327e1fa33f (patch) | |
| tree | 0e30fcc08cca08347d5cf3de7f8ccf895e7279f6 /src/test/ui | |
| parent | 3a57a2cca489da43fa3168aa1cb453e2b175a1f6 (diff) | |
More c-variadic errors as semantic restrictions.
Diffstat (limited to 'src/test/ui')
4 files changed, 284 insertions, 38 deletions
diff --git a/src/test/ui/c-variadic/variadic-ffi-no-fixed-args.stderr b/src/test/ui/c-variadic/variadic-ffi-no-fixed-args.stderr index cb6060525fc..7af38c88f43 100644 --- a/src/test/ui/c-variadic/variadic-ffi-no-fixed-args.stderr +++ b/src/test/ui/c-variadic/variadic-ffi-no-fixed-args.stderr @@ -1,8 +1,8 @@ error: C-variadic function must be declared with at least one named argument - --> $DIR/variadic-ffi-no-fixed-args.rs:2:11 + --> $DIR/variadic-ffi-no-fixed-args.rs:2:12 | LL | fn foo(...); - | ^ + | ^^^^ error: aborting due to previous error diff --git a/src/test/ui/parser/variadic-ffi-semantic-restrictions.rs b/src/test/ui/parser/variadic-ffi-semantic-restrictions.rs index 57086bca2f4..aa85f6d6b52 100644 --- a/src/test/ui/parser/variadic-ffi-semantic-restrictions.rs +++ b/src/test/ui/parser/variadic-ffi-semantic-restrictions.rs @@ -2,25 +2,75 @@ fn main() {} -fn f1(x: isize, ...) {} -//~^ ERROR: only foreign or `unsafe extern "C" functions may be C-variadic +fn f1_1(x: isize, ...) {} +//~^ ERROR only foreign or `unsafe extern "C" functions may be C-variadic -extern "C" fn f2(x: isize, ...) {} -//~^ ERROR: only foreign or `unsafe extern "C" functions may be C-variadic +fn f1_2(...) {} +//~^ ERROR only foreign or `unsafe extern "C" functions may be C-variadic +//~| ERROR C-variadic function must be declared with at least one named argument -extern fn f3(x: isize, ...) {} -//~^ ERROR: only foreign or `unsafe extern "C" functions may be C-variadic +extern "C" fn f2_1(x: isize, ...) {} +//~^ ERROR only foreign or `unsafe extern "C" functions may be C-variadic + +extern "C" fn f2_2(...) {} +//~^ ERROR only foreign or `unsafe extern "C" functions may be C-variadic +//~| ERROR C-variadic function must be declared with at least one named argument + +extern "C" fn f2_3(..., x: isize) {} +//~^ ERROR only foreign or `unsafe extern "C" functions may be C-variadic +//~| ERROR `...` must be the last argument of a C-variadic function + +extern fn f3_1(x: isize, ...) {} +//~^ ERROR only foreign or `unsafe extern "C" functions may be C-variadic + +extern fn f3_2(...) {} +//~^ ERROR only foreign or `unsafe extern "C" functions may be C-variadic +//~| ERROR C-variadic function must be declared with at least one named argument + +extern fn f3_3(..., x: isize) {} +//~^ ERROR only foreign or `unsafe extern "C" functions may be C-variadic +//~| ERROR `...` must be the last argument of a C-variadic function + +extern { + fn e_f1(...); + //~^ ERROR C-variadic function must be declared with at least one named argument + fn e_f2(..., x: isize); + //~^ ERROR `...` must be the last argument of a C-variadic function +} struct X; impl X { - fn f4(x: isize, ...) {} - //~^ ERROR: only foreign or `unsafe extern "C" functions may be C-variadic + fn i_f1(x: isize, ...) {} + //~^ ERROR only foreign or `unsafe extern "C" functions may be C-variadic + fn i_f2(...) {} + //~^ ERROR only foreign or `unsafe extern "C" functions may be C-variadic + //~| ERROR C-variadic function must be declared with at least one named argument + fn i_f3(..., x: isize, ...) {} + //~^ ERROR only foreign or `unsafe extern "C" functions may be C-variadic + //~| ERROR only foreign or `unsafe extern "C" functions may be C-variadic + //~| ERROR `...` must be the last argument of a C-variadic function + fn i_f4(..., x: isize, ...) {} + //~^ ERROR only foreign or `unsafe extern "C" functions may be C-variadic + //~| ERROR only foreign or `unsafe extern "C" functions may be C-variadic + //~| ERROR `...` must be the last argument of a C-variadic function } trait T { - fn f5(x: isize, ...) {} - //~^ ERROR: only foreign or `unsafe extern "C" functions may be C-variadic - fn f6(x: isize, ...); - //~^ ERROR: only foreign or `unsafe extern "C" functions may be C-variadic + fn t_f1(x: isize, ...) {} + //~^ ERROR only foreign or `unsafe extern "C" functions may be C-variadic + fn t_f2(x: isize, ...); + //~^ ERROR only foreign or `unsafe extern "C" functions may be C-variadic + fn t_f3(...) {} + //~^ ERROR only foreign or `unsafe extern "C" functions may be C-variadic + //~| ERROR C-variadic function must be declared with at least one named argument + fn t_f4(...); + //~^ ERROR only foreign or `unsafe extern "C" functions may be C-variadic + //~| ERROR C-variadic function must be declared with at least one named argument + fn t_f5(..., x: isize) {} + //~^ ERROR only foreign or `unsafe extern "C" functions may be C-variadic + //~| ERROR `...` must be the last argument of a C-variadic function + fn t_f6(..., x: isize); + //~^ ERROR only foreign or `unsafe extern "C" functions may be C-variadic + //~| ERROR `...` must be the last argument of a C-variadic function } diff --git a/src/test/ui/parser/variadic-ffi-semantic-restrictions.stderr b/src/test/ui/parser/variadic-ffi-semantic-restrictions.stderr index 69244d92ee3..21992a29670 100644 --- a/src/test/ui/parser/variadic-ffi-semantic-restrictions.stderr +++ b/src/test/ui/parser/variadic-ffi-semantic-restrictions.stderr @@ -1,38 +1,206 @@ error: only foreign or `unsafe extern "C" functions may be C-variadic - --> $DIR/variadic-ffi-semantic-restrictions.rs:5:17 + --> $DIR/variadic-ffi-semantic-restrictions.rs:5:19 | -LL | fn f1(x: isize, ...) {} - | ^^^^ +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:8:9 + | +LL | fn f1_2(...) {} + | ^^^^ + +error: only foreign or `unsafe extern "C" functions may be C-variadic + --> $DIR/variadic-ffi-semantic-restrictions.rs:8:9 + | +LL | fn f1_2(...) {} + | ^^^^ + +error: only foreign or `unsafe extern "C" functions may be C-variadic + --> $DIR/variadic-ffi-semantic-restrictions.rs:12: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:15: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:15:20 + | +LL | extern "C" fn f2_2(...) {} + | ^^^^ + +error: `...` must be the last argument of a C-variadic function + --> $DIR/variadic-ffi-semantic-restrictions.rs:19: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:19: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:8:28 + --> $DIR/variadic-ffi-semantic-restrictions.rs:23:26 | -LL | extern "C" fn f2(x: isize, ...) {} +LL | extern fn f3_1(x: isize, ...) {} + | ^^^^ + +error: C-variadic function must be declared with at least one named argument + --> $DIR/variadic-ffi-semantic-restrictions.rs:26:16 + | +LL | extern fn f3_2(...) {} + | ^^^^ + +error: only foreign or `unsafe extern "C" functions may be C-variadic + --> $DIR/variadic-ffi-semantic-restrictions.rs:26:16 + | +LL | extern fn f3_2(...) {} + | ^^^^ + +error: `...` must be the last argument of a C-variadic function + --> $DIR/variadic-ffi-semantic-restrictions.rs:30:16 + | +LL | extern fn f3_3(..., x: isize) {} + | ^^^^ + +error: only foreign or `unsafe extern "C" functions may be C-variadic + --> $DIR/variadic-ffi-semantic-restrictions.rs:30:16 + | +LL | extern fn f3_3(..., x: isize) {} + | ^^^^ + +error: C-variadic function must be declared with at least one named argument + --> $DIR/variadic-ffi-semantic-restrictions.rs:35:13 + | +LL | fn e_f1(...); + | ^^^^ + +error: `...` must be the last argument of a C-variadic function + --> $DIR/variadic-ffi-semantic-restrictions.rs:37: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:44: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:46:13 + | +LL | fn i_f2(...) {} + | ^^^^ + +error: only foreign or `unsafe extern "C" functions may be C-variadic + --> $DIR/variadic-ffi-semantic-restrictions.rs:46:13 + | +LL | fn i_f2(...) {} + | ^^^^ + +error: `...` must be the last argument of a C-variadic function + --> $DIR/variadic-ffi-semantic-restrictions.rs:49: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:49: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:49:28 + | +LL | fn i_f3(..., x: isize, ...) {} | ^^^^ +error: `...` must be the last argument of a C-variadic function + --> $DIR/variadic-ffi-semantic-restrictions.rs:53: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:11:24 + --> $DIR/variadic-ffi-semantic-restrictions.rs:53:13 | -LL | extern fn f3(x: isize, ...) {} - | ^^^^ +LL | fn i_f4(..., x: isize, ...) {} + | ^^^^ + +error: only foreign or `unsafe extern "C" functions may be C-variadic + --> $DIR/variadic-ffi-semantic-restrictions.rs:53:28 + | +LL | fn i_f4(..., x: isize, ...) {} + | ^^^^ error: only foreign or `unsafe extern "C" functions may be C-variadic - --> $DIR/variadic-ffi-semantic-restrictions.rs:17:21 + --> $DIR/variadic-ffi-semantic-restrictions.rs:60:23 | -LL | fn f4(x: isize, ...) {} - | ^^^^ +LL | fn t_f1(x: isize, ...) {} + | ^^^^ error: only foreign or `unsafe extern "C" functions may be C-variadic - --> $DIR/variadic-ffi-semantic-restrictions.rs:22:21 + --> $DIR/variadic-ffi-semantic-restrictions.rs:62: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:64:13 + | +LL | fn t_f3(...) {} + | ^^^^ + +error: only foreign or `unsafe extern "C" functions may be C-variadic + --> $DIR/variadic-ffi-semantic-restrictions.rs:64:13 + | +LL | fn t_f3(...) {} + | ^^^^ + +error: C-variadic function must be declared with at least one named argument + --> $DIR/variadic-ffi-semantic-restrictions.rs:67:13 + | +LL | fn t_f4(...); + | ^^^^ + +error: only foreign or `unsafe extern "C" functions may be C-variadic + --> $DIR/variadic-ffi-semantic-restrictions.rs:67:13 + | +LL | fn t_f4(...); + | ^^^^ + +error: `...` must be the last argument of a C-variadic function + --> $DIR/variadic-ffi-semantic-restrictions.rs:70: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:70:13 + | +LL | fn t_f5(..., x: isize) {} + | ^^^^ + +error: `...` must be the last argument of a C-variadic function + --> $DIR/variadic-ffi-semantic-restrictions.rs:73:13 | -LL | fn f5(x: isize, ...) {} - | ^^^^ +LL | fn t_f6(..., x: isize); + | ^^^^ error: only foreign or `unsafe extern "C" functions may be C-variadic - --> $DIR/variadic-ffi-semantic-restrictions.rs:24:21 + --> $DIR/variadic-ffi-semantic-restrictions.rs:73:13 | -LL | fn f6(x: isize, ...); - | ^^^^ +LL | fn t_f6(..., x: isize); + | ^^^^ -error: aborting due to 6 previous errors +error: aborting due to 34 previous errors diff --git a/src/test/ui/parser/variadic-ffi-syntactic-pass.rs b/src/test/ui/parser/variadic-ffi-syntactic-pass.rs index f8fcce6ba73..3875d6af137 100644 --- a/src/test/ui/parser/variadic-ffi-syntactic-pass.rs +++ b/src/test/ui/parser/variadic-ffi-syntactic-pass.rs @@ -3,23 +3,51 @@ fn main() {} #[cfg(FALSE)] -fn f1(x: isize, ...) {} +fn f1_1(x: isize, ...) {} #[cfg(FALSE)] -extern "C" fn f2(x: isize, ...) {} +fn f1_2(...) {} #[cfg(FALSE)] -extern fn f3(x: isize, ...) {} +extern "C" fn f2_1(x: isize, ...) {} + +#[cfg(FALSE)] +extern "C" fn f2_2(...) {} + +#[cfg(FALSE)] +extern "C" fn f2_3(..., x: isize) {} + +#[cfg(FALSE)] +extern fn f3_1(x: isize, ...) {} + +#[cfg(FALSE)] +extern fn f3_2(...) {} + +#[cfg(FALSE)] +extern fn f3_3(..., x: isize) {} + +#[cfg(FALSE)] +extern { + fn e_f1(...); + fn e_f2(..., x: isize); +} struct X; #[cfg(FALSE)] impl X { - fn f4(x: isize, ...) {} + fn i_f1(x: isize, ...) {} + fn i_f2(...) {} + fn i_f3(..., x: isize, ...) {} + fn i_f4(..., x: isize, ...) {} } #[cfg(FALSE)] trait T { - fn f5(x: isize, ...) {} - fn f6(x: isize, ...); + fn t_f1(x: isize, ...) {} + fn t_f2(x: isize, ...); + fn t_f3(...) {} + fn t_f4(...); + fn t_f5(..., x: isize) {} + fn t_f6(..., x: isize); } |
