From d0cf4306bd238209aa26a5263074dbb3480a4387 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 25 Jan 2019 20:55:38 +0300 Subject: fix todo --- crates/ra_ide_api/src/goto_definition.rs | 4 +-- crates/ra_ide_api/src/navigation_target.rs | 45 +++++++----------------------- 2 files changed, 11 insertions(+), 38 deletions(-) diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide_api/src/goto_definition.rs index 45b4c56ef..dc0c50918 100644 --- a/crates/ra_ide_api/src/goto_definition.rs +++ b/crates/ra_ide_api/src/goto_definition.rs @@ -97,9 +97,7 @@ pub(crate) fn reference_definition( { let resolved = module.resolve_path(db, &path); if let Some(def_id) = resolved.take_types().or(resolved.take_values()) { - if let Some(target) = NavigationTarget::from_def(db, def_id) { - return Exact(target); - } + return Exact(NavigationTarget::from_def(db, def_id)); } } } diff --git a/crates/ra_ide_api/src/navigation_target.rs b/crates/ra_ide_api/src/navigation_target.rs index ae2175dbc..d73d4afa7 100644 --- a/crates/ra_ide_api/src/navigation_target.rs +++ b/crates/ra_ide_api/src/navigation_target.rs @@ -112,62 +112,37 @@ impl NavigationTarget { } } - // TODO once Def::Item is gone, this should be able to always return a NavigationTarget - pub(crate) fn from_def( - db: &RootDatabase, - module_def: hir::ModuleDef, - ) -> Option { + pub(crate) fn from_def(db: &RootDatabase, module_def: hir::ModuleDef) -> NavigationTarget { match module_def { - hir::ModuleDef::Module(module) => Some(NavigationTarget::from_module(db, module)), - hir::ModuleDef::Function(func) => Some(NavigationTarget::from_function(db, func)), + hir::ModuleDef::Module(module) => NavigationTarget::from_module(db, module), + hir::ModuleDef::Function(func) => NavigationTarget::from_function(db, func), hir::ModuleDef::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) } hir::ModuleDef::Const(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) } hir::ModuleDef::Static(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) } hir::ModuleDef::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) } hir::ModuleDef::EnumVariant(var) => { let (file_id, node) = var.source(db); - Some(NavigationTarget::from_named( - file_id.original_file(db), - &*node, - )) + NavigationTarget::from_named(file_id.original_file(db), &*node) } hir::ModuleDef::Trait(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) } hir::ModuleDef::Type(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) } } } -- cgit v1.2.3