Skip to content

Commit 707c075

Browse files
authored
Rollup merge of rust-lang#148301 - GuillaumeGomez:import-filter, r=notriddle
[rustdoc search] Include extern crates when filtering on `import` As discussed rust-lang#147909, some filters should have been "grouped". This PR allows extern crates to match the `import` filter. This PR also allowed me to uncover a bug for the URL generated for renamed extern crates. Opened rust-lang#148300 for it. r? `@notriddle`
2 parents 9227c00 + 2a1595e commit 707c075

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3906,6 +3906,8 @@ class DocSearch {
39063906
return name === "traitalias";
39073907
case "macro":
39083908
return name === "attr" || name === "derive";
3909+
case "import":
3910+
return name === "externcrate";
39093911
}
39103912

39113913
// No match

tests/rustdoc-js/import-filter.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// This test ensures that when filtering on `import`, `externcrate` items are also displayed.
2+
// It also ensures that the opposite is not true.
3+
4+
const EXPECTED = [
5+
{
6+
'query': 'import:st',
7+
'others': [
8+
{ 'path': 'foo', 'name': 'st', 'href': '../foo/index.html#reexport.st' },
9+
// FIXME: `href` is wrong: <https://github.com/rust-lang/rust/issues/148300>
10+
{ 'path': 'foo', 'name': 'st2', 'href': '../st2/index.html' },
11+
],
12+
},
13+
{
14+
'query': 'externcrate:st',
15+
'others': [
16+
// FIXME: `href` is wrong: <https://github.com/rust-lang/rust/issues/148300>
17+
{ 'path': 'foo', 'name': 'st2', 'href': '../st2/index.html' },
18+
],
19+
},
20+
];

tests/rustdoc-js/import-filter.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#![crate_name = "foo"]
2+
3+
pub extern crate std as st2;
4+
5+
pub use crate::Bar as st;
6+
7+
pub struct Bar;

0 commit comments

Comments
 (0)