Skip to content

Commit 14d05c4

Browse files
committed
add test for #52334
Fixes #52334
1 parent 548e14b commit 14d05c4

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// test for #52334 ICE when casting extern "C" fn when it has a non-FFI-safe argument
2+
//@ check-pass
3+
4+
type Foo = extern "C" fn(::std::ffi::CStr);
5+
//~^ WARN `extern` fn uses type `[i8]`, which is not FFI-safe
6+
extern "C" {
7+
fn meh(blah: Foo);
8+
//~^ WARN `extern` block uses type `[i8]`, which is not FFI-safe
9+
}
10+
11+
fn main() {
12+
meh as usize;
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
warning: `extern` fn uses type `[i8]`, which is not FFI-safe
2+
--> $DIR/extern-C-non-FFI-safe-arg-ice-52334.rs:4:12
3+
|
4+
LL | type Foo = extern "C" fn(::std::ffi::CStr);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
6+
|
7+
= help: consider using a raw pointer instead
8+
= note: slices have no C equivalent
9+
= note: `#[warn(improper_ctypes_definitions)]` on by default
10+
11+
warning: `extern` block uses type `[i8]`, which is not FFI-safe
12+
--> $DIR/extern-C-non-FFI-safe-arg-ice-52334.rs:7:18
13+
|
14+
LL | fn meh(blah: Foo);
15+
| ^^^ not FFI-safe
16+
|
17+
= help: consider using a raw pointer instead
18+
= note: slices have no C equivalent
19+
= note: `#[warn(improper_ctypes)]` on by default
20+
21+
warning: 2 warnings emitted
22+

0 commit comments

Comments
 (0)