diff options
author | Aleksey Kladov <[email protected]> | 2019-11-20 17:33:18 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-20 17:38:37 +0000 |
commit | cb642fc578100c0945088accb85acb8f03d2e1fd (patch) | |
tree | 5a16aa6fbc213909a5d7be3c852fa2a6b9c62299 /crates/ra_hir/src | |
parent | c51dcb1c4bdd71f9f17de508bd0d47e3c06ae1d5 (diff) |
Move generic_params query to HIR
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/db.rs | 10 | ||||
-rw-r--r-- | crates/ra_hir/src/generics.rs | 19 |
2 files changed, 6 insertions, 23 deletions
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index 5bb7961b3..a9982a70f 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs | |||
@@ -8,7 +8,7 @@ use ra_syntax::SmolStr; | |||
8 | 8 | ||
9 | use crate::{ | 9 | use crate::{ |
10 | debug::HirDebugDatabase, | 10 | debug::HirDebugDatabase, |
11 | generics::{GenericDef, GenericParams}, | 11 | generics::GenericDef, |
12 | ids, | 12 | ids, |
13 | lang_item::{LangItemTarget, LangItems}, | 13 | lang_item::{LangItemTarget, LangItems}, |
14 | ty::{ | 14 | ty::{ |
@@ -24,8 +24,9 @@ use crate::{ | |||
24 | 24 | ||
25 | pub use hir_def::db::{ | 25 | pub use hir_def::db::{ |
26 | BodyQuery, BodyWithSourceMapQuery, CrateDefMapQuery, DefDatabase2, DefDatabase2Storage, | 26 | BodyQuery, BodyWithSourceMapQuery, CrateDefMapQuery, DefDatabase2, DefDatabase2Storage, |
27 | EnumDataQuery, ExprScopesQuery, ImplDataQuery, InternDatabase, InternDatabaseStorage, | 27 | EnumDataQuery, ExprScopesQuery, GenericParamsQuery, ImplDataQuery, InternDatabase, |
28 | RawItemsQuery, RawItemsWithSourceMapQuery, StructDataQuery, TraitDataQuery, | 28 | InternDatabaseStorage, RawItemsQuery, RawItemsWithSourceMapQuery, StructDataQuery, |
29 | TraitDataQuery, | ||
29 | }; | 30 | }; |
30 | pub use hir_expand::db::{ | 31 | pub use hir_expand::db::{ |
31 | AstDatabase, AstDatabaseStorage, AstIdMapQuery, MacroArgQuery, MacroDefQuery, MacroExpandQuery, | 32 | AstDatabase, AstDatabaseStorage, AstIdMapQuery, MacroArgQuery, MacroDefQuery, MacroExpandQuery, |
@@ -36,9 +37,6 @@ pub use hir_expand::db::{ | |||
36 | #[salsa::query_group(DefDatabaseStorage)] | 37 | #[salsa::query_group(DefDatabaseStorage)] |
37 | #[salsa::requires(AstDatabase)] | 38 | #[salsa::requires(AstDatabase)] |
38 | pub trait DefDatabase: HirDebugDatabase + DefDatabase2 { | 39 | pub trait DefDatabase: HirDebugDatabase + DefDatabase2 { |
39 | #[salsa::invoke(crate::generics::generic_params_query)] | ||
40 | fn generic_params(&self, def: GenericDef) -> Arc<GenericParams>; | ||
41 | |||
42 | #[salsa::invoke(FnData::fn_data_query)] | 40 | #[salsa::invoke(FnData::fn_data_query)] |
43 | fn fn_data(&self, func: Function) -> Arc<FnData>; | 41 | fn fn_data(&self, func: Function) -> Arc<FnData>; |
44 | 42 | ||
diff --git a/crates/ra_hir/src/generics.rs b/crates/ra_hir/src/generics.rs index caedb90e6..54ed03642 100644 --- a/crates/ra_hir/src/generics.rs +++ b/crates/ra_hir/src/generics.rs | |||
@@ -2,7 +2,7 @@ | |||
2 | use std::sync::Arc; | 2 | use std::sync::Arc; |
3 | 3 | ||
4 | use crate::{ | 4 | use crate::{ |
5 | db::{AstDatabase, DefDatabase, HirDatabase}, | 5 | db::{DefDatabase, HirDatabase}, |
6 | Adt, Const, Container, Enum, EnumVariant, Function, ImplBlock, Struct, Trait, TypeAlias, Union, | 6 | Adt, Const, Container, Enum, EnumVariant, Function, ImplBlock, Struct, Trait, TypeAlias, Union, |
7 | }; | 7 | }; |
8 | 8 | ||
@@ -31,21 +31,6 @@ impl_froms!( | |||
31 | Const | 31 | Const |
32 | ); | 32 | ); |
33 | 33 | ||
34 | pub(crate) fn generic_params_query( | ||
35 | db: &(impl DefDatabase + AstDatabase), | ||
36 | def: GenericDef, | ||
37 | ) -> Arc<GenericParams> { | ||
38 | let parent = match def { | ||
39 | GenericDef::Function(it) => it.container(db).map(GenericDef::from), | ||
40 | GenericDef::TypeAlias(it) => it.container(db).map(GenericDef::from), | ||
41 | GenericDef::Const(it) => it.container(db).map(GenericDef::from), | ||
42 | GenericDef::EnumVariant(it) => Some(it.parent_enum(db).into()), | ||
43 | GenericDef::Adt(_) | GenericDef::Trait(_) => None, | ||
44 | GenericDef::ImplBlock(_) => None, | ||
45 | }; | ||
46 | Arc::new(GenericParams::new(db, def.into(), parent.map(|it| db.generic_params(it)))) | ||
47 | } | ||
48 | |||
49 | impl GenericDef { | 34 | impl GenericDef { |
50 | pub(crate) fn resolver(&self, db: &impl HirDatabase) -> crate::Resolver { | 35 | pub(crate) fn resolver(&self, db: &impl HirDatabase) -> crate::Resolver { |
51 | match self { | 36 | match self { |
@@ -78,6 +63,6 @@ where | |||
78 | T: Into<GenericDef> + Copy, | 63 | T: Into<GenericDef> + Copy, |
79 | { | 64 | { |
80 | fn generic_params(self, db: &impl DefDatabase) -> Arc<GenericParams> { | 65 | fn generic_params(self, db: &impl DefDatabase) -> Arc<GenericParams> { |
81 | db.generic_params(self.into()) | 66 | db.generic_params(self.into().into()) |
82 | } | 67 | } |
83 | } | 68 | } |