Skip to content

Commit c9db1f8

Browse files
committed
Auto merge of rust-lang#115012 - Zoxc:thir-check-root, r=cjgillot
Ensure that THIR unsafety check is done before stealing it This ensures that THIR unsafety check is done before stealing it by running it on the typeck root instead of on a closure, which does nothing. Fixes rust-lang#111520
2 parents 4410868 + 4170ca4 commit c9db1f8

File tree

1 file changed

+2
-1
lines changed
  • compiler/rustc_mir_build/src/build

1 file changed

+2
-1
lines changed

compiler/rustc_mir_build/src/build/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ pub(crate) fn closure_saved_names_of_captured_variables<'tcx>(
5656
/// Construct the MIR for a given `DefId`.
5757
fn mir_build(tcx: TyCtxt<'_>, def: LocalDefId) -> Body<'_> {
5858
// Ensure unsafeck and abstract const building is ran before we steal the THIR.
59-
tcx.ensure_with_value().thir_check_unsafety(def);
59+
tcx.ensure_with_value()
60+
.thir_check_unsafety(tcx.typeck_root_def_id(def.to_def_id()).expect_local());
6061
tcx.ensure_with_value().thir_abstract_const(def);
6162
if let Err(e) = tcx.check_match(def) {
6263
return construct_error(tcx, def, e);

0 commit comments

Comments
 (0)