diff options
author | Aleksey Kladov <[email protected]> | 2019-01-24 16:29:44 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-24 16:29:44 +0000 |
commit | 11dda8a0fb905a1b41a64001d564632eb062b9aa (patch) | |
tree | 2f7214d22d0ee232fbaa23b951b322b9f5299650 /crates/ra_hir | |
parent | a7c0336a7516e4973a9efb86bfb97cf290441413 (diff) |
remove useless aliases
Diffstat (limited to 'crates/ra_hir')
-rw-r--r-- | crates/ra_hir/src/adt.rs | 10 | ||||
-rw-r--r-- | crates/ra_hir/src/code_model_impl/function.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir/src/ids.rs | 36 |
3 files changed, 14 insertions, 38 deletions
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::{ | |||
13 | HirDatabase, DefKind, | 13 | HirDatabase, DefKind, |
14 | SourceItemId, | 14 | SourceItemId, |
15 | type_ref::TypeRef, | 15 | type_ref::TypeRef, |
16 | ids::{StructLoc, EnumLoc}, | 16 | ids::ItemLoc, |
17 | }; | 17 | }; |
18 | 18 | ||
19 | impl Struct { | 19 | impl Struct { |
@@ -23,8 +23,8 @@ impl Struct { | |||
23 | file_id: HirFileId, | 23 | file_id: HirFileId, |
24 | ast: &ast::StructDef, | 24 | ast: &ast::StructDef, |
25 | ) -> Struct { | 25 | ) -> Struct { |
26 | let loc: StructLoc = StructLoc::from_ast(db, module, file_id, ast); | 26 | let loc = ItemLoc::from_ast(db, module, file_id, ast); |
27 | let id = loc.id(db); | 27 | let id = db.as_ref().structs.loc2id(&loc); |
28 | Struct { id } | 28 | Struct { id } |
29 | } | 29 | } |
30 | 30 | ||
@@ -40,8 +40,8 @@ impl Enum { | |||
40 | file_id: HirFileId, | 40 | file_id: HirFileId, |
41 | ast: &ast::EnumDef, | 41 | ast: &ast::EnumDef, |
42 | ) -> Enum { | 42 | ) -> Enum { |
43 | let loc: EnumLoc = EnumLoc::from_ast(db, module, file_id, ast); | 43 | let loc = ItemLoc::from_ast(db, module, file_id, ast); |
44 | let id = loc.id(db); | 44 | let id = db.as_ref().enums.loc2id(&loc); |
45 | Enum { id } | 45 | Enum { id } |
46 | } | 46 | } |
47 | } | 47 | } |
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::{ | |||
9 | type_ref::{TypeRef, Mutability}, | 9 | type_ref::{TypeRef, Mutability}, |
10 | expr::Body, | 10 | expr::Body, |
11 | impl_block::ImplBlock, | 11 | impl_block::ImplBlock, |
12 | ids::FunctionLoc, | 12 | ids::ItemLoc, |
13 | }; | 13 | }; |
14 | 14 | ||
15 | pub use self::scope::{FnScopes, ScopesWithSyntaxMapping, ScopeEntryWithSyntax}; | 15 | pub use self::scope::{FnScopes, ScopesWithSyntaxMapping, ScopeEntryWithSyntax}; |
@@ -21,8 +21,8 @@ impl Function { | |||
21 | file_id: HirFileId, | 21 | file_id: HirFileId, |
22 | ast: &ast::FnDef, | 22 | ast: &ast::FnDef, |
23 | ) -> Function { | 23 | ) -> Function { |
24 | let loc: FunctionLoc = FunctionLoc::from_ast(db, module, file_id, ast); | 24 | let loc = ItemLoc::from_ast(db, module, file_id, ast); |
25 | let id = loc.id(db); | 25 | let id = db.as_ref().fns.loc2id(&loc); |
26 | Function { id } | 26 | Function { id } |
27 | } | 27 | } |
28 | 28 | ||
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::{ | |||
13 | pub struct HirInterner { | 13 | pub struct HirInterner { |
14 | defs: LocationIntener<DefLoc, DefId>, | 14 | defs: LocationIntener<DefLoc, DefId>, |
15 | macros: LocationIntener<MacroCallLoc, MacroCallId>, | 15 | macros: LocationIntener<MacroCallLoc, MacroCallId>, |
16 | fns: LocationIntener<FunctionLoc, FunctionId>, | 16 | pub(crate) fns: LocationIntener<ItemLoc<ast::FnDef>, FunctionId>, |
17 | structs: LocationIntener<StructLoc, StructId>, | 17 | pub(crate) structs: LocationIntener<ItemLoc<ast::StructDef>, StructId>, |
18 | enums: LocationIntener<EnumLoc, EnumId>, | 18 | pub(crate) enums: LocationIntener<ItemLoc<ast::EnumDef>, EnumId>, |
19 | } | 19 | } |
20 | 20 | ||
21 | impl HirInterner { | 21 | impl HirInterner { |
@@ -182,56 +182,32 @@ impl<N: AstNode> Clone for ItemLoc<N> { | |||
182 | pub struct FunctionId(RawId); | 182 | pub struct FunctionId(RawId); |
183 | impl_arena_id!(FunctionId); | 183 | impl_arena_id!(FunctionId); |
184 | 184 | ||
185 | pub(crate) type FunctionLoc = ItemLoc<ast::FnDef>; | ||
186 | |||
187 | impl FunctionId { | 185 | impl FunctionId { |
188 | pub(crate) fn loc(self, db: &impl AsRef<HirInterner>) -> FunctionLoc { | 186 | pub(crate) fn loc(self, db: &impl AsRef<HirInterner>) -> ItemLoc<ast::FnDef> { |
189 | db.as_ref().fns.id2loc(self) | 187 | db.as_ref().fns.id2loc(self) |
190 | } | 188 | } |
191 | } | 189 | } |
192 | 190 | ||
193 | impl FunctionLoc { | ||
194 | pub(crate) fn id(&self, db: &impl AsRef<HirInterner>) -> FunctionId { | ||
195 | db.as_ref().fns.loc2id(&self) | ||
196 | } | ||
197 | } | ||
198 | |||
199 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 191 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
200 | pub struct StructId(RawId); | 192 | pub struct StructId(RawId); |
201 | impl_arena_id!(StructId); | 193 | impl_arena_id!(StructId); |
202 | 194 | ||
203 | pub(crate) type StructLoc = ItemLoc<ast::StructDef>; | ||
204 | |||
205 | impl StructId { | 195 | impl StructId { |
206 | pub(crate) fn loc(self, db: &impl AsRef<HirInterner>) -> StructLoc { | 196 | pub(crate) fn loc(self, db: &impl AsRef<HirInterner>) -> ItemLoc<ast::StructDef> { |
207 | db.as_ref().structs.id2loc(self) | 197 | db.as_ref().structs.id2loc(self) |
208 | } | 198 | } |
209 | } | 199 | } |
210 | 200 | ||
211 | impl StructLoc { | ||
212 | pub(crate) fn id(&self, db: &impl AsRef<HirInterner>) -> StructId { | ||
213 | db.as_ref().structs.loc2id(&self) | ||
214 | } | ||
215 | } | ||
216 | |||
217 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 201 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
218 | pub struct EnumId(RawId); | 202 | pub struct EnumId(RawId); |
219 | impl_arena_id!(EnumId); | 203 | impl_arena_id!(EnumId); |
220 | 204 | ||
221 | pub(crate) type EnumLoc = ItemLoc<ast::EnumDef>; | ||
222 | |||
223 | impl EnumId { | 205 | impl EnumId { |
224 | pub(crate) fn loc(self, db: &impl AsRef<HirInterner>) -> EnumLoc { | 206 | pub(crate) fn loc(self, db: &impl AsRef<HirInterner>) -> ItemLoc<ast::EnumDef> { |
225 | db.as_ref().enums.id2loc(self) | 207 | db.as_ref().enums.id2loc(self) |
226 | } | 208 | } |
227 | } | 209 | } |
228 | 210 | ||
229 | impl EnumLoc { | ||
230 | pub(crate) fn id(&self, db: &impl AsRef<HirInterner>) -> EnumId { | ||
231 | db.as_ref().enums.loc2id(&self) | ||
232 | } | ||
233 | } | ||
234 | |||
235 | /// Def's are a core concept of hir. A `Def` is an Item (function, module, etc) | 211 | /// Def's are a core concept of hir. A `Def` is an Item (function, module, etc) |
236 | /// in a specific module. | 212 | /// in a specific module. |
237 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 213 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |