about summary refs log tree commit diff
path: root/src/librustdoc
diff options
context:
space:
mode:
authorLeón Orell Valerian Liehr <liehr.exchange@gmx.net>2022-04-07 16:50:51 +0200
committerLeón Orell Valerian Liehr <liehr.exchange@gmx.net>2022-04-07 20:40:17 +0200
commit4623d51573b22c95ec25c2041aa43221a9e61597 (patch)
tree42af6daa29f8100cf480a2d658adc17631713f06 /src/librustdoc
parented6c958ee4bf081deec951996ace9c508360c1d9 (diff)
downloadrust-4623d51573b22c95ec25c2041aa43221a9e61597.tar.gz
rust-4623d51573b22c95ec25c2041aa43221a9e61597.zip
Hide cross-crate doc-hidden assoc items in trait impls
Diffstat (limited to 'src/librustdoc')
-rw-r--r--src/librustdoc/clean/inline.rs21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs
index 8c19cf973fc..d06e4fa1cc2 100644
--- a/src/librustdoc/clean/inline.rs
+++ b/src/librustdoc/clean/inline.rs
@@ -425,13 +425,26 @@ crate fn build_impl(
         None => (
             tcx.associated_items(did)
                 .in_definition_order()
-                .filter_map(|item| {
-                    if associated_trait.is_some() || item.vis.is_public() {
-                        Some(item.clean(cx))
+                .filter(|item| {
+                    // If this is a trait impl, filter out associated items whose corresponding item
+                    // in the associated trait is marked `doc(hidden)`.
+                    // If this is an inherent impl, filter out private associated items.
+                    if let Some(associated_trait) = associated_trait {
+                        let trait_item = tcx
+                            .associated_items(associated_trait.def_id)
+                            .find_by_name_and_kind(
+                                tcx,
+                                item.ident(tcx),
+                                item.kind,
+                                associated_trait.def_id,
+                            )
+                            .unwrap(); // corresponding associated item has to exist
+                        !tcx.is_doc_hidden(trait_item.def_id)
                     } else {
-                        None
+                        item.vis.is_public()
                     }
                 })
+                .map(|item| item.clean(cx))
                 .collect::<Vec<_>>(),
             clean::enter_impl_trait(cx, |cx| {
                 clean_ty_generics(cx, tcx.generics_of(did), predicates)