Skip to content

Commit 5e62233

Browse files
bors[bot]Veykril
andauthored
Merge #6401
6401: Only show `self` ident when showing parameter self hints r=matklad a=Veykril This just hints all self parameters with the `self` token, this is therefor equal to how all other parameters are displayed, but given the self param special in how its defined in a function signature it might make sense to keep the `&`/`&mut` parts as well as emitting those tokens for explict `Self` types that are taken by ref like `self: &Rc<Self>`? Fixes #6400 Co-authored-by: Lukas Wirth <[email protected]>
2 parents 8ad01d8 + 74c82ca commit 5e62233

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

crates/ide/src/inlay_hints.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ fn get_param_name_hints(
162162
.zip(args)
163163
.filter_map(|((param, _ty), arg)| {
164164
let param_name = match param? {
165-
Either::Left(self_param) => self_param.to_string(),
165+
Either::Left(_) => "self".to_string(),
166166
Either::Right(pat) => match pat {
167167
ast::Pat::IdentPat(it) => it.name()?.to_string(),
168168
_ => return None,
@@ -809,7 +809,7 @@ fn main() {
809809
t.method(123);
810810
//^^^ param
811811
Test::method(&t, 3456);
812-
//^^ &self ^^^^ param
812+
//^^ self ^^^^ param
813813
Test::from_syntax(
814814
FileId {},
815815
//^^^^^^^^^ file_id
@@ -1360,4 +1360,25 @@ fn main() {
13601360
"#,
13611361
);
13621362
}
1363+
1364+
#[test]
1365+
fn self_param_hints() {
1366+
check(
1367+
r#"
1368+
struct Foo;
1369+
1370+
impl Foo {
1371+
fn foo(self: Self) {}
1372+
fn bar(self: &Self) {}
1373+
}
1374+
1375+
fn main() {
1376+
Foo::foo(Foo);
1377+
//^^^ self
1378+
Foo::bar(&Foo);
1379+
//^^^^ self
1380+
}
1381+
"#,
1382+
)
1383+
}
13631384
}

0 commit comments

Comments
 (0)