@@ -132,11 +132,11 @@ pub(crate) struct IndexItem {
132132 pub ( crate ) ty : ItemType ,
133133 pub ( crate ) defid : Option < DefId > ,
134134 pub ( crate ) name : Symbol ,
135- pub ( crate ) path : String ,
135+ pub ( crate ) module_path : Vec < Symbol > ,
136136 pub ( crate ) desc : String ,
137137 pub ( crate ) parent : Option < DefId > ,
138- pub ( crate ) parent_idx : Option < isize > ,
139- pub ( crate ) exact_path : Option < String > ,
138+ pub ( crate ) parent_idx : Option < usize > ,
139+ pub ( crate ) exact_module_path : Option < Vec < Symbol > > ,
140140 pub ( crate ) impl_id : Option < DefId > ,
141141 pub ( crate ) search_type : Option < IndexItemFunctionType > ,
142142 pub ( crate ) aliases : Box < [ Symbol ] > ,
@@ -193,6 +193,62 @@ impl RenderType {
193193 write_optional_id ( self . id , string) ;
194194 }
195195 }
196+ fn read_from_bytes ( string : & [ u8 ] ) -> ( RenderType , usize ) {
197+ let mut i = 0 ;
198+ if string[ i] == b'{' {
199+ i += 1 ;
200+ let ( id, offset) = RenderTypeId :: read_from_bytes ( & string[ i..] ) ;
201+ i += offset;
202+ let generics = if string[ i] == b'{' {
203+ i += 1 ;
204+ let mut generics = Vec :: new ( ) ;
205+ while string[ i] != b'}' {
206+ let ( ty, offset) = RenderType :: read_from_bytes ( & string[ i..] ) ;
207+ i += offset;
208+ generics. push ( ty) ;
209+ }
210+ assert ! ( string[ i] == b'}' ) ;
211+ i += 1 ;
212+ Some ( generics)
213+ } else {
214+ None
215+ } ;
216+ let bindings = if string[ i] == b'{' {
217+ i += 1 ;
218+ let mut bindings = Vec :: new ( ) ;
219+ while string[ i] == b'{' {
220+ i += 1 ;
221+ let ( binding, boffset) = RenderTypeId :: read_from_bytes ( & string[ i..] ) ;
222+ i += boffset;
223+ let mut bconstraints = Vec :: new ( ) ;
224+ assert ! ( string[ i] == b'{' ) ;
225+ i += 1 ;
226+ while string[ i] != b'}' {
227+ let ( constraint, coffset) = RenderType :: read_from_bytes ( & string[ i..] ) ;
228+ i += coffset;
229+ bconstraints. push ( constraint) ;
230+ }
231+ assert ! ( string[ i] == b'}' ) ;
232+ i += 1 ;
233+ bindings. push ( ( binding. unwrap ( ) , bconstraints) ) ;
234+ assert ! ( string[ i] == b'}' ) ;
235+ i += 1 ;
236+ }
237+ assert ! ( string[ i] == b'}' ) ;
238+ i += 1 ;
239+ Some ( bindings)
240+ } else {
241+ None
242+ } ;
243+ assert ! ( string[ i] == b'}' ) ;
244+ i += 1 ;
245+ ( RenderType { id, generics, bindings } , i)
246+ } else {
247+ let ( id, offset) = RenderTypeId :: read_from_bytes ( string) ;
248+ i += offset;
249+ ( RenderType { id, generics : None , bindings : None } , i)
250+ }
251+ }
196252}
197253
198254#[ derive( Clone , Copy , Debug , Eq , PartialEq ) ]
@@ -214,7 +270,20 @@ impl RenderTypeId {
214270 RenderTypeId :: Index ( idx) => ( * idx) . try_into ( ) . unwrap ( ) ,
215271 _ => panic ! ( "must convert render types to indexes before serializing" ) ,
216272 } ;
217- search_index:: encode:: write_vlqhex_to_string ( id, string) ;
273+ search_index:: encode:: write_signed_vlqhex_to_string ( id, string) ;
274+ }
275+ fn read_from_bytes ( string : & [ u8 ] ) -> ( Option < RenderTypeId > , usize ) {
276+ let Some ( ( value, offset) ) = search_index:: encode:: read_signed_vlqhex_from_string ( string)
277+ else {
278+ return ( None , 0 ) ;
279+ } ;
280+ let value = isize:: try_from ( value) . unwrap ( ) ;
281+ let ty = match value {
282+ ..0 => Some ( RenderTypeId :: Index ( value) ) ,
283+ 0 => None ,
284+ 1 .. => Some ( RenderTypeId :: Index ( value - 1 ) ) ,
285+ } ;
286+ ( ty, offset)
218287 }
219288}
220289
@@ -228,12 +297,55 @@ pub(crate) struct IndexItemFunctionType {
228297}
229298
230299impl IndexItemFunctionType {
231- fn write_to_string < ' a > (
232- & ' a self ,
233- string : & mut String ,
234- backref_queue : & mut VecDeque < & ' a IndexItemFunctionType > ,
235- ) {
236- assert ! ( backref_queue. len( ) <= 16 ) ;
300+ fn read_from_string_without_param_names ( string : & [ u8 ] ) -> ( IndexItemFunctionType , usize ) {
301+ let mut i = 0 ;
302+ if string[ i] == b'`' {
303+ return (
304+ IndexItemFunctionType {
305+ inputs : Vec :: new ( ) ,
306+ output : Vec :: new ( ) ,
307+ where_clause : Vec :: new ( ) ,
308+ param_names : Vec :: new ( ) ,
309+ } ,
310+ 1 ,
311+ ) ;
312+ }
313+ assert_eq ! ( b'{' , string[ i] ) ;
314+ i += 1 ;
315+ fn read_args_from_string ( string : & [ u8 ] ) -> ( Vec < RenderType > , usize ) {
316+ let mut i = 0 ;
317+ let mut params = Vec :: new ( ) ;
318+ if string[ i] == b'{' {
319+ // multiple params
320+ i += 1 ;
321+ while string[ i] != b'}' {
322+ let ( ty, offset) = RenderType :: read_from_bytes ( & string[ i..] ) ;
323+ i += offset;
324+ params. push ( ty) ;
325+ }
326+ i += 1 ;
327+ } else if string[ i] != b'}' {
328+ let ( tyid, offset) = RenderTypeId :: read_from_bytes ( & string[ i..] ) ;
329+ params. push ( RenderType { id : tyid, generics : None , bindings : None } ) ;
330+ i += offset;
331+ }
332+ ( params, i)
333+ }
334+ let ( inputs, offset) = read_args_from_string ( & string[ i..] ) ;
335+ i += offset;
336+ let ( output, offset) = read_args_from_string ( & string[ i..] ) ;
337+ i += offset;
338+ let mut where_clause = Vec :: new ( ) ;
339+ while string[ i] != b'}' {
340+ let ( constraint, offset) = read_args_from_string ( & string[ i..] ) ;
341+ i += offset;
342+ where_clause. push ( constraint) ;
343+ }
344+ assert_eq ! ( b'}' , string[ i] , "{} {}" , String :: from_utf8_lossy( & string) , i) ;
345+ i += 1 ;
346+ ( IndexItemFunctionType { inputs, output, where_clause, param_names : Vec :: new ( ) } , i)
347+ }
348+ fn write_to_string_without_param_names < ' a > ( & ' a self , string : & mut String ) {
237349 // If we couldn't figure out a type, just write 0,
238350 // which is encoded as `` ` `` (see RenderTypeId::write_to_string).
239351 let has_missing = self
@@ -243,18 +355,7 @@ impl IndexItemFunctionType {
243355 . any ( |i| i. id . is_none ( ) && i. generics . is_none ( ) ) ;
244356 if has_missing {
245357 string. push ( '`' ) ;
246- } else if let Some ( idx) = backref_queue. iter ( ) . position ( |other| * other == self ) {
247- // The backref queue has 16 items, so backrefs use
248- // a single hexit, disjoint from the ones used for numbers.
249- string. push (
250- char:: try_from ( '0' as u32 + u32:: try_from ( idx) . unwrap ( ) )
251- . expect ( "last possible value is '?'" ) ,
252- ) ;
253358 } else {
254- backref_queue. push_front ( self ) ;
255- if backref_queue. len ( ) > 16 {
256- backref_queue. pop_back ( ) ;
257- }
258359 string. push ( '{' ) ;
259360 match & self . inputs [ ..] {
260361 [ one] if one. generics . is_none ( ) && one. bindings . is_none ( ) => {
0 commit comments