Skip to content

Commit

Permalink
Improve tests for FFI attr validation
Browse files Browse the repository at this point in the history
  • Loading branch information
inquisitivecrystal committed Jan 27, 2023
1 parent 6e04e67 commit bc23e9a
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 3 deletions.
10 changes: 10 additions & 0 deletions tests/ui/ffi_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,13 @@

#[ffi_const] //~ ERROR `#[ffi_const]` may only be used on foreign functions
pub fn foo() {}

#[ffi_const] //~ ERROR `#[ffi_const]` may only be used on foreign functions
macro_rules! bar {
() => ()
}

extern "C" {
#[ffi_const] //~ ERROR `#[ffi_const]` may only be used on foreign functions
static INT: i32;
}
14 changes: 13 additions & 1 deletion tests/ui/ffi_const.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ error[E0756]: `#[ffi_const]` may only be used on foreign functions
LL | #[ffi_const]
| ^^^^^^^^^^^^

error: aborting due to previous error
error[E0756]: `#[ffi_const]` may only be used on foreign functions
--> $DIR/ffi_const.rs:7:1
|
LL | #[ffi_const]
| ^^^^^^^^^^^^

error[E0756]: `#[ffi_const]` may only be used on foreign functions
--> $DIR/ffi_const.rs:13:5
|
LL | #[ffi_const]
| ^^^^^^^^^^^^

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0756`.
10 changes: 10 additions & 0 deletions tests/ui/ffi_pure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,13 @@

#[ffi_pure] //~ ERROR `#[ffi_pure]` may only be used on foreign functions
pub fn foo() {}

#[ffi_pure] //~ ERROR `#[ffi_pure]` may only be used on foreign functions
macro_rules! bar {
() => ()
}

extern "C" {
#[ffi_pure] //~ ERROR `#[ffi_pure]` may only be used on foreign functions
static INT: i32;
}
14 changes: 13 additions & 1 deletion tests/ui/ffi_pure.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ error[E0755]: `#[ffi_pure]` may only be used on foreign functions
LL | #[ffi_pure]
| ^^^^^^^^^^^

error: aborting due to previous error
error[E0755]: `#[ffi_pure]` may only be used on foreign functions
--> $DIR/ffi_pure.rs:7:1
|
LL | #[ffi_pure]
| ^^^^^^^^^^^

error[E0755]: `#[ffi_pure]` may only be used on foreign functions
--> $DIR/ffi_pure.rs:13:5
|
LL | #[ffi_pure]
| ^^^^^^^^^^^

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0755`.
10 changes: 10 additions & 0 deletions tests/ui/ffi_returns_twice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,13 @@

#[ffi_returns_twice] //~ ERROR `#[ffi_returns_twice]` may only be used on foreign functions
pub fn foo() {}

#[ffi_returns_twice] //~ ERROR `#[ffi_returns_twice]` may only be used on foreign functions
macro_rules! bar {
() => ()
}

extern "C" {
#[ffi_returns_twice] //~ ERROR `#[ffi_returns_twice]` may only be used on foreign functions
static INT: i32;
}
14 changes: 13 additions & 1 deletion tests/ui/ffi_returns_twice.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ error[E0724]: `#[ffi_returns_twice]` may only be used on foreign functions
LL | #[ffi_returns_twice]
| ^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error
error[E0724]: `#[ffi_returns_twice]` may only be used on foreign functions
--> $DIR/ffi_returns_twice.rs:7:1
|
LL | #[ffi_returns_twice]
| ^^^^^^^^^^^^^^^^^^^^

error[E0724]: `#[ffi_returns_twice]` may only be used on foreign functions
--> $DIR/ffi_returns_twice.rs:13:5
|
LL | #[ffi_returns_twice]
| ^^^^^^^^^^^^^^^^^^^^

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0724`.

0 comments on commit bc23e9a

Please sign in to comment.