diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-04-19 21:07:24 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-04-19 21:07:24 +0200 |
| commit | e0437ec364017b11b5e63d1c09e3204029d8b497 (patch) | |
| tree | 34950a70b04fa2bc525c95a9c03b32dfd5b551ee | |
| parent | ae4b6d6c65c32d41d8017b4e3765a8a1871e8519 (diff) | |
| download | rust-e0437ec364017b11b5e63d1c09e3204029d8b497.tar.gz rust-e0437ec364017b11b5e63d1c09e3204029d8b497.zip | |
Fix error when an intra doc link is trying to resolve an empty associated item
| -rw-r--r-- | src/librustdoc/passes/collect_intra_doc_links.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 297597b3dea..36f5889dcf4 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -59,7 +59,12 @@ fn filter_assoc_items_by_name_and_namespace( ident: Ident, ns: Namespace, ) -> impl Iterator<Item = &ty::AssocItem> { - tcx.associated_items(assoc_items_of).filter_by_name_unhygienic(ident.name).filter(move |item| { + 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| { item.namespace() == ns && tcx.hygienic_eq(ident, item.ident(tcx), assoc_items_of) }) } |
