Skip to content

Commit 7c63899

Browse files
committed
Auto merge of #120834 - oli-obk:only_local_coherence, r=<try>
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 #120558
2 parents 98aa362 + 0727f9a commit 7c63899

File tree

1 file changed

+1
-1
lines changed
  • compiler/rustc_hir_analysis/src/coherence

1 file changed

+1
-1
lines changed

compiler/rustc_hir_analysis/src/coherence/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,11 @@ pub fn provide(providers: &mut Providers) {
120120
}
121121

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

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

0 commit comments

Comments
 (0)