mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
use .expr() to remove ref
This commit is contained in:
parent
ae416f3c6e
commit
ebc61709c8
1 changed files with 10 additions and 5 deletions
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue