@@ -284,24 +284,30 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
284284 . collect :: < Option < Vec < _ > > > ( ) ?;
285285 let variant = if ty. is_enum ( ) { Some ( variant) } else { None } ;
286286 let ty = self . ecx . layout_of ( ty) . ok ( ) ?;
287- let alloc_id = self
288- . ecx
289- . intern_with_temp_alloc ( ty, |ecx, dest| {
290- let variant_dest = if let Some ( variant) = variant {
291- ecx. project_downcast ( dest, variant) ?
292- } else {
293- dest. clone ( )
294- } ;
295- for ( field_index, op) in fields. into_iter ( ) . enumerate ( ) {
296- let field_dest = ecx. project_field ( & variant_dest, field_index) ?;
297- ecx. copy_op ( op, & field_dest, /*allow_transmute*/ false ) ?;
298- }
299- ecx. write_discriminant ( variant. unwrap_or ( FIRST_VARIANT ) , dest)
300- } )
301- . ok ( ) ?;
302- let mplace =
303- self . ecx . raw_const_to_mplace ( ConstAlloc { alloc_id, ty : ty. ty } ) . ok ( ) ?;
304- mplace. into ( )
287+ if ty. is_zst ( ) {
288+ ImmTy :: uninit ( ty) . into ( )
289+ } else if matches ! ( ty. abi, Abi :: Scalar ( ..) | Abi :: ScalarPair ( ..) ) {
290+ let alloc_id = self
291+ . ecx
292+ . intern_with_temp_alloc ( ty, |ecx, dest| {
293+ let variant_dest = if let Some ( variant) = variant {
294+ ecx. project_downcast ( dest, variant) ?
295+ } else {
296+ dest. clone ( )
297+ } ;
298+ for ( field_index, op) in fields. into_iter ( ) . enumerate ( ) {
299+ let field_dest = ecx. project_field ( & variant_dest, field_index) ?;
300+ ecx. copy_op ( op, & field_dest, /*allow_transmute*/ false ) ?;
301+ }
302+ ecx. write_discriminant ( variant. unwrap_or ( FIRST_VARIANT ) , dest)
303+ } )
304+ . ok ( ) ?;
305+ let mplace =
306+ self . ecx . raw_const_to_mplace ( ConstAlloc { alloc_id, ty : ty. ty } ) . ok ( ) ?;
307+ mplace. into ( )
308+ } else {
309+ return None ;
310+ }
305311 }
306312
307313 Projection ( base, elem) => {
0 commit comments