@@ -14,7 +14,7 @@ use rustc_target::abi::{VariantIdx, Variants};
14
14
use super :: {
15
15
alloc_range, from_known_layout, mir_assign_valid_types, AllocId , ConstValue , Frame , GlobalId ,
16
16
InterpCx , InterpResult , MPlaceTy , Machine , MemPlace , MemPlaceMeta , Place , PlaceTy , Pointer ,
17
- PointerArithmetic , Provenance , Scalar , ScalarMaybeUninit ,
17
+ Provenance , Scalar , ScalarMaybeUninit ,
18
18
} ;
19
19
20
20
/// An `Immediate` represents a single immediate self-contained Rust value.
@@ -363,17 +363,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
363
363
Abi :: Scalar ( s) if force => Some ( s. primitive ( ) ) ,
364
364
_ => None ,
365
365
} ;
366
- let read_provenance = |s : abi:: Primitive , size| {
367
- // Should be just `s.is_ptr()`, but we support a Miri flag that accepts more
368
- // questionable ptr-int transmutes.
369
- let number_may_have_provenance = !M :: enforce_number_no_provenance ( self ) ;
370
- s. is_ptr ( ) || ( number_may_have_provenance && size == self . pointer_size ( ) )
371
- } ;
372
366
if let Some ( s) = scalar_layout {
373
367
let size = s. size ( self ) ;
374
368
assert_eq ! ( size, mplace. layout. size, "abi::Scalar size does not match layout size" ) ;
375
- let scalar =
376
- alloc . read_scalar ( alloc_range ( Size :: ZERO , size) , read_provenance ( s , size ) ) ?;
369
+ let scalar = alloc
370
+ . read_scalar ( alloc_range ( Size :: ZERO , size) , /* read_provenance*/ s . is_ptr ( ) ) ?;
377
371
return Ok ( Some ( ImmTy { imm : scalar. into ( ) , layout : mplace. layout } ) ) ;
378
372
}
379
373
let scalar_pair_layout = match mplace. layout . abi {
@@ -391,10 +385,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
391
385
let ( a_size, b_size) = ( a. size ( self ) , b. size ( self ) ) ;
392
386
let b_offset = a_size. align_to ( b. align ( self ) . abi ) ;
393
387
assert ! ( b_offset. bytes( ) > 0 ) ; // in `operand_field` we use the offset to tell apart the fields
394
- let a_val =
395
- alloc. read_scalar ( alloc_range ( Size :: ZERO , a_size) , read_provenance ( a, a_size) ) ?;
396
- let b_val =
397
- alloc. read_scalar ( alloc_range ( b_offset, b_size) , read_provenance ( b, b_size) ) ?;
388
+ let a_val = alloc. read_scalar (
389
+ alloc_range ( Size :: ZERO , a_size) ,
390
+ /*read_provenance*/ a. is_ptr ( ) ,
391
+ ) ?;
392
+ let b_val = alloc
393
+ . read_scalar ( alloc_range ( b_offset, b_size) , /*read_provenance*/ b. is_ptr ( ) ) ?;
398
394
return Ok ( Some ( ImmTy {
399
395
imm : Immediate :: ScalarPair ( a_val, b_val) ,
400
396
layout : mplace. layout ,
@@ -459,7 +455,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
459
455
& self ,
460
456
op : & OpTy < ' tcx , M :: Provenance > ,
461
457
) -> InterpResult < ' tcx , Pointer < Option < M :: Provenance > > > {
462
- self . scalar_to_ptr ( self . read_scalar ( op) ?. check_init ( ) ? )
458
+ self . read_scalar ( op) ?. to_pointer ( self )
463
459
}
464
460
465
461
/// Turn the wide MPlace into a string (must already be dereferenced!)
0 commit comments