From af8a6049a50809b0f375ec66d1636a5703c83568 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Wed, 14 Apr 2021 19:11:17 +0300 Subject: Profile trait solving for all invocations --- crates/hir_ty/src/autoderef.rs | 5 +---- crates/hir_ty/src/db.rs | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 5 deletions(-) (limited to 'crates/hir_ty') diff --git a/crates/hir_ty/src/autoderef.rs b/crates/hir_ty/src/autoderef.rs index 6d2cf4619..2c07494a9 100644 --- a/crates/hir_ty/src/autoderef.rs +++ b/crates/hir_ty/src/autoderef.rs @@ -85,10 +85,7 @@ fn deref_by_trait( environment: ty.environment.clone(), }, }; - if { - let _p = profile::span("db.trait_solve"); - db.trait_solve(krate, implements_goal).is_none() - } { + if db.trait_solve(krate, implements_goal).is_none() { return None; } diff --git a/crates/hir_ty/src/db.rs b/crates/hir_ty/src/db.rs index 1690926ad..cf67d4266 100644 --- a/crates/hir_ty/src/db.rs +++ b/crates/hir_ty/src/db.rs @@ -128,13 +128,21 @@ pub trait HirDatabase: DefDatabase + Upcast { id: chalk_db::AssociatedTyValueId, ) -> Arc; - #[salsa::invoke(crate::traits::trait_solve_query)] + #[salsa::invoke(trait_solve_wait)] + #[salsa::transparent] fn trait_solve( &self, krate: CrateId, goal: crate::Canonical>, ) -> Option; + #[salsa::invoke(crate::traits::trait_solve_query)] + fn trait_solve_query( + &self, + krate: CrateId, + goal: crate::Canonical>, + ) -> Option; + #[salsa::invoke(chalk_db::program_clauses_for_chalk_env_query)] fn program_clauses_for_chalk_env( &self, @@ -156,6 +164,15 @@ fn infer_wait(db: &dyn HirDatabase, def: DefWithBodyId) -> Arc db.infer_query(def) } +fn trait_solve_wait( + db: &dyn HirDatabase, + krate: CrateId, + goal: crate::Canonical>, +) -> Option { + let _p = profile::span("trait_solve::wait"); + db.trait_solve_query(krate, goal) +} + #[test] fn hir_database_is_object_safe() { fn _assert_object_safe(_: &dyn HirDatabase) {} -- cgit v1.2.3