Skip to content

Commit 955c054

Browse files
Fix primitive types not showing up
1 parent aabfed5 commit 955c054

File tree

1 file changed

+43
-45
lines changed

1 file changed

+43
-45
lines changed

src/librustdoc/html/static/main.js

+43-45
Original file line numberDiff line numberDiff line change
@@ -381,13 +381,6 @@
381381
}
382382
}
383383

384-
function min(a, b) {
385-
if (a < b) {
386-
return a;
387-
}
388-
return b;
389-
}
390-
391384
function extractGenerics(val) {
392385
val = val.toLowerCase();
393386
if (val.indexOf('<') !== -1) {
@@ -425,7 +418,7 @@
425418
}
426419
if (lev.pos !== -1) {
427420
elems.splice(lev.pos, 1);
428-
lev_distance = min(lev.lev, lev_distance);
421+
lev_distance = Math.min(lev.lev, lev_distance);
429422
} else {
430423
return MAX_LEV_DISTANCE + 1;
431424
}
@@ -488,11 +481,12 @@
488481
var new_lev = levenshtein(obj.name, val.name);
489482
if (new_lev < lev_distance) {
490483
if ((lev = checkGenerics(obj, val)) <= MAX_LEV_DISTANCE) {
491-
lev_distance = min(min(new_lev, lev), lev_distance);
484+
lev_distance = Math.min(Math.min(new_lev, lev), lev_distance);
492485
}
493486
} else if (obj.generics && obj.generics.length > 0) {
494487
for (var x = 0; x < obj.generics.length; ++x) {
495-
lev_distance = min(levenshtein(obj.generics[x], val.name), lev_distance);
488+
lev_distance = Math.min(levenshtein(obj.generics[x], val.name),
489+
lev_distance);
496490
}
497491
}
498492
// Now whatever happens, the returned distance is "less good" so we should mark it
@@ -509,7 +503,7 @@
509503
if (literalSearch === true && tmp === true) {
510504
return true;
511505
}
512-
lev_distance = min(tmp, lev_distance);
506+
lev_distance = Math.min(tmp, lev_distance);
513507
if (lev_distance === 0) {
514508
return 0;
515509
}
@@ -526,7 +520,7 @@
526520
if (literalSearch === true && tmp === true) {
527521
return true;
528522
}
529-
lev_distance = min(tmp, lev_distance);
523+
lev_distance = Math.min(tmp, lev_distance);
530524
if (lev_distance === 0) {
531525
return 0;
532526
}
@@ -567,18 +561,20 @@
567561
var in_args = findArg(searchIndex[i], val, true);
568562
var returned = checkReturned(searchIndex[i], val, true);
569563
var ty = searchIndex[i];
564+
var fullId = itemTypes[ty.ty] + ty.path + ty.name;
565+
570566
if (searchWords[i] === val.name) {
571567
// filter type: ... queries
572568
if (typePassesFilter(typeFilter, searchIndex[i].ty) &&
573-
results[ty.path + ty.name] === undefined)
569+
results[fullId] === undefined)
574570
{
575-
results[ty.path + ty.name] = {id: i, index: -1};
571+
results[fullId] = {id: i, index: -1};
576572
results_length += 1;
577573
}
578574
} else if ((in_args === true || returned === true) &&
579575
typePassesFilter(typeFilter, searchIndex[i].ty)) {
580-
if (results[ty.path + ty.name] === undefined) {
581-
results[ty.path + ty.name] = {
576+
if (results[fullId] === undefined) {
577+
results[fullId] = {
582578
id: i,
583579
index: -1,
584580
dontValidate: true,
@@ -588,10 +584,10 @@
588584
results_length += 1;
589585
} else {
590586
if (in_args === true) {
591-
results[ty.path + ty.name].in_args = true;
587+
results[fullId].in_args = true;
592588
}
593589
if (returned === true) {
594-
results[ty.path + ty.name].returned = true;
590+
results[fullId].returned = true;
595591
}
596592
}
597593
}
@@ -620,6 +616,7 @@
620616
if (!type) {
621617
continue;
622618
}
619+
var fullId = itemTypes[ty.ty] + ty.path + ty.name;
623620

624621
// allow searching for void (no output) functions as well
625622
var typeOutput = type.output ? type.output.name : "";
@@ -638,15 +635,15 @@
638635
in_args = allFound;
639636
}
640637
if (in_args === true || returned === true || module === true) {
641-
if (results[ty.path + ty.name] !== undefined) {
638+
if (results[fullId] !== undefined) {
642639
if (returned === true) {
643-
results[ty.path + ty.name].returned = true;
640+
results[fullId].returned = true;
644641
}
645642
if (in_args === true) {
646-
results[ty.path + ty.name].in_args = true;
643+
results[fullId].in_args = true;
647644
}
648645
} else {
649-
results[ty.path + ty.name] = {
646+
results[fullId] = {
650647
id: i,
651648
index: -1,
652649
dontValidate: true,
@@ -681,48 +678,49 @@
681678
var index = -1;
682679
// we want lev results to go lower than others
683680
var lev = MAX_LEV_DISTANCE;
681+
var fullId = itemTypes[ty.ty] + ty.path + ty.name;
684682

685683
if (searchWords[j].indexOf(split[i]) > -1 ||
686684
searchWords[j].indexOf(val) > -1 ||
687685
searchWords[j].replace(/_/g, "").indexOf(val) > -1)
688686
{
689687
// filter type: ... queries
690-
if (typePassesFilter(typeFilter, searchIndex[j].ty) &&
691-
results[ty.path + ty.name] === undefined) {
688+
if (typePassesFilter(typeFilter, ty) &&
689+
results[fullId] === undefined) {
692690
index = searchWords[j].replace(/_/g, "").indexOf(val);
693691
}
694692
}
695693
if ((lev_distance = levenshtein(searchWords[j], val)) <= MAX_LEV_DISTANCE) {
696-
if (typePassesFilter(typeFilter, searchIndex[j].ty) &&
697-
(results[ty.path + ty.name] === undefined ||
698-
results[ty.path + ty.name].lev > lev_distance)) {
699-
lev = min(lev, lev_distance);
700-
index = 0;
694+
if (typePassesFilter(typeFilter, ty) &&
695+
(results[fullId] === undefined ||
696+
results[fullId].lev > lev_distance)) {
697+
lev = Math.min(lev, lev_distance);
698+
index = Math.max(0, index);
701699
}
702700
}
703701
if ((lev_distance = findArg(searchIndex[j], valGenerics))
704702
<= MAX_LEV_DISTANCE) {
705-
if (typePassesFilter(typeFilter, searchIndex[j].ty) &&
706-
(results[ty.path + ty.name] === undefined ||
707-
results[ty.path + ty.name].lev > lev_distance)) {
703+
if (typePassesFilter(typeFilter, ty) &&
704+
(results[fullId] === undefined ||
705+
results[fullId].lev > lev_distance)) {
708706
in_args = true;
709-
lev = min(lev_distance, lev);
710-
index = 0;
707+
lev = Math.min(lev_distance, lev);
708+
index = Math.max(0, index);
711709
}
712710
}
713711
if ((lev_distance = checkReturned(searchIndex[j], valGenerics)) <=
714712
MAX_LEV_DISTANCE) {
715-
if (typePassesFilter(typeFilter, searchIndex[j].ty) &&
716-
(results[ty.path + ty.name] === undefined ||
717-
results[ty.path + ty.name].lev > lev_distance)) {
713+
if (typePassesFilter(typeFilter, ty) &&
714+
(results[fullId] === undefined ||
715+
results[fullId].lev > lev_distance)) {
718716
returned = true;
719-
lev = min(lev_distance, lev);
720-
index = 0;
717+
lev = Math.min(lev_distance, lev);
718+
index = Math.max(0, index);
721719
}
722720
}
723721
if (index !== -1) {
724-
if (results[ty.path + ty.name] === undefined) {
725-
results[ty.path + ty.name] = {
722+
if (results[fullId] === undefined) {
723+
results[fullId] = {
726724
id: j,
727725
index: index,
728726
lev: lev,
@@ -731,14 +729,14 @@
731729
};
732730
results_length += 1;
733731
} else {
734-
if (results[ty.path + ty.name].lev > lev) {
735-
results[ty.path + ty.name].lev = lev;
732+
if (results[fullId].lev > lev) {
733+
results[fullId].lev = lev;
736734
}
737735
if (in_args === true) {
738-
results[ty.path + ty.name].in_args = true;
736+
results[fullId].in_args = true;
739737
}
740738
if (returned === true) {
741-
results[ty.path + ty.name].returned = true;
739+
results[fullId].returned = true;
742740
}
743741
}
744742
}

0 commit comments

Comments
 (0)