Skip to content

Commit

Permalink
Auto merge of rust-lang#115012 - Zoxc:thir-check-root, r=cjgillot
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Aug 24, 2023
2 parents 4410868 + 4170ca4 commit c9db1f8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compiler/rustc_mir_build/src/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ pub(crate) fn closure_saved_names_of_captured_variables<'tcx>(
/// Construct the MIR for a given `DefId`.
fn mir_build(tcx: TyCtxt<'_>, def: LocalDefId) -> Body<'_> {
// Ensure unsafeck and abstract const building is ran before we steal the THIR.
tcx.ensure_with_value().thir_check_unsafety(def);
tcx.ensure_with_value()
.thir_check_unsafety(tcx.typeck_root_def_id(def.to_def_id()).expect_local());
tcx.ensure_with_value().thir_abstract_const(def);
if let Err(e) = tcx.check_match(def) {
return construct_error(tcx, def, e);
Expand Down

0 comments on commit c9db1f8

Please sign in to comment.