@@ -1096,7 +1096,10 @@ impl Clean<Item> for hir::TraitItem<'_> {
1096
1096
AssocTypeItem ( bounds. clean ( cx) , default. clean ( cx) )
1097
1097
}
1098
1098
} ;
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 }
1100
1103
} )
1101
1104
}
1102
1105
}
@@ -1124,7 +1127,21 @@ impl Clean<Item> for hir::ImplItem<'_> {
1124
1127
TypedefItem ( Typedef { type_, generics : Generics :: default ( ) , item_type } , true )
1125
1128
}
1126
1129
} ;
1127
- Item :: from_def_id_and_parts ( local_did, Some ( self . ident . name ) , inner, cx)
1130
+
1131
+ let what_rustc_thinks =
1132
+ Item :: from_def_id_and_parts ( local_did, Some ( self . ident . name ) , inner, cx) ;
1133
+ let parent_item = cx. tcx . hir ( ) . expect_item ( cx. tcx . hir ( ) . get_parent_item ( self . hir_id ) ) ;
1134
+ if let hir:: ItemKind :: Impl { of_trait, .. } = & parent_item. kind {
1135
+ if of_trait. is_some ( ) {
1136
+ // Trait impl items always inherit the impl's visibility --
1137
+ // we don't want to show `pub`.
1138
+ Item { visibility : Inherited , ..what_rustc_thinks }
1139
+ } else {
1140
+ what_rustc_thinks
1141
+ }
1142
+ } else {
1143
+ panic ! ( "found impl item with non-impl parent {:?}" , parent_item) ;
1144
+ }
1128
1145
} )
1129
1146
}
1130
1147
}
0 commit comments