Skip to content

Commit

Permalink
swap external_traits into the crate before running strip_hidden
Browse files Browse the repository at this point in the history
  • Loading branch information
QuietMisdreavus committed Sep 20, 2018
1 parent de6a897 commit a45d387
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/librustdoc/passes/strip_hidden.rs
Expand Up @@ -24,9 +24,13 @@ pub const STRIP_HIDDEN: Pass =
"strips all doc(hidden) items from the output");

/// Strip items marked `#[doc(hidden)]`
pub fn strip_hidden(krate: clean::Crate, _: &DocContext) -> clean::Crate {
pub fn strip_hidden(mut krate: clean::Crate, cx: &DocContext) -> clean::Crate {
let mut retained = DefIdSet();

// as an early pass, the external traits haven't been swapped in, so we need to do that ahead
// of time
mem::swap(&mut krate.external_traits, &mut cx.external_traits.borrow_mut());

// strip all #[doc(hidden)] items
let krate = {
let mut stripper = Stripper{ retained: &mut retained, update_retained: true };
Expand All @@ -35,7 +39,10 @@ pub fn strip_hidden(krate: clean::Crate, _: &DocContext) -> clean::Crate {

// strip all impls referencing stripped items
let mut stripper = ImplStripper { retained: &retained };
stripper.fold_crate(krate)
let mut krate = stripper.fold_crate(krate);
mem::swap(&mut krate.external_traits, &mut cx.external_traits.borrow_mut());

krate
}

struct Stripper<'a> {
Expand All @@ -46,7 +53,7 @@ struct Stripper<'a> {
impl<'a> fold::DocFolder for Stripper<'a> {
fn fold_item(&mut self, i: Item) -> Option<Item> {
if i.attrs.lists("doc").has_word("hidden") {
debug!("found one in strip_hidden; removing");
debug!("strip_hidden: stripping {} {:?}", i.type_(), i.name);
// use a dedicated hidden item for given item type if any
match i.inner {
clean::StructFieldItem(..) | clean::ModuleItem(..) => {
Expand Down

0 comments on commit a45d387

Please sign in to comment.