Skip to content

Commit a314707

Browse files
Prevent showing methods from blanket impls of not available foreign traits to show up in the search results
1 parent 6d05c43 commit a314707

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/librustdoc/formats/cache.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,19 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
310310
for_: clean::Type::BorrowedRef { type_, .. },
311311
..
312312
} => type_.def_id(&self.cache),
313-
ParentStackItem::Impl { for_, .. } => for_.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+
}
314326
ParentStackItem::Type(item_id) => item_id.as_def_id(),
315327
};
316328
let path = did

0 commit comments

Comments
 (0)