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