Skip to content

Commit 51e9769

Browse files
Emit an error for unclosed generic
1 parent 7a809ce commit 51e9769

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

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

+13-1
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,15 @@ function initSearch(rawSearchIndex) {
469469
}
470470
const posBefore = parserState.pos;
471471
getNextElem(query, parserState, elems, endChar === ">");
472+
if (endChar !== "") {
473+
if (parserState.pos >= parserState.length) {
474+
throw ["Unclosed ", "<"];
475+
}
476+
const c2 = parserState.userQuery[parserState.pos];
477+
if (!isSeparatorCharacter(c2) && c2 !== endChar) {
478+
throw ["Expected ", endChar, ", found ", c2];
479+
}
480+
}
472481
// This case can be encountered if `getNextElem` encountered a "stop character" right
473482
// from the start. For example if you have `,,` or `<>`. In this case, we simply move up
474483
// the current position to continue the parsing.
@@ -477,7 +486,10 @@ function initSearch(rawSearchIndex) {
477486
}
478487
foundStopChar = false;
479488
}
480-
// We are either at the end of the string or on the `endChar`` character, let's move forward
489+
if (parserState.pos >= parserState.length && endChar !== "") {
490+
throw ["Unclosed ", "<"];
491+
}
492+
// We are either at the end of the string or on the `endChar` character, let's move forward
481493
// in any case.
482494
parserState.pos += 1;
483495
}

0 commit comments

Comments
 (0)