From 1a6f51da66f16a46eb5fd80dc6ea0a2c179d5ff2 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 2 Mar 2020 19:03:32 +0100 Subject: Simplify: remove couple of useless functions --- crates/ra_ide/src/references/classify.rs | 6 ++---- crates/ra_ide_db/src/defs.rs | 30 +++++++++++------------------- 2 files changed, 13 insertions(+), 23 deletions(-) (limited to 'crates') diff --git a/crates/ra_ide/src/references/classify.rs b/crates/ra_ide/src/references/classify.rs index e837ca8a3..571236fdc 100644 --- a/crates/ra_ide/src/references/classify.rs +++ b/crates/ra_ide/src/references/classify.rs @@ -7,8 +7,6 @@ use ra_prof::profile; use ra_syntax::{ast, AstNode}; use test_utils::tested_by; -pub use ra_ide_db::defs::{from_module_def, from_struct_field}; - pub enum NameRefClass { NameDefinition(NameDefinition), FieldShorthand { local: Local, field: NameDefinition }, @@ -68,14 +66,14 @@ pub(crate) fn classify_name_ref( let path = name_ref.syntax().ancestors().find_map(ast::Path::cast)?; let resolved = sema.resolve_path(&path)?; let res = match resolved { - PathResolution::Def(def) => from_module_def(def), + PathResolution::Def(def) => NameDefinition::ModuleDef(def), PathResolution::AssocItem(item) => { let def = match item { hir::AssocItem::Function(it) => it.into(), hir::AssocItem::Const(it) => it.into(), hir::AssocItem::TypeAlias(it) => it.into(), }; - from_module_def(def) + NameDefinition::ModuleDef(def) } PathResolution::Local(local) => NameDefinition::Local(local), PathResolution::TypeParam(par) => NameDefinition::TypeParam(par), diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ra_ide_db/src/defs.rs index ad4638906..7b1030a14 100644 --- a/crates/ra_ide_db/src/defs.rs +++ b/crates/ra_ide_db/src/defs.rs @@ -111,47 +111,47 @@ fn classify_name_inner(sema: &Semantics, name: &ast::Name) -> Opti }, ast::RecordFieldDef(it) => { let field: hir::StructField = sema.to_def(&it)?; - Some(from_struct_field(field)) + Some(NameDefinition::StructField(field)) }, ast::Module(it) => { let def = sema.to_def(&it)?; - Some(from_module_def(def.into())) + Some(NameDefinition::ModuleDef(def.into())) }, ast::StructDef(it) => { let def: hir::Struct = sema.to_def(&it)?; - Some(from_module_def(def.into())) + Some(NameDefinition::ModuleDef(def.into())) }, ast::UnionDef(it) => { let def: hir::Union = sema.to_def(&it)?; - Some(from_module_def(def.into())) + Some(NameDefinition::ModuleDef(def.into())) }, ast::EnumDef(it) => { let def: hir::Enum = sema.to_def(&it)?; - Some(from_module_def(def.into())) + Some(NameDefinition::ModuleDef(def.into())) }, ast::TraitDef(it) => { let def: hir::Trait = sema.to_def(&it)?; - Some(from_module_def(def.into())) + Some(NameDefinition::ModuleDef(def.into())) }, ast::StaticDef(it) => { let def: hir::Static = sema.to_def(&it)?; - Some(from_module_def(def.into())) + Some(NameDefinition::ModuleDef(def.into())) }, ast::EnumVariant(it) => { let def: hir::EnumVariant = sema.to_def(&it)?; - Some(from_module_def(def.into())) + Some(NameDefinition::ModuleDef(def.into())) }, ast::FnDef(it) => { let def: hir::Function = sema.to_def(&it)?; - Some(from_module_def(def.into())) + Some(NameDefinition::ModuleDef(def.into())) }, ast::ConstDef(it) => { let def: hir::Const = sema.to_def(&it)?; - Some(from_module_def(def.into())) + Some(NameDefinition::ModuleDef(def.into())) }, ast::TypeAliasDef(it) => { let def: hir::TypeAlias = sema.to_def(&it)?; - Some(from_module_def(def.into())) + Some(NameDefinition::ModuleDef(def.into())) }, ast::MacroCall(it) => { let def = sema.to_def(&it)?; @@ -165,11 +165,3 @@ fn classify_name_inner(sema: &Semantics, name: &ast::Name) -> Opti } } } - -pub fn from_struct_field(field: StructField) -> NameDefinition { - NameDefinition::StructField(field) -} - -pub fn from_module_def(def: ModuleDef) -> NameDefinition { - NameDefinition::ModuleDef(def) -} -- cgit v1.2.3