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
This commit is contained in:
commit
c5283576ec
11 changed files with 116 additions and 56 deletions
|
@ -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!({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue