@@ -159,7 +159,15 @@ impl<'tcx, Prov: Provenance> ImmTy<'tcx, Prov> {
159
159
160
160
#[ inline( always) ]
161
161
pub fn from_immediate ( imm : Immediate < Prov > , layout : TyAndLayout < ' tcx > ) -> Self {
162
- debug_assert ! ( layout. is_sized( ) , "immediates must be sized" ) ;
162
+ debug_assert ! (
163
+ match ( imm, layout. abi) {
164
+ ( Immediate :: Scalar ( ..) , Abi :: Scalar ( ..) ) => true ,
165
+ ( Immediate :: ScalarPair ( ..) , Abi :: ScalarPair ( ..) ) => true ,
166
+ ( Immediate :: Uninit , _) if layout. is_sized( ) => true ,
167
+ _ => false ,
168
+ } ,
169
+ "immediate {imm:?} does not fit to layout {layout:?}" ,
170
+ ) ;
163
171
ImmTy { imm, layout }
164
172
}
165
173
@@ -448,7 +456,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
448
456
alloc_range ( Size :: ZERO , size) ,
449
457
/*read_provenance*/ matches ! ( s, abi:: Pointer ( _) ) ,
450
458
) ?;
451
- Some ( ImmTy { imm : scalar . into ( ) , layout : mplace. layout } )
459
+ Some ( ImmTy :: from_scalar ( scalar , mplace. layout ) )
452
460
}
453
461
Abi :: ScalarPair (
454
462
abi:: Scalar :: Initialized { value : a, .. } ,
@@ -468,7 +476,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
468
476
alloc_range ( b_offset, b_size) ,
469
477
/*read_provenance*/ matches ! ( b, abi:: Pointer ( _) ) ,
470
478
) ?;
471
- Some ( ImmTy { imm : Immediate :: ScalarPair ( a_val, b_val) , layout : mplace. layout } )
479
+ Some ( ImmTy :: from_immediate ( Immediate :: ScalarPair ( a_val, b_val) , mplace. layout ) )
472
480
}
473
481
_ => {
474
482
// Neither a scalar nor scalar pair.
0 commit comments