11//! Support for inlining external documentation into the current AST.
22
3+ use std:: collections:: VecDeque ;
34use std:: iter:: once;
45use std:: sync:: Arc ;
56
@@ -15,7 +16,9 @@ use rustc_span::hygiene::MacroKind;
1516use rustc_span:: symbol:: { kw, sym, Symbol } ;
1617use rustc_span:: Span ;
1718
18- use crate :: clean:: { self , Attributes , AttributesExt , FakeDefId , GetDefId , ToSource } ;
19+ use crate :: clean:: {
20+ self , Attributes , AttributesExt , FakeDefId , GetDefId , NestedAttributesExt , ToSource , Type ,
21+ } ;
1922use crate :: core:: DocContext ;
2023use crate :: formats:: item_type:: ItemType ;
2124
@@ -420,6 +423,20 @@ crate fn build_impl(
420423 if trait_. def_id ( ) == tcx. lang_items ( ) . deref_trait ( ) {
421424 super :: build_deref_target_impls ( cx, & trait_items, ret) ;
422425 }
426+
427+ // Return if the trait itself or any types of the generic parameters are doc(hidden).
428+ let mut deque: VecDeque < & Type > = trait_. iter ( ) . collect ( ) ;
429+ while let Some ( ty) = deque. pop_back ( ) {
430+ if let Some ( did) = ty. def_id ( ) {
431+ if cx. tcx . get_attrs ( did) . lists ( sym:: doc) . has_word ( sym:: hidden) {
432+ return ;
433+ }
434+ }
435+ if let Some ( generics) = ty. generics ( ) {
436+ deque. extend ( generics) ;
437+ }
438+ }
439+
423440 if let Some ( trait_did) = trait_. def_id ( ) {
424441 record_extern_trait ( cx, trait_did) ;
425442 }
0 commit comments