Skip to content

Commit bc23e9a

Browse files
Improve tests for FFI attr validation
1 parent 6e04e67 commit bc23e9a

6 files changed

+69
-3
lines changed

tests/ui/ffi_const.rs

+10
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,13 @@
33

44
#[ffi_const] //~ ERROR `#[ffi_const]` may only be used on foreign functions
55
pub fn foo() {}
6+
7+
#[ffi_const] //~ ERROR `#[ffi_const]` may only be used on foreign functions
8+
macro_rules! bar {
9+
() => ()
10+
}
11+
12+
extern "C" {
13+
#[ffi_const] //~ ERROR `#[ffi_const]` may only be used on foreign functions
14+
static INT: i32;
15+
}

tests/ui/ffi_const.stderr

+13-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ error[E0756]: `#[ffi_const]` may only be used on foreign functions
44
LL | #[ffi_const]
55
| ^^^^^^^^^^^^
66

7-
error: aborting due to previous error
7+
error[E0756]: `#[ffi_const]` may only be used on foreign functions
8+
--> $DIR/ffi_const.rs:7:1
9+
|
10+
LL | #[ffi_const]
11+
| ^^^^^^^^^^^^
12+
13+
error[E0756]: `#[ffi_const]` may only be used on foreign functions
14+
--> $DIR/ffi_const.rs:13:5
15+
|
16+
LL | #[ffi_const]
17+
| ^^^^^^^^^^^^
18+
19+
error: aborting due to 3 previous errors
820

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

tests/ui/ffi_pure.rs

+10
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,13 @@
33

44
#[ffi_pure] //~ ERROR `#[ffi_pure]` may only be used on foreign functions
55
pub fn foo() {}
6+
7+
#[ffi_pure] //~ ERROR `#[ffi_pure]` may only be used on foreign functions
8+
macro_rules! bar {
9+
() => ()
10+
}
11+
12+
extern "C" {
13+
#[ffi_pure] //~ ERROR `#[ffi_pure]` may only be used on foreign functions
14+
static INT: i32;
15+
}

tests/ui/ffi_pure.stderr

+13-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ error[E0755]: `#[ffi_pure]` may only be used on foreign functions
44
LL | #[ffi_pure]
55
| ^^^^^^^^^^^
66

7-
error: aborting due to previous error
7+
error[E0755]: `#[ffi_pure]` may only be used on foreign functions
8+
--> $DIR/ffi_pure.rs:7:1
9+
|
10+
LL | #[ffi_pure]
11+
| ^^^^^^^^^^^
12+
13+
error[E0755]: `#[ffi_pure]` may only be used on foreign functions
14+
--> $DIR/ffi_pure.rs:13:5
15+
|
16+
LL | #[ffi_pure]
17+
| ^^^^^^^^^^^
18+
19+
error: aborting due to 3 previous errors
820

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

tests/ui/ffi_returns_twice.rs

+10
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,13 @@
33

44
#[ffi_returns_twice] //~ ERROR `#[ffi_returns_twice]` may only be used on foreign functions
55
pub fn foo() {}
6+
7+
#[ffi_returns_twice] //~ ERROR `#[ffi_returns_twice]` may only be used on foreign functions
8+
macro_rules! bar {
9+
() => ()
10+
}
11+
12+
extern "C" {
13+
#[ffi_returns_twice] //~ ERROR `#[ffi_returns_twice]` may only be used on foreign functions
14+
static INT: i32;
15+
}

tests/ui/ffi_returns_twice.stderr

+13-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ error[E0724]: `#[ffi_returns_twice]` may only be used on foreign functions
44
LL | #[ffi_returns_twice]
55
| ^^^^^^^^^^^^^^^^^^^^
66

7-
error: aborting due to previous error
7+
error[E0724]: `#[ffi_returns_twice]` may only be used on foreign functions
8+
--> $DIR/ffi_returns_twice.rs:7:1
9+
|
10+
LL | #[ffi_returns_twice]
11+
| ^^^^^^^^^^^^^^^^^^^^
12+
13+
error[E0724]: `#[ffi_returns_twice]` may only be used on foreign functions
14+
--> $DIR/ffi_returns_twice.rs:13:5
15+
|
16+
LL | #[ffi_returns_twice]
17+
| ^^^^^^^^^^^^^^^^^^^^
18+
19+
error: aborting due to 3 previous errors
820

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

0 commit comments

Comments
 (0)