rustdoc-search: single result for items with multiple paths
This change uses the same "exact" paths as trait implementors and type alias inlining to track items with multiple reachable paths. This way, if you search for `vec`, you get only the `std` exports of it, and not the one from `alloc`. It still includes all the items in the search index so that you can search for them by all available paths. For example, try `core::option` and `std::option`, and notice that the results page doesn't show duplicates, but still shows all the items in their respective crates.
This commit is contained in:
parent
ab5bda1aa7
commit
f36c5af359
13 changed files with 313 additions and 25 deletions
7
tests/rustdoc-js/auxiliary/macro-in-module.rs
Normal file
7
tests/rustdoc-js/auxiliary/macro-in-module.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
#[macro_use]
|
||||
mod hidden_macro_module {
|
||||
#[macro_export]
|
||||
macro_rules! vec {
|
||||
() => {};
|
||||
}
|
||||
}
|
11
tests/rustdoc-js/reexport-dedup-macro.js
Normal file
11
tests/rustdoc-js/reexport-dedup-macro.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
// exact-check
|
||||
|
||||
const EXPECTED = [
|
||||
{
|
||||
'query': 'vec',
|
||||
'others': [
|
||||
{ 'path': 'foo', 'name': 'vec', 'exactPath': 'macro_in_module' },
|
||||
{ 'path': 'foo', 'name': 'myspecialvec', 'exactPath': 'foo' },
|
||||
],
|
||||
},
|
||||
];
|
15
tests/rustdoc-js/reexport-dedup-macro.rs
Normal file
15
tests/rustdoc-js/reexport-dedup-macro.rs
Normal file
|
@ -0,0 +1,15 @@
|
|||
//@ aux-crate: macro_in_module=macro-in-module.rs
|
||||
#![crate_name="foo"]
|
||||
extern crate macro_in_module;
|
||||
|
||||
// Test case based on the relationship between alloc and std.
|
||||
#[doc(inline)]
|
||||
pub use macro_in_module::vec;
|
||||
|
||||
#[macro_use]
|
||||
mod hidden_macro_module {
|
||||
#[macro_export]
|
||||
macro_rules! myspecialvec {
|
||||
() => {};
|
||||
}
|
||||
}
|
16
tests/rustdoc-js/reexport-dedup-method.js
Normal file
16
tests/rustdoc-js/reexport-dedup-method.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
// exact-check
|
||||
|
||||
const EXPECTED = [
|
||||
{
|
||||
'query': 'Subscriber dostuff',
|
||||
'others': [
|
||||
{ 'path': 'foo::fmt::Subscriber', 'name': 'dostuff' },
|
||||
],
|
||||
},
|
||||
{
|
||||
'query': 'AnotherOne dostuff',
|
||||
'others': [
|
||||
{ 'path': 'foo::AnotherOne', 'name': 'dostuff' },
|
||||
],
|
||||
},
|
||||
];
|
18
tests/rustdoc-js/reexport-dedup-method.rs
Normal file
18
tests/rustdoc-js/reexport-dedup-method.rs
Normal file
|
@ -0,0 +1,18 @@
|
|||
// This test enforces that the (renamed) reexports are present in the search results.
|
||||
#![crate_name="foo"]
|
||||
|
||||
pub mod fmt {
|
||||
pub struct Subscriber;
|
||||
impl Subscriber {
|
||||
pub fn dostuff(&self) {}
|
||||
}
|
||||
}
|
||||
mod foo {
|
||||
pub struct AnotherOne;
|
||||
impl AnotherOne {
|
||||
pub fn dostuff(&self) {}
|
||||
}
|
||||
}
|
||||
|
||||
pub use foo::AnotherOne;
|
||||
pub use fmt::Subscriber;
|
22
tests/rustdoc-js/reexport-dedup.js
Normal file
22
tests/rustdoc-js/reexport-dedup.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
// exact-check
|
||||
|
||||
const EXPECTED = [
|
||||
{
|
||||
'query': 'Subscriber',
|
||||
'others': [
|
||||
{ 'path': 'foo', 'name': 'Subscriber' },
|
||||
],
|
||||
},
|
||||
{
|
||||
'query': 'fmt Subscriber',
|
||||
'others': [
|
||||
{ 'path': 'foo::fmt', 'name': 'Subscriber' },
|
||||
],
|
||||
},
|
||||
{
|
||||
'query': 'AnotherOne',
|
||||
'others': [
|
||||
{ 'path': 'foo', 'name': 'AnotherOne' },
|
||||
],
|
||||
},
|
||||
];
|
12
tests/rustdoc-js/reexport-dedup.rs
Normal file
12
tests/rustdoc-js/reexport-dedup.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
// This test enforces that the (renamed) reexports are present in the search results.
|
||||
#![crate_name="foo"]
|
||||
|
||||
pub mod fmt {
|
||||
pub struct Subscriber;
|
||||
}
|
||||
mod foo {
|
||||
pub struct AnotherOne;
|
||||
}
|
||||
|
||||
pub use foo::AnotherOne;
|
||||
pub use fmt::Subscriber;
|
|
@ -1,4 +1,6 @@
|
|||
// This test enforces that the (renamed) reexports are present in the search results.
|
||||
// This is a DWIM case, since renaming the export probably means the intent is also different.
|
||||
// For the de-duplication case of exactly the same name, see reexport-dedup
|
||||
|
||||
pub mod fmt {
|
||||
pub struct Subscriber;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue