diff options
author | IceSentry <[email protected]> | 2020-04-09 17:26:49 +0100 |
---|---|---|
committer | IceSentry <[email protected]> | 2020-04-09 17:26:49 +0100 |
commit | ebc61709c86a9bfceafecc0b6ed9cc4f4624e0fe (patch) | |
tree | 4999b97b6b293ad47d6439ad0dde43ef89ad4606 /crates/ra_ide/src | |
parent | ae416f3c6e90a8d2b2f9d1713d2db4ddce12df65 (diff) |
use .expr() to remove ref
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r-- | crates/ra_ide/src/inlay_hints.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs index b1661d238..da9f55a69 100644 --- a/crates/ra_ide/src/inlay_hints.rs +++ b/crates/ra_ide/src/inlay_hints.rs | |||
@@ -254,14 +254,19 @@ fn should_show_param_hint( | |||
254 | } | 254 | } |
255 | 255 | ||
256 | fn is_argument_similar_to_param(argument: &ast::Expr, param_name: &str) -> bool { | 256 | fn is_argument_similar_to_param(argument: &ast::Expr, param_name: &str) -> bool { |
257 | let argument_string = if let ast::Expr::RefExpr(ref_expr) = argument { | 257 | let argument_string = remove_ref(argument.clone()).syntax().to_string(); |
258 | ref_expr.syntax().last_token().expect("RefExpr should have a last_token").to_string() | ||
259 | } else { | ||
260 | argument.syntax().to_string() | ||
261 | }; | ||
262 | argument_string.starts_with(¶m_name) || argument_string.ends_with(¶m_name) | 258 | argument_string.starts_with(¶m_name) || argument_string.ends_with(¶m_name) |
263 | } | 259 | } |
264 | 260 | ||
261 | fn remove_ref(expr: ast::Expr) -> ast::Expr { | ||
262 | if let ast::Expr::RefExpr(ref_expr) = &expr { | ||
263 | if let Some(inner) = ref_expr.expr() { | ||
264 | return inner; | ||
265 | } | ||
266 | } | ||
267 | expr | ||
268 | } | ||
269 | |||
265 | fn is_obvious_param(param_name: &str) -> bool { | 270 | fn is_obvious_param(param_name: &str) -> bool { |
266 | let is_obvious_param_name = match param_name { | 271 | let is_obvious_param_name = match param_name { |
267 | "predicate" | "value" | "pat" | "rhs" | "other" => true, | 272 | "predicate" | "value" | "pat" | "rhs" | "other" => true, |