@@ -112,6 +112,7 @@ pub(crate) struct IndexItem {
112112pub ( crate ) struct RenderType {
113113 id : Option < RenderTypeId > ,
114114 generics : Option < Vec < RenderType > > ,
115+ bindings : Option < Vec < ( RenderTypeId , Vec < RenderType > ) > > ,
115116}
116117
117118impl Serialize for RenderType {
@@ -128,24 +129,47 @@ impl Serialize for RenderType {
128129 Some ( RenderTypeId :: Index ( idx) ) => * idx,
129130 _ => panic ! ( "must convert render types to indexes before serializing" ) ,
130131 } ;
131- if let Some ( generics) = & self . generics {
132+ if self . generics . is_some ( ) || self . bindings . is_some ( ) {
132133 let mut seq = serializer. serialize_seq ( None ) ?;
133134 seq. serialize_element ( & id) ?;
134- seq. serialize_element ( generics) ?;
135+ seq. serialize_element ( self . generics . as_ref ( ) . map ( Vec :: as_slice) . unwrap_or_default ( ) ) ?;
136+ if self . bindings . is_some ( ) {
137+ seq. serialize_element (
138+ self . bindings . as_ref ( ) . map ( Vec :: as_slice) . unwrap_or_default ( ) ,
139+ ) ?;
140+ }
135141 seq. end ( )
136142 } else {
137143 id. serialize ( serializer)
138144 }
139145 }
140146}
141147
142- #[ derive( Clone , Debug ) ]
148+ #[ derive( Clone , Copy , Debug ) ]
143149pub ( crate ) enum RenderTypeId {
144150 DefId ( DefId ) ,
145151 Primitive ( clean:: PrimitiveType ) ,
152+ AssociatedType ( Symbol ) ,
146153 Index ( isize ) ,
147154}
148155
156+ impl Serialize for RenderTypeId {
157+ fn serialize < S > ( & self , serializer : S ) -> Result < S :: Ok , S :: Error >
158+ where
159+ S : Serializer ,
160+ {
161+ let id = match & self {
162+ // 0 is a sentinel, everything else is one-indexed
163+ // concrete type
164+ RenderTypeId :: Index ( idx) if * idx >= 0 => idx + 1 ,
165+ // generic type parameter
166+ RenderTypeId :: Index ( idx) => * idx,
167+ _ => panic ! ( "must convert render types to indexes before serializing" ) ,
168+ } ;
169+ id. serialize ( serializer)
170+ }
171+ }
172+
149173/// Full type of functions/methods in the search index.
150174#[ derive( Debug ) ]
151175pub ( crate ) struct IndexItemFunctionType {
@@ -170,16 +194,20 @@ impl Serialize for IndexItemFunctionType {
170194 } else {
171195 let mut seq = serializer. serialize_seq ( None ) ?;
172196 match & self . inputs [ ..] {
173- [ one] if one. generics . is_none ( ) => seq. serialize_element ( one) ?,
197+ [ one] if one. generics . is_none ( ) && one. bindings . is_none ( ) => {
198+ seq. serialize_element ( one) ?
199+ }
174200 _ => seq. serialize_element ( & self . inputs ) ?,
175201 }
176202 match & self . output [ ..] {
177203 [ ] if self . where_clause . is_empty ( ) => { }
178- [ one] if one. generics . is_none ( ) => seq. serialize_element ( one) ?,
204+ [ one] if one. generics . is_none ( ) && one. bindings . is_none ( ) => {
205+ seq. serialize_element ( one) ?
206+ }
179207 _ => seq. serialize_element ( & self . output ) ?,
180208 }
181209 for constraint in & self . where_clause {
182- if let [ one] = & constraint[ ..] && one. generics . is_none ( ) {
210+ if let [ one] = & constraint[ ..] && one. generics . is_none ( ) && one . bindings . is_none ( ) {
183211 seq. serialize_element ( one) ?;
184212 } else {
185213 seq. serialize_element ( constraint) ?;
0 commit comments