Skip to content

Commit 718a495

Browse files
Replace "bang macro" mentions with "decl macro"
Add more typescript type annotations Improve functions naming
1 parent 6eca740 commit 718a495

6 files changed

Lines changed: 9 additions & 15 deletions

File tree

src/librustdoc/clean/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ impl Item {
768768
}
769769

770770
/// Returns true if this a macro declared with the `macro` keyword or with `macro_rules!.
771-
pub(crate) fn is_bang_macro_or_macro_rules(&self) -> bool {
771+
pub(crate) fn is_decl_macro(&self) -> bool {
772772
matches!(self.kind, ItemKind::MacroItem(..))
773773
}
774774

src/librustdoc/html/render/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ impl<'tcx> Context<'tcx> {
351351
Some(s) => s,
352352
};
353353

354-
let is_macro_rules = item.is_bang_macro_or_macro_rules();
354+
let is_macro_rules = item.is_decl_macro();
355355
for type_ in item.types() {
356356
if inserted.entry(type_).or_default().insert(name) {
357357
let type_ = type_.to_string();

src/librustdoc/html/render/print_item.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,8 @@ pub(super) fn print_item(cx: &Context<'_>, item: &clean::Item) -> impl fmt::Disp
129129
let item_vars = ItemVars {
130130
typ,
131131
name: item.name.as_ref().unwrap().as_str(),
132-
// It's fine to use `type_` here because, even if it's a bang macro with multiple kinds,
133-
// since we're generating its documentation page, we can default to the "parent" type,
134-
// ie "macro".
132+
// It's fine to use `type_` here because, even if it's a decl macro with multiple kinds,
133+
// since we're generating its documentation page, we can default to the macro type.
135134
item_type: &item.type_().to_string(),
136135
path_components,
137136
stability_since_raw: &stability_since_raw,
@@ -231,7 +230,7 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
231230
FxIndexMap::default();
232231

233232
for (index, item) in items.iter().filter(|i| !i.is_stripped()).enumerate() {
234-
// To prevent having new "bang macro attribute/derive" sections in the module,
233+
// To prevent having new "decl macro attribute/derive" sections in the module,
235234
// we cheat by turning them into their "proc-macro equivalent".
236235
for type_ in item.types() {
237236
let type_ = match type_ {

src/librustdoc/html/static/js/main.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -732,12 +732,7 @@ function preLoadCss(cssUrl) {
732732
ul.className = "block " + shortty;
733733

734734
for (const item of filtered) {
735-
let name = item;
736-
let isMacro = false;
737-
if (Array.isArray(item)) {
738-
name = item[0];
739-
isMacro = true;
740-
}
735+
const [name, isMacro] = Array.isArray(item) ? [item[0], true] : [item, false];
741736
let path;
742737
if (shortty === "mod") {
743738
path = `${modpath}${name}/index.html`;

src/librustdoc/html/static/js/rustdoc.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ declare global {
2727
/** Make the current theme easy to find */
2828
currentTheme: HTMLLinkElement|null;
2929
/** Generated in `render/context.rs` */
30-
SIDEBAR_ITEMS?: { [key: string]: string[] };
30+
SIDEBAR_ITEMS?: { [key: string]: Array<string | string[]> };
3131
/** Notable trait data */
3232
NOTABLE_TRAITS?: { [key: string]: string };
3333
CURRENT_TOOLTIP_ELEMENT?: HTMLElement & { TOOLTIP_BASE: HTMLElement };

src/librustdoc/html/static/js/search.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,8 +1661,8 @@ class DocSearch {
16611661
forceMacroHref: false,
16621662
};
16631663
if (item.ty === 28 || item.ty === 29) {
1664-
// "proc attribute" is 23, "proc derive" is 24 whereas "bang macro attribute" is 28 and
1665-
// "bang macro derive" is 29, so 5 of difference to go from the latter to the former.
1664+
// "proc attribute" is 23, "proc derive" is 24 whereas "decl macro attribute" is 28 and
1665+
// "decl macro derive" is 29, so 5 of difference to go from the latter to the former.
16661666
item.ty -= 5;
16671667
item.forceMacroHref = true;
16681668
}

0 commit comments

Comments
 (0)