-
Notifications
You must be signed in to change notification settings - Fork 13k
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 #72890 - davidtwco:issue-66202-normalize-and-transpar…
…ent-improper-ctypes, r=varkor improper ctypes: normalize return types and transparent structs Fixes #66202. See each commit individually (except the first which adds a test) for more detailed explanations on the changes made. In summary, this PR ensures that return types are normalized before being checked for FFI-safety, and that transparent newtype wrappers are FFI-safe if the type being wrapped is FFI-safe (often true previously, but not if, after substitution, all types in a transparent newtype were zero sized).
- Loading branch information
Showing
4 changed files
with
105 additions
and
40 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
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,17 @@ | ||
// check-pass | ||
|
||
#![deny(improper_ctypes)] | ||
|
||
// This test checks that return types are normalized before being checked for FFI-safety, and that | ||
// transparent newtype wrappers are FFI-safe if the type being wrapped is FFI-safe. | ||
|
||
#[repr(transparent)] | ||
pub struct W<T>(T); | ||
|
||
extern "C" { | ||
pub fn bare() -> (); | ||
pub fn normalize() -> <() as ToOwned>::Owned; | ||
pub fn transparent() -> W<()>; | ||
} | ||
|
||
fn main() {} |