From d88269bc2d36d163eef5173912c40d5b6eee3847 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 13 Apr 2019 09:38:37 +0300 Subject: generalize --- crates/ra_hir/src/source_binder.rs | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'crates') diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index 649c5b684..5bb6d64ff 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs @@ -139,21 +139,13 @@ fn resolver_for_node( node.ancestors() .find_map(|node| { if ast::Expr::cast(node).is_some() || ast::Block::cast(node).is_some() { - if let Some(func) = node - .ancestors() - .find_map(ast::FnDef::cast) - .and_then(|it| function_from_source(db, file_id, it)) - { - let scopes = func.scopes(db); - let scope = match offset { - None => scopes.scope_for(&node), - Some(offset) => scopes.scope_for_offset(offset), - }; - Some(expr::resolver_for_scope(func.body(db), db, scope)) - } else { - // FIXME const/static/array length - None - } + let def = def_with_body_from_child_node(db, file_id, node)?; + let scopes = def.scopes(db); + let scope = match offset { + None => scopes.scope_for(&node), + Some(offset) => scopes.scope_for_offset(offset), + }; + Some(expr::resolver_for_scope(def.body(db), db, scope)) } else { try_get_resolver_for_node(db, file_id, node) } -- cgit v1.2.3