-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mark ZST as FFI-safe if all its fields are PhantomData
Modify the linting behavior and add the corresponding regression test
- 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() {} |