From 94244a7a1179ec827546c2af6676f6b7bcda563c Mon Sep 17 00:00:00 2001 From: Yunfei Date: Mon, 29 Jul 2024 15:55:21 +0800 Subject: [PATCH] feat(ide-completion): explictly show `async` keyword on `impl trait` --- .../ide-completion/src/completions/item_list/trait_impl.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/ide-completion/src/completions/item_list/trait_impl.rs b/crates/ide-completion/src/completions/item_list/trait_impl.rs index f9dc62562f..4a1f985b30 100644 --- a/crates/ide-completion/src/completions/item_list/trait_impl.rs +++ b/crates/ide-completion/src/completions/item_list/trait_impl.rs @@ -180,8 +180,10 @@ fn add_function_impl( ) { let fn_name = func.name(ctx.db); + let is_async = func.is_async(ctx.db); let label = format_smolstr!( - "fn {}({})", + "{}fn {}({})", + if is_async { "async " } else { "" }, fn_name.display(ctx.db), if func.assoc_fn_params(ctx.db).is_empty() { "" } else { ".." } ); @@ -193,7 +195,7 @@ fn add_function_impl( }); let mut item = CompletionItem::new(completion_kind, replacement_range, label); - item.lookup_by(format!("fn {}", fn_name.display(ctx.db))) + item.lookup_by(format!("{}fn {}", if is_async { "async "} else { "" },fn_name.display(ctx.db))) .set_documentation(func.docs(ctx.db)) .set_relevance(CompletionRelevance { is_item_from_trait: true, ..Default::default() });