rustdoc: Fix intra-doc links for cross-crate re-exports of traits

#58972 ignored extern_traits because before #65983 was fixed, they
would always fail to resolve, giving spurious warnings.
This undoes that change, so extern traits are now seen by the
`collect_intra_doc_links` pass. There are also some minor changes in
librustdoc/fold.rs to avoid borrowing the extern_traits RefCell more
than once at a time.
This commit is contained in:
Joshua Nelson 2020-08-05 00:11:57 -04:00
parent 1dc748fb3d
commit 868927fefb
4 changed files with 8 additions and 21 deletions

View file

@ -628,7 +628,9 @@ pub fn record_extern_trait(cx: &DocContext<'_>, did: DefId) {
}
}
{
cx.active_extern_traits.borrow_mut().insert(did);
}
debug!("record_extern_trait: {:?}", did);
let trait_ = build_external_trait(cx, did);

View file

@ -93,15 +93,11 @@ pub trait DocFolder: Sized {
c.module = c.module.take().and_then(|module| self.fold_item(module));
{
let mut guard = c.external_traits.borrow_mut();
let external_traits = std::mem::replace(&mut *guard, Default::default());
*guard = external_traits
.into_iter()
.map(|(k, mut v)| {
let external_traits = { std::mem::take(&mut *c.external_traits.borrow_mut()) };
for (k, mut v) in external_traits {
v.items = v.items.into_iter().filter_map(|i| self.fold_item(i)).collect();
(k, v)
})
.collect();
c.external_traits.borrow_mut().insert(k, v);
}
}
c
}

View file

@ -971,15 +971,6 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
self.fold_item_recur(item)
}
}
// FIXME: if we can resolve intra-doc links from other crates, we can use the stock
// `fold_crate`, but until then we should avoid scanning `krate.external_traits` since those
// will never resolve properly
fn fold_crate(&mut self, mut c: Crate) -> Crate {
c.module = c.module.take().and_then(|module| self.fold_item(module));
c
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]

View file

@ -1,5 +1,3 @@
// ignore-test
// ^ this is https://github.com/rust-lang/rust/issues/73829
// aux-build:traits.rs
// build-aux-docs
// ignore-tidy-line-length