Skip to content

Commit e0abd59

Browse files
Emit an error for unclosed generic
1 parent 18caf88 commit e0abd59

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,15 @@ function initSearch(rawSearchIndex) {
446446
}
447447
const posBefore = parserState.pos;
448448
getNextElem(query, parserState, elems, endChar === ">");
449+
if (endChar !== "") {
450+
if (parserState.pos >= parserState.length) {
451+
throw new Error("Unclosed `<`");
452+
}
453+
const c2 = parserState.userQuery[parserState.pos];
454+
if (!isSeparatorCharacter(c2) && c2 !== endChar) {
455+
throw new Error(`Expected \`${endChar}\`, found \`${c2}\``);
456+
}
457+
}
449458
// This case can be encountered if `getNextElem` encountered a "stop character" right
450459
// from the start. For example if you have `,,` or `<>`. In this case, we simply move up
451460
// the current position to continue the parsing.
@@ -454,7 +463,10 @@ function initSearch(rawSearchIndex) {
454463
}
455464
foundStopChar = false;
456465
}
457-
// We are either at the end of the string or on the `endChar`` character, let's move forward
466+
if (parserState.pos >= parserState.length && endChar !== "") {
467+
throw new Error("Unclosed `<`");
468+
}
469+
// We are either at the end of the string or on the `endChar` character, let's move forward
458470
// in any case.
459471
parserState.pos += 1;
460472
}

0 commit comments

Comments
 (0)