From a5dd04078e6be1e3a874a2c9017d824f5a067315 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 11 Jan 2019 13:29:53 +0300 Subject: reshuffle nones --- crates/ra_ide_api/src/navigation_target.rs | 31 ++++++++++-------------------- 1 file changed, 10 insertions(+), 21 deletions(-) (limited to 'crates/ra_ide_api') diff --git a/crates/ra_ide_api/src/navigation_target.rs b/crates/ra_ide_api/src/navigation_target.rs index cff11eeab..b2a53e9aa 100644 --- a/crates/ra_ide_api/src/navigation_target.rs +++ b/crates/ra_ide_api/src/navigation_target.rs @@ -24,34 +24,22 @@ impl NavigationTarget { // TODO once Def::Item is gone, this should be able to always return a NavigationTarget pub(crate) fn from_def(db: &RootDatabase, def: Def) -> Cancelable> { - Ok(match def { + let res = match def { Def::Struct(s) => { let (file_id, node) = s.source(db)?; - Some(NavigationTarget::from_named( - file_id.original_file(db), - &*node, - )) + NavigationTarget::from_named(file_id.original_file(db), &*node) } Def::Enum(e) => { let (file_id, node) = e.source(db)?; - Some(NavigationTarget::from_named( - file_id.original_file(db), - &*node, - )) + NavigationTarget::from_named(file_id.original_file(db), &*node) } Def::EnumVariant(ev) => { let (file_id, node) = ev.source(db)?; - Some(NavigationTarget::from_named( - file_id.original_file(db), - &*node, - )) + NavigationTarget::from_named(file_id.original_file(db), &*node) } Def::Function(f) => { let (file_id, node) = f.source(db)?; - Some(NavigationTarget::from_named( - file_id.original_file(db), - &*node, - )) + NavigationTarget::from_named(file_id.original_file(db), &*node) } Def::Module(m) => { let (file_id, source) = m.definition_source(db)?; @@ -61,15 +49,16 @@ impl NavigationTarget { .unwrap_or_else(|| SmolStr::new("")); match source { ModuleSource::SourceFile(node) => { - Some(NavigationTarget::from_syntax(file_id, name, node.syntax())) + NavigationTarget::from_syntax(file_id, name, node.syntax()) } ModuleSource::Module(node) => { - Some(NavigationTarget::from_syntax(file_id, name, node.syntax())) + NavigationTarget::from_syntax(file_id, name, node.syntax()) } } } - Def::Item => None, - }) + Def::Item => return Ok(None), + }; + Ok(Some(res)) } fn from_named(file_id: FileId, node: &impl ast::NameOwner) -> NavigationTarget { -- cgit v1.2.3