aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-04-14 15:20:13 +0100
committerGitHub <[email protected]>2021-04-14 15:20:13 +0100
commit678af4106504913ea04672e29f452861d97fae18 (patch)
tree359cb4c3a3ef739ff9fa4a84987f5354e1bde679 /crates/hir_ty
parent10a243ea55565a0dd1de52f8f802c3e3a7bfef54 (diff)
parent75a2605361e497cdb6f8c8a4056a6ecd1e35ad68 (diff)
Merge #8514
8514: Add more profiling spans into type inference r=matklad a=SomeoneToIgnore Fixes https://github.com/rust-analyzer/rust-analyzer/issues/8503 I've added a minimal set of spans to remove `???` and showcase the underlying issue: <img width="1552" alt="image" src="https://user-images.githubusercontent.com/2690773/114722983-f2181900-9d42-11eb-821d-9e93ded5f81f.png"> `db.trait_solve` reliably produces the same timings for the same input in the same place for me, despite supposedly being cached by Salsa. In my perception, this is a bit odd, so I've decided to stop at this point and discuss it with people with better knowledge on the topic. Co-authored-by: Kirill Bulatov <[email protected]>
Diffstat (limited to 'crates/hir_ty')
-rw-r--r--crates/hir_ty/src/autoderef.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/crates/hir_ty/src/autoderef.rs b/crates/hir_ty/src/autoderef.rs
index 71bc436e6..6d2cf4619 100644
--- a/crates/hir_ty/src/autoderef.rs
+++ b/crates/hir_ty/src/autoderef.rs
@@ -36,6 +36,7 @@ pub(crate) fn deref(
36 krate: CrateId, 36 krate: CrateId,
37 ty: InEnvironment<&Canonical<Ty>>, 37 ty: InEnvironment<&Canonical<Ty>>,
38) -> Option<Canonical<Ty>> { 38) -> Option<Canonical<Ty>> {
39 let _p = profile::span("deref");
39 if let Some(derefed) = builtin_deref(&ty.goal.value) { 40 if let Some(derefed) = builtin_deref(&ty.goal.value) {
40 Some(Canonical { value: derefed, binders: ty.goal.binders.clone() }) 41 Some(Canonical { value: derefed, binders: ty.goal.binders.clone() })
41 } else { 42 } else {
@@ -56,6 +57,7 @@ fn deref_by_trait(
56 krate: CrateId, 57 krate: CrateId,
57 ty: InEnvironment<&Canonical<Ty>>, 58 ty: InEnvironment<&Canonical<Ty>>,
58) -> Option<Canonical<Ty>> { 59) -> Option<Canonical<Ty>> {
60 let _p = profile::span("deref_by_trait");
59 let deref_trait = match db.lang_item(krate, "deref".into())? { 61 let deref_trait = match db.lang_item(krate, "deref".into())? {
60 LangItemTarget::TraitId(it) => it, 62 LangItemTarget::TraitId(it) => it,
61 _ => return None, 63 _ => return None,
@@ -83,7 +85,10 @@ fn deref_by_trait(
83 environment: ty.environment.clone(), 85 environment: ty.environment.clone(),
84 }, 86 },
85 }; 87 };
86 if db.trait_solve(krate, implements_goal).is_none() { 88 if {
89 let _p = profile::span("db.trait_solve");
90 db.trait_solve(krate, implements_goal).is_none()
91 } {
87 return None; 92 return None;
88 } 93 }
89 94