Skip to content

Commit 5b95be6

Browse files
authored
Rollup merge of #134231 - notriddle:notriddle/mismatched-path, r=GuillaumeGomez
rustdoc-search: fix mismatched path when parent re-exported twice
2 parents 6cf13b0 + 98318c5 commit 5b95be6

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

Diff for: src/librustdoc/html/render/search_index.rs

+8
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,14 @@ pub(crate) fn build_index(
423423
}
424424
Some(path)
425425
});
426+
} else if let Some(parent_idx) = item.parent_idx {
427+
let i = <isize as TryInto<usize>>::try_into(parent_idx).unwrap();
428+
item.path = {
429+
let p = &crate_paths[i].1;
430+
join_with_double_colon(&p[..p.len() - 1])
431+
};
432+
item.exact_path =
433+
crate_paths[i].2.as_ref().map(|xp| join_with_double_colon(&xp[..xp.len() - 1]));
426434
}
427435

428436
// Omit the parent path if it is same to that of the prior item.

Diff for: tests/rustdoc-js-std/osstring-to-string.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
const EXPECTED = {
55
'query': 'OsString -> String',
66
'others': [
7-
{ 'path': 'std::ffi::os_str::OsString', 'name': 'into_string' },
7+
{ 'path': 'std::ffi::OsString', 'name': 'into_string' },
88
]
99
};

Diff for: tests/rustdoc-js/reexport.js

+9
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,13 @@ const EXPECTED = [
1414
{ 'path': 'reexport', 'name': 'AnotherOne' },
1515
],
1616
},
17+
{
18+
'query': 'fn:Equivalent::equivalent',
19+
'others': [
20+
// These results must never contain `reexport::equivalent::NotEquivalent`,
21+
// since that path does not exist.
22+
{ 'path': 'equivalent::Equivalent', 'name': 'equivalent' },
23+
{ 'path': 'reexport::NotEquivalent', 'name': 'equivalent' },
24+
],
25+
},
1726
];

Diff for: tests/rustdoc-js/reexport.rs

+9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
// This is a DWIM case, since renaming the export probably means the intent is also different.
33
// For the de-duplication case of exactly the same name, see reexport-dedup
44

5+
//@ aux-crate:equivalent=equivalent.rs
6+
//@ compile-flags: --extern equivalent
7+
//@ aux-build:equivalent.rs
8+
//@ build-aux-docs
9+
#[doc(inline)]
10+
pub extern crate equivalent;
11+
#[doc(inline)]
12+
pub use equivalent::Equivalent as NotEquivalent;
13+
514
pub mod fmt {
615
pub struct Subscriber;
716
}

0 commit comments

Comments
 (0)