aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/completion/presentation.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide/src/completion/presentation.rs')
-rw-r--r--crates/ide/src/completion/presentation.rs17
1 files changed, 6 insertions, 11 deletions
diff --git a/crates/ide/src/completion/presentation.rs b/crates/ide/src/completion/presentation.rs
index 0c29d0be2..059fdfdc9 100644
--- a/crates/ide/src/completion/presentation.rs
+++ b/crates/ide/src/completion/presentation.rs
@@ -192,20 +192,15 @@ impl Completions {
192 local_name: Option<String>, 192 local_name: Option<String>,
193 ) { 193 ) {
194 fn add_arg(arg: &str, ty: &Type, ctx: &CompletionContext) -> String { 194 fn add_arg(arg: &str, ty: &Type, ctx: &CompletionContext) -> String {
195 let mut prefix = "";
196 if let Some(derefed_ty) = ty.remove_ref() { 195 if let Some(derefed_ty) = ty.remove_ref() {
197 ctx.scope.process_all_names(&mut |name, scope| { 196 for (name, local) in ctx.locals.iter() {
198 if prefix != "" { 197 if name == arg && local.can_unify(derefed_ty.clone(), ctx.db) {
199 return; 198 return (if ty.is_mutable_reference() { "&mut " } else { "&" }).to_string()
199 + &arg.to_string();
200 } 200 }
201 if let ScopeDef::Local(local) = scope { 201 }
202 if name.to_string() == arg && local.can_unify(derefed_ty.clone(), ctx.db) {
203 prefix = if ty.is_mutable_reference() { "&mut " } else { "&" };
204 }
205 }
206 });
207 } 202 }
208 prefix.to_string() + arg 203 arg.to_string()
209 }; 204 };
210 let name = local_name.unwrap_or_else(|| func.name(ctx.db).to_string()); 205 let name = local_name.unwrap_or_else(|| func.name(ctx.db).to_string());
211 let ast_node = func.source(ctx.db).value; 206 let ast_node = func.source(ctx.db).value;