aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-08-13 11:20:59 +0100
committerGitHub <[email protected]>2020-08-13 11:20:59 +0100
commit4abdf323af5bc693f8b9ff3455e19ee1dff572a8 (patch)
tree0595d5ba73b7905154d66d6f3a91820711d24db6 /crates/ra_ide
parentde1d93455f85747410efb69c28e0c1379e8e328a (diff)
parent0de795fc4c121033890c21ffd41ef9274dc3c74e (diff)
Merge #5732
5732: Consider only IdentPats for param name hints r=matklad a=SomeoneToIgnore Closes https://github.com/rust-analyzer/rust-analyzer/issues/4960 Avoid displaying any param name hints like <img width="590" alt="image" src="https://user-images.githubusercontent.com/2690773/90071461-47a4ad80-dcfe-11ea-9330-fb4f4e2d1b71.png"> Those hints seem to occupy plenty of space for no apparent benefit, with their destructured content not used in the code with the function hints. I'm not entirely sure if we should show something else than `IdentPat`s, since I don't understand some of the `Pat` variant meanings: https://github.com/rust-analyzer/rust-analyzer/blob/a1c187eef3ba08076aedb5154929f7eda8d1b424/crates/syntax/src/ast/generated/nodes.rs#L1336-L1352 Co-authored-by: Kirill Bulatov <[email protected]>
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 }