From 6da22ed9752b239fcd4e7c75673907ceb1ac6b65 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 16 Jul 2020 18:24:26 +0200 Subject: Redner self as param for call infor for assoc fn call --- crates/ra_ide/src/call_info.rs | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 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 a2d23b2ec..35a8a0dc5 100644 --- a/crates/ra_ide/src/call_info.rs +++ b/crates/ra_ide/src/call_info.rs @@ -1,4 +1,5 @@ //! FIXME: write short doc here +use either::Either; use hir::{Docs, HirDisplay, Semantics, Type}; use ra_ide_db::RootDatabase; use ra_syntax::{ @@ -80,7 +81,10 @@ pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option format_to!(buf, "self: "), + Either::Right(pat) => format_to!(buf, "{}: ", pat), + } } format_to!(buf, "{}", ty.display(db)); res.push_param(&buf); @@ -383,20 +387,37 @@ fn bar() { check( r#" struct S; -impl S { pub fn do_it(&self, x: i32) {} } - -fn bar() { - let s: S = S; - s.do_it(<|>); +impl S { + fn foo(&self, x: i32) {} } + +fn main() { S.foo(<|>); } "#, expect![[r#" - fn do_it(&self, x: i32) + fn foo(&self, x: i32) () "#]], ); } + #[test] + fn test_fn_signature_for_method_with_arg_as_assoc_fn() { + check( + r#" +struct S; +impl S { + fn foo(&self, x: i32) {} +} + +fn main() { S::foo(<|>); } +"#, + expect![[r#" + fn foo(self: &S, x: i32) + (, x: i32) + "#]], + ); + } + #[test] fn test_fn_signature_with_docs_simple() { check( -- cgit v1.2.3