diff options
| author | bors <bors@rust-lang.org> | 2023-02-15 20:56:07 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-02-15 20:56:07 +0000 |
| commit | c5283576ec18937d98889679a54aa8f2dee2b875 (patch) | |
| tree | 950ca5fd9d874fa9f7c990eee71df8a14e5ee58c /compiler/rustc_const_eval/src/interpret | |
| parent | 2d14db321b043ffc579a7461464c88d7e3f54f83 (diff) | |
| parent | b096f0e0f01f9cc1f13d4d664fda93f9efe95485 (diff) | |
| download | rust-c5283576ec18937d98889679a54aa8f2dee2b875.tar.gz rust-c5283576ec18937d98889679a54aa8f2dee2b875.zip | |
Auto merge of #108012 - compiler-errors:issue-107999, r=oli-obk
Don't ICE in `might_permit_raw_init` if reference is polymorphic Emitting optimized MIR for a polymorphic function may require computing layout of a type that isn't (yet) known. This happens in the instcombine pass, for example. Let's fail gracefully in that condition. cc `@saethlin` fixes #107999
Diffstat (limited to 'compiler/rustc_const_eval/src/interpret')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/intrinsics.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics.rs b/compiler/rustc_const_eval/src/interpret/intrinsics.rs index 907f014dfb5..14cb83eb709 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics.rs @@ -448,7 +448,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { } if intrinsic_name == sym::assert_zero_valid { - let should_panic = !self.tcx.permits_zero_init(self.param_env.and(layout)); + let should_panic = !self + .tcx + .permits_zero_init(self.param_env.and(ty)) + .map_err(|_| err_inval!(TooGeneric))?; if should_panic { M::abort( @@ -462,7 +465,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { } if intrinsic_name == sym::assert_mem_uninitialized_valid { - let should_panic = !self.tcx.permits_uninit_init(self.param_env.and(layout)); + let should_panic = !self + .tcx + .permits_uninit_init(self.param_env.and(ty)) + .map_err(|_| err_inval!(TooGeneric))?; if should_panic { M::abort( |
