diff options
Diffstat (limited to 'crates/ra_hir/src/db.rs')
-rw-r--r-- | crates/ra_hir/src/db.rs | 40 |
1 files changed, 9 insertions, 31 deletions
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index 6d34c671d..8f6cb2da7 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs | |||
@@ -2,8 +2,8 @@ | |||
2 | 2 | ||
3 | use std::sync::Arc; | 3 | use std::sync::Arc; |
4 | 4 | ||
5 | use ra_db::{salsa, SourceDatabase}; | 5 | use ra_db::salsa; |
6 | use ra_syntax::{ast, SmolStr}; | 6 | use ra_syntax::SmolStr; |
7 | 7 | ||
8 | use crate::{ | 8 | use crate::{ |
9 | adt::{EnumData, StructData}, | 9 | adt::{EnumData, StructData}, |
@@ -23,40 +23,12 @@ use crate::{ | |||
23 | Static, Struct, StructField, Trait, TypeAlias, | 23 | Static, Struct, StructField, Trait, TypeAlias, |
24 | }; | 24 | }; |
25 | 25 | ||
26 | pub use hir_def::db::{InternDatabase, InternDatabaseStorage}; | ||
26 | pub use hir_expand::db::{ | 27 | pub use hir_expand::db::{ |
27 | AstDatabase, AstDatabaseStorage, AstIdMapQuery, MacroArgQuery, MacroDefQuery, MacroExpandQuery, | 28 | AstDatabase, AstDatabaseStorage, AstIdMapQuery, MacroArgQuery, MacroDefQuery, MacroExpandQuery, |
28 | ParseMacroQuery, | 29 | ParseMacroQuery, |
29 | }; | 30 | }; |
30 | 31 | ||
31 | /// We store all interned things in the single QueryGroup. | ||
32 | /// | ||
33 | /// This is done mainly to allow both "volatile" `AstDatabase` and "stable" | ||
34 | /// `DefDatabase` to access macros, without adding hard dependencies between the | ||
35 | /// two. | ||
36 | #[salsa::query_group(InternDatabaseStorage)] | ||
37 | pub trait InternDatabase: SourceDatabase { | ||
38 | #[salsa::interned] | ||
39 | fn intern_function(&self, loc: ids::ItemLoc<ast::FnDef>) -> ids::FunctionId; | ||
40 | #[salsa::interned] | ||
41 | fn intern_struct(&self, loc: ids::ItemLoc<ast::StructDef>) -> ids::StructId; | ||
42 | #[salsa::interned] | ||
43 | fn intern_enum(&self, loc: ids::ItemLoc<ast::EnumDef>) -> ids::EnumId; | ||
44 | #[salsa::interned] | ||
45 | fn intern_const(&self, loc: ids::ItemLoc<ast::ConstDef>) -> ids::ConstId; | ||
46 | #[salsa::interned] | ||
47 | fn intern_static(&self, loc: ids::ItemLoc<ast::StaticDef>) -> ids::StaticId; | ||
48 | #[salsa::interned] | ||
49 | fn intern_trait(&self, loc: ids::ItemLoc<ast::TraitDef>) -> ids::TraitId; | ||
50 | #[salsa::interned] | ||
51 | fn intern_type_alias(&self, loc: ids::ItemLoc<ast::TypeAliasDef>) -> ids::TypeAliasId; | ||
52 | |||
53 | // Interned IDs for Chalk integration | ||
54 | #[salsa::interned] | ||
55 | fn intern_type_ctor(&self, type_ctor: TypeCtor) -> ids::TypeCtorId; | ||
56 | #[salsa::interned] | ||
57 | fn intern_impl(&self, impl_: Impl) -> ids::GlobalImplId; | ||
58 | } | ||
59 | |||
60 | // This database uses `AstDatabase` internally, | 32 | // This database uses `AstDatabase` internally, |
61 | #[salsa::query_group(DefDatabaseStorage)] | 33 | #[salsa::query_group(DefDatabaseStorage)] |
62 | #[salsa::requires(AstDatabase)] | 34 | #[salsa::requires(AstDatabase)] |
@@ -176,6 +148,12 @@ pub trait HirDatabase: DefDatabase + AstDatabase { | |||
176 | #[salsa::invoke(crate::ty::traits::trait_solver_query)] | 148 | #[salsa::invoke(crate::ty::traits::trait_solver_query)] |
177 | fn trait_solver(&self, krate: Crate) -> crate::ty::traits::TraitSolver; | 149 | fn trait_solver(&self, krate: Crate) -> crate::ty::traits::TraitSolver; |
178 | 150 | ||
151 | // Interned IDs for Chalk integration | ||
152 | #[salsa::interned] | ||
153 | fn intern_type_ctor(&self, type_ctor: TypeCtor) -> ids::TypeCtorId; | ||
154 | #[salsa::interned] | ||
155 | fn intern_impl(&self, impl_: Impl) -> ids::GlobalImplId; | ||
156 | |||
179 | #[salsa::invoke(crate::ty::traits::chalk::associated_ty_data_query)] | 157 | #[salsa::invoke(crate::ty::traits::chalk::associated_ty_data_query)] |
180 | fn associated_ty_data(&self, id: chalk_ir::TypeId) -> Arc<chalk_rust_ir::AssociatedTyDatum>; | 158 | fn associated_ty_data(&self, id: chalk_ir::TypeId) -> Arc<chalk_rust_ir::AssociatedTyDatum>; |
181 | 159 | ||