3504: Normalize waiting queries names r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2020-03-06 23:18:28 +00:00 committed by GitHub
commit 48bb1c5172
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 26 additions and 31 deletions

View File

@ -1,7 +1,7 @@
//! FIXME: write short doc here
pub use hir_def::db::{
AttrsQuery, BodyQuery, BodyWithSourceMapQuery, ComputeCrateDefMapQuery, ConstDataQuery,
AttrsQuery, BodyQuery, BodyWithSourceMapQuery, ConstDataQuery, CrateDefMapQueryQuery,
CrateLangItemsQuery, DefDatabase, DefDatabaseStorage, DocumentationQuery, EnumDataQuery,
ExprScopesQuery, FunctionDataQuery, GenericParamsQuery, ImplDataQuery, InternConstQuery,
InternDatabase, InternDatabaseStorage, InternEnumQuery, InternFunctionQuery, InternImplQuery,
@ -14,10 +14,10 @@ pub use hir_expand::db::{
MacroExpandQuery, ParseMacroQuery,
};
pub use hir_ty::db::{
AssociatedTyDataQuery, AssociatedTyValueQuery, CallableItemSignatureQuery, DoInferQuery,
FieldTypesQuery, GenericDefaultsQuery, GenericPredicatesForParamQuery, GenericPredicatesQuery,
HirDatabase, HirDatabaseStorage, ImplDatumQuery, ImplSelfTyQuery, ImplTraitQuery,
ImplsForTraitQuery, ImplsInCrateQuery, InternAssocTyValueQuery, InternChalkImplQuery,
AssociatedTyDataQuery, AssociatedTyValueQuery, CallableItemSignatureQuery, FieldTypesQuery,
GenericDefaultsQuery, GenericPredicatesForParamQuery, GenericPredicatesQuery, HirDatabase,
HirDatabaseStorage, ImplDatumQuery, ImplSelfTyQuery, ImplTraitQuery, ImplsForTraitQuery,
ImplsInCrateQuery, InferQueryQuery, InternAssocTyValueQuery, InternChalkImplQuery,
InternTypeCtorQuery, StructDatumQuery, TraitDatumQuery, TraitSolveQuery, TyQuery, ValueTyQuery,
};

View File

@ -47,11 +47,11 @@ pub trait DefDatabase: InternDatabase + AstDatabase {
#[salsa::invoke(RawItems::raw_items_query)]
fn raw_items(&self, file_id: HirFileId) -> Arc<RawItems>;
#[salsa::transparent]
#[salsa::invoke(crate_def_map_wait)]
fn crate_def_map(&self, krate: CrateId) -> Arc<CrateDefMap>;
#[salsa::invoke(CrateDefMap::compute_crate_def_map_query)]
fn compute_crate_def_map(&self, krate: CrateId) -> Arc<CrateDefMap>;
#[salsa::invoke(CrateDefMap::crate_def_map_query)]
fn crate_def_map_query(&self, krate: CrateId) -> Arc<CrateDefMap>;
#[salsa::invoke(StructData::struct_data_query)]
fn struct_data(&self, id: StructId) -> Arc<StructData>;
@ -109,7 +109,7 @@ pub trait DefDatabase: InternDatabase + AstDatabase {
fn documentation(&self, def: AttrDefId) -> Option<Documentation>;
}
fn crate_def_map(db: &impl DefDatabase, krate: CrateId) -> Arc<CrateDefMap> {
let _p = profile("wait_crate_def_map");
db.compute_crate_def_map(krate)
fn crate_def_map_wait(db: &impl DefDatabase, krate: CrateId) -> Arc<CrateDefMap> {
let _p = profile("crate_def_map:wait");
db.crate_def_map_query(krate)
}

View File

@ -176,13 +176,8 @@ pub struct ModuleData {
}
impl CrateDefMap {
pub(crate) fn compute_crate_def_map_query(
// Note that this doesn't have `+ AstDatabase`!
// This gurantess that `CrateDefMap` is stable across reparses.
db: &impl DefDatabase,
krate: CrateId,
) -> Arc<CrateDefMap> {
let _p = profile("crate_def_map");
pub(crate) fn crate_def_map_query(db: &impl DefDatabase, krate: CrateId) -> Arc<CrateDefMap> {
let _p = profile("crate_def_map_query");
let def_map = {
let crate_graph = db.crate_graph();
let edition = crate_graph.edition(krate);

View File

@ -21,11 +21,11 @@ use hir_expand::name::Name;
#[salsa::query_group(HirDatabaseStorage)]
#[salsa::requires(salsa::Database)]
pub trait HirDatabase: DefDatabase {
#[salsa::transparent]
#[salsa::invoke(infer_wait)]
fn infer(&self, def: DefWithBodyId) -> Arc<InferenceResult>;
#[salsa::invoke(crate::do_infer_query)]
fn do_infer(&self, def: DefWithBodyId) -> Arc<InferenceResult>;
#[salsa::invoke(crate::infer::infer_query)]
fn infer_query(&self, def: DefWithBodyId) -> Arc<InferenceResult>;
#[salsa::invoke(crate::lower::ty_query)]
#[salsa::cycle(crate::lower::ty_recover)]
@ -103,8 +103,8 @@ pub trait HirDatabase: DefDatabase {
) -> Option<crate::traits::Solution>;
}
fn infer(db: &impl HirDatabase, def: DefWithBodyId) -> Arc<InferenceResult> {
let _p = profile("wait_infer").detail(|| match def {
fn infer_wait(db: &impl HirDatabase, def: DefWithBodyId) -> Arc<InferenceResult> {
let _p = profile("infer:wait").detail(|| match def {
DefWithBodyId::FunctionId(it) => db.function_data(it).name.to_string(),
DefWithBodyId::StaticId(it) => {
db.static_data(it).name.clone().unwrap_or_else(Name::missing).to_string()
@ -113,7 +113,7 @@ fn infer(db: &impl HirDatabase, def: DefWithBodyId) -> Arc<InferenceResult> {
db.const_data(it).name.clone().unwrap_or_else(Name::missing).to_string()
}
});
db.do_infer(def)
db.infer_query(def)
}
#[test]

View File

@ -63,8 +63,8 @@ mod pat;
mod coerce;
/// The entry point of type inference.
pub fn do_infer_query(db: &impl HirDatabase, def: DefWithBodyId) -> Arc<InferenceResult> {
let _p = profile("infer");
pub(crate) fn infer_query(db: &impl HirDatabase, def: DefWithBodyId) -> Arc<InferenceResult> {
let _p = profile("infer_query");
let resolver = def.resolver(db);
let mut ctx = InferenceContext::new(db, def, resolver);

View File

@ -26,7 +26,7 @@ pub mod traits;
pub mod method_resolution;
mod op;
mod lower;
mod infer;
pub(crate) mod infer;
pub mod display;
pub(crate) mod utils;
pub mod db;
@ -57,7 +57,7 @@ use crate::{
use display::HirDisplay;
pub use autoderef::autoderef;
pub use infer::{do_infer_query, InferTy, InferenceResult};
pub use infer::{InferTy, InferenceResult};
pub use lower::CallableDef;
pub use lower::{
callable_item_sig, ImplTraitLoweringMode, TyDefId, TyLoweringContext, ValueTyDefId,

View File

@ -279,7 +279,7 @@ impl RootDatabase {
self.query(hir::db::BodyWithSourceMapQuery).sweep(sweep);
self.query(hir::db::ExprScopesQuery).sweep(sweep);
self.query(hir::db::DoInferQuery).sweep(sweep);
self.query(hir::db::InferQueryQuery).sweep(sweep);
self.query(hir::db::BodyQuery).sweep(sweep);
}
@ -318,7 +318,7 @@ impl RootDatabase {
// DefDatabase
hir::db::RawItemsQuery
hir::db::ComputeCrateDefMapQuery
hir::db::CrateDefMapQueryQuery
hir::db::StructDataQuery
hir::db::UnionDataQuery
hir::db::EnumDataQuery
@ -350,7 +350,7 @@ impl RootDatabase {
hir::db::InternImplQuery
// HirDatabase
hir::db::DoInferQuery
hir::db::InferQueryQuery
hir::db::TyQuery
hir::db::ValueTyQuery
hir::db::ImplSelfTyQuery