rustdoc search: increase strictness of typechecking
This commit is contained in:
parent
617aad8c2e
commit
a8c0b3bfff
2 changed files with 11 additions and 6 deletions
10
src/librustdoc/html/static/js/rustdoc.d.ts
vendored
10
src/librustdoc/html/static/js/rustdoc.d.ts
vendored
|
@ -123,7 +123,7 @@ declare namespace rustdoc {
|
|||
* Same as QueryElement, but bindings and typeFilter support strings
|
||||
*/
|
||||
interface ParserQueryElement {
|
||||
name: string,
|
||||
name: string|null,
|
||||
id: number|null,
|
||||
fullPath: Array<string>,
|
||||
pathWithoutLast: Array<string>,
|
||||
|
@ -131,10 +131,16 @@ declare namespace rustdoc {
|
|||
normalizedPathLast: string,
|
||||
generics: Array<ParserQueryElement>,
|
||||
bindings: Map<string, Array<ParserQueryElement>>,
|
||||
bindingName: {name: string, generics: ParserQueryElement[]}|null,
|
||||
bindingName: {name: string|null, generics: ParserQueryElement[]}|null,
|
||||
typeFilter: string|null,
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as ParserQueryElement, but all fields are optional.
|
||||
*/
|
||||
type ParserQueryElementFields = {
|
||||
[K in keyof ParserQueryElement]?: ParserQueryElement[T]
|
||||
}
|
||||
/**
|
||||
* Intermediate parser state. Discarded when parsing is done.
|
||||
*/
|
||||
|
|
|
@ -638,7 +638,6 @@ function getNextElem(query, parserState, elems, isInGenerics) {
|
|||
getFilteredNextElem(query, parserState, generics, isInGenerics);
|
||||
generics[generics.length - 1].bindingName = makePrimitiveElement("output");
|
||||
} else {
|
||||
// @ts-expect-error
|
||||
generics.push(makePrimitiveElement(null, {
|
||||
bindingName: makePrimitiveElement("output"),
|
||||
typeFilter: null,
|
||||
|
@ -791,7 +790,7 @@ function createQueryElement(query, parserState, name, generics, isInGenerics) {
|
|||
generics: generics.filter(gen => {
|
||||
// Syntactically, bindings are parsed as generics,
|
||||
// but the query engine treats them differently.
|
||||
if (gen.bindingName !== null) {
|
||||
if (gen.bindingName !== null && gen.bindingName.name !== null) {
|
||||
if (gen.name !== null) {
|
||||
gen.bindingName.generics.unshift(gen);
|
||||
}
|
||||
|
@ -811,8 +810,8 @@ function createQueryElement(query, parserState, name, generics, isInGenerics) {
|
|||
|
||||
/**
|
||||
*
|
||||
* @param {string} name
|
||||
* @param {Object=} extra
|
||||
* @param {string|null} name
|
||||
* @param {rustdoc.ParserQueryElementFields=} extra
|
||||
* @returns {rustdoc.ParserQueryElement}
|
||||
*/
|
||||
function makePrimitiveElement(name, extra) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue