From 0a9b73524059cf29a19f9333c7753c11e268ef51 Mon Sep 17 00:00:00 2001 From: Nick Spain Date: Fri, 1 Jan 2021 16:49:44 +1100 Subject: Handle missing source in filter_assoc_items --- crates/assists/src/utils.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'crates') diff --git a/crates/assists/src/utils.rs b/crates/assists/src/utils.rs index d15e5a24b..7c159b5ba 100644 --- a/crates/assists/src/utils.rs +++ b/crates/assists/src/utils.rs @@ -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 { -- cgit v1.2.3