aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2020-02-16 16:39:58 +0000
committerKirill Bulatov <[email protected]>2020-02-16 16:44:46 +0000
commitdabdb57067309e18ac0a391bf35425f5d7dcf978 (patch)
tree4ad0693c04ee758038474cdbbda67415812973fe /crates/ra_ide
parent426c0f26fe90e7d4fcf5950e217a64843e651fe9 (diff)
Simplify module retrieval
Diffstat (limited to 'crates/ra_ide')
-rw-r--r--crates/ra_ide/src/runnables.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/crates/ra_ide/src/runnables.rs b/crates/ra_ide/src/runnables.rs
index 863b85591..be2a67d0a 100644
--- a/crates/ra_ide/src/runnables.rs
+++ b/crates/ra_ide/src/runnables.rs
@@ -73,11 +73,9 @@ fn runnable_fn(
73 let kind = if name_string == "main" { 73 let kind = if name_string == "main" {
74 RunnableKind::Bin 74 RunnableKind::Bin
75 } else { 75 } else {
76 let test_id = if let Some(module) = fn_def 76 let test_id = if let Some(module) = source_binder
77 .syntax() 77 .to_def(InFile::new(file_id.into(), fn_def.clone()))
78 .ancestors() 78 .map(|def| def.module(db))
79 .find_map(ast::Module::cast)
80 .and_then(|module| source_binder.to_def(InFile::new(file_id.into(), module)))
81 { 79 {
82 let path = module 80 let path = module
83 .path_to_root(db) 81 .path_to_root(db)
@@ -174,7 +172,7 @@ mod tests {
174 Runnable { 172 Runnable {
175 range: [22; 46), 173 range: [22; 46),
176 kind: Test { 174 kind: Test {
177 test_id: Name( 175 test_id: Path(
178 "test_foo", 176 "test_foo",
179 ), 177 ),
180 }, 178 },
@@ -182,7 +180,7 @@ mod tests {
182 Runnable { 180 Runnable {
183 range: [47; 81), 181 range: [47; 81),
184 kind: Test { 182 kind: Test {
185 test_id: Name( 183 test_id: Path(
186 "test_foo", 184 "test_foo",
187 ), 185 ),
188 }, 186 },