aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorIceSentry <[email protected]>2020-04-09 00:07:21 +0100
committerIceSentry <[email protected]>2020-04-09 00:07:21 +0100
commitde6db0632228ae61f7ec1f87eaf520ccd4e46925 (patch)
treec64b7572223639e0f4bbcf94c808005cb4d1954f /crates
parenta2dc18f71acf83dd2946622603d3da00b456d42a (diff)
ignore `&mut ` and `&` when checking params
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_ide/src/inlay_hints.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs
index a86e18fbb..6b8b5813d 100644
--- a/crates/ra_ide/src/inlay_hints.rs
+++ b/crates/ra_ide/src/inlay_hints.rs
@@ -235,7 +235,15 @@ fn should_show_param_hint(
235 param_name: &str, 235 param_name: &str,
236 argument: &ast::Expr, 236 argument: &ast::Expr,
237) -> bool { 237) -> bool {
238 let argument_string = argument.syntax().to_string(); 238 let argument_string = {
239 let arg_string = argument.syntax().to_string();
240 let arg_split: Vec<char> = arg_string.chars().collect();
241 match arg_split.as_slice() {
242 ['&', 'm', 'u', 't', ' ', arg_name @ ..] => arg_name.into_iter().collect::<String>(),
243 ['&', arg_name @ ..] => arg_name.into_iter().collect::<String>(),
244 _ => arg_string,
245 }
246 };
239 if param_name.is_empty() 247 if param_name.is_empty()
240 || argument_string.ends_with(&param_name) 248 || argument_string.ends_with(&param_name)
241 || argument_string.starts_with(&param_name) 249 || argument_string.starts_with(&param_name)
@@ -1077,7 +1085,8 @@ impl Test {
1077 1085
1078struct Param {} 1086struct Param {}
1079 1087
1080fn different_order(param: Param) {} 1088fn different_order(param: &Param) {}
1089fn different_order_mut(param: &mut Param) {}
1081 1090
1082fn main() { 1091fn main() {
1083 let container: TestVarContainer = TestVarContainer { test_var: 42 }; 1092 let container: TestVarContainer = TestVarContainer { test_var: 42 };
@@ -1093,7 +1102,8 @@ fn main() {
1093 test_processed.no_hints_expected(33, container.test_var); 1102 test_processed.no_hints_expected(33, container.test_var);
1094 1103
1095 let param_begin: Param = Param {}; 1104 let param_begin: Param = Param {};
1096 different_order(param_begin); 1105 different_order(&param_begin);
1106 different_order(&mut param_begin);
1097 1107
1098 let a: f64 = 7.0; 1108 let a: f64 = 7.0;
1099 let b: f64 = 4.0; 1109 let b: f64 = 4.0;