@@ -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 , ItemId , RenderedLink } ;
69+ use crate :: clean:: { self , 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_impl, print_path, 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 } ;
@@ -144,6 +145,43 @@ pub(crate) struct IndexItem {
144145 pub ( crate ) deprecation : Option < Deprecation > ,
145146}
146147
148+ impl IndexItem {
149+ pub ( crate ) fn new (
150+ tcx : TyCtxt < ' _ > ,
151+ cache : & Cache ,
152+ item : & Item ,
153+ name : Option < Symbol > ,
154+ defid : Option < DefId > ,
155+ module_path : Vec < Symbol > ,
156+ parent_did : Option < DefId > ,
157+ impl_id : Option < DefId > ,
158+ trait_parent : Option < DefId > ,
159+ impl_generics : Option < & ( clean:: Type , clean:: Generics ) > ,
160+ ) -> Self {
161+ let desc = short_markdown_summary ( & item. doc_value ( ) , & item. link_names ( cache) ) ;
162+ let search_type = get_function_type_for_search ( item, tcx, impl_generics, parent_did, cache) ;
163+ let aliases = item. attrs . get_doc_aliases ( ) ;
164+ let deprecation = item. deprecation ( tcx) ;
165+
166+ Self {
167+ ty : item. type_ ( ) ,
168+ defid : defid. or_else ( || item. item_id . as_def_id ( ) ) ,
169+ name : name. or ( item. name ) . unwrap ( ) ,
170+ module_path,
171+ desc,
172+ parent : parent_did,
173+ parent_idx : None ,
174+ trait_parent,
175+ trait_parent_idx : None ,
176+ exact_module_path : None ,
177+ impl_id,
178+ search_type,
179+ aliases,
180+ deprecation,
181+ }
182+ }
183+ }
184+
147185/// A type used for the search index.
148186#[ derive( Clone , Debug , Eq , PartialEq ) ]
149187struct RenderType {
0 commit comments