rustdoc: Clean Visibility
outside of display_macro_source
This change should make the code a bit clearer and easier to change.
This commit is contained in:
parent
41301c3b23
commit
7a7698aa1b
3 changed files with 9 additions and 13 deletions
|
@ -592,14 +592,9 @@ fn build_macro(
|
|||
match CStore::from_tcx(cx.tcx).load_macro_untracked(def_id, cx.sess()) {
|
||||
LoadedMacro::MacroDef(item_def, _) => {
|
||||
if let ast::ItemKind::MacroDef(ref def) = item_def.kind {
|
||||
let vis = cx.tcx.visibility(import_def_id.unwrap_or(def_id)).clean(cx);
|
||||
clean::MacroItem(clean::Macro {
|
||||
source: utils::display_macro_source(
|
||||
cx,
|
||||
name,
|
||||
def,
|
||||
def_id,
|
||||
cx.tcx.visibility(import_def_id.unwrap_or(def_id)),
|
||||
),
|
||||
source: utils::display_macro_source(cx, name, def, def_id, vis),
|
||||
})
|
||||
} else {
|
||||
unreachable!()
|
||||
|
|
|
@ -1792,9 +1792,12 @@ impl Clean<Vec<Item>> for (&hir::Item<'_>, Option<Symbol>) {
|
|||
ItemKind::Fn(ref sig, ref generics, body_id) => {
|
||||
clean_fn_or_proc_macro(item, sig, generics, body_id, &mut name, cx)
|
||||
}
|
||||
ItemKind::Macro(ref macro_def) => MacroItem(Macro {
|
||||
source: display_macro_source(cx, name, macro_def, def_id, item.vis),
|
||||
}),
|
||||
ItemKind::Macro(ref macro_def) => {
|
||||
let vis = item.vis.clean(cx);
|
||||
MacroItem(Macro {
|
||||
source: display_macro_source(cx, name, macro_def, def_id, vis),
|
||||
})
|
||||
}
|
||||
ItemKind::Trait(is_auto, unsafety, ref generics, bounds, item_ids) => {
|
||||
let items = item_ids
|
||||
.iter()
|
||||
|
|
|
@ -529,7 +529,7 @@ pub(super) fn display_macro_source(
|
|||
name: Symbol,
|
||||
def: &ast::MacroDef,
|
||||
def_id: DefId,
|
||||
vis: impl Clean<Visibility>,
|
||||
vis: Visibility,
|
||||
) -> String {
|
||||
let tts: Vec<_> = def.body.inner_tokens().into_trees().collect();
|
||||
// Extract the spans of all matchers. They represent the "interface" of the macro.
|
||||
|
@ -538,8 +538,6 @@ pub(super) fn display_macro_source(
|
|||
if def.macro_rules {
|
||||
format!("macro_rules! {} {{\n{}}}", name, render_macro_arms(matchers, ";"))
|
||||
} else {
|
||||
let vis = vis.clean(cx);
|
||||
|
||||
if matchers.len() <= 1 {
|
||||
format!(
|
||||
"{}macro {}{} {{\n ...\n}}",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue