You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use core::marker::PhantomData;#[repr(C)]enumTheEnum{VariantWithPhantomData(u8,PhantomData<String>),// VariantWithStruct(StructWithPhantomData),}#[repr(C)]structStructWithPhantomData(u8,PhantomData<String>);extern"C"fndemo(_x:TheEnum){}
I expected to see no warnings about TheEnum.
Instead, this happened:
warning: `extern` fn uses type `TheEnum`, which is not FFI-safe
--> src/lib.rs:12:24
|
12 | extern "C" fn demo(_x: TheEnum) {}
| ^^^^^^^ not FFI-safe
|
= note: this enum contains a PhantomData field
note: the type is defined here
--> src/lib.rs:4:1
|
4 | enum TheEnum {
| ^^^^^^^^^^^^
= note: `#[warn(improper_ctypes_definitions)]` on by default
If I move the PhantomData to a struct (see VariantWithPhantomData), then the problem goes away. The problem goes away even if I leave the original variant that it previously complained about.
Meta
This reproduces back to at least Rust 1.56 and to recent nightly versions:
I tried this code:
I expected to see no warnings about
TheEnum
.Instead, this happened:
If I move the
PhantomData
to a struct (seeVariantWithPhantomData
), then the problem goes away. The problem goes away even if I leave the original variant that it previously complained about.Meta
This reproduces back to at least Rust 1.56 and to recent nightly versions:
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: