4297: refactor: use parent instead ancestors for use alias r=matklad a=bnjjj

Linked to this comment https://github.com/rust-analyzer/rust-analyzer/pull/4269/files#r419343670

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
This commit is contained in:
bors[bot] 2020-05-04 12:37:41 +00:00 committed by GitHub
commit 580c5a969d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -121,7 +121,7 @@ fn classify_name_inner(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Opti
match parent {
ast::Alias(it) => {
tested_by!(goto_def_for_use_alias; force);
let use_tree = it.syntax().ancestors().find_map(ast::UseTree::cast)?;
let use_tree = it.syntax().parent().and_then(ast::UseTree::cast)?;
let path = use_tree.path()?;
let path_segment = path.segment()?;
let name_ref = path_segment.name_ref()?;