-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #106675 - krtab:fix_improper_ctypes, r=davidtwco
Mark ZST as FFI-safe if all its fields are PhantomData This presents one possible solution to issue: #106629. This is my first (tentative) contribution to the compiler itself. I'm looking forward for comments and feedback Closes: #106629
- Loading branch information
Showing
2 changed files
with
45 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// This is a regression test for issue https://github.com/rust-lang/rust/issues/106629. | ||
// It ensures that transparent types where all fields are PhantomData are marked as | ||
// FFI-safe. | ||
|
||
// check-pass | ||
|
||
#[repr(transparent)] | ||
#[derive(Copy, Clone)] | ||
struct MyPhantom(core::marker::PhantomData<u8>); | ||
|
||
#[repr(C)] | ||
#[derive(Copy, Clone)] | ||
pub struct Bar { | ||
pub x: i32, | ||
_marker: MyPhantom, | ||
} | ||
|
||
extern "C" { | ||
pub fn foo(bar: *mut Bar); | ||
} | ||
|
||
fn main() {} |