Change:
Minimal reproducible example (on stable and nightly): Document crate and take a look at the generated pages of and : You should be able to actually see the associated type in the block despite being marked as hidden. You probably need to click (expand) first. The block I refer to is in section Implementors on the trait page and in section Trait Implementations on the implementor's page. It should be noted that even though wrongly shows up in those blocks, it is indeed not shown in the code block at the start of the trait page – at the “definition site” if you will (compared to the “use sites” – the blocks). It is crucial that the trait and the type are defined inside of an external crate. If they were defined in the “current” crate, this bug would not occur: The hidden associated items would not be shown. You can check this for yourself by documenting on its own and viewing its documentation separately, or by re-exporting the crate from (e.g. with ) and then documenting : On the page for , the associated item is hidden On the page for the re-export , however, the associated item is displayed after a CI job failed because the linkchecker complained about broken links in the standard library when documenting it with a modified rustdoc. The broken links are not relevant for this bug, they are mere symptoms of it: If everything was properly hidden, no broken links would ever be generated. This bug currently affects the standard library documentation (for stable and nightly) as mentioned in the linked comment. In this case, the trait is  the type is  the associated type that shouldn't be shown is crate “alpha” is crate “beta” is label T-rustdoc A-cross-crate-reexports <!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --<!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOTEND --
claim

Discussion:
None => ( tcx.associated_items(did) .in_definition_order() <del> .filter_map(|item| { if associated_trait.is_some() || item.vis.is_public() { Some(item.clean(cx)) </del> <ins> .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) </ins> } else { <del> None </del> <ins> item.vis.is_public() </ins> } }) <ins> .map(|item| item.clean(cx)) </ins> .collect::<Vec<_>>(), clean::enter_impl_trait(cx, |cx| { clean_ty_generics(cx, tcx.generics_of(did), predicates)

<ins> pub trait Tr { type VisibleAssoc; #[doc(hidden)] type HiddenAssoc; const VISIBLE_ASSOC: (); #[doc(hidden)] const HIDDEN_ASSOC: (); } pub struct Ty; impl Tr for Ty { type VisibleAssoc = (); type HiddenAssoc = (); const VISIBLE_ASSOC: () = (); const HIDDEN_ASSOC: () = (); } </ins>

<ins> // Regression test for issue #95717 // Hide cross-crate `#[doc(hidden)]` associated items in trait impls. #![crate_name = "dependent"] // edition:2021 // aux-crate:dependency=cross-crate-hidden-assoc-trait-items.rs // The trait `Tr` contains 2 hidden and 2 visisible associated items. // Instead of checking for the absence of the hidden items, check for the presence of the // visible items instead and assert that there are *exactly two* associated items // (by counting the number of `section`s). This is more robust and future-proof. // @has dependent/struct.Ty.html // @has - '//*[@id="associatedtype.VisibleAssoc"]' 'type VisibleAssoc = ()' // @has - '//*[@id="associatedconstant.VISIBLE_ASSOC"]' 'const VISIBLE_ASSOC: ()' // @count - '//*[@class="impl-items"]/section' 2 // @has dependent/trait.Tr.html // @has - '//*[@id="associatedtype.VisibleAssoc-1"]' 'type VisibleAssoc = ()' // @has - '//*[@id="associatedconstant.VISIBLE_ASSOC-1"]' 'const VISIBLE_ASSOC: ()' // @count - '//*[@class="impl-items"]/section' 2 pub use dependency::{Tr, Ty}; </ins>