aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2020-08-12 22:43:01 +0100
committerKirill Bulatov <[email protected]>2020-08-12 22:44:16 +0100
commit0de795fc4c121033890c21ffd41ef9274dc3c74e (patch)
tree73a91e17f2fae1fd9db08c896b71976671512172 /crates/ra_ide
parentf277ec27ac024992e8b8834c68e16b31c983be1b (diff)
Consider only IdentPats for param name hints
Diffstat (limited to 'crates/ra_ide')
-rw-r--r--crates/ra_ide/src/inlay_hints.rs22
1 files changed, 14 insertions, 8 deletions
diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs
index 46ddc528e..81fe274ad 100644
--- a/crates/ra_ide/src/inlay_hints.rs
+++ b/crates/ra_ide/src/inlay_hints.rs
@@ -156,15 +156,15 @@ fn get_param_name_hints(
156 .params(sema.db) 156 .params(sema.db)
157 .into_iter() 157 .into_iter()
158 .zip(args) 158 .zip(args)
159 .filter_map(|((param, _ty), arg)| match param? { 159 .filter_map(|((param, _ty), arg)| {
160 Either::Left(self_param) => Some((self_param.to_string(), arg)), 160 let param_name = match param? {
161 Either::Right(pat) => { 161 Either::Left(self_param) => self_param.to_string(),
162 let param_name = match pat { 162 Either::Right(pat) => match pat {
163 ast::Pat::IdentPat(it) => it.name()?.to_string(), 163 ast::Pat::IdentPat(it) => it.name()?.to_string(),
164 it => it.to_string(), 164 _ => return None,
165 }; 165 },
166 Some((param_name, arg)) 166 };
167 } 167 Some((param_name, arg))
168 }) 168 })
169 .filter(|(param_name, arg)| should_show_param_name_hint(sema, &callable, &param_name, &arg)) 169 .filter(|(param_name, arg)| should_show_param_name_hint(sema, &callable, &param_name, &arg))
170 .map(|(param_name, arg)| InlayHint { 170 .map(|(param_name, arg)| InlayHint {
@@ -707,6 +707,8 @@ fn different_order(param: &Param) {}
707fn different_order_mut(param: &mut Param) {} 707fn different_order_mut(param: &mut Param) {}
708fn has_underscore(_param: bool) {} 708fn has_underscore(_param: bool) {}
709fn enum_matches_param_name(completion_kind: CompletionKind) {} 709fn enum_matches_param_name(completion_kind: CompletionKind) {}
710fn param_destructuring_omitted_1((a, b): (u32, u32)) {}
711fn param_destructuring_omitted_2(TestVarContainer { test_var: _ }: TestVarContainer) {}
710 712
711fn twiddle(twiddle: bool) {} 713fn twiddle(twiddle: bool) {}
712fn doo(_doo: bool) {} 714fn doo(_doo: bool) {}
@@ -746,6 +748,10 @@ fn main() {
746 let b: f64 = 4.0; 748 let b: f64 = 4.0;
747 let _: f64 = a.div_euclid(b); 749 let _: f64 = a.div_euclid(b);
748 let _: f64 = a.abs_sub(b); 750 let _: f64 = a.abs_sub(b);
751
752 let range: (u32, u32) = (3, 5);
753 param_destructuring_omitted_1(range);
754 param_destructuring_omitted_2(container);
749}"#, 755}"#,
750 ); 756 );
751 } 757 }