-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-ABIArea: Concerning the application binary interface (ABI)Area: Concerning the application binary interface (ABI)A-FFIArea: Foreign function interface (FFI)Area: Foreign function interface (FFI)C-discussionCategory: Discussion or questions that doesn't represent real issues.Category: Discussion or questions that doesn't represent real issues.T-langRelevant to the language teamRelevant to the language team
Description
Currently, for extern "C"
functions returning ZSTs the compiler returns void
(as well as for other ABIs, but this is not related). However, improper_ctypes_definitions
fire for such functions (if they don't return ()
), e.g.:
// #[repr(C)] // Adding that does not change the outcome.
pub struct Zst;
pub extern "C" fn foo() -> Zst {
Zst
}
warning: `extern` fn uses type `Zst`, which is not FFI-safe
--> src/lib.rs:4:28
|
4 | pub extern "C" fn foo() -> Zst {
| ^^^ not FFI-safe
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
--> src/lib.rs:2:1
|
2 | pub struct Zst;
| ^^^^^^^^^^^^^^
= note: `#[warn(improper_ctypes_definitions)]` on by default
It's pretty clear we do not want to guarantee the FFI-safety of ZST arguments. But what about the FFI safety of ZST return types? Do we want to guarantee they'll keep translating to void
, or keep this not guaranteed?
Context: https://stackoverflow.com/q/76950446/7884305.
@rustbot label T-lang
Metadata
Metadata
Assignees
Labels
A-ABIArea: Concerning the application binary interface (ABI)Area: Concerning the application binary interface (ABI)A-FFIArea: Foreign function interface (FFI)Area: Foreign function interface (FFI)C-discussionCategory: Discussion or questions that doesn't represent real issues.Category: Discussion or questions that doesn't represent real issues.T-langRelevant to the language teamRelevant to the language team