From 7b62d28cf2ca427dde2635e1ae5147a774442c99 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 30 Jun 2021 14:11:09 +0200 Subject: [PATCH 1/2] Enforce search typed queries --- src/librustdoc/html/static/search.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/html/static/search.js b/src/librustdoc/html/static/search.js index 0aebb0e9d6588..f6343e4c3d246 100644 --- a/src/librustdoc/html/static/search.js +++ b/src/librustdoc/html/static/search.js @@ -801,7 +801,8 @@ window.initSearch = function(rawSearchIndex) { results_returned[fullId].lev = Math.min(results_returned[fullId].lev, returned); } - if (index !== -1 || lev <= MAX_LEV_DISTANCE) { + if (typePassesFilter(typeFilter, ty.ty) && + (index !== -1 || lev <= MAX_LEV_DISTANCE)) { if (index !== -1 && paths.length < 2) { lev = 0; } From 855923c895681976d7a3ce6ff376f9b4c3b21ae8 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 30 Jun 2021 14:20:17 +0200 Subject: [PATCH 2/2] Add test to ensure that the typed queries are not including other types --- src/test/rustdoc-js-std/typed-query.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/test/rustdoc-js-std/typed-query.js diff --git a/src/test/rustdoc-js-std/typed-query.js b/src/test/rustdoc-js-std/typed-query.js new file mode 100644 index 0000000000000..f656aa72986fd --- /dev/null +++ b/src/test/rustdoc-js-std/typed-query.js @@ -0,0 +1,12 @@ +// exact-check + +const QUERY = 'macro:print'; + +const EXPECTED = { + 'others': [ + { 'path': 'std', 'name': 'print' }, + { 'path': 'std', 'name': 'eprint' }, + { 'path': 'std', 'name': 'println' }, + { 'path': 'std', 'name': 'eprintln' }, + ], +};