@@ -319,6 +319,7 @@ impl<'tcx, Prov: Provenance> ImmTy<'tcx, Prov> {
319319 // some fieldless enum variants can have non-zero size but still `Aggregate` ABI... try
320320 // to detect those here and also give them no data
321321 _ if matches ! ( layout. abi, Abi :: Aggregate { .. } )
322+ && matches ! ( layout. variants, abi:: Variants :: Single { .. } )
322323 && matches ! ( & layout. fields, abi:: FieldsShape :: Arbitrary { offsets, .. } if offsets. len( ) == 0 ) =>
323324 {
324325 Immediate :: Uninit
@@ -328,8 +329,9 @@ impl<'tcx, Prov: Provenance> ImmTy<'tcx, Prov> {
328329 assert_eq ! ( offset. bytes( ) , 0 ) ;
329330 assert ! (
330331 match ( self . layout. abi, layout. abi) {
331- ( Abi :: Scalar ( ..) , Abi :: Scalar ( ..) ) => true ,
332- ( Abi :: ScalarPair ( ..) , Abi :: ScalarPair ( ..) ) => true ,
332+ ( Abi :: Scalar ( l) , Abi :: Scalar ( r) ) => l. size( cx) == r. size( cx) ,
333+ ( Abi :: ScalarPair ( l1, l2) , Abi :: ScalarPair ( r1, r2) ) =>
334+ l1. size( cx) == r1. size( cx) && l2. size( cx) == r2. size( cx) ,
333335 _ => false ,
334336 } ,
335337 "cannot project into {} immediate with equally-sized field {}\n outer ABI: {:#?}\n field ABI: {:#?}" ,
@@ -344,16 +346,23 @@ impl<'tcx, Prov: Provenance> ImmTy<'tcx, Prov> {
344346 ( Immediate :: ScalarPair ( a_val, b_val) , Abi :: ScalarPair ( a, b) ) => {
345347 assert_matches ! ( layout. abi, Abi :: Scalar ( ..) ) ;
346348 Immediate :: from ( if offset. bytes ( ) == 0 {
347- debug_assert_eq ! ( layout. size, a. size( cx) ) ;
349+ // It is "okay" to transmute from `usize` to a pointer (GVN relies on that).
350+ // So only compare the size.
351+ assert_eq ! ( layout. size, a. size( cx) ) ;
348352 a_val
349353 } else {
350- debug_assert_eq ! ( offset, a. size( cx) . align_to( b. align( cx) . abi) ) ;
351- debug_assert_eq ! ( layout. size, b. size( cx) ) ;
354+ assert_eq ! ( offset, a. size( cx) . align_to( b. align( cx) . abi) ) ;
355+ assert_eq ! ( layout. size, b. size( cx) ) ;
352356 b_val
353357 } )
354358 }
355359 // everything else is a bug
356- _ => bug ! ( "invalid field access on immediate {}, layout {:#?}" , self , self . layout) ,
360+ _ => bug ! (
361+ "invalid field access on immediate {} at offset {}, original layout {:#?}" ,
362+ self ,
363+ offset. bytes( ) ,
364+ self . layout
365+ ) ,
357366 } ;
358367
359368 ImmTy :: from_immediate ( inner_val, layout)
0 commit comments