@@ -66,7 +66,7 @@ use tracing::{debug, info};
6666pub ( crate ) use self :: context:: * ;
6767pub ( crate ) use self :: span_map:: { LinkFromSrc , collect_spans_and_sources} ;
6868pub ( crate ) use self :: write_shared:: * ;
69- use crate :: clean:: { self , Defaultness , ItemId , RenderedLink } ;
69+ use crate :: clean:: { self , Defaultness , Item , ItemId , RenderedLink } ;
7070use crate :: display:: { Joined as _, MaybeDisplay as _} ;
7171use crate :: error:: Error ;
7272use crate :: formats:: Impl ;
@@ -79,8 +79,9 @@ use crate::html::format::{
7979 print_type, print_where_clause, visibility_print_with_space,
8080} ;
8181use crate :: html:: markdown:: {
82- HeadingOffset , IdMap , Markdown , MarkdownItemInfo , MarkdownSummaryLine ,
82+ HeadingOffset , IdMap , Markdown , MarkdownItemInfo , MarkdownSummaryLine , short_markdown_summary ,
8383} ;
84+ use crate :: html:: render:: search_index:: get_function_type_for_search;
8485use crate :: html:: static_files:: SCRAPE_EXAMPLES_HELP_MD ;
8586use crate :: html:: { highlight, sources} ;
8687use crate :: scrape_examples:: { CallData , CallLocation } ;
@@ -124,6 +125,32 @@ enum RenderMode {
124125// Helper structs for rendering items/sidebars and carrying along contextual
125126// information
126127
128+ #[ derive( Debug ) ]
129+ pub ( crate ) struct IndexItemInfo {
130+ pub ( crate ) desc : String ,
131+ pub ( crate ) search_type : Option < IndexItemFunctionType > ,
132+ pub ( crate ) aliases : Box < [ Symbol ] > ,
133+ pub ( crate ) deprecation : Option < Deprecation > ,
134+ pub ( crate ) is_unstable : bool ,
135+ }
136+
137+ impl IndexItemInfo {
138+ pub ( crate ) fn new (
139+ tcx : TyCtxt < ' _ > ,
140+ cache : & Cache ,
141+ item : & Item ,
142+ parent_did : Option < DefId > ,
143+ impl_generics : Option < & ( clean:: Type , clean:: Generics ) > ,
144+ ) -> Self {
145+ let desc = short_markdown_summary ( & item. doc_value ( ) , & item. link_names ( cache) ) ;
146+ let search_type = get_function_type_for_search ( item, tcx, impl_generics, parent_did, cache) ;
147+ let aliases = item. attrs . get_doc_aliases ( ) ;
148+ let deprecation = item. deprecation ( tcx) ;
149+ let is_unstable = item. is_unstable ( ) ;
150+ Self { desc, search_type, aliases, deprecation, is_unstable }
151+ }
152+ }
153+
127154/// Struct representing one entry in the JS search index. These are all emitted
128155/// by hand to a large JS file at the end of cache-creation.
129156#[ derive( Debug ) ]
@@ -132,17 +159,13 @@ pub(crate) struct IndexItem {
132159 pub ( crate ) defid : Option < DefId > ,
133160 pub ( crate ) name : Symbol ,
134161 pub ( crate ) module_path : Vec < Symbol > ,
135- pub ( crate ) desc : String ,
136162 pub ( crate ) parent : Option < DefId > ,
137163 pub ( crate ) parent_idx : Option < usize > ,
138164 pub ( crate ) trait_parent : Option < DefId > ,
139165 pub ( crate ) trait_parent_idx : Option < usize > ,
140166 pub ( crate ) exact_module_path : Option < Vec < Symbol > > ,
141167 pub ( crate ) impl_id : Option < DefId > ,
142- pub ( crate ) search_type : Option < IndexItemFunctionType > ,
143- pub ( crate ) aliases : Box < [ Symbol ] > ,
144- pub ( crate ) is_deprecated : bool ,
145- pub ( crate ) is_unstable : bool ,
168+ pub ( crate ) info : IndexItemInfo ,
146169}
147170
148171/// A type used for the search index.
0 commit comments