about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/lint/lint-ctypes-113436-1.rs28
-rw-r--r--tests/ui/lint/lint-ctypes-113436-1.stderr35
-rw-r--r--tests/ui/lint/lint-ctypes-113436.rs5
-rw-r--r--tests/ui/lint/lint-ctypes-113436.stderr43
-rw-r--r--tests/ui/repr/repr-transparent-issue-87496.rs2
-rw-r--r--tests/ui/repr/repr-transparent-issue-87496.stderr10
6 files changed, 72 insertions, 51 deletions
diff --git a/tests/ui/lint/lint-ctypes-113436-1.rs b/tests/ui/lint/lint-ctypes-113436-1.rs
new file mode 100644
index 00000000000..1ca59c6868d
--- /dev/null
+++ b/tests/ui/lint/lint-ctypes-113436-1.rs
@@ -0,0 +1,28 @@
+#![deny(improper_ctypes_definitions)]
+
+#[repr(C)]
+pub struct Foo {
+    a: u8,
+    b: (),
+}
+
+extern "C" fn foo(x: Foo) -> Foo {
+    todo!()
+}
+
+struct NotSafe(u32);
+
+#[repr(C)]
+pub struct Bar {
+    a: u8,
+    b: (),
+    c: NotSafe,
+}
+
+extern "C" fn bar(x: Bar) -> Bar {
+    //~^ ERROR `extern` fn uses type `NotSafe`, which is not FFI-safe
+    //~^^ ERROR `extern` fn uses type `NotSafe`, which is not FFI-safe
+    todo!()
+}
+
+fn main() {}
diff --git a/tests/ui/lint/lint-ctypes-113436-1.stderr b/tests/ui/lint/lint-ctypes-113436-1.stderr
new file mode 100644
index 00000000000..7b63043f057
--- /dev/null
+++ b/tests/ui/lint/lint-ctypes-113436-1.stderr
@@ -0,0 +1,35 @@
+error: `extern` fn uses type `NotSafe`, which is not FFI-safe
+  --> $DIR/lint-ctypes-113436-1.rs:22:22
+   |
+LL | extern "C" fn bar(x: Bar) -> Bar {
+   |                      ^^^ not FFI-safe
+   |
+   = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
+   = note: this struct has unspecified layout
+note: the type is defined here
+  --> $DIR/lint-ctypes-113436-1.rs:13:1
+   |
+LL | struct NotSafe(u32);
+   | ^^^^^^^^^^^^^^
+note: the lint level is defined here
+  --> $DIR/lint-ctypes-113436-1.rs:1:9
+   |
+LL | #![deny(improper_ctypes_definitions)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: `extern` fn uses type `NotSafe`, which is not FFI-safe
+  --> $DIR/lint-ctypes-113436-1.rs:22:30
+   |
+LL | extern "C" fn bar(x: Bar) -> Bar {
+   |                              ^^^ not FFI-safe
+   |
+   = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
+   = note: this struct has unspecified layout
+note: the type is defined here
+  --> $DIR/lint-ctypes-113436-1.rs:13:1
+   |
+LL | struct NotSafe(u32);
+   | ^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/lint/lint-ctypes-113436.rs b/tests/ui/lint/lint-ctypes-113436.rs
index d1328af9924..4f733b5bb16 100644
--- a/tests/ui/lint/lint-ctypes-113436.rs
+++ b/tests/ui/lint/lint-ctypes-113436.rs
@@ -1,3 +1,4 @@
+// check-pass
 #![deny(improper_ctypes_definitions)]
 
 #[repr(C)]
@@ -7,20 +8,16 @@ pub struct Wrap<T>(T);
 pub struct TransparentWrap<T>(T);
 
 pub extern "C" fn f() -> Wrap<()> {
-    //~^ ERROR `extern` fn uses type `()`, which is not FFI-safe
     todo!()
 }
 
 const _: extern "C" fn() -> Wrap<()> = f;
-//~^ ERROR `extern` fn uses type `()`, which is not FFI-safe
 
 pub extern "C" fn ff() -> Wrap<Wrap<()>> {
-    //~^ ERROR `extern` fn uses type `()`, which is not FFI-safe
     todo!()
 }
 
 const _: extern "C" fn() -> Wrap<Wrap<()>> = ff;
-//~^ ERROR `extern` fn uses type `()`, which is not FFI-safe
 
 pub extern "C" fn g() -> TransparentWrap<()> {
     todo!()
diff --git a/tests/ui/lint/lint-ctypes-113436.stderr b/tests/ui/lint/lint-ctypes-113436.stderr
deleted file mode 100644
index 72f92c1a49c..00000000000
--- a/tests/ui/lint/lint-ctypes-113436.stderr
+++ /dev/null
@@ -1,43 +0,0 @@
-error: `extern` fn uses type `()`, which is not FFI-safe
-  --> $DIR/lint-ctypes-113436.rs:9:26
-   |
-LL | pub extern "C" fn f() -> Wrap<()> {
-   |                          ^^^^^^^^ not FFI-safe
-   |
-   = help: consider using a struct instead
-   = note: tuples have unspecified layout
-note: the lint level is defined here
-  --> $DIR/lint-ctypes-113436.rs:1:9
-   |
-LL | #![deny(improper_ctypes_definitions)]
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: `extern` fn uses type `()`, which is not FFI-safe
-  --> $DIR/lint-ctypes-113436.rs:14:10
-   |
-LL | const _: extern "C" fn() -> Wrap<()> = f;
-   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
-   |
-   = help: consider using a struct instead
-   = note: tuples have unspecified layout
-
-error: `extern` fn uses type `()`, which is not FFI-safe
-  --> $DIR/lint-ctypes-113436.rs:17:27
-   |
-LL | pub extern "C" fn ff() -> Wrap<Wrap<()>> {
-   |                           ^^^^^^^^^^^^^^ not FFI-safe
-   |
-   = help: consider using a struct instead
-   = note: tuples have unspecified layout
-
-error: `extern` fn uses type `()`, which is not FFI-safe
-  --> $DIR/lint-ctypes-113436.rs:22:10
-   |
-LL | const _: extern "C" fn() -> Wrap<Wrap<()>> = ff;
-   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
-   |
-   = help: consider using a struct instead
-   = note: tuples have unspecified layout
-
-error: aborting due to 4 previous errors
-
diff --git a/tests/ui/repr/repr-transparent-issue-87496.rs b/tests/ui/repr/repr-transparent-issue-87496.rs
index 0ce6fb2c19f..a4dd45c63f5 100644
--- a/tests/ui/repr/repr-transparent-issue-87496.rs
+++ b/tests/ui/repr/repr-transparent-issue-87496.rs
@@ -6,7 +6,7 @@
 struct TransparentCustomZst(());
 extern "C" {
     fn good17(p: TransparentCustomZst);
-    //~^ WARNING: `extern` block uses type `()`, which is not FFI-safe
+    //~^ WARNING: `extern` block uses type `TransparentCustomZst`, which is not FFI-safe
 }
 
 fn main() {}
diff --git a/tests/ui/repr/repr-transparent-issue-87496.stderr b/tests/ui/repr/repr-transparent-issue-87496.stderr
index 03c62f8514e..aee31212b4e 100644
--- a/tests/ui/repr/repr-transparent-issue-87496.stderr
+++ b/tests/ui/repr/repr-transparent-issue-87496.stderr
@@ -1,11 +1,15 @@
-warning: `extern` block uses type `()`, which is not FFI-safe
+warning: `extern` block uses type `TransparentCustomZst`, which is not FFI-safe
   --> $DIR/repr-transparent-issue-87496.rs:8:18
    |
 LL |     fn good17(p: TransparentCustomZst);
    |                  ^^^^^^^^^^^^^^^^^^^^ not FFI-safe
    |
-   = help: consider using a struct instead
-   = note: tuples have unspecified layout
+   = note: this struct contains only zero-sized fields
+note: the type is defined here
+  --> $DIR/repr-transparent-issue-87496.rs:6:1
+   |
+LL | struct TransparentCustomZst(());
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: `#[warn(improper_ctypes)]` on by default
 
 warning: 1 warning emitted