Handle missing source in filter_assoc_items

This commit is contained in:
Nick Spain 2021-01-01 16:49:44 +11:00
parent 1c009c9f12
commit 0a9b735240

View File

@ -98,13 +98,14 @@ fn has_def_name(item: &ast::AssocItem) -> bool {
items items
.iter() .iter()
.map(|i| { // Note: This throws away items with no source.
#[allow(deprecated)] .filter_map(|i| {
match i { let item = match i {
hir::AssocItem::Function(i) => ast::AssocItem::Fn(i.source_old(db).value), hir::AssocItem::Function(i) => ast::AssocItem::Fn(i.source(db)?.value),
hir::AssocItem::TypeAlias(i) => ast::AssocItem::TypeAlias(i.source_old(db).value), hir::AssocItem::TypeAlias(i) => ast::AssocItem::TypeAlias(i.source(db)?.value),
hir::AssocItem::Const(i) => ast::AssocItem::Const(i.source_old(db).value), hir::AssocItem::Const(i) => ast::AssocItem::Const(i.source(db)?.value),
} };
Some(item)
}) })
.filter(has_def_name) .filter(has_def_name)
.filter(|it| match it { .filter(|it| match it {