Rollup merge of #138917 - nnethercote:rustdoc-remove-useless, r=GuillaumeGomez
rustdoc: remove useless `Symbol::is_empty` checks. There are a number of `is_empty` checks that can never fail. This commit removes them, in support of #137978. r? `@GuillaumeGomez`
This commit is contained in:
commit
04cbe2816d
3 changed files with 38 additions and 38 deletions
|
@ -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> {
|
pub(crate) fn item_relative_path(tcx: TyCtxt<'_>, def_id: DefId) -> Vec<Symbol> {
|
||||||
tcx.def_path(def_id)
|
tcx.def_path(def_id).data.into_iter().filter_map(|elem| elem.data.get_opt_name()).collect()
|
||||||
.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()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Record an external fully qualified name in the external_paths cache.
|
/// Record an external fully qualified name in the external_paths cache.
|
||||||
|
|
|
@ -288,7 +288,7 @@ impl DocFolder for CacheBuilder<'_, '_> {
|
||||||
|
|
||||||
// Keep track of the fully qualified path for this item.
|
// Keep track of the fully qualified path for this item.
|
||||||
let pushed = match item.name {
|
let pushed = match item.name {
|
||||||
Some(n) if !n.is_empty() => {
|
Some(n) => {
|
||||||
self.cache.stack.push(n);
|
self.cache.stack.push(n);
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
|
@ -734,9 +734,11 @@ fn get_methods<'a>(
|
||||||
) -> Vec<Link<'a>> {
|
) -> Vec<Link<'a>> {
|
||||||
i.items
|
i.items
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|item| match item.name {
|
.filter_map(|item| {
|
||||||
Some(ref name) if !name.is_empty() && item.is_method() => {
|
if let Some(ref name) = item.name
|
||||||
if !for_deref || super::should_render_item(item, deref_mut, tcx) {
|
&& item.is_method()
|
||||||
|
&& (!for_deref || super::should_render_item(item, deref_mut, tcx))
|
||||||
|
{
|
||||||
Some(Link::new(
|
Some(Link::new(
|
||||||
get_next_url(used_links, format!("{typ}.{name}", typ = ItemType::Method)),
|
get_next_url(used_links, format!("{typ}.{name}", typ = ItemType::Method)),
|
||||||
name.as_str(),
|
name.as_str(),
|
||||||
|
@ -744,10 +746,8 @@ fn get_methods<'a>(
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
|
||||||
_ => None,
|
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_associated_constants<'a>(
|
fn get_associated_constants<'a>(
|
||||||
|
@ -756,14 +756,19 @@ fn get_associated_constants<'a>(
|
||||||
) -> Vec<Link<'a>> {
|
) -> Vec<Link<'a>> {
|
||||||
i.items
|
i.items
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|item| match item.name {
|
.filter_map(|item| {
|
||||||
Some(ref name) if !name.is_empty() && item.is_associated_const() => Some(Link::new(
|
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)),
|
get_next_url(used_links, format!("{typ}.{name}", typ = ItemType::AssocConst)),
|
||||||
name.as_str(),
|
name.as_str(),
|
||||||
)),
|
))
|
||||||
_ => None,
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_associated_types<'a>(
|
fn get_associated_types<'a>(
|
||||||
|
@ -772,12 +777,17 @@ fn get_associated_types<'a>(
|
||||||
) -> Vec<Link<'a>> {
|
) -> Vec<Link<'a>> {
|
||||||
i.items
|
i.items
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|item| match item.name {
|
.filter_map(|item| {
|
||||||
Some(ref name) if !name.is_empty() && item.is_associated_type() => Some(Link::new(
|
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)),
|
get_next_url(used_links, format!("{typ}.{name}", typ = ItemType::AssocType)),
|
||||||
name.as_str(),
|
name.as_str(),
|
||||||
)),
|
))
|
||||||
_ => None,
|
} else {
|
||||||
})
|
None
|
||||||
.collect::<Vec<_>>()
|
}
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue