@@ -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
if 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
}
@@ -311,19 +318,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
311
318
for_ : clean:: Type :: BorrowedRef { type_, .. } ,
312
319
..
313
320
} => type_. def_id ( & self . cache ) ,
314
- ParentStackItem :: Impl { for_, trait_, .. } => {
315
- if let Some ( trait_) = trait_ {
316
- let trait_did = trait_. def_id ( ) ;
317
- // If this is a foreign trait impl but the trait documentation
318
- // is not available, we should not allow the methods to show up
319
- // in the search results.
320
- if !trait_did. is_local ( ) && self . tcx . is_private_dep ( trait_did. krate )
321
- {
322
- return None ;
323
- }
324
- }
325
- for_. def_id ( & self . cache )
326
- }
321
+ ParentStackItem :: Impl { for_, .. } => for_. def_id ( & self . cache ) ,
327
322
ParentStackItem :: Type ( item_id) => item_id. as_def_id ( ) ,
328
323
} ;
329
324
let path = did
0 commit comments