@@ -221,16 +221,23 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
221221 _ => self . cache . stripped_mod ,
222222 } ;
223223
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+
224231 // If the impl is from a masked crate or references something from a
225232 // masked crate then remove it completely.
226233 if let clean:: ImplItem ( ref i) = * item. kind {
227234 if self . cache . masked_crates . contains ( & item. item_id . krate ( ) )
228235 || i. trait_
229236 . 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 ( ) ) )
231238 || i. for_
232239 . 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 ) )
234241 {
235242 return None ;
236243 }
@@ -311,19 +318,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
311318 for_ : clean:: Type :: BorrowedRef { type_, .. } ,
312319 ..
313320 } => 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 ) ,
327322 ParentStackItem :: Type ( item_id) => item_id. as_def_id ( ) ,
328323 } ;
329324 let path = did
0 commit comments