aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2021-04-14 17:11:17 +0100
committerKirill Bulatov <[email protected]>2021-04-14 17:11:17 +0100
commitaf8a6049a50809b0f375ec66d1636a5703c83568 (patch)
tree10d0173b20dd96e0884d677181139e651b511f3f
parent678af4106504913ea04672e29f452861d97fae18 (diff)
Profile trait solving for all invocations
-rw-r--r--crates/hir_ty/src/autoderef.rs5
-rw-r--r--crates/hir_ty/src/db.rs19
-rw-r--r--crates/ide_db/src/apply_change.rs2
3 files changed, 20 insertions, 6 deletions
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(
85 environment: ty.environment.clone(), 85 environment: ty.environment.clone(),
86 }, 86 },
87 }; 87 };
88 if { 88 if db.trait_solve(krate, implements_goal).is_none() {
89 let _p = profile::span("db.trait_solve");
90 db.trait_solve(krate, implements_goal).is_none()
91 } {
92 return None; 89 return None;
93 } 90 }
94 91
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<dyn DefDatabase> {
128 id: chalk_db::AssociatedTyValueId, 128 id: chalk_db::AssociatedTyValueId,
129 ) -> Arc<chalk_db::AssociatedTyValue>; 129 ) -> Arc<chalk_db::AssociatedTyValue>;
130 130
131 #[salsa::invoke(crate::traits::trait_solve_query)] 131 #[salsa::invoke(trait_solve_wait)]
132 #[salsa::transparent]
132 fn trait_solve( 133 fn trait_solve(
133 &self, 134 &self,
134 krate: CrateId, 135 krate: CrateId,
135 goal: crate::Canonical<crate::InEnvironment<crate::DomainGoal>>, 136 goal: crate::Canonical<crate::InEnvironment<crate::DomainGoal>>,
136 ) -> Option<crate::Solution>; 137 ) -> Option<crate::Solution>;
137 138
139 #[salsa::invoke(crate::traits::trait_solve_query)]
140 fn trait_solve_query(
141 &self,
142 krate: CrateId,
143 goal: crate::Canonical<crate::InEnvironment<crate::DomainGoal>>,
144 ) -> Option<crate::Solution>;
145
138 #[salsa::invoke(chalk_db::program_clauses_for_chalk_env_query)] 146 #[salsa::invoke(chalk_db::program_clauses_for_chalk_env_query)]
139 fn program_clauses_for_chalk_env( 147 fn program_clauses_for_chalk_env(
140 &self, 148 &self,
@@ -156,6 +164,15 @@ fn infer_wait(db: &dyn HirDatabase, def: DefWithBodyId) -> Arc<InferenceResult>
156 db.infer_query(def) 164 db.infer_query(def)
157} 165}
158 166
167fn trait_solve_wait(
168 db: &dyn HirDatabase,
169 krate: CrateId,
170 goal: crate::Canonical<crate::InEnvironment<crate::DomainGoal>>,
171) -> Option<crate::Solution> {
172 let _p = profile::span("trait_solve::wait");
173 db.trait_solve_query(krate, goal)
174}
175
159#[test] 176#[test]
160fn hir_database_is_object_safe() { 177fn hir_database_is_object_safe() {
161 fn _assert_object_safe(_: &dyn HirDatabase) {} 178 fn _assert_object_safe(_: &dyn HirDatabase) {}
diff --git a/crates/ide_db/src/apply_change.rs b/crates/ide_db/src/apply_change.rs
index 6c67425d7..eac5ef6b9 100644
--- a/crates/ide_db/src/apply_change.rs
+++ b/crates/ide_db/src/apply_change.rs
@@ -201,7 +201,7 @@ impl RootDatabase {
201 hir::db::InternImplTraitIdQuery 201 hir::db::InternImplTraitIdQuery
202 hir::db::InternClosureQuery 202 hir::db::InternClosureQuery
203 hir::db::AssociatedTyValueQuery 203 hir::db::AssociatedTyValueQuery
204 hir::db::TraitSolveQuery 204 hir::db::TraitSolveQueryQuery
205 205
206 // SymbolsDatabase 206 // SymbolsDatabase
207 crate::symbol_index::FileSymbolsQuery 207 crate::symbol_index::FileSymbolsQuery