@@ -113,6 +113,7 @@ pub(crate) struct IndexItem {
113113pub ( crate ) struct RenderType {
114114 id : Option < RenderTypeId > ,
115115 generics : Option < Vec < RenderType > > ,
116+ bindings : Option < Vec < ( RenderTypeId , Vec < RenderType > ) > > ,
116117}
117118
118119impl Serialize for RenderType {
@@ -129,24 +130,47 @@ impl Serialize for RenderType {
129130 Some ( RenderTypeId :: Index ( idx) ) => * idx,
130131 _ => panic ! ( "must convert render types to indexes before serializing" ) ,
131132 } ;
132- if let Some ( generics) = & self . generics {
133+ if self . generics . is_some ( ) || self . bindings . is_some ( ) {
133134 let mut seq = serializer. serialize_seq ( None ) ?;
134135 seq. serialize_element ( & id) ?;
135- seq. serialize_element ( generics) ?;
136+ seq. serialize_element ( self . generics . as_ref ( ) . map ( Vec :: as_slice) . unwrap_or_default ( ) ) ?;
137+ if self . bindings . is_some ( ) {
138+ seq. serialize_element (
139+ self . bindings . as_ref ( ) . map ( Vec :: as_slice) . unwrap_or_default ( ) ,
140+ ) ?;
141+ }
136142 seq. end ( )
137143 } else {
138144 id. serialize ( serializer)
139145 }
140146 }
141147}
142148
143- #[ derive( Clone , Debug ) ]
149+ #[ derive( Clone , Copy , Debug ) ]
144150pub ( crate ) enum RenderTypeId {
145151 DefId ( DefId ) ,
146152 Primitive ( clean:: PrimitiveType ) ,
153+ AssociatedType ( Symbol ) ,
147154 Index ( isize ) ,
148155}
149156
157+ impl Serialize for RenderTypeId {
158+ fn serialize < S > ( & self , serializer : S ) -> Result < S :: Ok , S :: Error >
159+ where
160+ S : Serializer ,
161+ {
162+ let id = match & self {
163+ // 0 is a sentinel, everything else is one-indexed
164+ // concrete type
165+ RenderTypeId :: Index ( idx) if * idx >= 0 => idx + 1 ,
166+ // generic type parameter
167+ RenderTypeId :: Index ( idx) => * idx,
168+ _ => panic ! ( "must convert render types to indexes before serializing" ) ,
169+ } ;
170+ id. serialize ( serializer)
171+ }
172+ }
173+
150174/// Full type of functions/methods in the search index.
151175#[ derive( Debug ) ]
152176pub ( crate ) struct IndexItemFunctionType {
@@ -171,16 +195,20 @@ impl Serialize for IndexItemFunctionType {
171195 } else {
172196 let mut seq = serializer. serialize_seq ( None ) ?;
173197 match & self . inputs [ ..] {
174- [ one] if one. generics . is_none ( ) => seq. serialize_element ( one) ?,
198+ [ one] if one. generics . is_none ( ) && one. bindings . is_none ( ) => {
199+ seq. serialize_element ( one) ?
200+ }
175201 _ => seq. serialize_element ( & self . inputs ) ?,
176202 }
177203 match & self . output [ ..] {
178204 [ ] if self . where_clause . is_empty ( ) => { }
179- [ one] if one. generics . is_none ( ) => seq. serialize_element ( one) ?,
205+ [ one] if one. generics . is_none ( ) && one. bindings . is_none ( ) => {
206+ seq. serialize_element ( one) ?
207+ }
180208 _ => seq. serialize_element ( & self . output ) ?,
181209 }
182210 for constraint in & self . where_clause {
183- if let [ one] = & constraint[ ..] && one. generics . is_none ( ) {
211+ if let [ one] = & constraint[ ..] && one. generics . is_none ( ) && one . bindings . is_none ( ) {
184212 seq. serialize_element ( one) ?;
185213 } else {
186214 seq. serialize_element ( constraint) ?;
0 commit comments