rust/tests/rustdoc-js-std/parser-filter.js
Michael Howell 28f17d97a9 rustdoc-search: make primitives and keywords less special
The search sorting code already sorts by item type discriminant,
putting things with smaller discriminants first. There was
also a special case for sorting keywords and primitives earlier,
and this commit removes it by giving them lower discriminants.

The sorting code has another criteria where items with descriptions
appear earlier than items without, and that criteria has higher
priority than the item type. This shouldn't matter, though,
because primitives and keywords normally only appear in the
standard library, and it always gives them descriptions.
2023-11-21 13:59:26 -07:00

166 lines
4.0 KiB
JavaScript

const PARSED = [
{
query: 'fn:foo',
elems: [{
name: "foo",
fullPath: ["foo"],
pathWithoutLast: [],
pathLast: "foo",
generics: [],
typeFilter: 7,
}],
foundElems: 1,
original: "fn:foo",
returned: [],
userQuery: "fn:foo",
error: null,
},
{
query: 'enum : foo',
elems: [{
name: "foo",
fullPath: ["foo"],
pathWithoutLast: [],
pathLast: "foo",
generics: [],
typeFilter: 6,
}],
foundElems: 1,
original: "enum : foo",
returned: [],
userQuery: "enum : foo",
error: null,
},
{
query: 'macro<f>:foo',
elems: [],
foundElems: 0,
original: "macro<f>:foo",
returned: [],
userQuery: "macro<f>:foo",
error: "Unexpected `<` in type filter (before `:`)",
},
{
query: 'macro!',
elems: [{
name: "macro",
fullPath: ["macro"],
pathWithoutLast: [],
pathLast: "macro",
generics: [],
typeFilter: 16,
}],
foundElems: 1,
original: "macro!",
returned: [],
userQuery: "macro!",
error: null,
},
{
query: 'macro:mac!',
elems: [{
name: "mac",
fullPath: ["mac"],
pathWithoutLast: [],
pathLast: "mac",
generics: [],
typeFilter: 16,
}],
foundElems: 1,
original: "macro:mac!",
returned: [],
userQuery: "macro:mac!",
error: null,
},
{
query: 'a::mac!',
elems: [{
name: "a::mac",
fullPath: ["a", "mac"],
pathWithoutLast: ["a"],
pathLast: "mac",
generics: [],
typeFilter: 16,
}],
foundElems: 1,
original: "a::mac!",
returned: [],
userQuery: "a::mac!",
error: null,
},
{
query: '-> fn:foo',
elems: [],
foundElems: 1,
original: "-> fn:foo",
returned: [{
name: "foo",
fullPath: ["foo"],
pathWithoutLast: [],
pathLast: "foo",
generics: [],
typeFilter: 7,
}],
userQuery: "-> fn:foo",
error: null,
},
{
query: '-> fn:foo<fn:bar>',
elems: [],
foundElems: 1,
original: "-> fn:foo<fn:bar>",
returned: [{
name: "foo",
fullPath: ["foo"],
pathWithoutLast: [],
pathLast: "foo",
generics: [
{
name: "bar",
fullPath: ["bar"],
pathWithoutLast: [],
pathLast: "bar",
generics: [],
typeFilter: 7,
}
],
typeFilter: 7,
}],
userQuery: "-> fn:foo<fn:bar>",
error: null,
},
{
query: '-> fn:foo<fn:bar, enum : baz::fuzz>',
elems: [],
foundElems: 1,
original: "-> fn:foo<fn:bar, enum : baz::fuzz>",
returned: [{
name: "foo",
fullPath: ["foo"],
pathWithoutLast: [],
pathLast: "foo",
generics: [
{
name: "bar",
fullPath: ["bar"],
pathWithoutLast: [],
pathLast: "bar",
generics: [],
typeFilter: 7,
},
{
name: "baz::fuzz",
fullPath: ["baz", "fuzz"],
pathWithoutLast: ["baz"],
pathLast: "fuzz",
generics: [],
typeFilter: 6,
},
],
typeFilter: 7,
}],
userQuery: "-> fn:foo<fn:bar, enum : baz::fuzz>",
error: null,
},
];