Skip to content

Commit 41db4ec

Browse files
Create Item::full_name method to include name of reexports
1 parent 4f372b1 commit 41db4ec

File tree

3 files changed

+12
-20
lines changed

3 files changed

+12
-20
lines changed

src/librustdoc/clean/types.rs

+10
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,16 @@ pub(crate) fn rustc_span(def_id: DefId, tcx: TyCtxt<'_>) -> Span {
404404
}
405405

406406
impl Item {
407+
/// If `item.name` is `None` and `self` is an `ImportItem`, it'll look for it.
408+
///
409+
/// It's especially usefully to get the name of `pub use x;` or `pub use x as y;`.
410+
pub(crate) fn full_name(&self) -> Option<Symbol> {
411+
self.name.or_else(|| {
412+
if let ImportItem(ref i) = *self.kind &&
413+
let ImportKind::Simple(s) = i.kind { Some(s) } else { None }
414+
})
415+
}
416+
407417
pub(crate) fn stability<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Option<Stability> {
408418
self.item_id.as_def_id().and_then(|did| tcx.lookup_stability(did))
409419
}

src/librustdoc/formats/cache.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -248,16 +248,7 @@ 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.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-
}) {
251+
if let Some(ref s) = item.full_name() && !item.is_stripped() {
261252
let (parent, is_inherent_impl_item) = match *item.kind {
262253
clean::StrippedItem(..) => ((None, None), false),
263254
clean::AssocConstItem(..) | clean::AssocTypeItem(..)

src/librustdoc/html/render/mod.rs

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

25432543
let item_sections_in_use: FxHashSet<_> = items
25442544
.iter()
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-
})
2545+
.filter(|it| !it.is_stripped() && it.full_name().is_some())
25552546
.map(|it| item_ty_to_section(it.type_()))
25562547
.collect();
25572548
for &sec in ItemSection::ALL.iter().filter(|sec| item_sections_in_use.contains(sec)) {

0 commit comments

Comments
 (0)