Skip to content
/ rust Public
forked from rust-lang/rust

Commit e0437ec

Browse files
Fix error when an intra doc link is trying to resolve an empty associated item
1 parent ae4b6d6 commit e0437ec

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/librustdoc/passes/collect_intra_doc_links.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ fn filter_assoc_items_by_name_and_namespace(
5959
ident: Ident,
6060
ns: Namespace,
6161
) -> impl Iterator<Item = &ty::AssocItem> {
62-
tcx.associated_items(assoc_items_of).filter_by_name_unhygienic(ident.name).filter(move |item| {
62+
let iter: Box<dyn Iterator<Item = &ty::AssocItem>> = if !ident.name.is_empty() {
63+
Box::new(tcx.associated_items(assoc_items_of).filter_by_name_unhygienic(ident.name))
64+
} else {
65+
Box::new([].iter())
66+
};
67+
iter.filter(move |item| {
6368
item.namespace() == ns && tcx.hygienic_eq(ident, item.ident(tcx), assoc_items_of)
6469
})
6570
}

0 commit comments

Comments
 (0)