diff options
Diffstat (limited to 'crates/hir_def/src/body/tests.rs')
-rw-r--r-- | crates/hir_def/src/body/tests.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/crates/hir_def/src/body/tests.rs b/crates/hir_def/src/body/tests.rs index da60072ce..404603360 100644 --- a/crates/hir_def/src/body/tests.rs +++ b/crates/hir_def/src/body/tests.rs | |||
@@ -43,7 +43,7 @@ fn block_def_map_at(ra_fixture: &str) -> Arc<DefMap> { | |||
43 | let mut block = | 43 | let mut block = |
44 | block_at_pos(&db, &def_map, position).expect("couldn't find enclosing function or block"); | 44 | block_at_pos(&db, &def_map, position).expect("couldn't find enclosing function or block"); |
45 | loop { | 45 | loop { |
46 | let def_map = db.block_def_map(block); | 46 | let def_map = db.block_def_map(block).unwrap_or_else(|| def_map.clone()); |
47 | let new_block = block_at_pos(&db, &def_map, position); | 47 | let new_block = block_at_pos(&db, &def_map, position); |
48 | match new_block { | 48 | match new_block { |
49 | Some(new_block) => { | 49 | Some(new_block) => { |
@@ -58,6 +58,7 @@ fn block_def_map_at(ra_fixture: &str) -> Arc<DefMap> { | |||
58 | } | 58 | } |
59 | 59 | ||
60 | fn block_at_pos(db: &dyn DefDatabase, def_map: &DefMap, position: FilePosition) -> Option<BlockId> { | 60 | fn block_at_pos(db: &dyn DefDatabase, def_map: &DefMap, position: FilePosition) -> Option<BlockId> { |
61 | // Find the smallest (innermost) function containing the cursor. | ||
61 | let mut size = None; | 62 | let mut size = None; |
62 | let mut fn_def = None; | 63 | let mut fn_def = None; |
63 | for (_, module) in def_map.modules() { | 64 | for (_, module) in def_map.modules() { |
@@ -73,7 +74,6 @@ fn block_at_pos(db: &dyn DefDatabase, def_map: &DefMap, position: FilePosition) | |||
73 | let ast = ast_map.get(item_tree[it.lookup(db).id.value].ast_id).to_node(&root); | 74 | let ast = ast_map.get(item_tree[it.lookup(db).id.value].ast_id).to_node(&root); |
74 | let range = ast.syntax().text_range(); | 75 | let range = ast.syntax().text_range(); |
75 | 76 | ||
76 | // Find the smallest (innermost) function containing the cursor. | ||
77 | if !range.contains(position.offset) { | 77 | if !range.contains(position.offset) { |
78 | continue; | 78 | continue; |
79 | } | 79 | } |