Skip to content

Commit

Permalink
Auto merge of rust-lang#12841 - Veykril:query-fix, r=Veykril
Browse files Browse the repository at this point in the history
fix: Fix `trait_impls_in_deps_query` being called directly instead of as a query

Fixes the inlay hint performance regression introdcuced by rust-lang/rust-analyzer#12549
  • Loading branch information
bors committed Jul 21, 2022
2 parents 2f6c390 + cfad882 commit 84a6fac
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion crates/hir-ty/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
4 changes: 2 additions & 2 deletions crates/hir-ty/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-ty/src/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
9 changes: 4 additions & 5 deletions crates/hir-ty/src/method_resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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() };

Expand Down Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -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| {
Expand Down

0 comments on commit 84a6fac

Please sign in to comment.