rust/tests/rustdoc-js-std/parser-bindings.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

246 lines
6.8 KiB
JavaScript

const PARSED = [
{
query: 'A<B=C>',
elems: [
{
name: "a",
fullPath: ["a"],
pathWithoutLast: [],
pathLast: "a",
generics: [],
bindings: [
[
'b',
[
{
name: "c",
fullPath: ["c"],
pathWithoutLast: [],
pathLast: "c",
generics: [],
typeFilter: -1,
},
]
],
],
typeFilter: -1,
},
],
foundElems: 1,
original: 'A<B=C>',
returned: [],
userQuery: 'a<b=c>',
error: null,
},
{
query: 'A<B = C>',
elems: [
{
name: "a",
fullPath: ["a"],
pathWithoutLast: [],
pathLast: "a",
generics: [],
bindings: [
[
'b',
[{
name: "c",
fullPath: ["c"],
pathWithoutLast: [],
pathLast: "c",
generics: [],
typeFilter: -1,
}]
],
],
typeFilter: -1,
},
],
foundElems: 1,
original: 'A<B = C>',
returned: [],
userQuery: 'a<b = c>',
error: null,
},
{
query: 'A<B=!>',
elems: [
{
name: "a",
fullPath: ["a"],
pathWithoutLast: [],
pathLast: "a",
generics: [],
bindings: [
[
'b',
[{
name: "never",
fullPath: ["never"],
pathWithoutLast: [],
pathLast: "never",
generics: [],
typeFilter: 1,
}]
],
],
typeFilter: -1,
},
],
foundElems: 1,
original: 'A<B=!>',
returned: [],
userQuery: 'a<b=!>',
error: null,
},
{
query: 'A<B=[]>',
elems: [
{
name: "a",
fullPath: ["a"],
pathWithoutLast: [],
pathLast: "a",
generics: [],
bindings: [
[
'b',
[{
name: "[]",
fullPath: ["[]"],
pathWithoutLast: [],
pathLast: "[]",
generics: [],
typeFilter: 1,
}]
],
],
typeFilter: -1,
},
],
foundElems: 1,
original: 'A<B=[]>',
returned: [],
userQuery: 'a<b=[]>',
error: null,
},
{
query: 'A<B=[!]>',
elems: [
{
name: "a",
fullPath: ["a"],
pathWithoutLast: [],
pathLast: "a",
generics: [],
bindings: [
[
'b',
[{
name: "[]",
fullPath: ["[]"],
pathWithoutLast: [],
pathLast: "[]",
generics: [
{
name: "never",
fullPath: ["never"],
pathWithoutLast: [],
pathLast: "never",
generics: [],
typeFilter: 1,
},
],
typeFilter: 1,
}]
],
],
typeFilter: -1,
},
],
foundElems: 1,
original: 'A<B=[!]>',
returned: [],
userQuery: 'a<b=[!]>',
error: null,
},
{
query: 'A<B=C=>',
elems: [],
foundElems: 0,
original: 'A<B=C=>',
returned: [],
userQuery: 'a<b=c=>',
error: "Cannot write `=` twice in a binding",
},
{
query: 'A<B=>',
elems: [],
foundElems: 0,
original: 'A<B=>',
returned: [],
userQuery: 'a<b=>',
error: "Unexpected `>` after `=`",
},
{
query: 'B=C',
elems: [],
foundElems: 0,
original: 'B=C',
returned: [],
userQuery: 'b=c',
error: "Type parameter `=` must be within generics list",
},
{
query: '[B=C]',
elems: [],
foundElems: 0,
original: '[B=C]',
returned: [],
userQuery: '[b=c]',
error: "Type parameter `=` cannot be within slice `[]`",
},
{
query: 'A<B<X>=C>',
elems: [
{
name: "a",
fullPath: ["a"],
pathWithoutLast: [],
pathLast: "a",
generics: [],
bindings: [
[
'b',
[
{
name: "c",
fullPath: ["c"],
pathWithoutLast: [],
pathLast: "c",
generics: [],
typeFilter: -1,
},
{
name: "x",
fullPath: ["x"],
pathWithoutLast: [],
pathLast: "x",
generics: [],
typeFilter: -1,
},
],
],
],
typeFilter: -1,
},
],
foundElems: 1,
original: 'A<B<X>=C>',
returned: [],
userQuery: 'a<b<x>=c>',
error: null,
},
];