diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 1f1868d88af5..f5e8a4e14a9c 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -770,8 +770,8 @@ pub(crate) fn type_(&self) -> ItemType { pub(crate) fn types(&self) -> impl Iterator { if let ItemKind::MacroItem(_, macro_kinds) = self.kind { Either::Right(macro_kinds.iter().map(|kind| match kind { - MacroKinds::ATTR => ItemType::BangMacroAttribute, - MacroKinds::DERIVE => ItemType::BangMacroDerive, + MacroKinds::ATTR => ItemType::DeclMacroAttribute, + MacroKinds::DERIVE => ItemType::DeclMacroDerive, MacroKinds::BANG => ItemType::Macro, _ => panic!("unsupported macro kind {kind:?}"), })) diff --git a/src/librustdoc/formats/item_type.rs b/src/librustdoc/formats/item_type.rs index e6db950a4236..5b3458e60491 100644 --- a/src/librustdoc/formats/item_type.rs +++ b/src/librustdoc/formats/item_type.rs @@ -105,8 +105,8 @@ fn visit_u64(self, v: u64) -> Result { // distinction because they will point to a `macro.[name].html` file and not // `[attr|derive].[name].html` file, so the link generation needs to take it into account while // still having the filtering working as expected. - BangMacroAttribute = 28, - BangMacroDerive = 29, + DeclMacroAttribute = 28, + DeclMacroDerive = 29, } impl<'a> From<&'a clean::Item> for ItemType { @@ -226,8 +226,8 @@ pub(crate) fn as_str(&self) -> &'static str { ItemType::AssocConst => "associatedconstant", ItemType::ForeignType => "foreigntype", ItemType::Keyword => "keyword", - ItemType::ProcAttribute | ItemType::BangMacroAttribute => "attr", - ItemType::ProcDerive | ItemType::BangMacroDerive => "derive", + ItemType::ProcAttribute | ItemType::DeclMacroAttribute => "attr", + ItemType::ProcDerive | ItemType::DeclMacroDerive => "derive", ItemType::TraitAlias => "traitalias", ItemType::Attribute => "attribute", } diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 70de77814371..bef3782b048e 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -543,10 +543,10 @@ fn add_item_entry(&mut self, item_type: ItemType, new_url: String, name: String) ItemType::TypeAlias => self.type_aliases.insert(ItemEntry::new(new_url, name)), ItemType::Static => self.statics.insert(ItemEntry::new(new_url, name)), ItemType::Constant => self.constants.insert(ItemEntry::new(new_url, name)), - ItemType::ProcAttribute | ItemType::BangMacroAttribute => { + ItemType::ProcAttribute | ItemType::DeclMacroAttribute => { self.attribute_macros.insert(ItemEntry::new(new_url, name)) } - ItemType::ProcDerive | ItemType::BangMacroDerive => { + ItemType::ProcDerive | ItemType::DeclMacroDerive => { self.derive_macros.insert(ItemEntry::new(new_url, name)) } ItemType::TraitAlias => self.trait_aliases.insert(ItemEntry::new(new_url, name)), @@ -2605,8 +2605,8 @@ fn id(self) -> &'static str { Self::AssociatedConstants => "associated-consts", Self::ForeignTypes => "foreign-types", Self::Keywords => "keywords", - Self::Attributes => "attributes", - Self::AttributeMacros => "attribute-macros", + Self::Attributes => "attribute-docs", + Self::AttributeMacros => "attributes", Self::DeriveMacros => "derives", Self::TraitAliases => "trait-aliases", } @@ -2667,8 +2667,8 @@ fn item_ty_to_section(ty: ItemType) -> ItemSection { ItemType::ForeignType => ItemSection::ForeignTypes, ItemType::Keyword => ItemSection::Keywords, ItemType::Attribute => ItemSection::Attributes, - ItemType::ProcAttribute | ItemType::BangMacroAttribute => ItemSection::AttributeMacros, - ItemType::ProcDerive | ItemType::BangMacroDerive => ItemSection::DeriveMacros, + ItemType::ProcAttribute | ItemType::DeclMacroAttribute => ItemSection::AttributeMacros, + ItemType::ProcDerive | ItemType::DeclMacroDerive => ItemSection::DeriveMacros, ItemType::TraitAlias => ItemSection::TraitAliases, } } diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 732e20bf5b11..ce33ad39c25f 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -235,8 +235,8 @@ fn deprecation_class_attr(is_deprecated: bool) -> &'static str { // we cheat by turning them into their "proc-macro equivalent". for type_ in item.types() { let type_ = match type_ { - ItemType::BangMacroAttribute => ItemType::ProcAttribute, - ItemType::BangMacroDerive => ItemType::ProcDerive, + ItemType::DeclMacroAttribute => ItemType::ProcAttribute, + ItemType::DeclMacroDerive => ItemType::ProcDerive, type_ => type_, }; not_stripped_items.entry(type_).or_default().push((index, item)); diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index c921e9703a5e..7a2a4616e3c6 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -793,8 +793,8 @@ function preLoadCss(cssUrl) { //block("associatedconstant", "associated-consts", "Associated Constants"); block("foreigntype", "foreign-types", "Foreign Types"); block("keyword", "keywords", "Keywords"); - block("attribute", "attributes", "Attributes"); - block("attr", "attribute-macros", "Attribute Macros"); + block("attribute", "attribute-docs", "Attributes"); + block("attr", "attributes", "Attribute Macros"); block("derive", "derives", "Derive Macros"); block("traitalias", "trait-aliases", "Trait Aliases"); } diff --git a/src/librustdoc/html/static/js/rustdoc.d.ts b/src/librustdoc/html/static/js/rustdoc.d.ts index de2155a47a8c..d77c87f40bb5 100644 --- a/src/librustdoc/html/static/js/rustdoc.d.ts +++ b/src/librustdoc/html/static/js/rustdoc.d.ts @@ -265,7 +265,7 @@ declare namespace rustdoc { * But the documentation lives in a single `macro.NAME.html` page, and * this boolean flag is used for generating that HREF. */ - isBangMacro: boolean, + forceMacroHref: boolean, } /** diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index d184b7429336..081f59aa9691 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -1658,13 +1658,13 @@ class DocSearch { deprecated: raw[6] === 1 ? true : false, unstable: raw[7] === 1 ? true : false, associatedItemDisambiguatorOrExternCrateUrl: raw.length === 8 ? null : raw[8], - isBangMacro: false, + forceMacroHref: false, }; if (item.ty === 28 || item.ty === 29) { // "proc attribute" is 23, "proc derive" is 24 whereas "bang macro attribute" is 28 and // "bang macro derive" is 29, so 5 of difference to go from the latter to the former. item.ty -= 5; - item.isBangMacro = true; + item.forceMacroHref = true; } return item; } @@ -2164,7 +2164,7 @@ class DocSearch { let displayPath; let href; let traitPath = null; - const type = item.entry && item.entry.isBangMacro ? "macro" : itemTypesName[item.ty]; + const type = item.entry && item.entry.forceMacroHref ? "macro" : itemTypesName[item.ty]; const name = item.name; let path = item.modulePath; let exactPath = item.exactModulePath; diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index 66481fea40b5..0c9ccd47c40d 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -899,8 +899,8 @@ fn from_clean(kind: &ItemType, _renderer: &JsonRenderer<'_>) -> Self { Keyword => ItemKind::Keyword, Attribute => ItemKind::Attribute, TraitAlias => ItemKind::TraitAlias, - ProcAttribute | BangMacroAttribute => ItemKind::ProcAttribute, - ProcDerive | BangMacroDerive => ItemKind::ProcDerive, + ProcAttribute | DeclMacroAttribute => ItemKind::ProcAttribute, + ProcDerive | DeclMacroDerive => ItemKind::ProcDerive, } } } diff --git a/tests/rustdoc-gui/attr-macros.goml b/tests/rustdoc-gui/attr-macros.goml index 23ad12fb582e..353fead84bd8 100644 --- a/tests/rustdoc-gui/attr-macros.goml +++ b/tests/rustdoc-gui/attr-macros.goml @@ -53,7 +53,7 @@ define-function: ( // Now we check it's correctly listed in the crate page. go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" -call-function: ("crate_page", {"name": "attr_macro", "section_id": "attribute-macros"}) +call-function: ("crate_page", {"name": "attr_macro", "section_id": "attributes"}) call-function: ("crate_page", {"name": "derive_macro", "section_id": "derives"}) // We also check we don't have duplicated sections. assert-count: ("//*[@id='main-content']/h2[text()='Attribute Macros']", 1) @@ -77,7 +77,7 @@ define-function: ( // And finally we check it's correctly listed in the "all items" page. go-to: "file://" + |DOC_PATH| + "/test_docs/all.html" -call-function: ("all_items_page", {"name": "attr_macro", "section_id": "attribute-macros"}) +call-function: ("all_items_page", {"name": "attr_macro", "section_id": "attributes"}) call-function: ("all_items_page", {"name": "derive_macro", "section_id": "derives"}) // We now check a macro with all 3 different kinds. diff --git a/tests/rustdoc-gui/module-items-font.goml b/tests/rustdoc-gui/module-items-font.goml index 822e0adc3b71..013b82a6bfaf 100644 --- a/tests/rustdoc-gui/module-items-font.goml +++ b/tests/rustdoc-gui/module-items-font.goml @@ -66,6 +66,15 @@ assert-css: ( {"font-family": '"Source Serif 4", NanumBarunGothic, serif'}, ) // attributes +assert-css: ( + "#attribute-docs + .item-table dt a", + {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'}, +) +assert-css: ( + "#attribute-docs + .item-table dd", + {"font-family": '"Source Serif 4", NanumBarunGothic, serif'}, +) +// attribute macros assert-css: ( "#attributes + .item-table dt a", {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'}, @@ -74,12 +83,3 @@ assert-css: ( "#attributes + .item-table dd", {"font-family": '"Source Serif 4", NanumBarunGothic, serif'}, ) -// attribute macros -assert-css: ( - "#attribute-macros + .item-table dt a", - {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'}, -) -assert-css: ( - "#attribute-macros + .item-table dd", - {"font-family": '"Source Serif 4", NanumBarunGothic, serif'}, -) diff --git a/tests/rustdoc-html/doc-attribute.rs b/tests/rustdoc-html/doc-attribute.rs index 92e603ae6e55..47f2a7fccf6f 100644 --- a/tests/rustdoc-html/doc-attribute.rs +++ b/tests/rustdoc-html/doc-attribute.rs @@ -4,10 +4,10 @@ #![feature(rustdoc_internals)] -//@ has foo/index.html '//h2[@id="attributes"]' 'Attributes' +//@ has foo/index.html '//h2[@id="attribute-docs"]' 'Attributes' //@ has foo/index.html '//a[@href="attribute.no_mangle.html"]' 'no_mangle' //@ has foo/index.html '//div[@class="sidebar-elems"]//li/a' 'Attributes' -//@ has foo/index.html '//div[@class="sidebar-elems"]//li/a/@href' '#attributes' +//@ has foo/index.html '//div[@class="sidebar-elems"]//li/a/@href' '#attribute-docs' //@ has foo/attribute.no_mangle.html '//h1' 'Attribute no_mangle' //@ has foo/attribute.no_mangle.html '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!' //@ has foo/index.html '//a/@href' '../foo/index.html'