about summary refs log tree commit diff
path: root/src/librustdoc
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-07-17 07:22:32 +0000
committerbors <bors@rust-lang.org>2020-07-17 07:22:32 +0000
commitc2dbebd3d4ad21e80ef4e7535dd1e868aaad7e50 (patch)
tree44aa8336d181f7ead3cea1005758c162bcb89267 /src/librustdoc
parent86c0b85da98a3c69e0fc9014e36e1c88bd3ae8d7 (diff)
parent90c678cb037c612e1ff4427f3649eb64e62bb671 (diff)
downloadrust-c2dbebd3d4ad21e80ef4e7535dd1e868aaad7e50.tar.gz
rust-c2dbebd3d4ad21e80ef4e7535dd1e868aaad7e50.zip
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
Diffstat (limited to 'src/librustdoc')
-rw-r--r--src/librustdoc/visit_ast.rs30
1 files changed, 13 insertions, 17 deletions
diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs
index c18f417e4f8..735446d235c 100644
--- a/src/librustdoc/visit_ast.rs
+++ b/src/librustdoc/visit_ast.rs
@@ -303,26 +303,22 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
         if !res_did.is_local() && !is_no_inline {
             let attrs = clean::inline::load_attrs(self.cx, res_did);
             let self_is_hidden = attrs.lists(sym::doc).has_word(sym::hidden);
-            match res {
-                Res::Def(
-                    DefKind::Trait
-                    | DefKind::Struct
-                    | DefKind::Union
-                    | DefKind::Enum
-                    | DefKind::ForeignTy
-                    | DefKind::TyAlias,
-                    did,
-                ) if !self_is_hidden => {
-                    self.cx.renderinfo.get_mut().access_levels.map.insert(did, AccessLevel::Public);
-                }
-                Res::Def(DefKind::Mod, did) => {
-                    if !self_is_hidden {
-                        crate::visit_lib::LibEmbargoVisitor::new(self.cx).visit_mod(did);
+            if !self_is_hidden {
+                if let Res::Def(kind, did) = res {
+                    if kind == DefKind::Mod {
+                        crate::visit_lib::LibEmbargoVisitor::new(self.cx).visit_mod(did)
+                    } else {
+                        // All items need to be handled here in case someone wishes to link
+                        // to them with intra-doc links
+                        self.cx
+                            .renderinfo
+                            .get_mut()
+                            .access_levels
+                            .map
+                            .insert(did, AccessLevel::Public);
                     }
                 }
-                _ => {}
             }
-
             return false;
         }