aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src/completions
diff options
context:
space:
mode:
authorrdambrosio <[email protected]>2021-06-18 17:42:13 +0100
committerrdambrosio <[email protected]>2021-06-18 17:42:13 +0100
commitb3e5c648e0def7a359a75b2b5023c18aceda83d3 (patch)
tree47717f12bc2d7708e81a907ee651867a3b957a56 /crates/ide_completion/src/completions
parent23e3354ae04f586f218162242b18ffe637cee3af (diff)
Lift ast -> hir out of the for_each
Diffstat (limited to 'crates/ide_completion/src/completions')
-rw-r--r--crates/ide_completion/src/completions/trait_impl.rs38
1 files changed, 18 insertions, 20 deletions
diff --git a/crates/ide_completion/src/completions/trait_impl.rs b/crates/ide_completion/src/completions/trait_impl.rs
index 37622aaad..65f0f3843 100644
--- a/crates/ide_completion/src/completions/trait_impl.rs
+++ b/crates/ide_completion/src/completions/trait_impl.rs
@@ -52,28 +52,26 @@ enum ImplCompletionKind {
52 52
53pub(crate) fn complete_trait_impl(acc: &mut Completions, ctx: &CompletionContext) { 53pub(crate) fn complete_trait_impl(acc: &mut Completions, ctx: &CompletionContext) {
54 if let Some((kind, trigger, impl_def)) = completion_match(ctx.token.clone()) { 54 if let Some((kind, trigger, impl_def)) = completion_match(ctx.token.clone()) {
55 get_missing_assoc_items(&ctx.sema, &impl_def).into_iter().for_each(|item| match item { 55 if let Some(hir_impl) = ctx.sema.to_def(&impl_def) {
56 hir::AssocItem::Function(fn_item) 56 get_missing_assoc_items(&ctx.sema, &impl_def).into_iter().for_each(|item| match item {
57 if kind == ImplCompletionKind::All || kind == ImplCompletionKind::Fn => 57 hir::AssocItem::Function(fn_item)
58 { 58 if kind == ImplCompletionKind::All || kind == ImplCompletionKind::Fn =>
59 if let Some(impl_def) = ctx.sema.to_def(&impl_def) { 59 {
60 add_function_impl(&trigger, acc, ctx, fn_item, impl_def) 60 add_function_impl(&trigger, acc, ctx, fn_item, hir_impl)
61 } 61 }
62 } 62 hir::AssocItem::TypeAlias(type_item)
63 hir::AssocItem::TypeAlias(type_item) 63 if kind == ImplCompletionKind::All || kind == ImplCompletionKind::TypeAlias =>
64 if kind == ImplCompletionKind::All || kind == ImplCompletionKind::TypeAlias => 64 {
65 { 65 add_type_alias_impl(&trigger, acc, ctx, type_item)
66 add_type_alias_impl(&trigger, acc, ctx, type_item)
67 }
68 hir::AssocItem::Const(const_item)
69 if kind == ImplCompletionKind::All || kind == ImplCompletionKind::Const =>
70 {
71 if let Some(impl_def) = ctx.sema.to_def(&impl_def) {
72 add_const_impl(&trigger, acc, ctx, const_item, impl_def)
73 } 66 }
74 } 67 hir::AssocItem::Const(const_item)
75 _ => {} 68 if kind == ImplCompletionKind::All || kind == ImplCompletionKind::Const =>
76 }); 69 {
70 add_const_impl(&trigger, acc, ctx, const_item, hir_impl)
71 }
72 _ => {}
73 });
74 }
77 } 75 }
78} 76}
79 77