about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlona Enraght-Moony <code@alona.page>2024-10-10 20:53:57 +0000
committerAlona Enraght-Moony <code@alona.page>2024-10-10 20:53:57 +0000
commit8a9b67028cd9e3e580318007e7bc6391a7c6b86c (patch)
treed0941e8e93ef37a9edb6dcf1674c3296a7b8be1a
parent8d94e06ec9758b5c03ea77bb5dab22a1a76bc261 (diff)
downloadrust-8a9b67028cd9e3e580318007e7bc6391a7c6b86c.tar.gz
rust-8a9b67028cd9e3e580318007e7bc6391a7c6b86c.zip
rustdoc-json: Add tests for unsafe/safe extern blocks (RFC 3484)
-rw-r--r--tests/rustdoc-json/fns/extern_safe.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/rustdoc-json/fns/extern_safe.rs b/tests/rustdoc-json/fns/extern_safe.rs
new file mode 100644
index 00000000000..a4a2d2c7f8c
--- /dev/null
+++ b/tests/rustdoc-json/fns/extern_safe.rs
@@ -0,0 +1,17 @@
+extern "C" {
+    //@ is "$.index[*][?(@.name=='f1')].inner.function.header.is_unsafe" true
+    pub fn f1();
+
+    // items in unadorned `extern` blocks cannot have safety qualifiers
+}
+
+unsafe extern "C" {
+    //@ is "$.index[*][?(@.name=='f4')].inner.function.header.is_unsafe" true
+    pub fn f4();
+
+    //@ is "$.index[*][?(@.name=='f5')].inner.function.header.is_unsafe" true
+    pub unsafe fn f5();
+
+    //@ is "$.index[*][?(@.name=='f6')].inner.function.header.is_unsafe" false
+    pub safe fn f6();
+}