Skip to content

Commit d1b8a7a

Browse files
committed
rustdoc js: typecheck sortQ
1 parent 6e2ded8 commit d1b8a7a

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/librustdoc/html/static/js/search.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4588,18 +4588,16 @@ class DocSearch {
45884588
// types with generic parameters go last.
45894589
// That's because of the way unification is structured: it eats off
45904590
// the end, and hits a fast path if the last item is a simple atom.
4591-
// @ts-expect-error
4591+
/** @type {function(rustdoc.QueryElement, rustdoc.QueryElement): number} */
45924592
const sortQ = (a, b) => {
45934593
const ag = a.generics.length === 0 && a.bindings.size === 0;
45944594
const bg = b.generics.length === 0 && b.bindings.size === 0;
45954595
if (ag !== bg) {
4596-
// @ts-expect-error
4597-
return ag - bg;
4596+
return +ag - +bg;
45984597
}
4599-
const ai = a.id > 0;
4600-
const bi = b.id > 0;
4601-
// @ts-expect-error
4602-
return ai - bi;
4598+
const ai = a.id !== null && a.id > 0;
4599+
const bi = b.id !== null && b.id > 0;
4600+
return +ai - +bi;
46034601
};
46044602
parsedQuery.elems.sort(sortQ);
46054603
parsedQuery.returned.sort(sortQ);

0 commit comments

Comments
 (0)