Skip to content

Commit 08f4d54

Browse files
committed
Extract local variables
1 parent 015aa8d commit 08f4d54

File tree

1 file changed

+33
-30
lines changed

1 file changed

+33
-30
lines changed

src/librustdoc/formats/cache.rs

+33-30
Original file line numberDiff line numberDiff line change
@@ -503,17 +503,15 @@ fn add_item_to_search_index(tcx: TyCtxt<'_>, cache: &mut Cache, item: &clean::It
503503
// We have a parent, but we don't know where they're
504504
// defined yet. Wait for later to index this item.
505505
let impl_generics = clean_impl_generics(cache.parent_stack.last());
506-
cache.orphan_impl_items.push(OrphanImplItem {
507-
parent: parent_did,
508-
item: item.clone(),
509-
impl_generics,
510-
impl_id: if let Some(ParentStackItem::Impl { item_id, .. }) = cache.parent_stack.last()
511-
{
512-
item_id.as_def_id()
513-
} else {
514-
None
515-
},
516-
});
506+
let impl_id = if let Some(ParentStackItem::Impl { item_id, .. }) = cache.parent_stack.last()
507+
{
508+
item_id.as_def_id()
509+
} else {
510+
None
511+
};
512+
let orphan_item =
513+
OrphanImplItem { parent: parent_did, item: item.clone(), impl_generics, impl_id };
514+
cache.orphan_impl_items.push(orphan_item);
517515
} else if let Some(path) = parent_path
518516
&& (is_impl_child || !cache.stripped_mod)
519517
{
@@ -540,32 +538,37 @@ fn add_item_to_search_index(tcx: TyCtxt<'_>, cache: &mut Cache, item: &clean::It
540538
// In case this is a field from a tuple struct, we don't add it into
541539
// the search index because its name is something like "0", which is
542540
// not useful for rustdoc search.
543-
cache.search_index.push(IndexItem {
541+
let path = join_with_double_colon(path);
542+
let impl_id =
543+
if let Some(ParentStackItem::Impl { item_id, .. }) = cache.parent_stack.last() {
544+
item_id.as_def_id()
545+
} else {
546+
None
547+
};
548+
let search_type = get_function_type_for_search(
549+
&item,
550+
tcx,
551+
clean_impl_generics(cache.parent_stack.last()).as_ref(),
552+
parent_did,
553+
cache,
554+
);
555+
let aliases = item.attrs.get_doc_aliases();
556+
let deprecation = item.deprecation(tcx);
557+
let index_item = IndexItem {
544558
ty,
545559
defid,
546560
name,
547-
path: join_with_double_colon(path),
561+
path,
548562
desc,
549563
parent: parent_did,
550564
parent_idx: None,
551565
exact_path: None,
552-
impl_id: if let Some(ParentStackItem::Impl { item_id, .. }) =
553-
cache.parent_stack.last()
554-
{
555-
item_id.as_def_id()
556-
} else {
557-
None
558-
},
559-
search_type: get_function_type_for_search(
560-
&item,
561-
tcx,
562-
clean_impl_generics(cache.parent_stack.last()).as_ref(),
563-
parent_did,
564-
cache,
565-
),
566-
aliases: item.attrs.get_doc_aliases(),
567-
deprecation: item.deprecation(tcx),
568-
});
566+
impl_id,
567+
search_type,
568+
aliases,
569+
deprecation,
570+
};
571+
cache.search_index.push(index_item);
569572
}
570573
}
571574
}

0 commit comments

Comments
 (0)