1
Fork 0

Decouple trait impls of different traits wrt incremental

This commit is contained in:
Oli Scherer 2025-03-27 11:48:06 +00:00
parent 97ea17b71a
commit a7b687c26e
5 changed files with 14 additions and 6 deletions

View file

@ -368,7 +368,7 @@ impl<'tcx> TyCtxt<'tcx> {
}
pub fn hir_trait_impls(self, trait_did: DefId) -> &'tcx [LocalDefId] {
self.all_local_trait_impls(()).get(&trait_did).map_or(&[], |xs| &xs[..])
self.local_trait_impls(trait_did)
}
/// Gets the attributes on the crate. This is preferable to

View file

@ -238,6 +238,8 @@ pub fn provide(providers: &mut Providers) {
}
};
providers.all_local_trait_impls = |tcx, ()| &tcx.resolutions(()).trait_impls;
providers.local_trait_impls =
|tcx, trait_id| tcx.resolutions(()).trait_impls.get(&trait_id).map_or(&[], |xs| &xs[..]);
providers.expn_that_defined =
|tcx, id| tcx.resolutions(()).expn_that_defined.get(&id).copied().unwrap_or(ExpnId::root());
providers.in_scope_traits_map = |tcx, id| {

View file

@ -1502,6 +1502,11 @@ rustc_queries! {
desc { "finding local trait impls" }
}
/// Return all `impl` blocks of the given trait in the current crate.
query local_trait_impls(trait_id: DefId) -> &'tcx [LocalDefId] {
desc { "finding local trait impls of `{}`", tcx.def_path_str(trait_id) }
}
/// Given a trait `trait_id`, return all known `impl` blocks.
query trait_impls_of(trait_id: DefId) -> &'tcx ty::trait_def::TraitImpls {
arena_cache