use .expr() to remove ref

This commit is contained in:
IceSentry 2020-04-09 12:26:49 -04:00
parent ae416f3c6e
commit ebc61709c8

View file

@ -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(&param_name) || argument_string.ends_with(&param_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,