aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src/render
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_completion/src/render')
-rw-r--r--crates/ide_completion/src/render/function.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/crates/ide_completion/src/render/function.rs b/crates/ide_completion/src/render/function.rs
index f4dabe3d1..47e26a5d8 100644
--- a/crates/ide_completion/src/render/function.rs
+++ b/crates/ide_completion/src/render/function.rs
@@ -5,7 +5,7 @@ use ide_db::SymbolKind;
5use syntax::ast::Fn; 5use syntax::ast::Fn;
6 6
7use crate::{ 7use crate::{
8 item::{CompletionItem, CompletionItemKind, CompletionKind, ImportEdit}, 8 item::{CompletionItem, CompletionItemKind, CompletionKind, CompletionRelevance, ImportEdit},
9 render::{builder_ext::Params, RenderContext}, 9 render::{builder_ext::Params, RenderContext},
10}; 10};
11 11
@@ -55,6 +55,21 @@ impl<'a> FunctionRender<'a> {
55 .add_call_parens(self.ctx.completion, self.name, params) 55 .add_call_parens(self.ctx.completion, self.name, params)
56 .add_import(import_to_add); 56 .add_import(import_to_add);
57 57
58 let mut relevance = CompletionRelevance::default();
59 if let Some(expected_type) = &self.ctx.completion.expected_type {
60 let ret_ty = self.func.ret_type(self.ctx.db());
61
62 // We don't ever consider a function which returns unit type to be an
63 // exact type match, since nearly always this is not meaningful to the
64 // user.
65 relevance.exact_type_match = &ret_ty == expected_type && !ret_ty.is_unit();
66 }
67 if let Some(expected_name) = &self.ctx.completion.expected_name {
68 relevance.exact_name_match =
69 expected_name == &self.func.name(self.ctx.db()).to_string();
70 }
71 item.set_relevance(relevance);
72
58 item.build() 73 item.build()
59 } 74 }
60 75