@@ -113,6 +113,7 @@ pub(crate) struct IndexItem {
113
113
pub ( crate ) struct RenderType {
114
114
id : Option < RenderTypeId > ,
115
115
generics : Option < Vec < RenderType > > ,
116
+ bindings : Option < Vec < ( RenderTypeId , Vec < RenderType > ) > > ,
116
117
}
117
118
118
119
impl Serialize for RenderType {
@@ -129,24 +130,47 @@ impl Serialize for RenderType {
129
130
Some ( RenderTypeId :: Index ( idx) ) => * idx,
130
131
_ => panic ! ( "must convert render types to indexes before serializing" ) ,
131
132
} ;
132
- if let Some ( generics) = & self . generics {
133
+ if self . generics . is_some ( ) || self . bindings . is_some ( ) {
133
134
let mut seq = serializer. serialize_seq ( None ) ?;
134
135
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
+ }
136
142
seq. end ( )
137
143
} else {
138
144
id. serialize ( serializer)
139
145
}
140
146
}
141
147
}
142
148
143
- #[ derive( Clone , Debug ) ]
149
+ #[ derive( Clone , Copy , Debug ) ]
144
150
pub ( crate ) enum RenderTypeId {
145
151
DefId ( DefId ) ,
146
152
Primitive ( clean:: PrimitiveType ) ,
153
+ AssociatedType ( Symbol ) ,
147
154
Index ( isize ) ,
148
155
}
149
156
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
+
150
174
/// Full type of functions/methods in the search index.
151
175
#[ derive( Debug ) ]
152
176
pub ( crate ) struct IndexItemFunctionType {
@@ -171,16 +195,20 @@ impl Serialize for IndexItemFunctionType {
171
195
} else {
172
196
let mut seq = serializer. serialize_seq ( None ) ?;
173
197
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
+ }
175
201
_ => seq. serialize_element ( & self . inputs ) ?,
176
202
}
177
203
match & self . output [ ..] {
178
204
[ ] 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
+ }
180
208
_ => seq. serialize_element ( & self . output ) ?,
181
209
}
182
210
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 ( ) {
184
212
seq. serialize_element ( one) ?;
185
213
} else {
186
214
seq. serialize_element ( constraint) ?;
0 commit comments