@@ -398,22 +398,27 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
398398 } ;
399399
400400 let field_layout = base. layout . field ( self , field) ;
401- if field_layout. is_zst ( ) {
402- let immediate = Scalar :: ZST . into ( ) ;
403- return Ok ( OpTy { op : Operand :: Immediate ( immediate) , layout : field_layout } ) ;
404- }
405-
406401 let offset = base. layout . fields . offset ( field) ;
407402 // This makes several assumptions about what layouts we will encounter; we match what
408403 // codegen does as good as we can (see `extract_field` in `rustc_codegen_ssa/src/mir/operand.rs`).
409- let field_val = match ( * base, base. layout . abi ) {
404+ let field_val: Immediate < _ > = match ( * base, base. layout . abi ) {
405+ // the field contains no information
406+ _ if field_layout. is_zst ( ) => {
407+ Scalar :: ZST . into ( )
408+ }
410409 // the field covers the entire type
411410 _ if field_layout. size == base. layout . size => {
411+ assert ! ( match ( base. layout. abi, field_layout. abi) {
412+ ( Abi :: Scalar ( ..) , Abi :: Scalar ( ..) ) => true ,
413+ ( Abi :: ScalarPair ( ..) , Abi :: ScalarPair ( ..) ) => true ,
414+ _ => false ,
415+ } ) ;
412416 assert ! ( offset. bytes( ) == 0 ) ;
413417 * base
414418 }
415419 // extract fields from types with `ScalarPair` ABI
416420 ( Immediate :: ScalarPair ( a_val, b_val) , Abi :: ScalarPair ( a, b) ) => {
421+ assert ! ( matches!( field_layout. abi, Abi :: Scalar ( ..) ) ) ;
417422 Immediate :: from ( if offset. bytes ( ) == 0 {
418423 assert_eq ! ( field_layout. size, a. size( self ) ) ;
419424 a_val
0 commit comments