From d1ff0145a9fe84f86192b2d88d5f0bd96a95a98f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 24 May 2020 15:47:05 +0200 Subject: Fix tests --- crates/ra_ide/src/runnables.rs | 50 +++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'crates/ra_ide/src') diff --git a/crates/ra_ide/src/runnables.rs b/crates/ra_ide/src/runnables.rs index ed98e58e0..6e7e47199 100644 --- a/crates/ra_ide/src/runnables.rs +++ b/crates/ra_ide/src/runnables.rs @@ -70,10 +70,10 @@ fn runnable_fn( let kind = if name_string == "main" { RunnableKind::Bin } else { - let test_id = if let Some(module) = sema.to_def(&fn_def).map(|def| def.module(sema.db)) { - let def = sema.to_def(&fn_def)?; - let impl_trait_name = - def.as_assoc_item(sema.db).and_then(|assoc_item| { + let test_id = match sema.to_def(&fn_def).map(|def| def.module(sema.db)) { + Some(module) => { + let def = sema.to_def(&fn_def)?; + let impl_trait_name = def.as_assoc_item(sema.db).and_then(|assoc_item| { match assoc_item.container(sema.db) { hir::AssocItemContainer::Trait(trait_item) => { Some(trait_item.name(sema.db).to_string()) @@ -85,25 +85,25 @@ fn runnable_fn( } }); - let path_iter = module - .path_to_root(sema.db) - .into_iter() - .rev() - .filter_map(|it| it.name(sema.db)) - .map(|name| name.to_string()); - - let path = if let Some(impl_trait_name) = impl_trait_name { - path_iter - .chain(std::iter::once(impl_trait_name)) - .chain(std::iter::once(name_string)) - .join("::") - } else { - path_iter.chain(std::iter::once(name_string)).join("::") - }; - - TestId::Path(path) - } else { - TestId::Name(name_string) + let path_iter = module + .path_to_root(sema.db) + .into_iter() + .rev() + .filter_map(|it| it.name(sema.db)) + .map(|name| name.to_string()); + + let path = if let Some(impl_trait_name) = impl_trait_name { + path_iter + .chain(std::iter::once(impl_trait_name)) + .chain(std::iter::once(name_string)) + .join("::") + } else { + path_iter.chain(std::iter::once(name_string)).join("::") + }; + + TestId::Path(path) + } + None => TestId::Name(name_string), }; if has_test_related_attribute(&fn_def) { @@ -472,7 +472,7 @@ mod tests { Runnable { range: 1..58, kind: Test { - test_id: Name( + test_id: Path( "test_foo1", ), attr: TestAttr { @@ -509,7 +509,7 @@ mod tests { Runnable { range: 1..80, kind: Test { - test_id: Name( + test_id: Path( "test_foo1", ), attr: TestAttr { -- cgit v1.2.3