Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions crates/ide/src/inlay_hints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -809,7 +809,7 @@ fn main() {
t.method(123);
//^^^ param
Test::method(&t, 3456);
//^^ &self ^^^^ param
//^^ self ^^^^ param
Test::from_syntax(
FileId {},
//^^^^^^^^^ file_id
Expand Down Expand Up @@ -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
}
"#,
)
}
}