rustdoc: Hide methods from #[doc(masked)] crates from the search index
This commit is contained in:
parent
fdc18b3067
commit
2e81ce7dfa
3 changed files with 87 additions and 25 deletions
|
@ -1174,6 +1174,16 @@ impl DocFolder for Cache {
|
|||
_ => self.stripped_mod,
|
||||
};
|
||||
|
||||
// If the impl is from a masked crate or references something from a
|
||||
// masked crate then remove it completely.
|
||||
if let clean::ImplItem(ref i) = item.inner {
|
||||
if self.masked_crates.contains(&item.def_id.krate) ||
|
||||
i.trait_.def_id().map_or(false, |d| self.masked_crates.contains(&d.krate)) ||
|
||||
i.for_.def_id().map_or(false, |d| self.masked_crates.contains(&d.krate)) {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
|
||||
// Register any generics to their corresponding string. This is used
|
||||
// when pretty-printing types.
|
||||
if let Some(generics) = item.inner.generics() {
|
||||
|
@ -1188,14 +1198,10 @@ impl DocFolder for Cache {
|
|||
|
||||
// Collect all the implementors of traits.
|
||||
if let clean::ImplItem(ref i) = item.inner {
|
||||
if !self.masked_crates.contains(&item.def_id.krate) {
|
||||
if let Some(did) = i.trait_.def_id() {
|
||||
if i.for_.def_id().map_or(true, |d| !self.masked_crates.contains(&d.krate)) {
|
||||
self.implementors.entry(did).or_insert(vec![]).push(Impl {
|
||||
impl_item: item.clone(),
|
||||
});
|
||||
}
|
||||
}
|
||||
if let Some(did) = i.trait_.def_id() {
|
||||
self.implementors.entry(did).or_insert(vec![]).push(Impl {
|
||||
impl_item: item.clone(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1358,24 +1364,20 @@ impl DocFolder for Cache {
|
|||
// Note: matching twice to restrict the lifetime of the `i` borrow.
|
||||
let mut dids = FxHashSet();
|
||||
if let clean::Item { inner: clean::ImplItem(ref i), .. } = item {
|
||||
let masked_trait = i.trait_.def_id().map_or(false,
|
||||
|d| self.masked_crates.contains(&d.krate));
|
||||
if !masked_trait {
|
||||
match i.for_ {
|
||||
clean::ResolvedPath { did, .. } |
|
||||
clean::BorrowedRef {
|
||||
type_: box clean::ResolvedPath { did, .. }, ..
|
||||
} => {
|
||||
dids.insert(did);
|
||||
}
|
||||
ref t => {
|
||||
let did = t.primitive_type().and_then(|t| {
|
||||
self.primitive_locations.get(&t).cloned()
|
||||
});
|
||||
match i.for_ {
|
||||
clean::ResolvedPath { did, .. } |
|
||||
clean::BorrowedRef {
|
||||
type_: box clean::ResolvedPath { did, .. }, ..
|
||||
} => {
|
||||
dids.insert(did);
|
||||
}
|
||||
ref t => {
|
||||
let did = t.primitive_type().and_then(|t| {
|
||||
self.primitive_locations.get(&t).cloned()
|
||||
});
|
||||
|
||||
if let Some(did) = did {
|
||||
dids.insert(did);
|
||||
}
|
||||
if let Some(did) = did {
|
||||
dids.insert(did);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue