@@ -13,7 +13,7 @@ use ::serde::{Deserialize, Serialize};
1313use rustc_ast:: join_path_syms;
1414use rustc_data_structures:: fx:: { FxHashMap , FxHashSet , FxIndexMap } ;
1515use rustc_data_structures:: thin_vec:: ThinVec ;
16- use rustc_hir:: def_id:: LOCAL_CRATE ;
16+ use rustc_hir:: def_id:: { CrateNum , DefIndex , LOCAL_CRATE } ;
1717use rustc_hir:: find_attr;
1818use rustc_middle:: ty:: TyCtxt ;
1919use rustc_span:: def_id:: DefId ;
@@ -29,7 +29,9 @@ use crate::error::Error;
2929use crate :: formats:: cache:: { Cache , OrphanImplItem } ;
3030use crate :: formats:: item_type:: ItemType ;
3131use crate :: html:: markdown:: short_markdown_summary;
32- use crate :: html:: render:: { self , IndexItem , IndexItemFunctionType , RenderType , RenderTypeId } ;
32+ use crate :: html:: render:: {
33+ self , IndexItem , IndexItemFunctionType , IndexItemInfo , RenderType , RenderTypeId ,
34+ } ;
3335
3436#[ derive( Clone , Debug , Default , Deserialize , Serialize ) ]
3537pub ( crate ) struct SerializedSearchIndex {
@@ -1270,29 +1272,18 @@ pub(crate) fn build_index(
12701272 & cache. orphan_impl_items
12711273 {
12721274 if let Some ( ( fqp, _) ) = cache. paths . get ( & parent) {
1273- let desc = short_markdown_summary ( & item. doc_value ( ) , & item . link_names ( cache ) ) ;
1275+ let info = IndexItemInfo :: new ( tcx , cache , item, Some ( parent ) , impl_generics . as_ref ( ) ) ;
12741276 search_index. push ( IndexItem {
1275- ty : item. type_ ( ) ,
12761277 defid : item. item_id . as_def_id ( ) ,
12771278 name : item. name . unwrap ( ) ,
12781279 module_path : fqp[ ..fqp. len ( ) - 1 ] . to_vec ( ) ,
1279- desc,
12801280 parent : Some ( parent) ,
12811281 parent_idx : None ,
12821282 trait_parent,
12831283 trait_parent_idx : None ,
12841284 exact_module_path : None ,
12851285 impl_id,
1286- search_type : get_function_type_for_search (
1287- item,
1288- tcx,
1289- impl_generics. as_ref ( ) ,
1290- Some ( parent) ,
1291- cache,
1292- ) ,
1293- aliases : item. attrs . get_doc_aliases ( ) ,
1294- is_deprecated : item. is_deprecated ( tcx) ,
1295- is_unstable : item. is_unstable ( ) ,
1286+ info,
12961287 } ) ;
12971288 }
12981289 }
@@ -1301,11 +1292,10 @@ pub(crate) fn build_index(
13011292 search_index. sort_unstable_by ( |k1, k2| {
13021293 // `sort_unstable_by_key` produces lifetime errors
13031294 // HACK(rustdoc): should not be sorting `CrateNum` or `DefIndex`, this will soon go away, too
1304- let k1 =
1305- ( & k1. module_path , k1. name . as_str ( ) , & k1. ty , k1. parent . map ( |id| ( id. index , id. krate ) ) ) ;
1306- let k2 =
1307- ( & k2. module_path , k2. name . as_str ( ) , & k2. ty , k2. parent . map ( |id| ( id. index , id. krate ) ) ) ;
1308- Ord :: cmp ( & k1, & k2)
1295+ fn key ( i : & IndexItem ) -> ( & [ Symbol ] , & str , ItemType , Option < ( DefIndex , CrateNum ) > ) {
1296+ ( & i. module_path , i. name . as_str ( ) , i. info . ty , i. parent . map ( |id| ( id. index , id. krate ) ) )
1297+ }
1298+ Ord :: cmp ( & key ( k1) , & key ( k2) )
13091299 } ) ;
13101300
13111301 // Now, convert to an on-disk search index format
@@ -1466,7 +1456,7 @@ pub(crate) fn build_index(
14661456 if fqp. last ( ) != Some ( & item. name ) {
14671457 return None ;
14681458 }
1469- let path = if item. ty == ItemType :: Macro
1459+ let path = if item. info . ty == ItemType :: Macro
14701460 && find_attr ! ( tcx, defid, MacroExport { .. } )
14711461 {
14721462 // `#[macro_export]` always exports to the crate root.
@@ -1501,8 +1491,9 @@ pub(crate) fn build_index(
15011491 if item. impl_id . is_some ( )
15021492 && let Some ( parent_idx) = item. parent_idx
15031493 {
1504- let count =
1505- associated_item_duplicates. entry ( ( parent_idx, item. ty , item. name ) ) . or_insert ( 0 ) ;
1494+ let count = associated_item_duplicates
1495+ . entry ( ( parent_idx, item. info . ty , item. name ) )
1496+ . or_insert ( 0 ) ;
15061497 * count += 1 ;
15071498 }
15081499 }
@@ -1525,24 +1516,27 @@ pub(crate) fn build_index(
15251516 let new_entry_id = serialized_index. add_entry (
15261517 item. name ,
15271518 EntryData {
1528- ty : item. ty ,
1519+ ty : item. info . ty ,
15291520 parent : item. parent_idx ,
15301521 trait_parent : item. trait_parent_idx ,
15311522 module_path,
15321523 exact_module_path,
1533- deprecated : item. is_deprecated ,
1534- unstable : item. is_unstable ,
1524+ deprecated : item
1525+ . info
1526+ . deprecation
1527+ . is_some_and ( |deprecation| deprecation. is_in_effect ( ) ) ,
1528+ unstable : item. info . is_unstable ,
15351529 associated_item_disambiguator_or_extern_crate_url : if let Some ( impl_id) =
15361530 item. impl_id
15371531 && let Some ( parent_idx) = item. parent_idx
15381532 && associated_item_duplicates
1539- . get ( & ( parent_idx, item. ty , item. name ) )
1533+ . get ( & ( parent_idx, item. info . ty , item. name ) )
15401534 . copied ( )
15411535 . unwrap_or ( 0 )
15421536 > 1
15431537 {
15441538 Some ( render:: get_id_for_impl ( tcx, ItemId :: DefId ( impl_id) ) )
1545- } else if item. ty == ItemType :: ExternCrate
1539+ } else if item. info . ty == ItemType :: ExternCrate
15461540 && let Some ( local_def_id) = item. defid . and_then ( |def_id| def_id. as_local ( ) )
15471541 && let cnum = tcx. extern_mod_stmt_cnum ( local_def_id) . unwrap_or ( LOCAL_CRATE )
15481542 && let Some ( ExternalLocation :: Remote { url, is_absolute } ) =
@@ -1555,12 +1549,12 @@ pub(crate) fn build_index(
15551549 } ,
15561550 krate : crate_idx,
15571551 } ,
1558- item. desc . to_string ( ) ,
1552+ item. info . desc . to_string ( ) ,
15591553 ) ;
15601554
15611555 // Aliases
15621556 // -------
1563- for alias in & item. aliases [ .. ] {
1557+ for alias in & item. info . aliases {
15641558 serialized_index. push_alias ( alias. as_str ( ) . to_string ( ) , new_entry_id) ;
15651559 }
15661560
@@ -1833,7 +1827,7 @@ pub(crate) fn build_index(
18331827 _ => { }
18341828 }
18351829 }
1836- if let Some ( search_type) = & mut item. search_type {
1830+ if let Some ( search_type) = & mut item. info . search_type {
18371831 let mut used_in_function_inputs = BTreeSet :: new ( ) ;
18381832 let mut used_in_function_output = BTreeSet :: new ( ) ;
18391833 for item in & mut search_type. inputs {
@@ -1900,7 +1894,7 @@ pub(crate) fn build_index(
19001894 // The number 8 is arbitrary. We want it big, but not enormous,
19011895 // because the postings list has to fill in an empty array for each
19021896 // unoccupied size.
1903- if item. ty . is_fn_like ( ) { 0 } else { 16 } ;
1897+ if item. info . ty . is_fn_like ( ) { 0 } else { 16 } ;
19041898 serialized_index. function_data [ new_entry_id] = Some ( search_type. clone ( ) ) ;
19051899
19061900 #[ derive( Clone , Copy ) ]
0 commit comments