Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-db/src/defs.rs')
| -rw-r--r-- | crates/ide-db/src/defs.rs | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/crates/ide-db/src/defs.rs b/crates/ide-db/src/defs.rs index e5390eeb32..2b1e8e325e 100644 --- a/crates/ide-db/src/defs.rs +++ b/crates/ide-db/src/defs.rs @@ -438,29 +438,23 @@ impl NameRefClass { name_ref: ast::NameRef, ) -> Option<NameRefClass> { let parent = name_ref.syntax().parent()?; - match_ast! { - match parent { - ast::MethodCallExpr(method_call) => { - sema.resolve_impl_method(&ast::Expr::MethodCallExpr(method_call)) - .map(Definition::Function) - .map(NameRefClass::Definition) - }, - ast::PathSegment(ps) => { - ps.syntax().parent().and_then(ast::Path::cast) - .map(|p| - p.syntax() - .parent() - .and_then(ast::PathExpr::cast) - .map(|pe| - sema.resolve_impl_method(&ast::Expr::PathExpr(pe)) - .map(Definition::Function) - .map(NameRefClass::Definition) - ).flatten() - ).flatten() - }, - _=> None - } - } + let expr = match_ast! { + match parent { + ast::MethodCallExpr(method_call) => { + Some(ast::Expr::MethodCallExpr(method_call)) + }, + ast::PathSegment(..) => { + parent.ancestors() + .find_map(ast::PathExpr::cast) + .map(ast::Expr::PathExpr) + }, + _=> None + } + }; + expr.as_ref() + .and_then(|e| sema.resolve_impl_method(e)) + .map(Definition::Function) + .map(NameRefClass::Definition) } pub fn classify_lifetime( sema: &Semantics<RootDatabase>, |