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 @@ pub fn filter_assoc_items(
items
.iter()
.map(|i| {
#[allow(deprecated)]
match i {
hir::AssocItem::Function(i) => ast::AssocItem::Fn(i.source_old(db).value),
hir::AssocItem::TypeAlias(i) => ast::AssocItem::TypeAlias(i.source_old(db).value),
hir::AssocItem::Const(i) => ast::AssocItem::Const(i.source_old(db).value),
}
// Note: This throws away items with no source.
.filter_map(|i| {
let item = match i {
hir::AssocItem::Function(i) => ast::AssocItem::Fn(i.source(db)?.value),
hir::AssocItem::TypeAlias(i) => ast::AssocItem::TypeAlias(i.source(db)?.value),
hir::AssocItem::Const(i) => ast::AssocItem::Const(i.source(db)?.value),
};
Some(item)
})
.filter(has_def_name)
.filter(|it| match it {