summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2023-02-14 00:59:40 +0000
committerMichael Goulet <michael@errs.io>2023-02-14 22:37:30 +0000
commitb096f0e0f01f9cc1f13d4d664fda93f9efe95485 (patch)
tree69998dffe386a7b1b5d54475f7125b7ae0e7547b /compiler/rustc_codegen_ssa
parent087a0136d01d0ee05d4e8c5e91f2e01978244a67 (diff)
downloadrust-b096f0e0f01f9cc1f13d4d664fda93f9efe95485.tar.gz
rust-b096f0e0f01f9cc1f13d4d664fda93f9efe95485.zip
Make permit_uninit/zero_init fallible
Diffstat (limited to 'compiler/rustc_codegen_ssa')
-rw-r--r--compiler/rustc_codegen_ssa/src/mir/block.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs
index 2623a650e07..9af408646ae 100644
--- a/compiler/rustc_codegen_ssa/src/mir/block.rs
+++ b/compiler/rustc_codegen_ssa/src/mir/block.rs
@@ -674,8 +674,14 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
             let layout = bx.layout_of(ty);
             let do_panic = match intrinsic {
                 Inhabited => layout.abi.is_uninhabited(),
-                ZeroValid => !bx.tcx().permits_zero_init(bx.param_env().and(layout)),
-                MemUninitializedValid => !bx.tcx().permits_uninit_init(bx.param_env().and(layout)),
+                ZeroValid => !bx
+                    .tcx()
+                    .permits_zero_init(bx.param_env().and(ty))
+                    .expect("expected to have layout during codegen"),
+                MemUninitializedValid => !bx
+                    .tcx()
+                    .permits_uninit_init(bx.param_env().and(ty))
+                    .expect("expected to have layout during codegen"),
             };
             Some(if do_panic {
                 let msg_str = with_no_visible_paths!({