summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorAlona Enraght-Moony <code@alona.page>2025-07-30 19:12:31 +0000
committerAlona Enraght-Moony <code@alona.page>2025-07-30 19:54:23 +0000
commit1a515e69490cdc3cee5325c4fc8d18baa502f38a (patch)
treeca4e2b9aa93f15b4d097ce3df3304c621d0121f3 /tests
parente5e79f8bd428d0b8d26e8240d718b134ef297459 (diff)
downloadrust-1a515e69490cdc3cee5325c4fc8d18baa502f38a.tar.gz
rust-1a515e69490cdc3cee5325c4fc8d18baa502f38a.zip
rustdoc-json: Add test for `#[macro_use]` attribute
Diffstat (limited to 'tests')
-rw-r--r--tests/rustdoc-json/attrs/macro_export.rs40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/rustdoc-json/attrs/macro_export.rs b/tests/rustdoc-json/attrs/macro_export.rs
new file mode 100644
index 00000000000..1472aabb6ff
--- /dev/null
+++ b/tests/rustdoc-json/attrs/macro_export.rs
@@ -0,0 +1,40 @@
+//@ compile-flags: --document-private-items
+
+//@ set exported_id = "$.index[?(@.name=='exported')].id"
+//@ is "$.index[?(@.name=='exported')].attrs" '[{"other": "#[macro_export]"}]'
+//@ is "$.index[?(@.name=='exported')].visibility" '"public"'
+
+#[macro_export]
+macro_rules! exported {
+    () => {};
+}
+
+//@ set not_exported_id = "$.index[?(@.name=='not_exported')].id"
+//@ is "$.index[?(@.name=='not_exported')].attrs" []
+//@ is "$.index[?(@.name=='not_exported')].visibility" '"crate"'
+macro_rules! not_exported {
+    () => {};
+}
+
+//@ set module_id = "$.index[?(@.name=='module')].id"
+pub mod module {
+    //@ set exported_from_mod_id = "$.index[?(@.name=='exported_from_mod')].id"
+    //@ is "$.index[?(@.name=='exported_from_mod')].attrs" '[{"other": "#[macro_export]"}]'
+    //@ is "$.index[?(@.name=='exported_from_mod')].visibility" '"public"'
+    #[macro_export]
+    macro_rules! exported_from_mod {
+        () => {};
+    }
+
+    //@ set not_exported_from_mod_id = "$.index[?(@.name=='not_exported_from_mod')].id"
+    //@ is "$.index[?(@.name=='not_exported_from_mod')].attrs" []
+    //@ is "$.index[?(@.name=='not_exported_from_mod')].visibility" '"crate"'
+    macro_rules! not_exported_from_mod {
+        () => {};
+    }
+}
+// The non-exported macro's are left in place, but the #[macro_export]'d ones
+// are moved to the crate root.
+
+//@ is "$.index[?(@.name=='module')].inner.module.items[*]" $not_exported_from_mod_id
+//@ ismany "$.index[?(@.name=='macro_export')].inner.module.items[*]" $exported_id $not_exported_id $module_id $exported_from_mod_id