about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_lint/src/types.rs9
-rw-r--r--src/test/ui/lint/lint-ctypes.rs2
-rw-r--r--src/test/ui/lint/lint-ctypes.stderr11
3 files changed, 11 insertions, 11 deletions
diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs
index 5d2256100ff..4e3bbc58559 100644
--- a/compiler/rustc_lint/src/types.rs
+++ b/compiler/rustc_lint/src/types.rs
@@ -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)
             }
diff --git a/src/test/ui/lint/lint-ctypes.rs b/src/test/ui/lint/lint-ctypes.rs
index 4a55b7cb25e..9165e14b7ff 100644
--- a/src/test/ui/lint/lint-ctypes.rs
+++ b/src/test/ui/lint/lint-ctypes.rs
@@ -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`
diff --git a/src/test/ui/lint/lint-ctypes.stderr b/src/test/ui/lint/lint-ctypes.stderr
index 8295d0655e3..342b6bfc6f8 100644
--- a/src/test/ui/lint/lint-ctypes.stderr
+++ b/src/test/ui/lint/lint-ctypes.stderr
@@ -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