Skip to content

Commit c2dbebd

Browse files
committed
Auto merge of #73365 - Manishearth:rustdoc-vis, r=GuillaumeGomez
Record visibility of reexports for all items, not just type items This fixes #73363 Unfortunately I can't add a test for this since this bug is obscured by the cross-crate bug, being fixed in #73363 . Tests will be added later. cc @jyn514 r? @GuillaumeGomez
2 parents 86c0b85 + 90c678c commit c2dbebd

File tree

3 files changed

+42
-17
lines changed

3 files changed

+42
-17
lines changed

src/librustdoc/visit_ast.rs

+13-17
Original file line numberDiff line numberDiff line change
@@ -303,26 +303,22 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
303303
if !res_did.is_local() && !is_no_inline {
304304
let attrs = clean::inline::load_attrs(self.cx, res_did);
305305
let self_is_hidden = attrs.lists(sym::doc).has_word(sym::hidden);
306-
match res {
307-
Res::Def(
308-
DefKind::Trait
309-
| DefKind::Struct
310-
| DefKind::Union
311-
| DefKind::Enum
312-
| DefKind::ForeignTy
313-
| DefKind::TyAlias,
314-
did,
315-
) if !self_is_hidden => {
316-
self.cx.renderinfo.get_mut().access_levels.map.insert(did, AccessLevel::Public);
317-
}
318-
Res::Def(DefKind::Mod, did) => {
319-
if !self_is_hidden {
320-
crate::visit_lib::LibEmbargoVisitor::new(self.cx).visit_mod(did);
306+
if !self_is_hidden {
307+
if let Res::Def(kind, did) = res {
308+
if kind == DefKind::Mod {
309+
crate::visit_lib::LibEmbargoVisitor::new(self.cx).visit_mod(did)
310+
} else {
311+
// All items need to be handled here in case someone wishes to link
312+
// to them with intra-doc links
313+
self.cx
314+
.renderinfo
315+
.get_mut()
316+
.access_levels
317+
.map
318+
.insert(did, AccessLevel::Public);
321319
}
322320
}
323-
_ => {}
324321
}
325-
326322
return false;
327323
}
328324

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#![crate_name = "hidden_dep"]
2+
#![deny(intra_doc_link_resolution_failure)]
3+
4+
#[doc(hidden)]
5+
pub mod __reexport {
6+
pub use crate::*;
7+
}
8+
9+
pub mod future {
10+
mod ready {
11+
12+
/// Link to [`ready`](function@ready)
13+
pub struct Ready;
14+
pub fn ready() {}
15+
16+
}
17+
pub use self::ready::{ready, Ready};
18+
19+
}
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// aux-build:hidden.rs
2+
// build-aux-docs
3+
#![deny(intra_doc_link_resolution_failure)]
4+
5+
// tests https://github.com/rust-lang/rust/issues/73363
6+
7+
extern crate hidden_dep;
8+
9+
// @has 'hidden/struct.Ready.html' '//a/@href' '../hidden/fn.ready.html'
10+
pub use hidden_dep::future::{ready, Ready};

0 commit comments

Comments
 (0)