Skip to content

Commit fe326a7

Browse files
committed
Auto merge of rust-lang#140959 - oli-obk:no-unsafe-children, r=<try>
Invoke a query only when it doesn't return immediately anyway This should cause less query key caching and less dep graph data, hopefully resulting in some perf improvements
2 parents 32d2385 + 34976ac commit fe326a7

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

compiler/rustc_interface/src/passes.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -996,10 +996,9 @@ fn run_required_analyses(tcx: TyCtxt<'_>) {
996996

997997
sess.time("MIR_borrow_checking", || {
998998
tcx.par_hir_body_owners(|def_id| {
999-
// Run unsafety check because it's responsible for stealing and
1000-
// deallocating THIR.
1001-
tcx.ensure_ok().check_unsafety(def_id);
1002999
if !tcx.is_typeck_child(def_id.to_def_id()) {
1000+
// Child unsafety and borrowck happens together with the parent
1001+
tcx.ensure_ok().check_unsafety(def_id);
10031002
tcx.ensure_ok().mir_borrowck(def_id)
10041003
}
10051004
});

compiler/rustc_mir_build/src/check_unsafety.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1148,8 +1148,9 @@ impl UnsafeOpKind {
11481148

11491149
pub(crate) fn check_unsafety(tcx: TyCtxt<'_>, def: LocalDefId) {
11501150
// Closures and inline consts are handled by their owner, if it has a body
1151+
assert!(!tcx.is_typeck_child(def.to_def_id()));
11511152
// Also, don't safety check custom MIR
1152-
if tcx.is_typeck_child(def.to_def_id()) || tcx.has_attr(def, sym::custom_mir) {
1153+
if tcx.has_attr(def, sym::custom_mir) {
11531154
return;
11541155
}
11551156

0 commit comments

Comments
 (0)