From ebc61709c86a9bfceafecc0b6ed9cc4f4624e0fe Mon Sep 17 00:00:00 2001 From: IceSentry Date: Thu, 9 Apr 2020 12:26:49 -0400 Subject: use .expr() to remove ref --- crates/ra_ide/src/inlay_hints.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'crates/ra_ide/src') 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( } fn is_argument_similar_to_param(argument: &ast::Expr, param_name: &str) -> bool { - let argument_string = if let ast::Expr::RefExpr(ref_expr) = argument { - ref_expr.syntax().last_token().expect("RefExpr should have a last_token").to_string() - } else { - argument.syntax().to_string() - }; + let argument_string = remove_ref(argument.clone()).syntax().to_string(); argument_string.starts_with(¶m_name) || argument_string.ends_with(¶m_name) } +fn remove_ref(expr: ast::Expr) -> ast::Expr { + if let ast::Expr::RefExpr(ref_expr) = &expr { + if let Some(inner) = ref_expr.expr() { + return inner; + } + } + expr +} + fn is_obvious_param(param_name: &str) -> bool { let is_obvious_param_name = match param_name { "predicate" | "value" | "pat" | "rhs" | "other" => true, -- cgit v1.2.3