From 74c82ca8ce82360f9509ab433263d2f4e872209b Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 29 Oct 2020 13:02:34 +0100 Subject: Only show `self` ident when showing parameter self hints --- crates/ide/src/inlay_hints.rs | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'crates/ide/src') diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs index ac704ae21..6cfb22e13 100644 --- a/crates/ide/src/inlay_hints.rs +++ b/crates/ide/src/inlay_hints.rs @@ -162,7 +162,7 @@ fn get_param_name_hints( .zip(args) .filter_map(|((param, _ty), arg)| { let param_name = match param? { - Either::Left(self_param) => self_param.to_string(), + Either::Left(_) => "self".to_string(), Either::Right(pat) => match pat { ast::Pat::IdentPat(it) => it.name()?.to_string(), _ => return None, @@ -809,7 +809,7 @@ fn main() { t.method(123); //^^^ param Test::method(&t, 3456); - //^^ &self ^^^^ param + //^^ self ^^^^ param Test::from_syntax( FileId {}, //^^^^^^^^^ file_id @@ -1360,4 +1360,25 @@ fn main() { "#, ); } + + #[test] + fn self_param_hints() { + check( + r#" +struct Foo; + +impl Foo { + fn foo(self: Self) {} + fn bar(self: &Self) {} +} + +fn main() { + Foo::foo(Foo); + //^^^ self + Foo::bar(&Foo); + //^^^^ self +} +"#, + ) + } } -- cgit v1.2.3