diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-04-18 10:01:41 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-04-18 10:01:41 +0100 |
commit | 09489321454bad8552c180448ac185c7805d7b79 (patch) | |
tree | 82ab4a86a315266ce06efd6d7fa9eeb8dbf00772 /crates/ra_ide/src | |
parent | 162481d5ce87a250c3144e7d9a7c72a6032b023d (diff) | |
parent | 8a51a74556c77d7f228867dd64cd6244bed82be6 (diff) |
Merge #4026
4026: Omit more parameter hints in the presence of underscores r=matklad a=lnicola
Fixes #4017.
Co-authored-by: Laurențiu Nicola <[email protected]>
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r-- | crates/ra_ide/src/inlay_hints.rs | 11 |
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 | ||
256 | fn is_argument_similar_to_param(argument: &ast::Expr, param_name: &str) -> bool { | 257 | fn 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(¶m_name) || argument_string.ends_with(¶m_name) | 261 | argument_string.starts_with(¶m_name) || argument_string.ends_with(¶m_name) |
259 | } | 262 | } |
260 | 263 | ||
@@ -1094,8 +1097,10 @@ struct Param {} | |||
1094 | 1097 | ||
1095 | fn different_order(param: &Param) {} | 1098 | fn different_order(param: &Param) {} |
1096 | fn different_order_mut(param: &mut Param) {} | 1099 | fn different_order_mut(param: &mut Param) {} |
1100 | fn has_underscore(_param: bool) {} | ||
1097 | 1101 | ||
1098 | fn twiddle(twiddle: bool) {} | 1102 | fn twiddle(twiddle: bool) {} |
1103 | fn doo(_doo: bool) {} | ||
1099 | 1104 | ||
1100 | fn main() { | 1105 | fn 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(¶m_begin); | 1123 | different_order(¶m_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); |