@@ -1036,20 +1036,18 @@ impl Clean<Item> for hir::ImplItem<'_> {
10361036 }
10371037 } ;
10381038
1039- let what_rustc_thinks =
1039+ let mut what_rustc_thinks =
10401040 Item :: from_def_id_and_parts ( local_did, Some ( self . ident . name ) , inner, cx) ;
1041- let parent_item = cx. tcx . hir ( ) . expect_item ( cx. tcx . hir ( ) . get_parent_item ( self . hir_id ( ) ) ) ;
1042- if let hir:: ItemKind :: Impl ( impl_) = & parent_item. kind {
1043- if impl_. of_trait . is_some ( ) {
1044- // Trait impl items always inherit the impl's visibility --
1045- // we don't want to show `pub`.
1046- Item { visibility : Inherited , ..what_rustc_thinks }
1047- } else {
1048- what_rustc_thinks
1049- }
1050- } else {
1051- panic ! ( "found impl item with non-impl parent {:?}" , parent_item) ;
1041+
1042+ let impl_ref = cx. tcx . parent ( local_did) . and_then ( |did| cx. tcx . impl_trait_ref ( did) ) ;
1043+
1044+ // Trait impl items always inherit the impl's visibility --
1045+ // we don't want to show `pub`.
1046+ if impl_ref. is_some ( ) {
1047+ what_rustc_thinks. visibility = Inherited ;
10521048 }
1049+
1050+ what_rustc_thinks
10531051 } )
10541052 }
10551053}
@@ -1204,16 +1202,18 @@ impl Clean<Item> for ty::AssocItem {
12041202 }
12051203 } ;
12061204
1207- let mut output = Item :: from_def_id_and_parts ( self . def_id , Some ( self . name ) , kind, cx) ;
1205+ let mut what_rustc_thinks =
1206+ Item :: from_def_id_and_parts ( self . def_id , Some ( self . name ) , kind, cx) ;
12081207
1209- // HACK: Override visibility for items in a trait implementation to match HIR
12101208 let impl_ref = tcx. parent ( self . def_id ) . and_then ( |did| tcx. impl_trait_ref ( did) ) ;
12111209
1210+ // Trait impl items always inherit the impl's visibility --
1211+ // we don't want to show `pub`.
12121212 if impl_ref. is_some ( ) {
1213- output . visibility = Visibility :: Inherited ;
1213+ what_rustc_thinks . visibility = Visibility :: Inherited ;
12141214 }
12151215
1216- output
1216+ what_rustc_thinks
12171217 }
12181218}
12191219
0 commit comments