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()) {
|
match CStore::from_tcx(cx.tcx).load_macro_untracked(def_id, cx.sess()) {
|
||||||
LoadedMacro::MacroDef(item_def, _) => {
|
LoadedMacro::MacroDef(item_def, _) => {
|
||||||
if let ast::ItemKind::MacroDef(ref def) = item_def.kind {
|
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 {
|
clean::MacroItem(clean::Macro {
|
||||||
source: utils::display_macro_source(
|
source: utils::display_macro_source(cx, name, def, def_id, vis),
|
||||||
cx,
|
|
||||||
name,
|
|
||||||
def,
|
|
||||||
def_id,
|
|
||||||
cx.tcx.visibility(import_def_id.unwrap_or(def_id)),
|
|
||||||
),
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
unreachable!()
|
unreachable!()
|
||||||
|
|
|
@ -1792,9 +1792,12 @@ impl Clean<Vec<Item>> for (&hir::Item<'_>, Option<Symbol>) {
|
||||||
ItemKind::Fn(ref sig, ref generics, body_id) => {
|
ItemKind::Fn(ref sig, ref generics, body_id) => {
|
||||||
clean_fn_or_proc_macro(item, sig, generics, body_id, &mut name, cx)
|
clean_fn_or_proc_macro(item, sig, generics, body_id, &mut name, cx)
|
||||||
}
|
}
|
||||||
ItemKind::Macro(ref macro_def) => MacroItem(Macro {
|
ItemKind::Macro(ref macro_def) => {
|
||||||
source: display_macro_source(cx, name, macro_def, def_id, item.vis),
|
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) => {
|
ItemKind::Trait(is_auto, unsafety, ref generics, bounds, item_ids) => {
|
||||||
let items = item_ids
|
let items = item_ids
|
||||||
.iter()
|
.iter()
|
||||||
|
|
|
@ -529,7 +529,7 @@ pub(super) fn display_macro_source(
|
||||||
name: Symbol,
|
name: Symbol,
|
||||||
def: &ast::MacroDef,
|
def: &ast::MacroDef,
|
||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
vis: impl Clean<Visibility>,
|
vis: Visibility,
|
||||||
) -> String {
|
) -> String {
|
||||||
let tts: Vec<_> = def.body.inner_tokens().into_trees().collect();
|
let tts: Vec<_> = def.body.inner_tokens().into_trees().collect();
|
||||||
// Extract the spans of all matchers. They represent the "interface" of the macro.
|
// 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 {
|
if def.macro_rules {
|
||||||
format!("macro_rules! {} {{\n{}}}", name, render_macro_arms(matchers, ";"))
|
format!("macro_rules! {} {{\n{}}}", name, render_macro_arms(matchers, ";"))
|
||||||
} else {
|
} else {
|
||||||
let vis = vis.clean(cx);
|
|
||||||
|
|
||||||
if matchers.len() <= 1 {
|
if matchers.len() <= 1 {
|
||||||
format!(
|
format!(
|
||||||
"{}macro {}{} {{\n ...\n}}",
|
"{}macro {}{} {{\n ...\n}}",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue