diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-04-14 21:53:27 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-04-14 21:53:27 +0100 |
commit | e131bfc747df1b21ae6ea04eb9c55001e06b7bf0 (patch) | |
tree | 10d0173b20dd96e0884d677181139e651b511f3f /crates/hir_ty/src | |
parent | 678af4106504913ea04672e29f452861d97fae18 (diff) | |
parent | af8a6049a50809b0f375ec66d1636a5703c83568 (diff) |
Merge #8515
8515: internal: Profile trait solving for all invocations r=flodiebold a=SomeoneToIgnore
Follow-up of https://github.com/rust-analyzer/rust-analyzer/pull/8514#issuecomment-819610492
Co-authored-by: Kirill Bulatov <[email protected]>
Diffstat (limited to 'crates/hir_ty/src')
-rw-r--r-- | crates/hir_ty/src/autoderef.rs | 5 | ||||
-rw-r--r-- | crates/hir_ty/src/db.rs | 19 |
2 files changed, 19 insertions, 5 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 | ||
167 | fn 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] |
160 | fn hir_database_is_object_safe() { | 177 | fn hir_database_is_object_safe() { |
161 | fn _assert_object_safe(_: &dyn HirDatabase) {} | 178 | fn _assert_object_safe(_: &dyn HirDatabase) {} |