Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions src/librustdoc/clean/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,17 +211,7 @@ pub(crate) fn load_attrs<'hir>(cx: &DocContext<'hir>, did: DefId) -> &'hir [hir:
}

pub(crate) fn item_relative_path(tcx: TyCtxt<'_>, def_id: DefId) -> Vec<Symbol> {
tcx.def_path(def_id)
.data
.into_iter()
.filter_map(|elem| {
// extern blocks (and a few others things) have an empty name.
match elem.data.get_opt_name() {
Some(s) if !s.is_empty() => Some(s),
_ => None,
}
})
.collect()
tcx.def_path(def_id).data.into_iter().filter_map(|elem| elem.data.get_opt_name()).collect()
}

/// Record an external fully qualified name in the external_paths cache.
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/formats/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ impl DocFolder for CacheBuilder<'_, '_> {

// Keep track of the fully qualified path for this item.
let pushed = match item.name {
Some(n) if !n.is_empty() => {
Some(n) => {
self.cache.stack.push(n);
true
}
Expand Down
62 changes: 36 additions & 26 deletions src/librustdoc/html/render/sidebar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -731,20 +731,20 @@ fn get_methods<'a>(
) -> Vec<Link<'a>> {
i.items
.iter()
.filter_map(|item| match item.name {
Some(ref name) if !name.is_empty() && item.is_method() => {
if !for_deref || super::should_render_item(item, deref_mut, tcx) {
Some(Link::new(
get_next_url(used_links, format!("{typ}.{name}", typ = ItemType::Method)),
name.as_str(),
))
} else {
None
}
.filter_map(|item| {
if let Some(ref name) = item.name
&& item.is_method()
&& (!for_deref || super::should_render_item(item, deref_mut, tcx))
{
Some(Link::new(
get_next_url(used_links, format!("{typ}.{name}", typ = ItemType::Method)),
name.as_str(),
))
} else {
None
}
_ => None,
})
.collect::<Vec<_>>()
.collect()
}

fn get_associated_constants<'a>(
Expand All @@ -753,14 +753,19 @@ fn get_associated_constants<'a>(
) -> Vec<Link<'a>> {
i.items
.iter()
.filter_map(|item| match item.name {
Some(ref name) if !name.is_empty() && item.is_associated_const() => Some(Link::new(
get_next_url(used_links, format!("{typ}.{name}", typ = ItemType::AssocConst)),
name.as_str(),
)),
_ => None,
.filter_map(|item| {
if let Some(ref name) = item.name
&& item.is_associated_const()
{
Some(Link::new(
get_next_url(used_links, format!("{typ}.{name}", typ = ItemType::AssocConst)),
name.as_str(),
))
} else {
None
}
})
.collect::<Vec<_>>()
.collect()
}

fn get_associated_types<'a>(
Expand All @@ -769,12 +774,17 @@ fn get_associated_types<'a>(
) -> Vec<Link<'a>> {
i.items
.iter()
.filter_map(|item| match item.name {
Some(ref name) if !name.is_empty() && item.is_associated_type() => Some(Link::new(
get_next_url(used_links, format!("{typ}.{name}", typ = ItemType::AssocType)),
name.as_str(),
)),
_ => None,
.filter_map(|item| {
if let Some(ref name) = item.name
&& item.is_associated_type()
{
Some(Link::new(
get_next_url(used_links, format!("{typ}.{name}", typ = ItemType::AssocType)),
name.as_str(),
))
} else {
None
}
})
.collect::<Vec<_>>()
.collect()
}
Loading