From cb642fc578100c0945088accb85acb8f03d2e1fd Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 20 Nov 2019 20:33:18 +0300 Subject: Move generic_params query to HIR --- crates/ra_hir/src/db.rs | 10 ++++------ crates/ra_hir/src/generics.rs | 19 ++----------------- 2 files changed, 6 insertions(+), 23 deletions(-) (limited to 'crates/ra_hir/src') 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; use crate::{ debug::HirDebugDatabase, - generics::{GenericDef, GenericParams}, + generics::GenericDef, ids, lang_item::{LangItemTarget, LangItems}, ty::{ @@ -24,8 +24,9 @@ use crate::{ pub use hir_def::db::{ BodyQuery, BodyWithSourceMapQuery, CrateDefMapQuery, DefDatabase2, DefDatabase2Storage, - EnumDataQuery, ExprScopesQuery, ImplDataQuery, InternDatabase, InternDatabaseStorage, - RawItemsQuery, RawItemsWithSourceMapQuery, StructDataQuery, TraitDataQuery, + EnumDataQuery, ExprScopesQuery, GenericParamsQuery, ImplDataQuery, InternDatabase, + InternDatabaseStorage, RawItemsQuery, RawItemsWithSourceMapQuery, StructDataQuery, + TraitDataQuery, }; pub use hir_expand::db::{ AstDatabase, AstDatabaseStorage, AstIdMapQuery, MacroArgQuery, MacroDefQuery, MacroExpandQuery, @@ -36,9 +37,6 @@ pub use hir_expand::db::{ #[salsa::query_group(DefDatabaseStorage)] #[salsa::requires(AstDatabase)] pub trait DefDatabase: HirDebugDatabase + DefDatabase2 { - #[salsa::invoke(crate::generics::generic_params_query)] - fn generic_params(&self, def: GenericDef) -> Arc; - #[salsa::invoke(FnData::fn_data_query)] fn fn_data(&self, func: Function) -> Arc; 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 @@ use std::sync::Arc; use crate::{ - db::{AstDatabase, DefDatabase, HirDatabase}, + db::{DefDatabase, HirDatabase}, Adt, Const, Container, Enum, EnumVariant, Function, ImplBlock, Struct, Trait, TypeAlias, Union, }; @@ -31,21 +31,6 @@ impl_froms!( Const ); -pub(crate) fn generic_params_query( - db: &(impl DefDatabase + AstDatabase), - def: GenericDef, -) -> Arc { - let parent = match def { - GenericDef::Function(it) => it.container(db).map(GenericDef::from), - GenericDef::TypeAlias(it) => it.container(db).map(GenericDef::from), - GenericDef::Const(it) => it.container(db).map(GenericDef::from), - GenericDef::EnumVariant(it) => Some(it.parent_enum(db).into()), - GenericDef::Adt(_) | GenericDef::Trait(_) => None, - GenericDef::ImplBlock(_) => None, - }; - Arc::new(GenericParams::new(db, def.into(), parent.map(|it| db.generic_params(it)))) -} - impl GenericDef { pub(crate) fn resolver(&self, db: &impl HirDatabase) -> crate::Resolver { match self { @@ -78,6 +63,6 @@ where T: Into + Copy, { fn generic_params(self, db: &impl DefDatabase) -> Arc { - db.generic_params(self.into()) + db.generic_params(self.into().into()) } } -- cgit v1.2.3