diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs index ac704ae2178..6cfb22e13ee 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 +} +"#, + ) + } }