diff options
| author | bors <bors@rust-lang.org> | 2023-08-24 00:42:46 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-08-24 00:42:46 +0000 |
| commit | c9db1f804bd324d8803afcb37028f1a0ef7b8992 (patch) | |
| tree | da3e3bc15956a9520f103bc198dcdd262af6062a | |
| parent | 441086879821d554ecdfde391e767d1a954fd5e2 (diff) | |
| parent | 4170ca4be92f1a8e4bfd1d2815c12804710b7087 (diff) | |
Auto merge of #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 https://github.com/rust-lang/rust/issues/111520
| -rw-r--r-- | compiler/rustc_mir_build/src/build/mod.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/compiler/rustc_mir_build/src/build/mod.rs b/compiler/rustc_mir_build/src/build/mod.rs index 2a23a69b584..e614046e83e 100644 --- a/compiler/rustc_mir_build/src/build/mod.rs +++ b/compiler/rustc_mir_build/src/build/mod.rs @@ -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); |
