aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/inlay_hints.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-11-03 16:43:26 +0000
committerGitHub <[email protected]>2020-11-03 16:43:26 +0000
commit5e622332774fbd57c12addd46b058c8feb2b08a6 (patch)
tree280d119f7430989cb9097425cbcfc03aa3c6eb04 /crates/ide/src/inlay_hints.rs
parent8ad01d863bd747f194ac391ba6fcb950c78e3ea3 (diff)
parent74c82ca8ce82360f9509ab433263d2f4e872209b (diff)
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]>
Diffstat (limited to 'crates/ide/src/inlay_hints.rs')
-rw-r--r--crates/ide/src/inlay_hints.rs25
1 files changed, 23 insertions, 2 deletions
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(
162 .zip(args) 162 .zip(args)
163 .filter_map(|((param, _ty), arg)| { 163 .filter_map(|((param, _ty), arg)| {
164 let param_name = match param? { 164 let param_name = match param? {
165 Either::Left(self_param) => self_param.to_string(), 165 Either::Left(_) => "self".to_string(),
166 Either::Right(pat) => match pat { 166 Either::Right(pat) => match pat {
167 ast::Pat::IdentPat(it) => it.name()?.to_string(), 167 ast::Pat::IdentPat(it) => it.name()?.to_string(),
168 _ => return None, 168 _ => return None,
@@ -809,7 +809,7 @@ fn main() {
809 t.method(123); 809 t.method(123);
810 //^^^ param 810 //^^^ param
811 Test::method(&t, 3456); 811 Test::method(&t, 3456);
812 //^^ &self ^^^^ param 812 //^^ self ^^^^ param
813 Test::from_syntax( 813 Test::from_syntax(
814 FileId {}, 814 FileId {},
815 //^^^^^^^^^ file_id 815 //^^^^^^^^^ file_id
@@ -1360,4 +1360,25 @@ fn main() {
1360 "#, 1360 "#,
1361 ); 1361 );
1362 } 1362 }
1363
1364 #[test]
1365 fn self_param_hints() {
1366 check(
1367 r#"
1368struct Foo;
1369
1370impl Foo {
1371 fn foo(self: Self) {}
1372 fn bar(self: &Self) {}
1373}
1374
1375fn main() {
1376 Foo::foo(Foo);
1377 //^^^ self
1378 Foo::bar(&Foo);
1379 //^^^^ self
1380}
1381"#,
1382 )
1383 }
1363} 1384}