summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorJacob Pratt <jacob@jhpratt.dev>2025-08-01 00:38:20 -0400
committerGitHub <noreply@github.com>2025-08-01 00:38:20 -0400
commit400b8b68622407de11b21be3461648521fba11f1 (patch)
treea836706bd116271ac702ae3139738b9bdc819b7b /tests
parentc7ec9bcc6e0adb9adea907db12174f22b0e83989 (diff)
parenta33e084afe698e0a025211abd6dc1c9a4bb22e9d (diff)
downloadrust-400b8b68622407de11b21be3461648521fba11f1.tar.gz
rust-400b8b68622407de11b21be3461648521fba11f1.zip
Rollup merge of #144700 - aDotInTheVoid:macro-rules-for-macro-fools, r=GuillaumeGomez
rustdoc-json: Move `#[macro_export]` from `Other` to it's own  variant

Followup to rust-lang/rust#142936.

cargo-semver-checks [cares about this attribute](https://github.com/obi1kenobi/trustfall-rustdoc-adapter/blob/4a0d1b0ca19b3115bb65d0b6695c388d7f474ac9/src/visibility_tracker.rs#L459-L476), and it wasn't included in the initial PR for structured attributes CC `@obi1kenobi.`

r? `@GuillaumeGomez`
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..5d487cf6a56
--- /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" '["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" '["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