@@ -56,13 +56,10 @@ impl<'a, 'tcx> DocFolder for Stripper<'a, 'tcx> {
5656 | clean:: TraitItem ( ..)
5757 | clean:: FunctionItem ( ..)
5858 | clean:: VariantItem ( ..)
59- | clean:: MethodItem ( ..)
6059 | clean:: ForeignFunctionItem ( ..)
6160 | clean:: ForeignStaticItem ( ..)
6261 | clean:: ConstantItem ( ..)
6362 | clean:: UnionItem ( ..)
64- | clean:: AssocConstItem ( ..)
65- | clean:: AssocTypeItem ( ..)
6663 | clean:: TraitAliasItem ( ..)
6764 | clean:: MacroItem ( ..)
6865 | clean:: ForeignTypeItem => {
@@ -80,6 +77,16 @@ impl<'a, 'tcx> DocFolder for Stripper<'a, 'tcx> {
8077 }
8178 }
8279
80+ clean:: MethodItem ( ..) | clean:: AssocConstItem ( ..) | clean:: AssocTypeItem ( ..) => {
81+ let item_id = i. item_id ;
82+ if item_id. is_local ( )
83+ && !self . effective_visibilities . is_reachable ( self . tcx , item_id. expect_def_id ( ) )
84+ {
85+ debug ! ( "Stripper: stripping {:?} {:?}" , i. type_( ) , i. name) ;
86+ return None ;
87+ }
88+ }
89+
8390 clean:: StructFieldItem ( ..) => {
8491 if i. visibility ( self . tcx ) != Some ( Visibility :: Public ) {
8592 return Some ( strip_item ( i) ) ;
@@ -192,16 +199,16 @@ impl<'a> DocFolder for ImplStripper<'a, '_> {
192199 && imp. items . iter ( ) . all ( |i| {
193200 let item_id = i. item_id ;
194201 item_id. is_local ( )
195- && !is_item_reachable (
196- self . tcx ,
197- self . is_json_output ,
198- & self . cache . effective_visibilities ,
199- item_id,
200- )
202+ && !self
203+ . cache
204+ . effective_visibilities
205+ . is_reachable ( self . tcx , item_id. expect_def_id ( ) )
201206 } )
202207 {
208+ debug ! ( "ImplStripper: no public item; removing {imp:?}" ) ;
203209 return None ;
204210 } else if imp. items . is_empty ( ) && i. doc_value ( ) . is_empty ( ) {
211+ debug ! ( "ImplStripper: no item and no doc; removing {imp:?}" ) ;
205212 return None ;
206213 }
207214 }
@@ -212,21 +219,21 @@ impl<'a> DocFolder for ImplStripper<'a, '_> {
212219 && !imp. for_ . is_assoc_ty ( )
213220 && !self . should_keep_impl ( & i, did)
214221 {
215- debug ! ( "ImplStripper: impl item for stripped type; removing" ) ;
222+ debug ! ( "ImplStripper: impl item for stripped type; removing {imp:?} " ) ;
216223 return None ;
217224 }
218225 if let Some ( did) = imp. trait_ . as_ref ( ) . map ( |t| t. def_id ( ) )
219226 && !self . should_keep_impl ( & i, did)
220227 {
221- debug ! ( "ImplStripper: impl item for stripped trait; removing" ) ;
228+ debug ! ( "ImplStripper: impl item for stripped trait; removing {imp:?} " ) ;
222229 return None ;
223230 }
224231 if let Some ( generics) = imp. trait_ . as_ref ( ) . and_then ( |t| t. generics ( ) ) {
225232 for typaram in generics {
226233 if let Some ( did) = typaram. def_id ( self . cache )
227234 && !self . should_keep_impl ( & i, did)
228235 {
229- debug ! ( "ImplStripper: stripped item in trait's generics; removing impl " ) ;
236+ debug ! ( "ImplStripper: stripped item in trait's generics; removing {imp:?} " ) ;
230237 return None ;
231238 }
232239 }
0 commit comments