aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide
diff options
context:
space:
mode:
authorIceSentry <[email protected]>2020-04-09 17:26:49 +0100
committerIceSentry <[email protected]>2020-04-09 17:26:49 +0100
commitebc61709c86a9bfceafecc0b6ed9cc4f4624e0fe (patch)
tree4999b97b6b293ad47d6439ad0dde43ef89ad4606 /crates/ra_ide
parentae416f3c6e90a8d2b2f9d1713d2db4ddce12df65 (diff)
use .expr() to remove ref
Diffstat (limited to 'crates/ra_ide')
-rw-r--r--crates/ra_ide/src/inlay_hints.rs15
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
256fn is_argument_similar_to_param(argument: &ast::Expr, param_name: &str) -> bool { 256fn 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(&param_name) || argument_string.ends_with(&param_name) 258 argument_string.starts_with(&param_name) || argument_string.ends_with(&param_name)
263} 259}
264 260
261fn 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
265fn is_obvious_param(param_name: &str) -> bool { 270fn 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,