@@ -1096,7 +1096,10 @@ impl Clean<Item> for hir::TraitItem<'_> {
10961096 AssocTypeItem ( bounds. clean ( cx) , default. clean ( cx) )
10971097 }
10981098 } ;
1099- Item :: from_def_id_and_parts ( local_did, Some ( self . ident . name ) , inner, cx)
1099+ let what_rustc_thinks =
1100+ Item :: from_def_id_and_parts ( local_did, Some ( self . ident . name ) , inner, cx) ;
1101+ // Trait items always inherit the trait's visibility -- we don't want to show `pub`.
1102+ Item { visibility : Inherited , ..what_rustc_thinks }
11001103 } )
11011104 }
11021105}
@@ -1131,7 +1134,21 @@ impl Clean<Item> for hir::ImplItem<'_> {
11311134 )
11321135 }
11331136 } ;
1134- Item :: from_def_id_and_parts ( local_did, Some ( self . ident . name ) , inner, cx)
1137+
1138+ let what_rustc_thinks =
1139+ Item :: from_def_id_and_parts ( local_did, Some ( self . ident . name ) , inner, cx) ;
1140+ let parent_item = cx. tcx . hir ( ) . expect_item ( cx. tcx . hir ( ) . get_parent_item ( self . hir_id ) ) ;
1141+ if let hir:: ItemKind :: Impl ( impl_) = & parent_item. kind {
1142+ if impl_. of_trait . is_some ( ) {
1143+ // Trait impl items always inherit the impl's visibility --
1144+ // we don't want to show `pub`.
1145+ Item { visibility : Inherited , ..what_rustc_thinks }
1146+ } else {
1147+ what_rustc_thinks
1148+ }
1149+ } else {
1150+ panic ! ( "found impl item with non-impl parent {:?}" , parent_item) ;
1151+ }
11351152 } )
11361153 }
11371154}
0 commit comments