From dabdb57067309e18ac0a391bf35425f5d7dcf978 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sun, 16 Feb 2020 18:39:58 +0200 Subject: Simplify module retrieval --- crates/ra_ide/src/runnables.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'crates') 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( let kind = if name_string == "main" { RunnableKind::Bin } else { - let test_id = if let Some(module) = fn_def - .syntax() - .ancestors() - .find_map(ast::Module::cast) - .and_then(|module| source_binder.to_def(InFile::new(file_id.into(), module))) + let test_id = if let Some(module) = source_binder + .to_def(InFile::new(file_id.into(), fn_def.clone())) + .map(|def| def.module(db)) { let path = module .path_to_root(db) @@ -174,7 +172,7 @@ mod tests { Runnable { range: [22; 46), kind: Test { - test_id: Name( + test_id: Path( "test_foo", ), }, @@ -182,7 +180,7 @@ mod tests { Runnable { range: [47; 81), kind: Test { - test_id: Name( + test_id: Path( "test_foo", ), }, -- cgit v1.2.3