Auto merge of #73365 - Manishearth:rustdoc-vis, r=GuillaumeGomez

Record visibility of reexports for all items, not just type items

This fixes https://github.com/rust-lang/rust/issues/73363

Unfortunately I can't add a test for this since this bug is obscured by the cross-crate bug, being fixed in https://github.com/rust-lang/rust/issues/73363 . Tests will be added later.

cc @jyn514

r? @GuillaumeGomez
This commit is contained in:
bors 2020-07-17 07:22:32 +00:00
commit c2dbebd3d4
3 changed files with 42 additions and 17 deletions

View file

@ -303,26 +303,22 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
if !res_did.is_local() && !is_no_inline { if !res_did.is_local() && !is_no_inline {
let attrs = clean::inline::load_attrs(self.cx, res_did); let attrs = clean::inline::load_attrs(self.cx, res_did);
let self_is_hidden = attrs.lists(sym::doc).has_word(sym::hidden); let self_is_hidden = attrs.lists(sym::doc).has_word(sym::hidden);
match res { if !self_is_hidden {
Res::Def( if let Res::Def(kind, did) = res {
DefKind::Trait if kind == DefKind::Mod {
| DefKind::Struct crate::visit_lib::LibEmbargoVisitor::new(self.cx).visit_mod(did)
| DefKind::Union } else {
| DefKind::Enum // All items need to be handled here in case someone wishes to link
| DefKind::ForeignTy // to them with intra-doc links
| DefKind::TyAlias, self.cx
did, .renderinfo
) if !self_is_hidden => { .get_mut()
self.cx.renderinfo.get_mut().access_levels.map.insert(did, AccessLevel::Public); .access_levels
} .map
Res::Def(DefKind::Mod, did) => { .insert(did, AccessLevel::Public);
if !self_is_hidden {
crate::visit_lib::LibEmbargoVisitor::new(self.cx).visit_mod(did);
} }
} }
_ => {}
} }
return false; return false;
} }

View file

@ -0,0 +1,19 @@
#![crate_name = "hidden_dep"]
#![deny(intra_doc_link_resolution_failure)]
#[doc(hidden)]
pub mod __reexport {
pub use crate::*;
}
pub mod future {
mod ready {
/// Link to [`ready`](function@ready)
pub struct Ready;
pub fn ready() {}
}
pub use self::ready::{ready, Ready};
}

View file

@ -0,0 +1,10 @@
// aux-build:hidden.rs
// build-aux-docs
#![deny(intra_doc_link_resolution_failure)]
// tests https://github.com/rust-lang/rust/issues/73363
extern crate hidden_dep;
// @has 'hidden/struct.Ready.html' '//a/@href' '../hidden/fn.ready.html'
pub use hidden_dep::future::{ready, Ready};