aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/db.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/db.rs')
-rw-r--r--crates/ra_hir/src/db.rs117
1 files changed, 6 insertions, 111 deletions
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs
index e192c8f47..bfae3660b 100644
--- a/crates/ra_hir/src/db.rs
+++ b/crates/ra_hir/src/db.rs
@@ -1,18 +1,5 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use std::sync::Arc;
4
5use hir_def::{DefWithBodyId, GenericDefId, ImplId, LocalStructFieldId, TraitId, VariantId};
6use ra_arena::map::ArenaMap;
7use ra_db::{salsa, CrateId};
8
9use crate::ty::{
10 method_resolution::CrateImplBlocks,
11 traits::{AssocTyValue, Impl},
12 CallableDef, FnSig, GenericPredicate, InferenceResult, Substs, Ty, TyDefId, TypeCtor,
13 ValueTyDefId,
14};
15
16pub use hir_def::db::{ 3pub use hir_def::db::{
17 BodyQuery, BodyWithSourceMapQuery, ConstDataQuery, CrateDefMapQuery, CrateLangItemsQuery, 4 BodyQuery, BodyWithSourceMapQuery, ConstDataQuery, CrateDefMapQuery, CrateLangItemsQuery,
18 DefDatabase, DefDatabaseStorage, DocumentationQuery, EnumDataQuery, ExprScopesQuery, 5 DefDatabase, DefDatabaseStorage, DocumentationQuery, EnumDataQuery, ExprScopesQuery,
@@ -24,104 +11,12 @@ pub use hir_expand::db::{
24 AstDatabase, AstDatabaseStorage, AstIdMapQuery, MacroArgQuery, MacroDefQuery, MacroExpandQuery, 11 AstDatabase, AstDatabaseStorage, AstIdMapQuery, MacroArgQuery, MacroDefQuery, MacroExpandQuery,
25 ParseMacroQuery, 12 ParseMacroQuery,
26}; 13};
27 14pub use hir_ty::db::{
28#[salsa::query_group(HirDatabaseStorage)] 15 AssociatedTyDataQuery, CallableItemSignatureQuery, FieldTypesQuery, GenericDefaultsQuery,
29#[salsa::requires(salsa::Database)] 16 GenericPredicatesQuery, HirDatabase, HirDatabaseStorage, ImplDatumQuery, ImplsForTraitQuery,
30pub trait HirDatabase: DefDatabase { 17 ImplsInCrateQuery, InferQuery, StructDatumQuery, TraitDatumQuery, TraitSolveQuery, TyQuery,
31 #[salsa::invoke(crate::ty::infer_query)] 18 ValueTyQuery,
32 fn infer(&self, def: DefWithBodyId) -> Arc<InferenceResult>; 19};
33
34 #[salsa::invoke(crate::ty::ty_query)]
35 fn ty(&self, def: TyDefId) -> Ty;
36
37 #[salsa::invoke(crate::ty::value_ty_query)]
38 fn value_ty(&self, def: ValueTyDefId) -> Ty;
39
40 #[salsa::invoke(crate::ty::field_types_query)]
41 fn field_types(&self, var: VariantId) -> Arc<ArenaMap<LocalStructFieldId, Ty>>;
42
43 #[salsa::invoke(crate::ty::callable_item_sig)]
44 fn callable_item_signature(&self, def: CallableDef) -> FnSig;
45
46 #[salsa::invoke(crate::ty::generic_predicates_for_param_query)]
47 fn generic_predicates_for_param(
48 &self,
49 def: GenericDefId,
50 param_idx: u32,
51 ) -> Arc<[GenericPredicate]>;
52
53 #[salsa::invoke(crate::ty::generic_predicates_query)]
54 fn generic_predicates(&self, def: GenericDefId) -> Arc<[GenericPredicate]>;
55
56 #[salsa::invoke(crate::ty::generic_defaults_query)]
57 fn generic_defaults(&self, def: GenericDefId) -> Substs;
58
59 #[salsa::invoke(crate::ty::method_resolution::CrateImplBlocks::impls_in_crate_query)]
60 fn impls_in_crate(&self, krate: CrateId) -> Arc<CrateImplBlocks>;
61
62 #[salsa::invoke(crate::ty::traits::impls_for_trait_query)]
63 fn impls_for_trait(&self, krate: CrateId, trait_: TraitId) -> Arc<[ImplId]>;
64
65 /// This provides the Chalk trait solver instance. Because Chalk always
66 /// works from a specific crate, this query is keyed on the crate; and
67 /// because Chalk does its own internal caching, the solver is wrapped in a
68 /// Mutex and the query does an untracked read internally, to make sure the
69 /// cached state is thrown away when input facts change.
70 #[salsa::invoke(crate::ty::traits::trait_solver_query)]
71 fn trait_solver(&self, krate: CrateId) -> crate::ty::traits::TraitSolver;
72
73 // Interned IDs for Chalk integration
74 #[salsa::interned]
75 fn intern_type_ctor(&self, type_ctor: TypeCtor) -> crate::ty::TypeCtorId;
76 #[salsa::interned]
77 fn intern_chalk_impl(&self, impl_: Impl) -> crate::ty::traits::GlobalImplId;
78 #[salsa::interned]
79 fn intern_assoc_ty_value(
80 &self,
81 assoc_ty_value: AssocTyValue,
82 ) -> crate::ty::traits::AssocTyValueId;
83
84 #[salsa::invoke(crate::ty::traits::chalk::associated_ty_data_query)]
85 fn associated_ty_data(
86 &self,
87 id: chalk_ir::TypeId,
88 ) -> Arc<chalk_rust_ir::AssociatedTyDatum<chalk_ir::family::ChalkIr>>;
89
90 #[salsa::invoke(crate::ty::traits::chalk::trait_datum_query)]
91 fn trait_datum(
92 &self,
93 krate: CrateId,
94 trait_id: chalk_ir::TraitId,
95 ) -> Arc<chalk_rust_ir::TraitDatum<chalk_ir::family::ChalkIr>>;
96
97 #[salsa::invoke(crate::ty::traits::chalk::struct_datum_query)]
98 fn struct_datum(
99 &self,
100 krate: CrateId,
101 struct_id: chalk_ir::StructId,
102 ) -> Arc<chalk_rust_ir::StructDatum<chalk_ir::family::ChalkIr>>;
103
104 #[salsa::invoke(crate::ty::traits::chalk::impl_datum_query)]
105 fn impl_datum(
106 &self,
107 krate: CrateId,
108 impl_id: chalk_ir::ImplId,
109 ) -> Arc<chalk_rust_ir::ImplDatum<chalk_ir::family::ChalkIr>>;
110
111 #[salsa::invoke(crate::ty::traits::chalk::associated_ty_value_query)]
112 fn associated_ty_value(
113 &self,
114 krate: CrateId,
115 id: chalk_rust_ir::AssociatedTyValueId,
116 ) -> Arc<chalk_rust_ir::AssociatedTyValue<chalk_ir::family::ChalkIr>>;
117
118 #[salsa::invoke(crate::ty::traits::trait_solve_query)]
119 fn trait_solve(
120 &self,
121 krate: CrateId,
122 goal: crate::ty::Canonical<crate::ty::InEnvironment<crate::ty::Obligation>>,
123 ) -> Option<crate::ty::traits::Solution>;
124}
125 20
126#[test] 21#[test]
127fn hir_database_is_object_safe() { 22fn hir_database_is_object_safe() {