Skip to content

Commit 166a286

Browse files
Prevent showing methods from blanket impls of not available foreign traits to show up in the search results
1 parent 1210aac commit 166a286

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
@@ -311,7 +311,19 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
311311
for_: clean::Type::BorrowedRef { type_, .. },
312312
..
313313
} => type_.def_id(&self.cache),
314-
ParentStackItem::Impl { for_, .. } => for_.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+
}
315327
ParentStackItem::Type(item_id) => item_id.as_def_id(),
316328
};
317329
let path = did

0 commit comments

Comments
 (0)