From 85d2d843c3cff20beb242a0d1726630ad10b5ff9 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 22 May 2025 13:25:45 +1000 Subject: [PATCH 1/2] Remove `is_empty` check in `filter_assoc_items_by_name_and_namespace`. It was added in #140052, but the subsequent changes in #140252 means it is no longer necessary. (Indeed, `Ident`s cannot be empty any more.) --- src/librustdoc/passes/collect_intra_doc_links.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index f3e2138d1a575..37628f166002d 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 { - let iter: Box> = 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) }) } From c309065ece12632a522676c794e0befbceb213f5 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 22 May 2025 13:31:19 +1000 Subject: [PATCH 2/2] Remove `is_empty` check in `Ident::is_numeric`. `Ident`s can no longer be empty, so the test always succeeds. --- compiler/rustc_span/src/symbol.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index fbe3b4ca6f5f6..dc77eb52b2e60 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()) } }