Skip to content

Commit

Permalink
Prevent showing methods from blanket impls of not available foreign t…
Browse files Browse the repository at this point in the history
…raits to show up in the search results.
  • Loading branch information
GuillaumeGomez committed Oct 10, 2023
1 parent 1210aac commit 6e0b21f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/librustdoc/formats/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,20 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
for_: clean::Type::BorrowedRef { type_, .. },
..
} => type_.def_id(&self.cache),
ParentStackItem::Impl { for_, .. } => for_.def_id(&self.cache),
ParentStackItem::Impl { for_, trait_, .. } => {
if let Some(trait_) = trait_ {
let trait_did = trait_.def_id();
// If this is a foreign trait impl but the trait documentation
// is not available, we should not allow the methods to show up
// in the search results.
if !trait_did.is_local()
&& !self.cache.traits.contains_key(&trait_did)
{
return None;
}
}
for_.def_id(&self.cache)
}
ParentStackItem::Type(item_id) => item_id.as_def_id(),
};
let path = did
Expand Down

0 comments on commit 6e0b21f

Please sign in to comment.