aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_assists/src/add_missing_impl_members.rs11
1 files changed, 2 insertions, 9 deletions
diff --git a/crates/ra_assists/src/add_missing_impl_members.rs b/crates/ra_assists/src/add_missing_impl_members.rs
index f121dafb2..97af6362c 100644
--- a/crates/ra_assists/src/add_missing_impl_members.rs
+++ b/crates/ra_assists/src/add_missing_impl_members.rs
@@ -1,5 +1,3 @@
1use std::collections::HashSet;
2
3use crate::{Assist, AssistId, AssistCtx}; 1use crate::{Assist, AssistId, AssistCtx};
4 2
5use hir::Resolver; 3use hir::Resolver;
@@ -69,14 +67,9 @@ pub(crate) fn add_missing_impl_members(mut ctx: AssistCtx<impl HirDatabase>) ->
69 let trait_fns = trait_items.map(ImplItem::kind).filter_map(fn_def_opt).collect::<Vec<_>>(); 67 let trait_fns = trait_items.map(ImplItem::kind).filter_map(fn_def_opt).collect::<Vec<_>>();
70 let impl_fns = impl_items.map(ImplItem::kind).filter_map(fn_def_opt).collect::<Vec<_>>(); 68 let impl_fns = impl_items.map(ImplItem::kind).filter_map(fn_def_opt).collect::<Vec<_>>();
71 69
72 let trait_fn_names = trait_fns.iter().cloned().filter_map(def_name).collect::<HashSet<_>>();
73 let impl_fn_names = impl_fns.iter().cloned().filter_map(def_name).collect::<HashSet<_>>();
74
75 let missing_fn_names = trait_fn_names.difference(&impl_fn_names).collect::<HashSet<_>>();
76 let missing_fns: Vec<_> = trait_fns 70 let missing_fns: Vec<_> = trait_fns
77 .iter() 71 .into_iter()
78 .cloned() 72 .filter(|t| impl_fns.iter().all(|i| def_name(i) != def_name(t)))
79 .filter(|t| def_name(t).map(|n| missing_fn_names.contains(&n)).unwrap_or(false))
80 .collect(); 73 .collect();
81 if missing_fns.is_empty() { 74 if missing_fns.is_empty() {
82 return None; 75 return None;