diff options
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/db.rs | 8 | ||||
-rw-r--r-- | crates/ra_hir/src/lib.rs | 1 | ||||
-rw-r--r-- | crates/ra_hir/src/type_alias.rs | 31 |
4 files changed, 4 insertions, 40 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 5690040a7..72c9b466f 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -937,7 +937,7 @@ impl TypeAlias { | |||
937 | } | 937 | } |
938 | 938 | ||
939 | pub fn type_ref(self, db: &impl DefDatabase) -> Option<TypeRef> { | 939 | pub fn type_ref(self, db: &impl DefDatabase) -> Option<TypeRef> { |
940 | db.type_alias_data(self).type_ref.clone() | 940 | db.type_alias_data(self.id).type_ref.clone() |
941 | } | 941 | } |
942 | 942 | ||
943 | pub fn ty(self, db: &impl HirDatabase) -> Ty { | 943 | pub fn ty(self, db: &impl HirDatabase) -> Ty { |
@@ -945,7 +945,7 @@ impl TypeAlias { | |||
945 | } | 945 | } |
946 | 946 | ||
947 | pub fn name(self, db: &impl DefDatabase) -> Name { | 947 | pub fn name(self, db: &impl DefDatabase) -> Name { |
948 | db.type_alias_data(self).name.clone() | 948 | db.type_alias_data(self.id).name.clone() |
949 | } | 949 | } |
950 | } | 950 | } |
951 | 951 | ||
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index ed0d68001..689874331 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs | |||
@@ -16,16 +16,15 @@ use crate::{ | |||
16 | CallableDef, FnSig, GenericPredicate, InferenceResult, Namespace, Substs, Ty, TypableDef, | 16 | CallableDef, FnSig, GenericPredicate, InferenceResult, Namespace, Substs, Ty, TypableDef, |
17 | TypeCtor, | 17 | TypeCtor, |
18 | }, | 18 | }, |
19 | type_alias::TypeAliasData, | ||
20 | Const, ConstData, Crate, DefWithBody, FnData, Function, GenericDef, ImplBlock, Module, Static, | 19 | Const, ConstData, Crate, DefWithBody, FnData, Function, GenericDef, ImplBlock, Module, Static, |
21 | StructField, Trait, TypeAlias, | 20 | StructField, Trait, |
22 | }; | 21 | }; |
23 | 22 | ||
24 | pub use hir_def::db::{ | 23 | pub use hir_def::db::{ |
25 | BodyQuery, BodyWithSourceMapQuery, CrateDefMapQuery, DefDatabase2, DefDatabase2Storage, | 24 | BodyQuery, BodyWithSourceMapQuery, CrateDefMapQuery, DefDatabase2, DefDatabase2Storage, |
26 | EnumDataQuery, ExprScopesQuery, GenericParamsQuery, ImplDataQuery, InternDatabase, | 25 | EnumDataQuery, ExprScopesQuery, GenericParamsQuery, ImplDataQuery, InternDatabase, |
27 | InternDatabaseStorage, RawItemsQuery, RawItemsWithSourceMapQuery, StructDataQuery, | 26 | InternDatabaseStorage, RawItemsQuery, RawItemsWithSourceMapQuery, StructDataQuery, |
28 | TraitDataQuery, | 27 | TraitDataQuery, TypeAliasDataQuery, |
29 | }; | 28 | }; |
30 | pub use hir_expand::db::{ | 29 | pub use hir_expand::db::{ |
31 | AstDatabase, AstDatabaseStorage, AstIdMapQuery, MacroArgQuery, MacroDefQuery, MacroExpandQuery, | 30 | AstDatabase, AstDatabaseStorage, AstIdMapQuery, MacroArgQuery, MacroDefQuery, MacroExpandQuery, |
@@ -39,9 +38,6 @@ pub trait DefDatabase: HirDebugDatabase + DefDatabase2 { | |||
39 | #[salsa::invoke(FnData::fn_data_query)] | 38 | #[salsa::invoke(FnData::fn_data_query)] |
40 | fn fn_data(&self, func: Function) -> Arc<FnData>; | 39 | fn fn_data(&self, func: Function) -> Arc<FnData>; |
41 | 40 | ||
42 | #[salsa::invoke(TypeAliasData::type_alias_data_query)] | ||
43 | fn type_alias_data(&self, typ: TypeAlias) -> Arc<TypeAliasData>; | ||
44 | |||
45 | #[salsa::invoke(ConstData::const_data_query)] | 41 | #[salsa::invoke(ConstData::const_data_query)] |
46 | fn const_data(&self, konst: Const) -> Arc<ConstData>; | 42 | fn const_data(&self, konst: Const) -> Arc<ConstData>; |
47 | 43 | ||
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs index 8c6834392..8e532c36c 100644 --- a/crates/ra_hir/src/lib.rs +++ b/crates/ra_hir/src/lib.rs | |||
@@ -32,7 +32,6 @@ pub mod db; | |||
32 | pub mod source_binder; | 32 | pub mod source_binder; |
33 | 33 | ||
34 | mod ids; | 34 | mod ids; |
35 | mod type_alias; | ||
36 | mod ty; | 35 | mod ty; |
37 | mod impl_block; | 36 | mod impl_block; |
38 | mod expr; | 37 | mod expr; |
diff --git a/crates/ra_hir/src/type_alias.rs b/crates/ra_hir/src/type_alias.rs deleted file mode 100644 index 392f244cf..000000000 --- a/crates/ra_hir/src/type_alias.rs +++ /dev/null | |||
@@ -1,31 +0,0 @@ | |||
1 | //! HIR for type aliases (i.e. the `type` keyword). | ||
2 | |||
3 | use std::sync::Arc; | ||
4 | |||
5 | use hir_def::type_ref::TypeRef; | ||
6 | use hir_expand::name::{AsName, Name}; | ||
7 | |||
8 | use ra_syntax::ast::NameOwner; | ||
9 | |||
10 | use crate::{ | ||
11 | db::{AstDatabase, DefDatabase}, | ||
12 | HasSource, TypeAlias, | ||
13 | }; | ||
14 | |||
15 | #[derive(Debug, Clone, PartialEq, Eq)] | ||
16 | pub struct TypeAliasData { | ||
17 | pub(crate) name: Name, | ||
18 | pub(crate) type_ref: Option<TypeRef>, | ||
19 | } | ||
20 | |||
21 | impl TypeAliasData { | ||
22 | pub(crate) fn type_alias_data_query( | ||
23 | db: &(impl DefDatabase + AstDatabase), | ||
24 | typ: TypeAlias, | ||
25 | ) -> Arc<TypeAliasData> { | ||
26 | let node = typ.source(db).value; | ||
27 | let name = node.name().map_or_else(Name::missing, |n| n.as_name()); | ||
28 | let type_ref = node.type_ref().map(TypeRef::from_ast); | ||
29 | Arc::new(TypeAliasData { name, type_ref }) | ||
30 | } | ||
31 | } | ||