@@ -398,22 +398,27 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
398
398
} ;
399
399
400
400
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
-
406
401
let offset = base. layout . fields . offset ( field) ;
407
402
// This makes several assumptions about what layouts we will encounter; we match what
408
403
// 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
+ }
410
409
// the field covers the entire type
411
410
_ 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
+ } ) ;
412
416
assert ! ( offset. bytes( ) == 0 ) ;
413
417
* base
414
418
}
415
419
// extract fields from types with `ScalarPair` ABI
416
420
( Immediate :: ScalarPair ( a_val, b_val) , Abi :: ScalarPair ( a, b) ) => {
421
+ assert ! ( matches!( field_layout. abi, Abi :: Scalar ( ..) ) ) ;
417
422
Immediate :: from ( if offset. bytes ( ) == 0 {
418
423
assert_eq ! ( field_layout. size, a. size( self ) ) ;
419
424
a_val
0 commit comments