@@ -880,7 +880,7 @@ function createQueryElement(query, parserState, name, generics, isInGenerics) {
880
880
*/
881
881
function makePrimitiveElement ( name , extra ) {
882
882
return Object . assign ( {
883
- name : name ,
883
+ name,
884
884
id : null ,
885
885
fullPath : [ name ] ,
886
886
pathWithoutLast : [ ] ,
@@ -1200,33 +1200,43 @@ class DocSearch {
1200
1200
if ( ! nn ) {
1201
1201
return ;
1202
1202
}
1203
+ // Each of these identifiers are used specially by
1204
+ // type-driven search.
1203
1205
const [
1206
+ // output is the special associated type that goes
1207
+ // after the arrow: the type checker desugars
1208
+ // the path `Fn(a) -> b` into `Fn<Output=b, (a)>`
1204
1209
output ,
1210
+ // fn, fnmut, and fnonce all match `->`
1205
1211
fn ,
1206
1212
fnMut ,
1207
1213
fnOnce ,
1214
+ hof ,
1215
+ // array and slice both match `[]`
1208
1216
array ,
1209
1217
slice ,
1210
1218
arrayOrSlice ,
1219
+ // tuple and unit both match `()`
1211
1220
tuple ,
1212
1221
unit ,
1213
1222
tupleOrUnit ,
1223
+ // reference matches `&`
1214
1224
reference ,
1215
- hof ,
1225
+ // never matches `!`
1216
1226
never ,
1217
1227
] = await Promise . all ( [
1218
1228
nn . search ( "output" ) ,
1219
1229
nn . search ( "fn" ) ,
1220
1230
nn . search ( "fnmut" ) ,
1221
1231
nn . search ( "fnonce" ) ,
1232
+ nn . search ( "->" ) ,
1222
1233
nn . search ( "array" ) ,
1223
1234
nn . search ( "slice" ) ,
1224
1235
nn . search ( "[]" ) ,
1225
1236
nn . search ( "tuple" ) ,
1226
1237
nn . search ( "unit" ) ,
1227
1238
nn . search ( "()" ) ,
1228
1239
nn . search ( "reference" ) ,
1229
- nn . search ( "->" ) ,
1230
1240
nn . search ( "never" ) ,
1231
1241
] ) ;
1232
1242
/**
@@ -4232,9 +4242,8 @@ class DocSearch {
4232
4242
unpackPostingsListAll ( inputs ) ,
4233
4243
unpackPostingsListAll ( output ) ,
4234
4244
] ) ;
4235
- const results = [ ] ;
4245
+ const resultPromises = [ ] ;
4236
4246
let checkCounter = 0 ;
4237
- let maxDist = 0 ;
4238
4247
for ( const [ inputsPostingList , inputs ] of allInputs ) {
4239
4248
for ( const [ outputPostingList , output ] of allOutput ) {
4240
4249
const postingList = inputsPostingList . intersection ( outputPostingList ) ;
@@ -4243,51 +4252,49 @@ class DocSearch {
4243
4252
if ( ( checkCounter & 0x7F ) === 0 ) {
4244
4253
await yieldToBrowser ( ) ;
4245
4254
}
4246
- const fnData = await this . getFunctionData ( id ) ;
4247
- if ( ! fnData || ! fnData . functionSignature ) {
4248
- continue ;
4249
- }
4250
- if ( fnData . elemCount > maxDist ) {
4251
- if ( results . length > 200 ) {
4252
- continue ;
4253
- } else {
4254
- maxDist = fnData . elemCount ;
4255
+ resultPromises . push ( this . getFunctionData ( id ) . then ( async ( fnData ) => {
4256
+ if ( ! fnData || ! fnData . functionSignature ) {
4257
+ return null ;
4255
4258
}
4256
- }
4257
- const functionSignature = fnData . functionSignature ;
4258
- if ( ! unifyFunctionTypes (
4259
- functionSignature . inputs ,
4260
- inputs ,
4261
- functionSignature . where_clause ,
4262
- null ,
4263
- mgens => {
4264
- return ! ! unifyFunctionTypes (
4265
- functionSignature . output ,
4266
- output ,
4267
- functionSignature . where_clause ,
4268
- mgens ,
4269
- checkTypeMgensForConflict ,
4270
- 0 , // unboxing depth
4271
- ) ;
4272
- } ,
4273
- 0 , // unboxing depth
4274
- ) ) {
4275
- continue ;
4276
- }
4277
- results . push ( {
4278
- id,
4279
- dist : fnData . elemCount ,
4280
- path_dist : 0 ,
4281
- index : - 1 ,
4282
- elems : inputs ,
4283
- returned : output ,
4284
- is_alias : false ,
4285
- } ) ;
4259
+ checkCounter += 1 ;
4260
+ if ( ( checkCounter & 0x7F ) === 0 ) {
4261
+ await yieldToBrowser ( ) ;
4262
+ }
4263
+ const functionSignature = fnData . functionSignature ;
4264
+ if ( ! unifyFunctionTypes (
4265
+ functionSignature . inputs ,
4266
+ inputs ,
4267
+ functionSignature . where_clause ,
4268
+ null ,
4269
+ mgens => {
4270
+ return ! ! unifyFunctionTypes (
4271
+ functionSignature . output ,
4272
+ output ,
4273
+ functionSignature . where_clause ,
4274
+ mgens ,
4275
+ checkTypeMgensForConflict ,
4276
+ 0 , // unboxing depth
4277
+ ) ;
4278
+ } ,
4279
+ 0 , // unboxing depth
4280
+ ) ) {
4281
+ return null ;
4282
+ }
4283
+ return {
4284
+ id,
4285
+ dist : fnData . elemCount ,
4286
+ path_dist : 0 ,
4287
+ index : - 1 ,
4288
+ elems : inputs ,
4289
+ returned : output ,
4290
+ is_alias : false ,
4291
+ } ;
4292
+ } ) ) ;
4286
4293
}
4287
4294
}
4288
4295
}
4289
4296
yield * sortAndTransformResults (
4290
- results ,
4297
+ await Promise . all ( resultPromises ) ,
4291
4298
typeInfo ,
4292
4299
currentCrate ,
4293
4300
new Set ( ) ,
0 commit comments