Skip to content

Commit 279dee5

Browse files
Fix reexports missing from the search index
1 parent 12d3f10 commit 279dee5

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

src/librustdoc/formats/cache.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,16 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
248248
}
249249

250250
// Index this method for searching later on.
251-
if let Some(ref s) = item.name {
251+
if let Some(ref s) = item.name.or_else(|| {
252+
if item.is_stripped() {
253+
None
254+
} else if let clean::ImportItem(ref i) = *item.kind &&
255+
let clean::ImportKind::Simple(s) = i.kind {
256+
Some(s)
257+
} else {
258+
None
259+
}
260+
}) {
252261
let (parent, is_inherent_impl_item) = match *item.kind {
253262
clean::StrippedItem(..) => ((None, None), false),
254263
clean::AssocConstItem(..) | clean::AssocTypeItem(..)

src/librustdoc/html/render/mod.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -2542,7 +2542,16 @@ fn sidebar_module(buf: &mut Buffer, items: &[clean::Item]) {
25422542

25432543
let item_sections_in_use: FxHashSet<_> = items
25442544
.iter()
2545-
.filter(|it| !it.is_stripped() && it.name.is_some())
2545+
.filter(|it| {
2546+
!it.is_stripped()
2547+
&& it
2548+
.name
2549+
.or_else(|| {
2550+
if let clean::ImportItem(ref i) = *it.kind &&
2551+
let clean::ImportKind::Simple(s) = i.kind { Some(s) } else { None }
2552+
})
2553+
.is_some()
2554+
})
25462555
.map(|it| item_ty_to_section(it.type_()))
25472556
.collect();
25482557
for &sec in ItemSection::ALL.iter().filter(|sec| item_sections_in_use.contains(sec)) {

src/librustdoc/html/render/print_item.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
346346
w.write_str(ITEM_TABLE_ROW_OPEN);
347347
write!(
348348
w,
349-
"<div class=\"item-left {stab}{add}import-item\">\
349+
"<div class=\"item-left {stab}{add}import-item\"{id}>\
350350
<code>{vis}{imp}</code>\
351351
</div>\
352352
<div class=\"item-right docblock-short\">{stab_tags}</div>",
@@ -355,6 +355,11 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
355355
vis = myitem.visibility.print_with_space(myitem.item_id, cx),
356356
imp = import.print(cx),
357357
stab_tags = stab_tags.unwrap_or_default(),
358+
id = match import.kind {
359+
clean::ImportKind::Simple(s) =>
360+
format!(" id=\"{}\"", cx.derive_id(format!("reexport.{}", s))),
361+
clean::ImportKind::Glob => String::new(),
362+
},
358363
);
359364
w.write_str(ITEM_TABLE_ROW_CLOSE);
360365
}

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

+3
Original file line numberDiff line numberDiff line change
@@ -1507,6 +1507,9 @@ window.initSearch = rawSearchIndex => {
15071507
displayPath = path + "::";
15081508
href = window.rootPath + path.replace(/::/g, "/") + "/" +
15091509
name + "/index.html";
1510+
} else if (type === "import") {
1511+
displayPath = item.path + "::";
1512+
href = window.rootPath + item.path.replace(/::/g, "/") + "/index.html#reexport." + name;
15101513
} else if (type === "primitive" || type === "keyword") {
15111514
displayPath = "";
15121515
href = window.rootPath + path.replace(/::/g, "/") +

0 commit comments

Comments
 (0)