about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis/src/coherence/mod.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-02-12 07:28:13 +0000
committerbors <bors@rust-lang.org>2024-02-12 07:28:13 +0000
commitaebf4511e919e8df6db8a9217fd56316a9f8a38f (patch)
tree9223c587594db48cf5e503397c62ea8505c9efaf /compiler/rustc_hir_analysis/src/coherence/mod.rs
parentde4d615e6b86f7ef6deacd24610b0678230b8af3 (diff)
parent614ff0fae999f3aeff6024413993c58453b11d96 (diff)
downloadrust-aebf4511e919e8df6db8a9217fd56316a9f8a38f.tar.gz
rust-aebf4511e919e8df6db8a9217fd56316a9f8a38f.zip
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
Diffstat (limited to 'compiler/rustc_hir_analysis/src/coherence/mod.rs')
-rw-r--r--compiler/rustc_hir_analysis/src/coherence/mod.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/rustc_hir_analysis/src/coherence/mod.rs b/compiler/rustc_hir_analysis/src/coherence/mod.rs
index c52448c60b9..7f59763f2a0 100644
--- a/compiler/rustc_hir_analysis/src/coherence/mod.rs
+++ b/compiler/rustc_hir_analysis/src/coherence/mod.rs
@@ -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`.