@@ -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 ( 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 }
@@ -310,19 +317,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
310317 for_ : clean:: Type :: BorrowedRef { type_, .. } ,
311318 ..
312319 } => 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 ) ,
326321 ParentStackItem :: Type ( item_id) => item_id. as_def_id ( ) ,
327322 } ;
328323 let path = did
0 commit comments