rustdoc: use let chain in CacheBuilder::fold_item
This commit is contained in:
parent
f73d376fb6
commit
9683f8a965
1 changed files with 29 additions and 31 deletions
|
@ -223,17 +223,16 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
|
||||||
|
|
||||||
// If the impl is from a masked crate or references something from a
|
// If the impl is from a masked crate or references something from a
|
||||||
// masked crate then remove it completely.
|
// masked crate then remove it completely.
|
||||||
if let clean::ImplItem(ref i) = *item.kind {
|
if let clean::ImplItem(ref i) = *item.kind &&
|
||||||
if self.cache.masked_crates.contains(&item.item_id.krate())
|
(self.cache.masked_crates.contains(&item.item_id.krate())
|
||||||
|| i.trait_
|
|| i.trait_
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |t| self.cache.masked_crates.contains(&t.def_id().krate))
|
.map_or(false, |t| self.cache.masked_crates.contains(&t.def_id().krate))
|
||||||
|| i.for_
|
|| i.for_
|
||||||
.def_id(self.cache)
|
.def_id(self.cache)
|
||||||
.map_or(false, |d| self.cache.masked_crates.contains(&d.krate))
|
.map_or(false, |d| self.cache.masked_crates.contains(&d.krate)))
|
||||||
{
|
{
|
||||||
return None;
|
return None;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Propagate a trait method's documentation to all implementors of the
|
// Propagate a trait method's documentation to all implementors of the
|
||||||
|
@ -334,33 +333,32 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
|
||||||
// A crate has a module at its root, containing all items,
|
// A crate has a module at its root, containing all items,
|
||||||
// which should not be indexed. The crate-item itself is
|
// which should not be indexed. The crate-item itself is
|
||||||
// inserted later on when serializing the search-index.
|
// inserted later on when serializing the search-index.
|
||||||
if item.item_id.as_def_id().map_or(false, |idx| !idx.is_crate_root()) {
|
if item.item_id.as_def_id().map_or(false, |idx| !idx.is_crate_root())
|
||||||
|
&& let ty = item.type_()
|
||||||
|
&& (ty != ItemType::StructField
|
||||||
|
|| u16::from_str_radix(s.as_str(), 10).is_err())
|
||||||
|
{
|
||||||
let desc =
|
let desc =
|
||||||
short_markdown_summary(&item.doc_value(), &item.link_names(self.cache));
|
short_markdown_summary(&item.doc_value(), &item.link_names(self.cache));
|
||||||
let ty = item.type_();
|
// In case this is a field from a tuple struct, we don't add it into
|
||||||
if ty != ItemType::StructField
|
// the search index because its name is something like "0", which is
|
||||||
|| u16::from_str_radix(s.as_str(), 10).is_err()
|
// not useful for rustdoc search.
|
||||||
{
|
self.cache.search_index.push(IndexItem {
|
||||||
// In case this is a field from a tuple struct, we don't add it into
|
ty,
|
||||||
// the search index because its name is something like "0", which is
|
name: s,
|
||||||
// not useful for rustdoc search.
|
path: join_with_double_colon(path),
|
||||||
self.cache.search_index.push(IndexItem {
|
desc,
|
||||||
ty,
|
parent,
|
||||||
name: s,
|
parent_idx: None,
|
||||||
path: join_with_double_colon(path),
|
search_type: get_function_type_for_search(
|
||||||
desc,
|
&item,
|
||||||
parent,
|
self.tcx,
|
||||||
parent_idx: None,
|
clean_impl_generics(self.cache.parent_stack.last()).as_ref(),
|
||||||
search_type: get_function_type_for_search(
|
self.cache,
|
||||||
&item,
|
),
|
||||||
self.tcx,
|
aliases: item.attrs.get_doc_aliases(),
|
||||||
clean_impl_generics(self.cache.parent_stack.last()).as_ref(),
|
deprecation: item.deprecation(self.tcx),
|
||||||
self.cache,
|
});
|
||||||
),
|
|
||||||
aliases: item.attrs.get_doc_aliases(),
|
|
||||||
deprecation: item.deprecation(self.tcx),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(Some(parent), None) if is_inherent_impl_item => {
|
(Some(parent), None) if is_inherent_impl_item => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue