about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-07-21 08:23:19 +0000
committerbors <bors@rust-lang.org>2022-07-21 08:23:19 +0000
commit84a6fac37ad61ff512993ee64b47deff9a52c560 (patch)
treea9424f32898d4584e141607f92589ce908de385a
parent2f6c39005c62d2fd35d031328f8a6c71875eb2ad (diff)
parentcfad882745f0425f0d6df44fa1f22f7f9a2a2509 (diff)
downloadrust-84a6fac37ad61ff512993ee64b47deff9a52c560.tar.gz
rust-84a6fac37ad61ff512993ee64b47deff9a52c560.zip
Auto merge of #12841 - Veykril:query-fix, r=Veykril
fix: Fix `trait_impls_in_deps_query` being called directly instead of as a query

Fixes the inlay hint performance regression introdcuced by https://github.com/rust-analyzer/rust-analyzer/issues/12549
-rw-r--r--crates/hir-ty/src/db.rs2
-rw-r--r--crates/hir-ty/src/lib.rs4
-rw-r--r--crates/hir-ty/src/lower.rs2
-rw-r--r--crates/hir-ty/src/method_resolution.rs9
4 files changed, 8 insertions, 9 deletions
diff --git a/crates/hir-ty/src/db.rs b/crates/hir-ty/src/db.rs
index de4c1535902..b385b1cafae 100644
--- a/crates/hir-ty/src/db.rs
+++ b/crates/hir-ty/src/db.rs
@@ -53,7 +53,7 @@ pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> {
     #[salsa::invoke(crate::lower::field_types_query)]
     fn field_types(&self, var: VariantId) -> Arc<ArenaMap<LocalFieldId, Binders<Ty>>>;
 
-    #[salsa::invoke(crate::callable_item_sig)]
+    #[salsa::invoke(crate::lower::callable_item_sig)]
     fn callable_item_signature(&self, def: CallableDefId) -> PolyFnSig;
 
     #[salsa::invoke(crate::lower::return_type_impl_traits)]
diff --git a/crates/hir-ty/src/lib.rs b/crates/hir-ty/src/lib.rs
index 125b3d7de86..5a5d610e360 100644
--- a/crates/hir-ty/src/lib.rs
+++ b/crates/hir-ty/src/lib.rs
@@ -54,8 +54,8 @@ pub use infer::{
 };
 pub use interner::Interner;
 pub use lower::{
-    associated_type_shorthand_candidates, callable_item_sig, CallableDefId, ImplTraitLoweringMode,
-    TyDefId, TyLoweringContext, ValueTyDefId,
+    associated_type_shorthand_candidates, CallableDefId, ImplTraitLoweringMode, TyDefId,
+    TyLoweringContext, ValueTyDefId,
 };
 pub use mapping::{
     from_assoc_type_id, from_chalk_trait_id, from_foreign_def_id, from_placeholder_idx,
diff --git a/crates/hir-ty/src/lower.rs b/crates/hir-ty/src/lower.rs
index a9420514a2b..3ed9c941f47 100644
--- a/crates/hir-ty/src/lower.rs
+++ b/crates/hir-ty/src/lower.rs
@@ -1033,7 +1033,7 @@ fn count_impl_traits(type_ref: &TypeRef) -> usize {
 }
 
 /// Build the signature of a callable item (function, struct or enum variant).
-pub fn callable_item_sig(db: &dyn HirDatabase, def: CallableDefId) -> PolyFnSig {
+pub(crate) fn callable_item_sig(db: &dyn HirDatabase, def: CallableDefId) -> PolyFnSig {
     match def {
         CallableDefId::FunctionId(f) => fn_sig_for_fn(db, f),
         CallableDefId::StructId(s) => fn_sig_for_struct_constructor(db, s),
diff --git a/crates/hir-ty/src/method_resolution.rs b/crates/hir-ty/src/method_resolution.rs
index b5810ad0544..15df7b3dd2b 100644
--- a/crates/hir-ty/src/method_resolution.rs
+++ b/crates/hir-ty/src/method_resolution.rs
@@ -137,7 +137,7 @@ pub struct TraitImpls {
 
 impl TraitImpls {
     pub(crate) fn trait_impls_in_crate_query(db: &dyn HirDatabase, krate: CrateId) -> Arc<Self> {
-        let _p = profile::span("trait_impls_in_crate_query");
+        let _p = profile::span("trait_impls_in_crate_query").detail(|| format!("{krate:?}"));
         let mut impls = Self { map: FxHashMap::default() };
 
         let crate_def_map = db.crate_def_map(krate);
@@ -162,7 +162,7 @@ impl TraitImpls {
     }
 
     pub(crate) fn trait_impls_in_deps_query(db: &dyn HirDatabase, krate: CrateId) -> Arc<Self> {
-        let _p = profile::span("trait_impls_in_deps_query");
+        let _p = profile::span("trait_impls_in_deps_query").detail(|| format!("{krate:?}"));
         let crate_graph = db.crate_graph();
         let mut res = Self { map: FxHashMap::default() };
 
@@ -214,8 +214,7 @@ impl TraitImpls {
         for (trait_, other_map) in &other.map {
             let map = self.map.entry(*trait_).or_default();
             for (fp, impls) in other_map {
-                let vec = map.entry(*fp).or_default();
-                vec.extend(impls);
+                map.entry(*fp).or_default().extend(impls);
             }
         }
     }
@@ -584,7 +583,7 @@ pub fn lookup_impl_method(
     name: &Name,
 ) -> Option<FunctionId> {
     let self_ty_fp = TyFingerprint::for_trait_impl(self_ty)?;
-    let trait_impls = TraitImpls::trait_impls_in_deps_query(db, env.krate);
+    let trait_impls = db.trait_impls_in_deps(env.krate);
     let impls = trait_impls.for_trait_and_self_ty(trait_, self_ty_fp);
     let mut table = InferenceTable::new(db, env.clone());
     find_matching_impl(impls, &mut table, &self_ty).and_then(|data| {