-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.A-reprArea: the `#[repr(stuff)]` attributeArea: the `#[repr(stuff)]` attributeC-bugCategory: This is a bug.Category: This is a bug.L-improper_ctypesLint: improper_ctypesLint: improper_ctypesT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Code
#[repr(C)]
pub struct Foo {
inner: [u8; 0]
}
extern "C" {
// Lint does not trigger, as expected
pub fn foo(_: &Foo);
}
#[repr(transparent)]
pub struct Bar(Foo);
extern "C" {
// Lint triggers unexpectedly
pub fn bar(_: &Bar);
}
Current output
warning: `extern` block uses type `Bar`, which is not FFI-safe
--> <source>:16:19
|
16 | pub fn bar(_: &Bar);
| ^^^^ not FFI-safe
|
= note: this struct contains only zero-sized fields
note: the type is defined here
--> <source>:12:1
|
12 | pub struct Bar(Foo);
| ^^^^^^^^^^^^^^
= note: `#[warn(improper_ctypes)]` on by default
warning: 1 warning emitted
Desired output
The lint should not fire
Rationale and extra context
Reproducible from Rust 1.57.0 (where #[repr(transparent)]
on a zero-sized struct was made valid) to the current nightly-2023-08-31
.
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.A-reprArea: the `#[repr(stuff)]` attributeArea: the `#[repr(stuff)]` attributeC-bugCategory: This is a bug.Category: This is a bug.L-improper_ctypesLint: improper_ctypesLint: improper_ctypesT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.