aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurenČ›iu Nicola <[email protected]>2020-04-18 08:53:48 +0100
committerLaurenČ›iu Nicola <[email protected]>2020-04-18 08:53:48 +0100
commit8a51a74556c77d7f228867dd64cd6244bed82be6 (patch)
treea01a8b54a203571d91d1858796b94ba36d8499dc
parent179d9835351f3abab03634b50bcee94723cce148 (diff)
Omit more parameter hints in the presence of underscores
-rw-r--r--crates/ra_ide/src/inlay_hints.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs
index 45b9f7802..0774fa0a1 100644
--- a/crates/ra_ide/src/inlay_hints.rs
+++ b/crates/ra_ide/src/inlay_hints.rs
@@ -237,7 +237,8 @@ fn should_show_param_hint(
237) -> bool { 237) -> bool {
238 if param_name.is_empty() 238 if param_name.is_empty()
239 || is_argument_similar_to_param(argument, param_name) 239 || is_argument_similar_to_param(argument, param_name)
240 || Some(param_name) == fn_signature.name.as_ref().map(String::as_str) 240 || Some(param_name.trim_start_matches('_'))
241 == fn_signature.name.as_ref().map(|s| s.trim_start_matches('_'))
241 { 242 {
242 return false; 243 return false;
243 } 244 }
@@ -255,6 +256,8 @@ fn should_show_param_hint(
255 256
256fn is_argument_similar_to_param(argument: &ast::Expr, param_name: &str) -> bool { 257fn is_argument_similar_to_param(argument: &ast::Expr, param_name: &str) -> bool {
257 let argument_string = remove_ref(argument.clone()).syntax().to_string(); 258 let argument_string = remove_ref(argument.clone()).syntax().to_string();
259 let param_name = param_name.trim_start_matches('_');
260 let argument_string = argument_string.trim_start_matches('_');
258 argument_string.starts_with(&param_name) || argument_string.ends_with(&param_name) 261 argument_string.starts_with(&param_name) || argument_string.ends_with(&param_name)
259} 262}
260 263
@@ -1094,8 +1097,10 @@ struct Param {}
1094 1097
1095fn different_order(param: &Param) {} 1098fn different_order(param: &Param) {}
1096fn different_order_mut(param: &mut Param) {} 1099fn different_order_mut(param: &mut Param) {}
1100fn has_underscore(_param: bool) {}
1097 1101
1098fn twiddle(twiddle: bool) {} 1102fn twiddle(twiddle: bool) {}
1103fn doo(_doo: bool) {}
1099 1104
1100fn main() { 1105fn main() {
1101 let container: TestVarContainer = TestVarContainer { test_var: 42 }; 1106 let container: TestVarContainer = TestVarContainer { test_var: 42 };
@@ -1112,11 +1117,15 @@ fn main() {
1112 test_processed.frob(false); 1117 test_processed.frob(false);
1113 1118
1114 twiddle(true); 1119 twiddle(true);
1120 doo(true);
1115 1121
1116 let param_begin: Param = Param {}; 1122 let param_begin: Param = Param {};
1117 different_order(&param_begin); 1123 different_order(&param_begin);
1118 different_order(&mut param_begin); 1124 different_order(&mut param_begin);
1119 1125
1126 let param: bool = true;
1127 has_underscore(param);
1128
1120 let a: f64 = 7.0; 1129 let a: f64 = 7.0;
1121 let b: f64 = 4.0; 1130 let b: f64 = 4.0;
1122 let _: f64 = a.div_euclid(b); 1131 let _: f64 = a.div_euclid(b);