about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-05-22 16:04:13 +0200
committerGitHub <noreply@github.com>2025-05-22 16:04:13 +0200
commit74b980d3a45a84adc5ceac192232356aa3502fc0 (patch)
tree74d6a0f9295833f8f88ea8f1453413044f7a159c
parent5cab70ed7fb444775a4ad7e965cd456592e3ffb7 (diff)
parentc309065ece12632a522676c794e0befbceb213f5 (diff)
downloadrust-74b980d3a45a84adc5ceac192232356aa3502fc0.tar.gz
rust-74b980d3a45a84adc5ceac192232356aa3502fc0.zip
Rollup merge of #141377 - nnethercote:rm-unnecessary-is_empty-checks, r=GuillaumeGomez
Remove unnecessary `is_empty` checks

Part of #137978.

r? `@GuillaumeGomez`
-rw-r--r--compiler/rustc_span/src/symbol.rs2
-rw-r--r--src/librustdoc/passes/collect_intra_doc_links.rs7
2 files changed, 2 insertions, 7 deletions
diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs
index fbe3b4ca6f5..dc77eb52b2e 100644
--- a/compiler/rustc_span/src/symbol.rs
+++ b/compiler/rustc_span/src/symbol.rs
@@ -2823,7 +2823,7 @@ impl Ident {
     /// Whether this would be the identifier for a tuple field like `self.0`, as
     /// opposed to a named field like `self.thing`.
     pub fn is_numeric(self) -> bool {
-        !self.name.is_empty() && self.as_str().bytes().all(|b| b.is_ascii_digit())
+        self.as_str().bytes().all(|b| b.is_ascii_digit())
     }
 }
 
diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs
index f3e2138d1a5..37628f16600 100644
--- a/src/librustdoc/passes/collect_intra_doc_links.rs
+++ b/src/librustdoc/passes/collect_intra_doc_links.rs
@@ -59,12 +59,7 @@ fn filter_assoc_items_by_name_and_namespace(
     ident: Ident,
     ns: Namespace,
 ) -> impl Iterator<Item = &ty::AssocItem> {
-    let iter: Box<dyn Iterator<Item = &ty::AssocItem>> = if !ident.name.is_empty() {
-        Box::new(tcx.associated_items(assoc_items_of).filter_by_name_unhygienic(ident.name))
-    } else {
-        Box::new([].iter())
-    };
-    iter.filter(move |item| {
+    tcx.associated_items(assoc_items_of).filter_by_name_unhygienic(ident.name).filter(move |item| {
         item.namespace() == ns && tcx.hygienic_eq(ident, item.ident(tcx), assoc_items_of)
     })
 }