@@ -221,16 +221,23 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
221
221
_ => self . cache . stripped_mod ,
222
222
} ;
223
223
224
+ #[ inline]
225
+ fn is_from_private_dep ( tcx : TyCtxt < ' _ > , cache : & Cache , def_id : DefId ) -> bool {
226
+ let krate = def_id. krate ;
227
+
228
+ cache. masked_crates . contains ( & krate) || tcx. is_private_dep ( krate)
229
+ }
230
+
224
231
// If the impl is from a masked crate or references something from a
225
232
// masked crate then remove it completely.
226
233
if let clean:: ImplItem ( ref i) = * item. kind &&
227
234
( self . cache . masked_crates . contains ( & item. item_id . krate ( ) )
228
235
|| i. trait_
229
236
. as_ref ( )
230
- . map_or ( false , |t| self . cache . masked_crates . contains ( & t. def_id ( ) . krate ) )
237
+ . map_or ( false , |t| is_from_private_dep ( self . tcx , self . cache , t. def_id ( ) ) )
231
238
|| i. for_
232
239
. def_id ( self . cache )
233
- . map_or ( false , |d| self . cache . masked_crates . contains ( & d . krate ) ) )
240
+ . map_or ( false , |d| is_from_private_dep ( self . tcx , self . cache , d ) ) )
234
241
{
235
242
return None ;
236
243
}
@@ -310,19 +317,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
310
317
for_ : clean:: Type :: BorrowedRef { type_, .. } ,
311
318
..
312
319
} => type_. def_id ( & self . cache ) ,
313
- ParentStackItem :: Impl { for_, trait_, .. } => {
314
- if let Some ( trait_) = trait_ {
315
- let trait_did = trait_. def_id ( ) ;
316
- // If this is a foreign trait impl but the trait documentation
317
- // is not available, we should not allow the methods to show up
318
- // in the search results.
319
- if !trait_did. is_local ( ) && self . tcx . is_private_dep ( trait_did. krate )
320
- {
321
- return None ;
322
- }
323
- }
324
- for_. def_id ( & self . cache )
325
- }
320
+ ParentStackItem :: Impl { for_, .. } => for_. def_id ( & self . cache ) ,
326
321
ParentStackItem :: Type ( item_id) => item_id. as_def_id ( ) ,
327
322
} ;
328
323
let path = did
0 commit comments