Skip to content

Commit b3e5c64

Browse files
committed
Lift ast -> hir out of the for_each
1 parent 23e3354 commit b3e5c64

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

crates/ide_completion/src/completions/trait_impl.rs

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,28 +52,26 @@ enum ImplCompletionKind {
5252

5353
pub(crate) fn complete_trait_impl(acc: &mut Completions, ctx: &CompletionContext) {
5454
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 {
56-
hir::AssocItem::Function(fn_item)
57-
if kind == ImplCompletionKind::All || kind == ImplCompletionKind::Fn =>
58-
{
59-
if let Some(impl_def) = ctx.sema.to_def(&impl_def) {
60-
add_function_impl(&trigger, acc, ctx, fn_item, impl_def)
55+
if let Some(hir_impl) = ctx.sema.to_def(&impl_def) {
56+
get_missing_assoc_items(&ctx.sema, &impl_def).into_iter().for_each(|item| match item {
57+
hir::AssocItem::Function(fn_item)
58+
if kind == ImplCompletionKind::All || kind == ImplCompletionKind::Fn =>
59+
{
60+
add_function_impl(&trigger, acc, ctx, fn_item, hir_impl)
6161
}
62-
}
63-
hir::AssocItem::TypeAlias(type_item)
64-
if kind == ImplCompletionKind::All || kind == ImplCompletionKind::TypeAlias =>
65-
{
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)
62+
hir::AssocItem::TypeAlias(type_item)
63+
if kind == ImplCompletionKind::All || kind == ImplCompletionKind::TypeAlias =>
64+
{
65+
add_type_alias_impl(&trigger, acc, ctx, type_item)
7366
}
74-
}
75-
_ => {}
76-
});
67+
hir::AssocItem::Const(const_item)
68+
if kind == ImplCompletionKind::All || kind == ImplCompletionKind::Const =>
69+
{
70+
add_const_impl(&trigger, acc, ctx, const_item, hir_impl)
71+
}
72+
_ => {}
73+
});
74+
}
7775
}
7876
}
7977

0 commit comments

Comments
 (0)