diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-01-08 23:20:54 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-08 23:20:54 +0000 |
| commit | 5fe8cb1fba2f0fec72f62758fbf02b18fc178d4c (patch) | |
| tree | e1dc8f568ac0cfa03fc04b60ab398e2b01105590 | |
| parent | 056cabf25d3ef7a96220f9f3a6f904b2841feab6 (diff) | |
| parent | 5889bb27d673e4762490c21ad734e7fd9705d591 (diff) | |
| download | rust-5fe8cb1fba2f0fec72f62758fbf02b18fc178d4c.tar.gz rust-5fe8cb1fba2f0fec72f62758fbf02b18fc178d4c.zip | |
Merge #7213
7213: Simplify r=Veykril a=Veykril bors r+ Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
| -rw-r--r-- | crates/ide/src/call_hierarchy.rs | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/crates/ide/src/call_hierarchy.rs b/crates/ide/src/call_hierarchy.rs index 4d8983cb213..b29d1fef9b8 100644 --- a/crates/ide/src/call_hierarchy.rs +++ b/crates/ide/src/call_hierarchy.rs @@ -5,7 +5,7 @@ use indexmap::IndexMap; use hir::Semantics; use ide_db::call_info::FnCallNode; use ide_db::RootDatabase; -use syntax::{ast, match_ast, AstNode, TextRange}; +use syntax::{ast, AstNode, TextRange}; use crate::{ display::TryToNav, goto_definition, references, FilePosition, NavigationTarget, RangeInfo, @@ -57,15 +57,9 @@ pub(crate) fn incoming_calls(db: &RootDatabase, position: FilePosition) -> Optio // This target is the containing function if let Some(nav) = syntax.ancestors().find_map(|node| { - match_ast! { - match node { - ast::Fn(it) => { - let def = sema.to_def(&it)?; - def.try_to_nav(sema.db) - }, - _ => None, - } - } + let fn_ = ast::Fn::cast(node)?; + let def = sema.to_def(&fn_)?; + def.try_to_nav(sema.db) }) { let relative_range = reference.file_range.range; calls.add(&nav, relative_range); @@ -91,17 +85,12 @@ pub(crate) fn outgoing_calls(db: &RootDatabase, position: FilePosition) -> Optio .filter_map(|node| FnCallNode::with_node_exact(&node)) .filter_map(|call_node| { let name_ref = call_node.name_ref()?; - - if let Some(func_target) = match &call_node { + let func_target = match call_node { FnCallNode::CallExpr(expr) => { //FIXME: Type::as_callable is broken let callable = sema.type_of_expr(&expr.expr()?)?.as_callable(db)?; match callable.kind() { - hir::CallableKind::Function(it) => { - let fn_def: hir::Function = it.into(); - let nav = fn_def.try_to_nav(db)?; - Some(nav) - } + hir::CallableKind::Function(it) => it.try_to_nav(db), _ => None, } } @@ -109,11 +98,8 @@ pub(crate) fn outgoing_calls(db: &RootDatabase, position: FilePosition) -> Optio let function = sema.resolve_method_call(&expr)?; function.try_to_nav(db) } - } { - Some((func_target, name_ref.syntax().text_range())) - } else { - None - } + }?; + Some((func_target, name_ref.syntax().text_range())) }) .for_each(|(nav, range)| calls.add(&nav, range)); |
