about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorDavid Wood <david@davidtw.co>2020-06-01 17:00:58 +0100
committerDavid Wood <david@davidtw.co>2020-06-09 14:37:08 +0100
commitd4d3d7de68d331829b5dcd08be3d4aec1a7a7f2b (patch)
tree2c0344dceb06682a889bbe4876f829b470ef8b48 /src/rustllvm/RustWrapper.cpp
parent3e7aabb1b3ec9ad66c7a306cd956e880a1a51483 (diff)
downloadrust-d4d3d7de68d331829b5dcd08be3d4aec1a7a7f2b.tar.gz
rust-d4d3d7de68d331829b5dcd08be3d4aec1a7a7f2b.zip
lint: transitive FFI-safety for transparent types
This commit ensures that if a `repr(transparent)` newtype's only
non-zero-sized field is FFI-safe then the newtype is also FFI-safe.

Previously, ZSTs were ignored for the purposes of linting FFI-safety
in transparent structs - thus, only the single non-ZST would be checked
for FFI-safety. However, if the non-zero-sized field is a generic
parameter, and is substituted for a ZST, then the type would be
considered FFI-unsafe (as when every field is thought to be zero-sized,
the type is considered to be "composed only of `PhantomData`" which is
FFI-unsafe).

In this commit, for transparent structs, the non-zero-sized field is
identified (before any substitutions are applied, necessarily) and then
that field's type (now with substitutions) is checked for FFI-safety
(where previously it would have been skipped for being zero-sized in
this case).

To handle the case where the non-zero-sized field is a generic
parameter, which is substituted for `()` (a ZST), and is being used
as a return type - the `FfiUnsafe` result (previously `FfiPhantom`) is
caught and silenced.

Signed-off-by: David Wood <david@davidtw.co>
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions