mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 15:01:51 +00:00
Rollup merge of #108656 - GuillaumeGomez:rustdoc-search-unclosed-generic, r=notriddle
Rustdoc search: Emit an error for unclosed generic Now, search like `a<` will error as it should (and as written in the eBNF). r? `@notriddle`
This commit is contained in:
commit
2fc4935cdb
@ -469,6 +469,15 @@ function initSearch(rawSearchIndex) {
|
|||||||
}
|
}
|
||||||
const posBefore = parserState.pos;
|
const posBefore = parserState.pos;
|
||||||
getNextElem(query, parserState, elems, endChar === ">");
|
getNextElem(query, parserState, elems, endChar === ">");
|
||||||
|
if (endChar !== "") {
|
||||||
|
if (parserState.pos >= parserState.length) {
|
||||||
|
throw ["Unclosed ", "<"];
|
||||||
|
}
|
||||||
|
const c2 = parserState.userQuery[parserState.pos];
|
||||||
|
if (!isSeparatorCharacter(c2) && c2 !== endChar) {
|
||||||
|
throw ["Expected ", endChar, ", found ", c2];
|
||||||
|
}
|
||||||
|
}
|
||||||
// This case can be encountered if `getNextElem` encountered a "stop character" right
|
// This case can be encountered if `getNextElem` encountered a "stop character" right
|
||||||
// from the start. For example if you have `,,` or `<>`. In this case, we simply move up
|
// from the start. For example if you have `,,` or `<>`. In this case, we simply move up
|
||||||
// the current position to continue the parsing.
|
// the current position to continue the parsing.
|
||||||
@ -477,7 +486,10 @@ function initSearch(rawSearchIndex) {
|
|||||||
}
|
}
|
||||||
foundStopChar = false;
|
foundStopChar = false;
|
||||||
}
|
}
|
||||||
// We are either at the end of the string or on the `endChar`` character, let's move forward
|
if (parserState.pos >= parserState.length && endChar !== "") {
|
||||||
|
throw ["Unclosed ", "<"];
|
||||||
|
}
|
||||||
|
// We are either at the end of the string or on the `endChar` character, let's move forward
|
||||||
// in any case.
|
// in any case.
|
||||||
parserState.pos += 1;
|
parserState.pos += 1;
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@ const QUERY = [
|
|||||||
"a!!",
|
"a!!",
|
||||||
"mod:a!",
|
"mod:a!",
|
||||||
"a!::a",
|
"a!::a",
|
||||||
|
"a<",
|
||||||
];
|
];
|
||||||
|
|
||||||
const PARSED = [
|
const PARSED = [
|
||||||
@ -402,4 +403,13 @@ const PARSED = [
|
|||||||
userQuery: "a!::a",
|
userQuery: "a!::a",
|
||||||
error: 'Cannot have associated items in macros',
|
error: 'Cannot have associated items in macros',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
elems: [],
|
||||||
|
foundElems: 0,
|
||||||
|
original: "a<",
|
||||||
|
returned: [],
|
||||||
|
typeFilter: -1,
|
||||||
|
userQuery: "a<",
|
||||||
|
error: "Unclosed `<`",
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
Loading…
Reference in New Issue
Block a user