about summary refs log tree commit diff
path: root/compiler/rustc_interface/src/passes.rs
diff options
context:
space:
mode:
authorOli Scherer <github333195615777966@oli-obk.de>2025-05-13 08:49:32 +0000
committerOli Scherer <github333195615777966@oli-obk.de>2025-05-13 08:55:32 +0000
commit34976ac9fe6bd46ca02631512a27cb8995b2c1ac (patch)
tree17c9242244532105bc540b8aee7e6f58ac644cb9 /compiler/rustc_interface/src/passes.rs
parent32d23857f168a71bd0e77b17c0984b567461f7dc (diff)
downloadrust-34976ac9fe6bd46ca02631512a27cb8995b2c1ac.tar.gz
rust-34976ac9fe6bd46ca02631512a27cb8995b2c1ac.zip
Invoke a query only when it doesn't return immediately anyway
Diffstat (limited to 'compiler/rustc_interface/src/passes.rs')
-rw-r--r--compiler/rustc_interface/src/passes.rs5
1 files changed, 2 insertions, 3 deletions
diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs
index 7ed32d559c3..b554cc715fe 100644
--- a/compiler/rustc_interface/src/passes.rs
+++ b/compiler/rustc_interface/src/passes.rs
@@ -996,10 +996,9 @@ fn run_required_analyses(tcx: TyCtxt<'_>) {
 
     sess.time("MIR_borrow_checking", || {
         tcx.par_hir_body_owners(|def_id| {
-            // Run unsafety check because it's responsible for stealing and
-            // deallocating THIR.
-            tcx.ensure_ok().check_unsafety(def_id);
             if !tcx.is_typeck_child(def_id.to_def_id()) {
+                // Child unsafety and borrowck happens together with the parent
+                tcx.ensure_ok().check_unsafety(def_id);
                 tcx.ensure_ok().mir_borrowck(def_id)
             }
         });