1
Fork 0

Extract local variables

This commit is contained in:
Noah Lev 2024-08-02 14:01:38 -07:00
parent 015aa8d0fb
commit 08f4d54ea9

View file

@ -503,17 +503,15 @@ fn add_item_to_search_index(tcx: TyCtxt<'_>, cache: &mut Cache, item: &clean::It
// We have a parent, but we don't know where they're // We have a parent, but we don't know where they're
// defined yet. Wait for later to index this item. // defined yet. Wait for later to index this item.
let impl_generics = clean_impl_generics(cache.parent_stack.last()); let impl_generics = clean_impl_generics(cache.parent_stack.last());
cache.orphan_impl_items.push(OrphanImplItem { let impl_id = if let Some(ParentStackItem::Impl { item_id, .. }) = cache.parent_stack.last()
parent: parent_did, {
item: item.clone(), item_id.as_def_id()
impl_generics, } else {
impl_id: if let Some(ParentStackItem::Impl { item_id, .. }) = cache.parent_stack.last() None
{ };
item_id.as_def_id() let orphan_item =
} else { OrphanImplItem { parent: parent_did, item: item.clone(), impl_generics, impl_id };
None cache.orphan_impl_items.push(orphan_item);
},
});
} else if let Some(path) = parent_path } else if let Some(path) = parent_path
&& (is_impl_child || !cache.stripped_mod) && (is_impl_child || !cache.stripped_mod)
{ {
@ -540,32 +538,37 @@ fn add_item_to_search_index(tcx: TyCtxt<'_>, cache: &mut Cache, item: &clean::It
// In case this is a field from a tuple struct, we don't add it into // In case this is a field from a tuple struct, we don't add it into
// the search index because its name is something like "0", which is // the search index because its name is something like "0", which is
// not useful for rustdoc search. // not useful for rustdoc search.
cache.search_index.push(IndexItem { let path = join_with_double_colon(path);
let impl_id =
if let Some(ParentStackItem::Impl { item_id, .. }) = cache.parent_stack.last() {
item_id.as_def_id()
} else {
None
};
let search_type = get_function_type_for_search(
&item,
tcx,
clean_impl_generics(cache.parent_stack.last()).as_ref(),
parent_did,
cache,
);
let aliases = item.attrs.get_doc_aliases();
let deprecation = item.deprecation(tcx);
let index_item = IndexItem {
ty, ty,
defid, defid,
name, name,
path: join_with_double_colon(path), path,
desc, desc,
parent: parent_did, parent: parent_did,
parent_idx: None, parent_idx: None,
exact_path: None, exact_path: None,
impl_id: if let Some(ParentStackItem::Impl { item_id, .. }) = impl_id,
cache.parent_stack.last() search_type,
{ aliases,
item_id.as_def_id() deprecation,
} else { };
None cache.search_index.push(index_item);
},
search_type: get_function_type_for_search(
&item,
tcx,
clean_impl_generics(cache.parent_stack.last()).as_ref(),
parent_did,
cache,
),
aliases: item.attrs.get_doc_aliases(),
deprecation: item.deprecation(tcx),
});
} }
} }
} }