Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/librustdoc/html/static/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ const ROOT_PATH = typeof window !== "undefined" ? window.rootPath : "../";
const UNBOXING_LIMIT = 5;

// used for search query verification
const REGEX_IDENT = /\p{ID_Start}\p{ID_Continue}*|_\p{ID_Continue}+/uy;
// because searches are often performed using substrings of identifiers,
// and not just full identiferes, we allow them to start with chars that otherwise
// can only appear in the middle of identifiers
const REGEX_IDENT = /\p{ID_Continue}+/uy;
const REGEX_INVALID_TYPE_FILTER = /[^a-z]/ui;

const MAX_RESULTS = 200;
Expand Down
2 changes: 1 addition & 1 deletion tests/rustdoc-js-std/parser-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ const PARSED = [
foundElems: 0,
userQuery: "_:",
returned: [],
error: "Unexpected `_` (not a valid identifier)",
error: "Unexpected `_` in type filter (before `:`)",
},
{
query: "ab:",
Expand Down
19 changes: 19 additions & 0 deletions tests/rustdoc-js-std/search-by-number.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// regression test for https://github.com/rust-lang/rust/issues/147763
//
// identifiers in search queries should not be required to follow the
// same strict rules around ID_Start that identifers in rust code follow,
// as searches frequently use substrings of identifers.
//
// for example, identifiers cannot start with digits,
// but they can contain them, so we allow search idents to start with digits.

const EXPECTED = {
'query': '8',
'others': [
{
'path': 'std',
'name': 'i8',
'href': '../std/primitive.i8.html',
},
]
};
Loading