aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir')
-rw-r--r--crates/ra_hir/src/db.rs10
-rw-r--r--crates/ra_hir/src/generics.rs19
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
9use crate::{ 9use 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
25pub use hir_def::db::{ 25pub 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};
30pub use hir_expand::db::{ 31pub 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)]
38pub trait DefDatabase: HirDebugDatabase + DefDatabase2 { 39pub 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 @@
2use std::sync::Arc; 2use std::sync::Arc;
3 3
4use crate::{ 4use 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
34pub(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
49impl GenericDef { 34impl 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}