From 11dda8a0fb905a1b41a64001d564632eb062b9aa Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 24 Jan 2019 19:29:44 +0300 Subject: remove useless aliases --- crates/ra_hir/src/adt.rs | 10 ++++---- crates/ra_hir/src/code_model_impl/function.rs | 6 ++--- crates/ra_hir/src/ids.rs | 36 +++++---------------------- 3 files changed, 14 insertions(+), 38 deletions(-) (limited to 'crates/ra_hir/src') diff --git a/crates/ra_hir/src/adt.rs b/crates/ra_hir/src/adt.rs index baf853a3a..17ece93a7 100644 --- a/crates/ra_hir/src/adt.rs +++ b/crates/ra_hir/src/adt.rs @@ -13,7 +13,7 @@ use crate::{ HirDatabase, DefKind, SourceItemId, type_ref::TypeRef, - ids::{StructLoc, EnumLoc}, + ids::ItemLoc, }; impl Struct { @@ -23,8 +23,8 @@ impl Struct { file_id: HirFileId, ast: &ast::StructDef, ) -> Struct { - let loc: StructLoc = StructLoc::from_ast(db, module, file_id, ast); - let id = loc.id(db); + let loc = ItemLoc::from_ast(db, module, file_id, ast); + let id = db.as_ref().structs.loc2id(&loc); Struct { id } } @@ -40,8 +40,8 @@ impl Enum { file_id: HirFileId, ast: &ast::EnumDef, ) -> Enum { - let loc: EnumLoc = EnumLoc::from_ast(db, module, file_id, ast); - let id = loc.id(db); + let loc = ItemLoc::from_ast(db, module, file_id, ast); + let id = db.as_ref().enums.loc2id(&loc); Enum { id } } } diff --git a/crates/ra_hir/src/code_model_impl/function.rs b/crates/ra_hir/src/code_model_impl/function.rs index d8dafb10e..8a2ab5714 100644 --- a/crates/ra_hir/src/code_model_impl/function.rs +++ b/crates/ra_hir/src/code_model_impl/function.rs @@ -9,7 +9,7 @@ use crate::{ type_ref::{TypeRef, Mutability}, expr::Body, impl_block::ImplBlock, - ids::FunctionLoc, + ids::ItemLoc, }; pub use self::scope::{FnScopes, ScopesWithSyntaxMapping, ScopeEntryWithSyntax}; @@ -21,8 +21,8 @@ impl Function { file_id: HirFileId, ast: &ast::FnDef, ) -> Function { - let loc: FunctionLoc = FunctionLoc::from_ast(db, module, file_id, ast); - let id = loc.id(db); + let loc = ItemLoc::from_ast(db, module, file_id, ast); + let id = db.as_ref().fns.loc2id(&loc); Function { id } } diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs index 332cec9c8..6375c76c9 100644 --- a/crates/ra_hir/src/ids.rs +++ b/crates/ra_hir/src/ids.rs @@ -13,9 +13,9 @@ use crate::{ pub struct HirInterner { defs: LocationIntener, macros: LocationIntener, - fns: LocationIntener, - structs: LocationIntener, - enums: LocationIntener, + pub(crate) fns: LocationIntener, FunctionId>, + pub(crate) structs: LocationIntener, StructId>, + pub(crate) enums: LocationIntener, EnumId>, } impl HirInterner { @@ -182,56 +182,32 @@ impl Clone for ItemLoc { pub struct FunctionId(RawId); impl_arena_id!(FunctionId); -pub(crate) type FunctionLoc = ItemLoc; - impl FunctionId { - pub(crate) fn loc(self, db: &impl AsRef) -> FunctionLoc { + pub(crate) fn loc(self, db: &impl AsRef) -> ItemLoc { db.as_ref().fns.id2loc(self) } } -impl FunctionLoc { - pub(crate) fn id(&self, db: &impl AsRef) -> FunctionId { - db.as_ref().fns.loc2id(&self) - } -} - #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct StructId(RawId); impl_arena_id!(StructId); -pub(crate) type StructLoc = ItemLoc; - impl StructId { - pub(crate) fn loc(self, db: &impl AsRef) -> StructLoc { + pub(crate) fn loc(self, db: &impl AsRef) -> ItemLoc { db.as_ref().structs.id2loc(self) } } -impl StructLoc { - pub(crate) fn id(&self, db: &impl AsRef) -> StructId { - db.as_ref().structs.loc2id(&self) - } -} - #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct EnumId(RawId); impl_arena_id!(EnumId); -pub(crate) type EnumLoc = ItemLoc; - impl EnumId { - pub(crate) fn loc(self, db: &impl AsRef) -> EnumLoc { + pub(crate) fn loc(self, db: &impl AsRef) -> ItemLoc { db.as_ref().enums.id2loc(self) } } -impl EnumLoc { - pub(crate) fn id(&self, db: &impl AsRef) -> EnumId { - db.as_ref().enums.loc2id(&self) - } -} - /// Def's are a core concept of hir. A `Def` is an Item (function, module, etc) /// in a specific module. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -- cgit v1.2.3