Skip to content

Commit 5b76f6b

Browse files
Rollup merge of rust-lang#130669 - workingjubilee:slicing-fnptr-tests-finely, r=compiler-errors
tests: Test that `extern "C" fn` ptrs lint on slices This seems to have slipped past the `improper_ctypes_definitions` lint at some point. I found similar tests but not one with this exact combination, so test the semi-unique combination.
2 parents b4ac138 + e62b5e6 commit 5b76f6b

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)