@@ -291,24 +291,30 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
291291 . collect :: < Option < Vec < _ > > > ( ) ?;
292292 let variant = if ty. is_enum ( ) { Some ( variant) } else { None } ;
293293 let ty = self . ecx . layout_of ( ty) . ok ( ) ?;
294- let alloc_id = self
295- . ecx
296- . intern_with_temp_alloc ( ty, |ecx, dest| {
297- let variant_dest = if let Some ( variant) = variant {
298- ecx. project_downcast ( dest, variant) ?
299- } else {
300- dest. clone ( )
301- } ;
302- for ( field_index, op) in fields. into_iter ( ) . enumerate ( ) {
303- let field_dest = ecx. project_field ( & variant_dest, field_index) ?;
304- ecx. copy_op ( op, & field_dest, /*allow_transmute*/ false ) ?;
305- }
306- ecx. write_discriminant ( variant. unwrap_or ( FIRST_VARIANT ) , dest)
307- } )
308- . ok ( ) ?;
309- let mplace =
310- self . ecx . raw_const_to_mplace ( ConstAlloc { alloc_id, ty : ty. ty } ) . ok ( ) ?;
311- mplace. into ( )
294+ if ty. is_zst ( ) {
295+ ImmTy :: uninit ( ty) . into ( )
296+ } else if matches ! ( ty. abi, Abi :: Scalar ( ..) | Abi :: ScalarPair ( ..) ) {
297+ let alloc_id = self
298+ . ecx
299+ . intern_with_temp_alloc ( ty, |ecx, dest| {
300+ let variant_dest = if let Some ( variant) = variant {
301+ ecx. project_downcast ( dest, variant) ?
302+ } else {
303+ dest. clone ( )
304+ } ;
305+ for ( field_index, op) in fields. into_iter ( ) . enumerate ( ) {
306+ let field_dest = ecx. project_field ( & variant_dest, field_index) ?;
307+ ecx. copy_op ( op, & field_dest, /*allow_transmute*/ false ) ?;
308+ }
309+ ecx. write_discriminant ( variant. unwrap_or ( FIRST_VARIANT ) , dest)
310+ } )
311+ . ok ( ) ?;
312+ let mplace =
313+ self . ecx . raw_const_to_mplace ( ConstAlloc { alloc_id, ty : ty. ty } ) . ok ( ) ?;
314+ mplace. into ( )
315+ } else {
316+ return None ;
317+ }
312318 }
313319
314320 Projection ( base, elem) => {
0 commit comments