@@ -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,42 @@ 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+ defid : Option < DefId > ,
154+ module_path : Vec < Symbol > ,
155+ parent_did : Option < DefId > ,
156+ impl_id : Option < DefId > ,
157+ trait_parent : Option < DefId > ,
158+ impl_generics : Option < & ( clean:: Type , clean:: Generics ) > ,
159+ ) -> Self {
160+ let desc = short_markdown_summary ( & item. doc_value ( ) , & item. link_names ( cache) ) ;
161+ let search_type = get_function_type_for_search ( item, tcx, impl_generics, parent_did, cache) ;
162+ let aliases = item. attrs . get_doc_aliases ( ) ;
163+ let deprecation = item. deprecation ( tcx) ;
164+
165+ Self {
166+ ty : item. type_ ( ) ,
167+ defid : defid. or_else ( || item. item_id . as_def_id ( ) ) ,
168+ name : item. name . unwrap ( ) ,
169+ module_path,
170+ desc,
171+ parent : parent_did,
172+ parent_idx : None ,
173+ trait_parent,
174+ trait_parent_idx : None ,
175+ exact_module_path : None ,
176+ impl_id,
177+ search_type,
178+ aliases,
179+ deprecation,
180+ }
181+ }
182+ }
183+
147184/// A type used for the search index.
148185#[ derive( Clone , Debug , Eq , PartialEq ) ]
149186struct RenderType {
0 commit comments