aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-07-16 17:24:26 +0100
committerAleksey Kladov <[email protected]>2020-07-16 17:24:26 +0100
commit6da22ed9752b239fcd4e7c75673907ceb1ac6b65 (patch)
tree34bea64bd48b51b0318b3a6e45037eb19aebc233 /crates/ra_ide/src
parenta4e9681c79095d6c10a851cfefe64cf1a3570ec5 (diff)
Redner self as param for call infor for assoc fn call
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r--crates/ra_ide/src/call_info.rs35
1 files changed, 28 insertions, 7 deletions
diff --git a/crates/ra_ide/src/call_info.rs b/crates/ra_ide/src/call_info.rs
index a2d23b2ec..35a8a0dc5 100644
--- a/crates/ra_ide/src/call_info.rs
+++ b/crates/ra_ide/src/call_info.rs
@@ -1,4 +1,5 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2use either::Either;
2use hir::{Docs, HirDisplay, Semantics, Type}; 3use hir::{Docs, HirDisplay, Semantics, Type};
3use ra_ide_db::RootDatabase; 4use ra_ide_db::RootDatabase;
4use ra_syntax::{ 5use ra_syntax::{
@@ -80,7 +81,10 @@ pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<Cal
80 for (pat, ty) in callable.params(db) { 81 for (pat, ty) in callable.params(db) {
81 buf.clear(); 82 buf.clear();
82 if let Some(pat) = pat { 83 if let Some(pat) = pat {
83 format_to!(buf, "{}: ", pat); 84 match pat {
85 Either::Left(_self) => format_to!(buf, "self: "),
86 Either::Right(pat) => format_to!(buf, "{}: ", pat),
87 }
84 } 88 }
85 format_to!(buf, "{}", ty.display(db)); 89 format_to!(buf, "{}", ty.display(db));
86 res.push_param(&buf); 90 res.push_param(&buf);
@@ -383,21 +387,38 @@ fn bar() {
383 check( 387 check(
384 r#" 388 r#"
385struct S; 389struct S;
386impl S { pub fn do_it(&self, x: i32) {} } 390impl S {
387 391 fn foo(&self, x: i32) {}
388fn bar() {
389 let s: S = S;
390 s.do_it(<|>);
391} 392}
393
394fn main() { S.foo(<|>); }
392"#, 395"#,
393 expect![[r#" 396 expect![[r#"
394 fn do_it(&self, x: i32) 397 fn foo(&self, x: i32)
395 (<x: i32>) 398 (<x: i32>)
396 "#]], 399 "#]],
397 ); 400 );
398 } 401 }
399 402
400 #[test] 403 #[test]
404 fn test_fn_signature_for_method_with_arg_as_assoc_fn() {
405 check(
406 r#"
407struct S;
408impl S {
409 fn foo(&self, x: i32) {}
410}
411
412fn main() { S::foo(<|>); }
413"#,
414 expect![[r#"
415 fn foo(self: &S, x: i32)
416 (<self: &S>, x: i32)
417 "#]],
418 );
419 }
420
421 #[test]
401 fn test_fn_signature_with_docs_simple() { 422 fn test_fn_signature_with_docs_simple() {
402 check( 423 check(
403 r#" 424 r#"