2019-09-30 03:58:53 -05:00
|
|
|
//! FIXME: write short doc here
|
|
|
|
|
2019-06-01 02:57:44 -05:00
|
|
|
use std::sync::Arc;
|
2018-11-27 18:42:26 -06:00
|
|
|
|
2019-11-24 14:48:39 -06:00
|
|
|
use ra_arena::map::ArenaMap;
|
2019-11-26 06:27:33 -06:00
|
|
|
use ra_db::{salsa, CrateId};
|
2018-11-27 18:42:26 -06:00
|
|
|
|
|
|
|
use crate::{
|
2019-07-04 15:05:17 -05:00
|
|
|
ty::{
|
2019-11-15 13:32:58 -06:00
|
|
|
method_resolution::CrateImplBlocks,
|
|
|
|
traits::{AssocTyValue, Impl},
|
2019-11-26 12:04:24 -06:00
|
|
|
CallableDef, FnSig, GenericPredicate, InferenceResult, Substs, Ty, TyDefId, TypeCtor,
|
|
|
|
ValueTyDefId,
|
2019-07-04 15:05:17 -05:00
|
|
|
},
|
2019-11-25 06:41:53 -06:00
|
|
|
Crate, DefWithBody, ImplBlock, Trait,
|
2019-10-29 06:55:39 -05:00
|
|
|
};
|
|
|
|
|
2019-11-24 14:48:39 -06:00
|
|
|
pub use hir_def::{
|
|
|
|
db::{
|
|
|
|
BodyQuery, BodyWithSourceMapQuery, ConstDataQuery, CrateDefMapQuery, CrateLangItemsQuery,
|
|
|
|
DefDatabase, DefDatabaseStorage, DocumentationQuery, EnumDataQuery, ExprScopesQuery,
|
|
|
|
FunctionDataQuery, GenericParamsQuery, ImplDataQuery, InternDatabase,
|
|
|
|
InternDatabaseStorage, LangItemQuery, ModuleLangItemsQuery, RawItemsQuery,
|
|
|
|
RawItemsWithSourceMapQuery, StaticDataQuery, StructDataQuery, TraitDataQuery,
|
|
|
|
TypeAliasDataQuery,
|
|
|
|
},
|
2019-11-25 06:39:12 -06:00
|
|
|
GenericDefId, LocalStructFieldId, VariantId,
|
2019-10-30 09:40:13 -05:00
|
|
|
};
|
2019-10-29 06:59:55 -05:00
|
|
|
pub use hir_expand::db::{
|
2019-10-29 06:55:39 -05:00
|
|
|
AstDatabase, AstDatabaseStorage, AstIdMapQuery, MacroArgQuery, MacroDefQuery, MacroExpandQuery,
|
|
|
|
ParseMacroQuery,
|
2018-11-27 18:42:26 -06:00
|
|
|
};
|
|
|
|
|
2019-01-31 08:28:31 -06:00
|
|
|
#[salsa::query_group(HirDatabaseStorage)]
|
2019-07-05 09:45:57 -05:00
|
|
|
#[salsa::requires(salsa::Database)]
|
2019-11-23 07:30:14 -06:00
|
|
|
pub trait HirDatabase: DefDatabase {
|
2019-05-21 08:24:53 -05:00
|
|
|
#[salsa::invoke(crate::ty::infer_query)]
|
2019-03-30 06:17:31 -05:00
|
|
|
fn infer(&self, def: DefWithBody) -> Arc<InferenceResult>;
|
2019-01-31 08:28:31 -06:00
|
|
|
|
2019-11-26 12:04:24 -06:00
|
|
|
#[salsa::invoke(crate::ty::ty_query)]
|
|
|
|
fn ty(&self, def: TyDefId) -> Ty;
|
|
|
|
|
|
|
|
#[salsa::invoke(crate::ty::value_ty_query)]
|
|
|
|
fn value_ty(&self, def: ValueTyDefId) -> Ty;
|
2019-01-31 08:28:31 -06:00
|
|
|
|
2019-11-24 14:48:39 -06:00
|
|
|
#[salsa::invoke(crate::ty::field_types_query)]
|
|
|
|
fn field_types(&self, var: VariantId) -> Arc<ArenaMap<LocalStructFieldId, Ty>>;
|
2019-01-31 08:28:31 -06:00
|
|
|
|
2019-03-16 11:29:55 -05:00
|
|
|
#[salsa::invoke(crate::ty::callable_item_sig)]
|
|
|
|
fn callable_item_signature(&self, def: CallableDef) -> FnSig;
|
|
|
|
|
2019-09-22 13:01:12 -05:00
|
|
|
#[salsa::invoke(crate::ty::generic_predicates_for_param_query)]
|
|
|
|
fn generic_predicates_for_param(
|
|
|
|
&self,
|
2019-11-25 06:41:53 -06:00
|
|
|
def: GenericDefId,
|
2019-09-22 13:01:12 -05:00
|
|
|
param_idx: u32,
|
|
|
|
) -> Arc<[GenericPredicate]>;
|
|
|
|
|
2019-07-06 09:41:04 -05:00
|
|
|
#[salsa::invoke(crate::ty::generic_predicates_query)]
|
2019-11-25 06:39:12 -06:00
|
|
|
fn generic_predicates(&self, def: GenericDefId) -> Arc<[GenericPredicate]>;
|
2019-05-05 07:21:00 -05:00
|
|
|
|
2019-07-06 09:41:04 -05:00
|
|
|
#[salsa::invoke(crate::ty::generic_defaults_query)]
|
2019-11-25 06:41:53 -06:00
|
|
|
fn generic_defaults(&self, def: GenericDefId) -> Substs;
|
2019-05-19 08:08:16 -05:00
|
|
|
|
2019-02-01 04:33:41 -06:00
|
|
|
#[salsa::invoke(crate::ty::method_resolution::CrateImplBlocks::impls_in_crate_query)]
|
2019-11-26 06:27:33 -06:00
|
|
|
fn impls_in_crate(&self, krate: CrateId) -> Arc<CrateImplBlocks>;
|
2019-03-24 11:37:27 -05:00
|
|
|
|
2019-05-21 04:44:08 -05:00
|
|
|
#[salsa::invoke(crate::ty::traits::impls_for_trait_query)]
|
2019-04-20 05:34:36 -05:00
|
|
|
fn impls_for_trait(&self, krate: Crate, trait_: Trait) -> Arc<[ImplBlock]>;
|
|
|
|
|
2019-05-01 10:13:33 -05:00
|
|
|
/// This provides the Chalk trait solver instance. Because Chalk always
|
|
|
|
/// works from a specific crate, this query is keyed on the crate; and
|
|
|
|
/// because Chalk does its own internal caching, the solver is wrapped in a
|
2019-07-05 09:45:57 -05:00
|
|
|
/// Mutex and the query does an untracked read internally, to make sure the
|
|
|
|
/// cached state is thrown away when input facts change.
|
2019-07-09 14:34:23 -05:00
|
|
|
#[salsa::invoke(crate::ty::traits::trait_solver_query)]
|
2019-07-05 09:45:57 -05:00
|
|
|
fn trait_solver(&self, krate: Crate) -> crate::ty::traits::TraitSolver;
|
2019-05-05 09:04:31 -05:00
|
|
|
|
2019-10-30 01:29:55 -05:00
|
|
|
// Interned IDs for Chalk integration
|
|
|
|
#[salsa::interned]
|
2019-11-24 05:25:48 -06:00
|
|
|
fn intern_type_ctor(&self, type_ctor: TypeCtor) -> crate::ty::TypeCtorId;
|
2019-10-30 01:29:55 -05:00
|
|
|
#[salsa::interned]
|
2019-11-24 05:25:48 -06:00
|
|
|
fn intern_chalk_impl(&self, impl_: Impl) -> crate::ty::traits::GlobalImplId;
|
2019-11-15 13:32:58 -06:00
|
|
|
#[salsa::interned]
|
2019-11-24 05:25:48 -06:00
|
|
|
fn intern_assoc_ty_value(
|
|
|
|
&self,
|
|
|
|
assoc_ty_value: AssocTyValue,
|
|
|
|
) -> crate::ty::traits::AssocTyValueId;
|
2019-10-30 01:29:55 -05:00
|
|
|
|
2019-06-26 04:54:13 -05:00
|
|
|
#[salsa::invoke(crate::ty::traits::chalk::associated_ty_data_query)]
|
2019-11-16 06:21:51 -06:00
|
|
|
fn associated_ty_data(
|
|
|
|
&self,
|
|
|
|
id: chalk_ir::TypeId,
|
|
|
|
) -> Arc<chalk_rust_ir::AssociatedTyDatum<chalk_ir::family::ChalkIr>>;
|
2019-06-26 04:54:13 -05:00
|
|
|
|
|
|
|
#[salsa::invoke(crate::ty::traits::chalk::trait_datum_query)]
|
|
|
|
fn trait_datum(
|
|
|
|
&self,
|
|
|
|
krate: Crate,
|
|
|
|
trait_id: chalk_ir::TraitId,
|
2019-11-16 06:21:51 -06:00
|
|
|
) -> Arc<chalk_rust_ir::TraitDatum<chalk_ir::family::ChalkIr>>;
|
2019-06-26 04:54:13 -05:00
|
|
|
|
|
|
|
#[salsa::invoke(crate::ty::traits::chalk::struct_datum_query)]
|
|
|
|
fn struct_datum(
|
|
|
|
&self,
|
|
|
|
krate: Crate,
|
|
|
|
struct_id: chalk_ir::StructId,
|
2019-11-16 06:21:51 -06:00
|
|
|
) -> Arc<chalk_rust_ir::StructDatum<chalk_ir::family::ChalkIr>>;
|
2019-06-26 04:54:13 -05:00
|
|
|
|
|
|
|
#[salsa::invoke(crate::ty::traits::chalk::impl_datum_query)]
|
2019-11-16 06:21:51 -06:00
|
|
|
fn impl_datum(
|
|
|
|
&self,
|
|
|
|
krate: Crate,
|
|
|
|
impl_id: chalk_ir::ImplId,
|
|
|
|
) -> Arc<chalk_rust_ir::ImplDatum<chalk_ir::family::ChalkIr>>;
|
2019-06-26 04:54:13 -05:00
|
|
|
|
2019-11-15 13:32:58 -06:00
|
|
|
#[salsa::invoke(crate::ty::traits::chalk::associated_ty_value_query)]
|
|
|
|
fn associated_ty_value(
|
|
|
|
&self,
|
|
|
|
krate: Crate,
|
|
|
|
id: chalk_rust_ir::AssociatedTyValueId,
|
2019-11-16 06:21:51 -06:00
|
|
|
) -> Arc<chalk_rust_ir::AssociatedTyValue<chalk_ir::family::ChalkIr>>;
|
2019-11-15 13:32:58 -06:00
|
|
|
|
2019-07-09 14:34:23 -05:00
|
|
|
#[salsa::invoke(crate::ty::traits::trait_solve_query)]
|
|
|
|
fn trait_solve(
|
2019-05-05 09:04:31 -05:00
|
|
|
&self,
|
|
|
|
krate: Crate,
|
2019-07-08 14:43:52 -05:00
|
|
|
goal: crate::ty::Canonical<crate::ty::InEnvironment<crate::ty::Obligation>>,
|
2019-05-12 10:53:44 -05:00
|
|
|
) -> Option<crate::ty::traits::Solution>;
|
2019-01-31 08:28:31 -06:00
|
|
|
}
|
2019-02-03 13:15:31 -06:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hir_database_is_object_safe() {
|
|
|
|
fn _assert_object_safe(_: &dyn HirDatabase) {}
|
|
|
|
}
|