aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir/src/code_model.rs4
-rw-r--r--crates/ra_hir/src/db.rs8
-rw-r--r--crates/ra_hir/src/lib.rs1
-rw-r--r--crates/ra_hir_def/src/db.rs6
-rw-r--r--crates/ra_hir_def/src/lib.rs1
-rw-r--r--crates/ra_hir_def/src/type_alias.rs (renamed from crates/ra_hir/src/type_alias.rs)16
6 files changed, 16 insertions, 20 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
24pub use hir_def::db::{ 23pub 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};
30pub use hir_expand::db::{ 29pub 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;
32pub mod source_binder; 32pub mod source_binder;
33 33
34mod ids; 34mod ids;
35mod type_alias;
36mod ty; 35mod ty;
37mod impl_block; 36mod impl_block;
38mod expr; 37mod expr;
diff --git a/crates/ra_hir_def/src/db.rs b/crates/ra_hir_def/src/db.rs
index 844f8bbe8..5bbdaa4b2 100644
--- a/crates/ra_hir_def/src/db.rs
+++ b/crates/ra_hir_def/src/db.rs
@@ -15,7 +15,8 @@ use crate::{
15 CrateDefMap, 15 CrateDefMap,
16 }, 16 },
17 traits::TraitData, 17 traits::TraitData,
18 DefWithBodyId, EnumId, GenericDefId, ImplId, ItemLoc, StructOrUnionId, TraitId, 18 type_alias::TypeAliasData,
19 DefWithBodyId, EnumId, GenericDefId, ImplId, ItemLoc, StructOrUnionId, TraitId, TypeAliasId,
19}; 20};
20 21
21#[salsa::query_group(InternDatabaseStorage)] 22#[salsa::query_group(InternDatabaseStorage)]
@@ -64,6 +65,9 @@ pub trait DefDatabase2: InternDatabase + AstDatabase {
64 #[salsa::invoke(TraitData::trait_data_query)] 65 #[salsa::invoke(TraitData::trait_data_query)]
65 fn trait_data(&self, e: TraitId) -> Arc<TraitData>; 66 fn trait_data(&self, e: TraitId) -> Arc<TraitData>;
66 67
68 #[salsa::invoke(TypeAliasData::type_alias_data_query)]
69 fn type_alias_data(&self, e: TypeAliasId) -> Arc<TypeAliasData>;
70
67 #[salsa::invoke(Body::body_with_source_map_query)] 71 #[salsa::invoke(Body::body_with_source_map_query)]
68 fn body_with_source_map(&self, def: DefWithBodyId) -> (Arc<Body>, Arc<BodySourceMap>); 72 fn body_with_source_map(&self, def: DefWithBodyId) -> (Arc<Body>, Arc<BodySourceMap>);
69 73
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs
index d579f5c7e..268144462 100644
--- a/crates/ra_hir_def/src/lib.rs
+++ b/crates/ra_hir_def/src/lib.rs
@@ -20,6 +20,7 @@ pub mod body;
20pub mod generics; 20pub mod generics;
21pub mod traits; 21pub mod traits;
22pub mod resolver; 22pub mod resolver;
23pub mod type_alias;
23 24
24#[cfg(test)] 25#[cfg(test)]
25mod test_db; 26mod test_db;
diff --git a/crates/ra_hir/src/type_alias.rs b/crates/ra_hir_def/src/type_alias.rs
index 392f244cf..c0b49aa7c 100644
--- a/crates/ra_hir/src/type_alias.rs
+++ b/crates/ra_hir_def/src/type_alias.rs
@@ -2,28 +2,24 @@
2 2
3use std::sync::Arc; 3use std::sync::Arc;
4 4
5use hir_def::type_ref::TypeRef;
6use hir_expand::name::{AsName, Name}; 5use hir_expand::name::{AsName, Name};
7 6
8use ra_syntax::ast::NameOwner; 7use ra_syntax::ast::NameOwner;
9 8
10use crate::{ 9use crate::{db::DefDatabase2, type_ref::TypeRef, HasSource, Lookup, TypeAliasId};
11 db::{AstDatabase, DefDatabase},
12 HasSource, TypeAlias,
13};
14 10
15#[derive(Debug, Clone, PartialEq, Eq)] 11#[derive(Debug, Clone, PartialEq, Eq)]
16pub struct TypeAliasData { 12pub struct TypeAliasData {
17 pub(crate) name: Name, 13 pub name: Name,
18 pub(crate) type_ref: Option<TypeRef>, 14 pub type_ref: Option<TypeRef>,
19} 15}
20 16
21impl TypeAliasData { 17impl TypeAliasData {
22 pub(crate) fn type_alias_data_query( 18 pub(crate) fn type_alias_data_query(
23 db: &(impl DefDatabase + AstDatabase), 19 db: &impl DefDatabase2,
24 typ: TypeAlias, 20 typ: TypeAliasId,
25 ) -> Arc<TypeAliasData> { 21 ) -> Arc<TypeAliasData> {
26 let node = typ.source(db).value; 22 let node = typ.lookup(db).source(db).value;
27 let name = node.name().map_or_else(Name::missing, |n| n.as_name()); 23 let name = node.name().map_or_else(Name::missing, |n| n.as_name());
28 let type_ref = node.type_ref().map(TypeRef::from_ast); 24 let type_ref = node.type_ref().map(TypeRef::from_ast);
29 Arc::new(TypeAliasData { name, type_ref }) 25 Arc::new(TypeAliasData { name, type_ref })