diff --git a/src/librustdoc/html/render/search_index.rs b/src/librustdoc/html/render/search_index.rs
index cfb62c3ca1640..134438efa5ec2 100644
--- a/src/librustdoc/html/render/search_index.rs
+++ b/src/librustdoc/html/render/search_index.rs
@@ -423,6 +423,14 @@ pub(crate) fn build_index(
}
Some(path)
});
+ } else if let Some(parent_idx) = item.parent_idx {
+ let i = >::try_into(parent_idx).unwrap();
+ item.path = {
+ let p = &crate_paths[i].1;
+ join_with_double_colon(&p[..p.len() - 1])
+ };
+ item.exact_path =
+ crate_paths[i].2.as_ref().map(|xp| join_with_double_colon(&xp[..xp.len() - 1]));
}
// Omit the parent path if it is same to that of the prior item.
diff --git a/tests/rustdoc-js-std/osstring-to-string.js b/tests/rustdoc-js-std/osstring-to-string.js
index 3fdc0b9f24a3c..17bb602a502af 100644
--- a/tests/rustdoc-js-std/osstring-to-string.js
+++ b/tests/rustdoc-js-std/osstring-to-string.js
@@ -4,6 +4,6 @@
const EXPECTED = {
'query': 'OsString -> String',
'others': [
- { 'path': 'std::ffi::os_str::OsString', 'name': 'into_string' },
+ { 'path': 'std::ffi::OsString', 'name': 'into_string' },
]
};
diff --git a/tests/rustdoc-js/reexport.js b/tests/rustdoc-js/reexport.js
index 9021cc2e90fe0..0b9415dd3e480 100644
--- a/tests/rustdoc-js/reexport.js
+++ b/tests/rustdoc-js/reexport.js
@@ -14,4 +14,13 @@ const EXPECTED = [
{ 'path': 'reexport', 'name': 'AnotherOne' },
],
},
+ {
+ 'query': 'fn:Equivalent::equivalent',
+ 'others': [
+ // These results must never contain `reexport::equivalent::NotEquivalent`,
+ // since that path does not exist.
+ { 'path': 'equivalent::Equivalent', 'name': 'equivalent' },
+ { 'path': 'reexport::NotEquivalent', 'name': 'equivalent' },
+ ],
+ },
];
diff --git a/tests/rustdoc-js/reexport.rs b/tests/rustdoc-js/reexport.rs
index 0b3718cd9a3e8..ecbbeca5ea89d 100644
--- a/tests/rustdoc-js/reexport.rs
+++ b/tests/rustdoc-js/reexport.rs
@@ -2,6 +2,15 @@
// 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
+//@ aux-crate:equivalent=equivalent.rs
+//@ compile-flags: --extern equivalent
+//@ aux-build:equivalent.rs
+//@ build-aux-docs
+#[doc(inline)]
+pub extern crate equivalent;
+#[doc(inline)]
+pub use equivalent::Equivalent as NotEquivalent;
+
pub mod fmt {
pub struct Subscriber;
}