Auto merge of #120835 - oli-obk:no_hir_coherence, r=cjgillot

Avoid accessing the HIR in the happy path of `coherent_trait`

Unfortunately the hir is still used in unsafety checks, and we do not have a way to avoid that. An impl's unsafety is not part of any query other than hir.

So this PR does not affect perf, but could still be considered a cleanup
This commit is contained in:
bors 2024-02-12 07:28:13 +00:00
commit aebf4511e9
4 changed files with 116 additions and 118 deletions

View file

@ -137,11 +137,12 @@ fn coherent_trait(tcx: TyCtxt<'_>, def_id: DefId) -> Result<(), ErrorGuaranteed>
res = res.and(check_impl(tcx, impl_def_id, trait_ref));
res = res.and(check_object_overlap(tcx, impl_def_id, trait_ref));
res = res.and(unsafety::check_item(tcx, impl_def_id));
res = res.and(unsafety::check_item(tcx, impl_def_id, trait_ref));
res = res.and(tcx.ensure().orphan_check_impl(impl_def_id));
res = res.and(builtin::check_trait(tcx, def_id, impl_def_id));
}
res.and(builtin::check_trait(tcx, def_id))
res
}
/// Checks whether an impl overlaps with the automatic `impl Trait for dyn Trait`.