]> git.proxmox.com Git - rustc.git/blobdiff - src/test/ui/lint/clashing-extern-fn.rs
New upstream version 1.52.0~beta.3+dfsg1
[rustc.git] / src / test / ui / lint / clashing-extern-fn.rs
index 41f0baecf24a892704d45d95beaed02c808b5fea..2ce4dd56eab0dcc534033544ef0e80e7fb1e3dfb 100644 (file)
@@ -1,6 +1,7 @@
 // check-pass
 // aux-build:external_extern_fn.rs
 #![crate_type = "lib"]
+#![feature(no_niche)]
 #![warn(clashing_extern_declarations)]
 
 mod redeclared_different_signature {
@@ -383,3 +384,36 @@ mod unknown_layout {
         }
     }
 }
+
+mod hidden_niche {
+    mod a {
+        extern "C" {
+            fn hidden_niche_transparent() -> usize;
+            fn hidden_niche_transparent_no_niche() -> usize;
+            fn hidden_niche_unsafe_cell() -> usize;
+        }
+    }
+    mod b {
+        use std::cell::UnsafeCell;
+        use std::num::NonZeroUsize;
+
+        #[repr(transparent)]
+        struct Transparent { x: NonZeroUsize }
+
+        #[repr(no_niche)]
+        #[repr(transparent)]
+        struct TransparentNoNiche { y: NonZeroUsize }
+
+        extern "C" {
+            fn hidden_niche_transparent() -> Option<Transparent>;
+
+            fn hidden_niche_transparent_no_niche() -> Option<TransparentNoNiche>;
+            //~^ WARN redeclared with a different signature
+            //~| WARN block uses type `Option<TransparentNoNiche>`, which is not FFI-safe
+
+            fn hidden_niche_unsafe_cell() -> Option<UnsafeCell<NonZeroUsize>>;
+            //~^ WARN redeclared with a different signature
+            //~| WARN block uses type `Option<UnsafeCell<NonZeroUsize>>`, which is not FFI-safe
+        }
+    }
+}