refactor: use parent instead ancestors for use alias

Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
This commit is contained in:
Benjamin Coenen 2020-05-04 13:41:41 +02:00
parent 96f581079f
commit e88c3e4fcd

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()?;