about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorFabian Wolff <fabian.wolff@alumni.ethz.ch>2021-07-27 23:40:32 +0200
committerFabian Wolff <fabian.wolff@alumni.ethz.ch>2021-07-31 15:57:51 +0200
commit4e76c3820fea97e06f08555d4eeee3de3be4eb5a (patch)
treee27651b61975fc2f601d5aefa372c06d727bc53c /src
parent7069a8c2b78c5d23205de1cabb4c2a65229dbd8f (diff)
downloadrust-4e76c3820fea97e06f08555d4eeee3de3be4eb5a.tar.gz
rust-4e76c3820fea97e06f08555d4eeee3de3be4eb5a.zip
Fix ICE in `improper_ctypes_definitions` lint with all-ZST transparent types
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/repr/repr-transparent-issue-87496.rs12
-rw-r--r--src/test/ui/repr/repr-transparent-issue-87496.stderr16
2 files changed, 28 insertions, 0 deletions
diff --git a/src/test/ui/repr/repr-transparent-issue-87496.rs b/src/test/ui/repr/repr-transparent-issue-87496.rs
new file mode 100644
index 00000000000..a4dd45c63f5
--- /dev/null
+++ b/src/test/ui/repr/repr-transparent-issue-87496.rs
@@ -0,0 +1,12 @@
+// Regression test for the ICE described in #87496.
+
+// check-pass
+
+#[repr(transparent)]
+struct TransparentCustomZst(());
+extern "C" {
+    fn good17(p: TransparentCustomZst);
+    //~^ WARNING: `extern` block uses type `TransparentCustomZst`, which is not FFI-safe
+}
+
+fn main() {}
diff --git a/src/test/ui/repr/repr-transparent-issue-87496.stderr b/src/test/ui/repr/repr-transparent-issue-87496.stderr
new file mode 100644
index 00000000000..c488755cc24
--- /dev/null
+++ b/src/test/ui/repr/repr-transparent-issue-87496.stderr
@@ -0,0 +1,16 @@
+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
+   |
+   = note: `#[warn(improper_ctypes)]` on by default
+   = 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(());
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+warning: 1 warning emitted
+