Skip to content

Commit 1f5c4c2

Browse files
Forbid rustdoc search query to end with ->
1 parent 8e29ed4 commit 1f5c4c2

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,9 @@ window.initSearch = function(rawSearchIndex) {
440440
// Get returned elements.
441441
getItemsBefore(query, parserState, query.returned, "");
442442
// Nothing can come afterward!
443+
if (query.returned.length === 0) {
444+
throw new Error("Expected at least one item after `->`");
445+
}
443446
break;
444447
} else {
445448
parserState.pos += 1;

src/test/rustdoc-js-std/parser-errors.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const QUERY = [
2121
"a-bb",
2222
"a>bb",
2323
"ab'",
24+
"a->",
2425
];
2526

2627
const PARSED = [
@@ -222,4 +223,13 @@ const PARSED = [
222223
userQuery: "ab'",
223224
error: "Unexpected `'`",
224225
},
226+
{
227+
elems: [],
228+
foundElems: 0,
229+
original: "a->",
230+
returned: [],
231+
typeFilter: -1,
232+
userQuery: "a->",
233+
error: "Expected at least one item after `->`",
234+
},
225235
];

0 commit comments

Comments
 (0)