@@ -256,10 +256,14 @@ impl SerializedSearchIndex {
256256 /// The returned ID can be used to attach more data to the search result.
257257 fn add_entry ( & mut self , name : Symbol , entry_data : EntryData , desc : String ) -> usize {
258258 let fqp = if let Some ( module_path_index) = entry_data. module_path {
259- let mut fqp = self . path_data [ module_path_index] . as_ref ( ) . unwrap ( ) . module_path . clone ( ) ;
260- fqp. push ( Symbol :: intern ( & self . names [ module_path_index] ) ) ;
261- fqp. push ( name) ;
262- fqp
259+ self . path_data [ module_path_index]
260+ . as_ref ( )
261+ . unwrap ( )
262+ . module_path
263+ . iter ( )
264+ . copied ( )
265+ . chain ( [ Symbol :: intern ( & self . names [ module_path_index] ) , name] )
266+ . collect ( )
263267 } else {
264268 vec ! [ name]
265269 } ;
@@ -306,13 +310,13 @@ impl SerializedSearchIndex {
306310
307311 pub ( crate ) fn union ( mut self , other : & SerializedSearchIndex ) -> SerializedSearchIndex {
308312 let other_entryid_offset = self . names . len ( ) ;
309- let mut map_other_pathid_to_self_pathid: Vec < usize > = Vec :: new ( ) ;
313+ let mut map_other_pathid_to_self_pathid = Vec :: new ( ) ;
310314 let mut skips = FxHashSet :: default ( ) ;
311315 for ( other_pathid, other_path_data) in other. path_data . iter ( ) . enumerate ( ) {
312316 if let Some ( other_path_data) = other_path_data {
313- let mut fqp = other_path_data. module_path . clone ( ) ;
314317 let name = Symbol :: intern ( & other. names [ other_pathid] ) ;
315- fqp. push ( name) ;
318+ let fqp =
319+ other_path_data. module_path . iter ( ) . copied ( ) . chain ( iter:: once ( name) ) . collect ( ) ;
316320 let self_pathid = other_entryid_offset + other_pathid;
317321 let self_pathid = match self . crate_paths_index . entry ( ( other_path_data. ty , fqp) ) {
318322 Entry :: Vacant ( slot) => {
@@ -1819,20 +1823,23 @@ pub(crate) fn build_index(
18191823 tcx,
18201824 ) ;
18211825 }
1822- let mut used_in_constraints = Vec :: new ( ) ;
1823- for constraint in & mut search_type. where_clause {
1824- let mut used_in_constraint = BTreeSet :: new ( ) ;
1825- for trait_ in & mut constraint[ ..] {
1826- convert_render_type (
1827- trait_,
1828- cache,
1829- & mut serialized_index,
1830- & mut used_in_constraint,
1831- tcx,
1832- ) ;
1833- }
1834- used_in_constraints. push ( used_in_constraint) ;
1835- }
1826+ let used_in_constraints = search_type
1827+ . where_clause
1828+ . iter_mut ( )
1829+ . map ( |constraint| {
1830+ let mut used_in_constraint = BTreeSet :: new ( ) ;
1831+ for trait_ in constraint {
1832+ convert_render_type (
1833+ trait_,
1834+ cache,
1835+ & mut serialized_index,
1836+ & mut used_in_constraint,
1837+ tcx,
1838+ ) ;
1839+ }
1840+ used_in_constraint
1841+ } )
1842+ . collect :: < Vec < _ > > ( ) ;
18361843 loop {
18371844 let mut inserted_any = false ;
18381845 for ( i, used_in_constraint) in used_in_constraints. iter ( ) . enumerate ( ) {
0 commit comments