aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_hir/src/source_binder.rs15
1 files changed, 5 insertions, 10 deletions
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs
index 880596615..649c5b684 100644
--- a/crates/ra_hir/src/source_binder.rs
+++ b/crates/ra_hir/src/source_binder.rs
@@ -101,15 +101,6 @@ fn function_from_source(
101 Some(Function { id: ctx.to_def(fn_def) }) 101 Some(Function { id: ctx.to_def(fn_def) })
102} 102}
103 103
104fn function_from_child_node(
105 db: &impl HirDatabase,
106 file_id: FileId,
107 node: &SyntaxNode,
108) -> Option<Function> {
109 let fn_def = node.ancestors().find_map(ast::FnDef::cast)?;
110 function_from_source(db, file_id, fn_def)
111}
112
113pub fn struct_from_module( 104pub fn struct_from_module(
114 db: &impl HirDatabase, 105 db: &impl HirDatabase,
115 module: Module, 106 module: Module,
@@ -148,7 +139,11 @@ fn resolver_for_node(
148 node.ancestors() 139 node.ancestors()
149 .find_map(|node| { 140 .find_map(|node| {
150 if ast::Expr::cast(node).is_some() || ast::Block::cast(node).is_some() { 141 if ast::Expr::cast(node).is_some() || ast::Block::cast(node).is_some() {
151 if let Some(func) = function_from_child_node(db, file_id, node) { 142 if let Some(func) = node
143 .ancestors()
144 .find_map(ast::FnDef::cast)
145 .and_then(|it| function_from_source(db, file_id, it))
146 {
152 let scopes = func.scopes(db); 147 let scopes = func.scopes(db);
153 let scope = match offset { 148 let scope = match offset {
154 None => scopes.scope_for(&node), 149 None => scopes.scope_for(&node),