Skip to content

Commit

Permalink
inline
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed Mar 14, 2024
1 parent 2602820 commit 580e5b8
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/librustdoc/html/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1509,8 +1509,6 @@ pub(crate) fn visibility_print_with_space<'a, 'tcx: 'a>(
cx: &'a Context<'tcx>,
) -> impl Display + 'a + Captures<'tcx> {
use std::fmt::Write as _;

let hidden: &'static str = if item.is_doc_hidden() { "#[doc(hidden)] " } else { "" };
let vis: Cow<'static, str> = match item.visibility(cx.tcx()) {
None => "".into(),
Some(ty::Visibility::Public) => "pub ".into(),
Expand Down Expand Up @@ -1546,8 +1544,13 @@ pub(crate) fn visibility_print_with_space<'a, 'tcx: 'a>(
}
}
};

let is_doc_hidden = item.is_doc_hidden();
display_fn(move |f| {
f.write_str(&hidden)?;
if is_doc_hidden {
f.write_str("#[doc(hidden)] ")?;
}

f.write_str(&vis)
})
}
Expand All @@ -1561,7 +1564,6 @@ pub(crate) fn visibility_to_src_with_space<'a, 'tcx: 'a>(
item_did: DefId,
is_doc_hidden: bool,
) -> impl Display + 'a + Captures<'tcx> {
let hidden: &'static str = if is_doc_hidden { "#[doc(hidden)] " } else { "" };
let vis: Cow<'static, str> = match visibility {
None => "".into(),
Some(ty::Visibility::Public) => "pub ".into(),
Expand All @@ -1587,7 +1589,9 @@ pub(crate) fn visibility_to_src_with_space<'a, 'tcx: 'a>(
}
};
display_fn(move |f| {
f.write_str(&hidden)?;
if is_doc_hidden {
f.write_str("#[doc(hidden)] ")?;
}
f.write_str(&vis)
})
}
Expand Down

0 comments on commit 580e5b8

Please sign in to comment.