Skip to content

Commit e62b5e6

Browse files
tests: Test that extern "C" fn ptrs lint on slices
1 parent f48c99a commit e62b5e6

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#[deny(improper_ctypes_definitions)]
2+
3+
// It's an improper ctype (a slice) arg in an extern "C" fnptr.
4+
5+
pub type F = extern "C" fn(&[u8]);
6+
//~^ ERROR: `extern` fn uses type `[u8]`, which is not FFI-safe
7+
8+
9+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error: `extern` fn uses type `[u8]`, which is not FFI-safe
2+
--> $DIR/extern-C-fnptr-lints-slices.rs:5:14
3+
|
4+
LL | pub type F = extern "C" fn(&[u8]);
5+
| ^^^^^^^^^^^^^^^^^^^^ not FFI-safe
6+
|
7+
= help: consider using a raw pointer instead
8+
= note: slices have no C equivalent
9+
note: the lint level is defined here
10+
--> $DIR/extern-C-fnptr-lints-slices.rs:1:8
11+
|
12+
LL | #[deny(improper_ctypes_definitions)]
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
15+
error: aborting due to 1 previous error
16+

0 commit comments

Comments
 (0)