diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js
index 0a73d32dac2de..e281139ca38ff 100644
--- a/src/librustdoc/html/static/js/search.js
+++ b/src/librustdoc/html/static/js/search.js
@@ -3906,6 +3906,8 @@ class DocSearch {
return name === "traitalias";
case "macro":
return name === "attr" || name === "derive";
+ case "import":
+ return name === "externcrate";
}
// No match
diff --git a/tests/rustdoc-js/import-filter.js b/tests/rustdoc-js/import-filter.js
new file mode 100644
index 0000000000000..408d0e3326179
--- /dev/null
+++ b/tests/rustdoc-js/import-filter.js
@@ -0,0 +1,20 @@
+// This test ensures that when filtering on `import`, `externcrate` items are also displayed.
+// It also ensures that the opposite is not true.
+
+const EXPECTED = [
+ {
+ 'query': 'import:st',
+ 'others': [
+ { 'path': 'foo', 'name': 'st', 'href': '../foo/index.html#reexport.st' },
+ // FIXME: `href` is wrong:
+ { 'path': 'foo', 'name': 'st2', 'href': '../st2/index.html' },
+ ],
+ },
+ {
+ 'query': 'externcrate:st',
+ 'others': [
+ // FIXME: `href` is wrong:
+ { 'path': 'foo', 'name': 'st2', 'href': '../st2/index.html' },
+ ],
+ },
+];
diff --git a/tests/rustdoc-js/import-filter.rs b/tests/rustdoc-js/import-filter.rs
new file mode 100644
index 0000000000000..7d30d00f5bbf8
--- /dev/null
+++ b/tests/rustdoc-js/import-filter.rs
@@ -0,0 +1,7 @@
+#![crate_name = "foo"]
+
+pub extern crate std as st2;
+
+pub use crate::Bar as st;
+
+pub struct Bar;