@@ -14,7 +14,7 @@ use rustc_target::abi::{VariantIdx, Variants};
1414use super :: {
1515 alloc_range, from_known_layout, mir_assign_valid_types, AllocId , ConstValue , Frame , GlobalId ,
1616 InterpCx , InterpResult , MPlaceTy , Machine , MemPlace , MemPlaceMeta , Place , PlaceTy , Pointer ,
17- PointerArithmetic , Provenance , Scalar , ScalarMaybeUninit ,
17+ Provenance , Scalar , ScalarMaybeUninit ,
1818} ;
1919
2020/// 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> {
363363 Abi :: Scalar ( s) if force => Some ( s. primitive ( ) ) ,
364364 _ => None ,
365365 } ;
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- } ;
372366 if let Some ( s) = scalar_layout {
373367 let size = s. size ( self ) ;
374368 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 ( ) ) ?;
377371 return Ok ( Some ( ImmTy { imm : scalar. into ( ) , layout : mplace. layout } ) ) ;
378372 }
379373 let scalar_pair_layout = match mplace. layout . abi {
@@ -391,10 +385,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
391385 let ( a_size, b_size) = ( a. size ( self ) , b. size ( self ) ) ;
392386 let b_offset = a_size. align_to ( b. align ( self ) . abi ) ;
393387 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 ( ) ) ?;
398394 return Ok ( Some ( ImmTy {
399395 imm : Immediate :: ScalarPair ( a_val, b_val) ,
400396 layout : mplace. layout ,
@@ -459,7 +455,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
459455 & self ,
460456 op : & OpTy < ' tcx , M :: Provenance > ,
461457 ) -> 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 )
463459 }
464460
465461 /// Turn the wide MPlace into a string (must already be dereferenced!)
0 commit comments