ffi-safe lint should be more aggressive in checking ffi stability of sub-types #72939
Labels
A-ffi
Area: Foreign Function Interface (FFI)
A-lint
Area: Lints (warnings about flaws in source code) such as unused_mut.
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
According to this answer, this code:
... should emit a warning that
struct A
is still#[repr(Rust)]
, so the layout ofB
isn't completely defined, specifically the order of the fieldsa
andb
are not specified in#[repr(Rust)]
. I'm not sure if theffi-safe
lint is active or not, but it would be very useful, so I know that if a type is marked#[repr(C)]
, all sub-types are also marked#[repr(C)]
.Another question: When compiling to a
cdylib
, why does cargo use#[repr(Rust)]
for publicly visible structs of a crate. It would be nice if, when compiling to acdylib
with this code:... there could be automatic warnings:
foo
is a public function, should be marked as#[no_mangle]
B
andA
should be marked as#[repr(C)]
... because the only representation that you usually want when compiling to a
cdylib
is#[repr(C)]
(or#[repr(C, u8)]
for enums).The text was updated successfully, but these errors were encountered: