@@ -389,13 +389,45 @@ crate fn build_impl(
389
389
}
390
390
}
391
391
392
+ let document_hidden = cx. render_options . document_hidden ;
392
393
let predicates = tcx. explicit_predicates_of ( did) ;
393
394
let ( trait_items, generics) = match impl_item {
394
395
Some ( impl_) => (
395
396
impl_
396
397
. items
397
398
. iter ( )
398
- . map ( |item| tcx. hir ( ) . impl_item ( item. id ) . clean ( cx) )
399
+ . map ( |item| tcx. hir ( ) . impl_item ( item. id ) )
400
+ . filter ( |item| {
401
+ // Filter out impl items whose corresponding trait item has `doc(hidden)`
402
+ // not to document such impl items.
403
+ // For inherent impls, we don't do any filtering.
404
+
405
+ // When `--document-hidden-items` is passed, we don't
406
+ // do any filtering, too.
407
+ if document_hidden {
408
+ return true ;
409
+ }
410
+ if let Some ( associated_trait) = associated_trait {
411
+ let assoc_kind = match item. kind {
412
+ hir:: ImplItemKind :: Const ( ..) => ty:: AssocKind :: Const ,
413
+ hir:: ImplItemKind :: Fn ( ..) => ty:: AssocKind :: Fn ,
414
+ hir:: ImplItemKind :: TyAlias ( ..) => ty:: AssocKind :: Type ,
415
+ } ;
416
+ let trait_item = tcx
417
+ . associated_items ( associated_trait. def_id )
418
+ . find_by_name_and_kind (
419
+ tcx,
420
+ item. ident ,
421
+ assoc_kind,
422
+ associated_trait. def_id ,
423
+ )
424
+ . unwrap ( ) ; // SAFETY: For all impl items there exists trait item that has the same name.
425
+ !tcx. get_attrs ( trait_item. def_id ) . lists ( sym:: doc) . has_word ( sym:: hidden)
426
+ } else {
427
+ true
428
+ }
429
+ } )
430
+ . map ( |item| item. clean ( cx) )
399
431
. collect :: < Vec < _ > > ( ) ,
400
432
impl_. generics . clean ( cx) ,
401
433
) ,
0 commit comments