aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src/completions/keyword.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_completion/src/completions/keyword.rs')
-rw-r--r--crates/ide_completion/src/completions/keyword.rs24
1 files changed, 13 insertions, 11 deletions
diff --git a/crates/ide_completion/src/completions/keyword.rs b/crates/ide_completion/src/completions/keyword.rs
index 9754122a0..af67f9315 100644
--- a/crates/ide_completion/src/completions/keyword.rs
+++ b/crates/ide_completion/src/completions/keyword.rs
@@ -37,17 +37,6 @@ pub(crate) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionC
37 } 37 }
38 }; 38 };
39 } 39 }
40
41 // Suggest .await syntax for types that implement Future trait
42 if let Some(receiver) = ctx.dot_receiver() {
43 if let Some(ty) = ctx.sema.type_of_expr(receiver) {
44 if ty.impls_future(ctx.db) {
45 let mut item = kw_completion("await");
46 item.detail("expr.await");
47 item.add_to(acc);
48 }
49 };
50 }
51} 40}
52 41
53pub(crate) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionContext) { 42pub(crate) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionContext) {
@@ -59,6 +48,19 @@ pub(crate) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte
59 cov_mark::hit!(no_keyword_completion_in_record_lit); 48 cov_mark::hit!(no_keyword_completion_in_record_lit);
60 return; 49 return;
61 } 50 }
51
52 // Suggest .await syntax for types that implement Future trait
53 if let Some(receiver) = ctx.dot_receiver() {
54 if let Some(ty) = ctx.sema.type_of_expr(receiver) {
55 if ty.impls_future(ctx.db) {
56 let mut item =
57 CompletionItem::new(CompletionKind::Keyword, ctx.source_range(), "await");
58 item.kind(CompletionItemKind::Keyword).detail("expr.await");
59 item.add_to(acc);
60 }
61 };
62 }
63
62 let mut add_keyword = |kw, snippet| add_keyword(ctx, acc, kw, snippet); 64 let mut add_keyword = |kw, snippet| add_keyword(ctx, acc, kw, snippet);
63 65
64 let expects_assoc_item = ctx.expects_assoc_item(); 66 let expects_assoc_item = ctx.expects_assoc_item();