Make *const (), *mut () okay for FFI
This commit is contained in:
parent
c17e3e2c09
commit
abfad74ec6
3 changed files with 11 additions and 11 deletions
|
@ -1060,6 +1060,15 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
|||
FfiSafe
|
||||
}
|
||||
|
||||
ty::RawPtr(ty::TypeAndMut { ty, .. })
|
||||
if match ty.kind() {
|
||||
ty::Tuple(tuple) => tuple.is_empty(),
|
||||
_ => false,
|
||||
} =>
|
||||
{
|
||||
FfiSafe
|
||||
}
|
||||
|
||||
ty::RawPtr(ty::TypeAndMut { ty, .. }) | ty::Ref(_, ty, _) => {
|
||||
self.check_type_for_ffi(cache, ty)
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ pub struct ZeroSizeWithPhantomData(::std::marker::PhantomData<i32>);
|
|||
extern "C" {
|
||||
pub fn ptr_type1(size: *const Foo); //~ ERROR: uses type `Foo`
|
||||
pub fn ptr_type2(size: *const Foo); //~ ERROR: uses type `Foo`
|
||||
pub fn ptr_unit(p: *const ()); //~ ERROR: uses type `()`
|
||||
pub fn ptr_unit(p: *const ());
|
||||
pub fn ptr_tuple(p: *const ((),)); //~ ERROR: uses type `((),)`
|
||||
pub fn slice_type(p: &[u32]); //~ ERROR: uses type `[u32]`
|
||||
pub fn str_type(p: &str); //~ ERROR: uses type `str`
|
||||
|
|
|
@ -31,15 +31,6 @@ note: the type is defined here
|
|||
LL | pub struct Foo;
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: `extern` block uses type `()`, which is not FFI-safe
|
||||
--> $DIR/lint-ctypes.rs:50:24
|
||||
|
|
||||
LL | pub fn ptr_unit(p: *const ());
|
||||
| ^^^^^^^^^ not FFI-safe
|
||||
|
|
||||
= help: consider using a struct instead
|
||||
= note: tuples have unspecified layout
|
||||
|
||||
error: `extern` block uses type `((),)`, which is not FFI-safe
|
||||
--> $DIR/lint-ctypes.rs:51:25
|
||||
|
|
||||
|
@ -267,5 +258,5 @@ LL | pub static static_u128_array_type: [u128; 16];
|
|||
|
|
||||
= note: 128-bit integers don't currently have a known stable ABI
|
||||
|
||||
error: aborting due to 28 previous errors
|
||||
error: aborting due to 27 previous errors
|
||||
|
||||
|
|
Loading…
Reference in a new issue