From 8a9b67028cd9e3e580318007e7bc6391a7c6b86c Mon Sep 17 00:00:00 2001 From: Alona Enraght-Moony Date: Thu, 10 Oct 2024 20:53:57 +0000 Subject: [PATCH] rustdoc-json: Add tests for unsafe/safe extern blocks (RFC 3484) --- tests/rustdoc-json/fns/extern_safe.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tests/rustdoc-json/fns/extern_safe.rs diff --git a/tests/rustdoc-json/fns/extern_safe.rs b/tests/rustdoc-json/fns/extern_safe.rs new file mode 100644 index 0000000000000..a4a2d2c7f8c1e --- /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(); +}