From 371c5aec1c4ad18f37e96b4bf85c49563fc4a01d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 17 Jul 2020 10:57:49 +0200 Subject: call_info works with closures --- crates/ra_ide/src/call_info.rs | 20 +++++++++++++++++++- crates/ra_ide/src/inlay_hints.rs | 4 +++- 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'crates/ra_ide/src') diff --git a/crates/ra_ide/src/call_info.rs b/crates/ra_ide/src/call_info.rs index 35a8a0dc5..53d56a0a4 100644 --- a/crates/ra_ide/src/call_info.rs +++ b/crates/ra_ide/src/call_info.rs @@ -70,6 +70,7 @@ pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option (), } res.signature.push('('); @@ -93,7 +94,7 @@ pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option { + hir::CallableKind::Function(_) | hir::CallableKind::Closure => { let ret_type = callable.return_type(); if !ret_type.is_unit() { format_to!(res.signature, " -> {}", ret_type.display(db)); @@ -702,4 +703,21 @@ id! { "#]], ); } + + #[test] + fn call_info_for_lambdas() { + check( + r#" +struct S; +fn foo(s: S) -> i32 { 92 } +fn main() { + (|s| foo(s))(<|>) +} + "#, + expect![[r#" + (S) -> i32 + () + "#]], + ) + } } diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs index cec3b04e8..43a5e29b5 100644 --- a/crates/ra_ide/src/inlay_hints.rs +++ b/crates/ra_ide/src/inlay_hints.rs @@ -262,7 +262,9 @@ fn should_show_param_name_hint( let param_name = param_name.trim_start_matches('_'); let fn_name = match callable.kind() { hir::CallableKind::Function(it) => Some(it.name(sema.db).to_string()), - hir::CallableKind::TupleStruct(_) | hir::CallableKind::TupleEnumVariant(_) => None, + hir::CallableKind::TupleStruct(_) + | hir::CallableKind::TupleEnumVariant(_) + | hir::CallableKind::Closure => None, }; if param_name.is_empty() || Some(param_name) == fn_name.as_ref().map(|s| s.trim_start_matches('_')) -- cgit v1.2.3