Skip to content

Commit

Permalink
Auto merge of rust-lang#120834 - oli-obk:only_local_coherence, r=<try>
Browse files Browse the repository at this point in the history
A trait's local impls are trivially coherent if there are no impls.

This avoids creating a dependency edge on the hir or the specialization graph

This may resolve part of the performance issue of rust-lang#120558
  • Loading branch information
bors committed Feb 9, 2024
2 parents 98aa362 + 0727f9a commit 7c63899
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/coherence/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ pub fn provide(providers: &mut Providers) {
}

fn coherent_trait(tcx: TyCtxt<'_>, def_id: DefId) -> Result<(), ErrorGuaranteed> {
let Some(impls) = tcx.all_local_trait_impls(()).get(&def_id) else { return Ok(()) };
// Trigger building the specialization graph for the trait. This will detect and report any
// overlap errors.
let mut res = tcx.ensure().specialization_graph_of(def_id);

let impls = tcx.hir().trait_impls(def_id);
for &impl_def_id in impls {
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap().instantiate_identity();

Expand Down

0 comments on commit 7c63899

Please sign in to comment.