Skip to content

Commit a33e084

Browse files
committed
rustdoc-json: Move #[macro_export] from Other to it's own variant
1 parent 1a515e6 commit a33e084

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src/librustdoc/json/conversions.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -908,8 +908,12 @@ fn maybe_from_hir_attr(
908908
hir::Attribute::Parsed(kind) => kind,
909909

910910
hir::Attribute::Unparsed(_) => {
911-
// FIXME: We should handle `#[doc(hidden)]`.
912-
return Some(other_attr(tcx, attr));
911+
return Some(if attr.has_name(sym::macro_export) {
912+
Attribute::MacroExport
913+
// FIXME: We should handle `#[doc(hidden)]`.
914+
} else {
915+
other_attr(tcx, attr)
916+
});
913917
}
914918
};
915919

src/rustdoc-json-types/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ pub type FxHashMap<K, V> = HashMap<K, V>; // re-export for use in src/librustdoc
3737
// will instead cause conflicts. See #94591 for more. (This paragraph and the "Latest feature" line
3838
// are deliberately not in a doc comment, because they need not be in public docs.)
3939
//
40-
// Latest feature: Structured Attributes
41-
pub const FORMAT_VERSION: u32 = 54;
40+
// Latest feature: Add Attribute::MacroUse
41+
pub const FORMAT_VERSION: u32 = 55;
4242

4343
/// The root of the emitted JSON blob.
4444
///
@@ -216,6 +216,9 @@ pub enum Attribute {
216216
/// `#[must_use]`
217217
MustUse { reason: Option<String> },
218218

219+
/// `#[macro_export]`
220+
MacroExport,
221+
219222
/// `#[export_name = "name"]`
220223
ExportName(String),
221224

tests/rustdoc-json/attrs/macro_export.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//@ compile-flags: --document-private-items
22

33
//@ set exported_id = "$.index[?(@.name=='exported')].id"
4-
//@ is "$.index[?(@.name=='exported')].attrs" '[{"other": "#[macro_export]"}]'
4+
//@ is "$.index[?(@.name=='exported')].attrs" '["macro_export"]'
55
//@ is "$.index[?(@.name=='exported')].visibility" '"public"'
66

77
#[macro_export]
@@ -19,7 +19,7 @@ macro_rules! not_exported {
1919
//@ set module_id = "$.index[?(@.name=='module')].id"
2020
pub mod module {
2121
//@ set exported_from_mod_id = "$.index[?(@.name=='exported_from_mod')].id"
22-
//@ is "$.index[?(@.name=='exported_from_mod')].attrs" '[{"other": "#[macro_export]"}]'
22+
//@ is "$.index[?(@.name=='exported_from_mod')].attrs" '["macro_export"]'
2323
//@ is "$.index[?(@.name=='exported_from_mod')].visibility" '"public"'
2424
#[macro_export]
2525
macro_rules! exported_from_mod {

0 commit comments

Comments
 (0)