aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide')
-rw-r--r--crates/ra_ide/src/call_info.rs35
-rw-r--r--crates/ra_ide/src/inlay_hints.rs4
2 files changed, 37 insertions, 2 deletions
diff --git a/crates/ra_ide/src/call_info.rs b/crates/ra_ide/src/call_info.rs
index 35a8a0dc5..14980afdd 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<Cal
70 variant.name(db) 70 variant.name(db)
71 ); 71 );
72 } 72 }
73 hir::CallableKind::Closure => (),
73 } 74 }
74 75
75 res.signature.push('('); 76 res.signature.push('(');
@@ -93,7 +94,7 @@ pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<Cal
93 res.signature.push(')'); 94 res.signature.push(')');
94 95
95 match callable.kind() { 96 match callable.kind() {
96 hir::CallableKind::Function(_) => { 97 hir::CallableKind::Function(_) | hir::CallableKind::Closure => {
97 let ret_type = callable.return_type(); 98 let ret_type = callable.return_type();
98 if !ret_type.is_unit() { 99 if !ret_type.is_unit() {
99 format_to!(res.signature, " -> {}", ret_type.display(db)); 100 format_to!(res.signature, " -> {}", ret_type.display(db));
@@ -702,4 +703,36 @@ id! {
702 "#]], 703 "#]],
703 ); 704 );
704 } 705 }
706
707 #[test]
708 fn call_info_for_lambdas() {
709 check(
710 r#"
711struct S;
712fn foo(s: S) -> i32 { 92 }
713fn main() {
714 (|s| foo(s))(<|>)
715}
716 "#,
717 expect![[r#"
718 (S) -> i32
719 (<S>)
720 "#]],
721 )
722 }
723
724 #[test]
725 fn call_info_for_fn_ptr() {
726 check(
727 r#"
728fn main(f: fn(i32, f64) -> char) {
729 f(0, <|>)
730}
731 "#,
732 expect![[r#"
733 (i32, f64) -> char
734 (i32, <f64>)
735 "#]],
736 )
737 }
705} 738}
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(
262 let param_name = param_name.trim_start_matches('_'); 262 let param_name = param_name.trim_start_matches('_');
263 let fn_name = match callable.kind() { 263 let fn_name = match callable.kind() {
264 hir::CallableKind::Function(it) => Some(it.name(sema.db).to_string()), 264 hir::CallableKind::Function(it) => Some(it.name(sema.db).to_string()),
265 hir::CallableKind::TupleStruct(_) | hir::CallableKind::TupleEnumVariant(_) => None, 265 hir::CallableKind::TupleStruct(_)
266 | hir::CallableKind::TupleEnumVariant(_)
267 | hir::CallableKind::Closure => None,
266 }; 268 };
267 if param_name.is_empty() 269 if param_name.is_empty()
268 || Some(param_name) == fn_name.as_ref().map(|s| s.trim_start_matches('_')) 270 || Some(param_name) == fn_name.as_ref().map(|s| s.trim_start_matches('_'))