@@ -264,13 +264,12 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
264264 Some ( ( size, _align) ) => size,
265265 None => self . get_raw ( ptr. alloc_id ) ?. size ( ) ,
266266 } ;
267- let align = Align :: from_bytes ( 1 ) . unwrap ( ) ;
268267 // This will also call the access hooks.
269268 self . copy (
270269 ptr. into ( ) ,
271- align ,
270+ Align :: ONE ,
272271 new_ptr. into ( ) ,
273- align ,
272+ Align :: ONE ,
274273 old_size. min ( new_size) ,
275274 /*nonoverlapping*/ true ,
276275 ) ?;
@@ -379,10 +378,10 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
379378 & self ,
380379 sptr : Scalar < M :: PointerTag > ,
381380 size : Size ,
382- align : Option < Align > ,
381+ align : Align ,
383382 msg : CheckInAllocMsg ,
384383 ) -> InterpResult < ' tcx > {
385- self . check_and_deref_ptr ( sptr, size, align, msg, |ptr| {
384+ self . check_and_deref_ptr ( sptr, size, Some ( align) , msg, |ptr| {
386385 let ( size, align) =
387386 self . get_size_and_align ( ptr. alloc_id , AllocCheck :: Dereferenceable ) ?;
388387 Ok ( ( size, align, ( ) ) )
@@ -604,6 +603,11 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
604603 }
605604 }
606605
606+ /// Return the `extra` field of the given allocation.
607+ pub fn get_alloc_extra < ' a > ( & ' a self , id : AllocId ) -> InterpResult < ' tcx , & ' a M :: AllocExtra > {
608+ Ok ( & self . get_raw ( id) ?. extra )
609+ }
610+
607611 /// Gives raw mutable access to the `Allocation`, without bounds or alignment checks.
608612 /// The caller is responsible for calling the access hooks!
609613 ///
@@ -664,6 +668,14 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
664668 }
665669 }
666670
671+ /// Return the `extra` field of the given allocation.
672+ pub fn get_alloc_extra_mut < ' a > (
673+ & ' a mut self ,
674+ id : AllocId ,
675+ ) -> InterpResult < ' tcx , & ' a mut M :: AllocExtra > {
676+ Ok ( & mut self . get_raw_mut ( id) ?. 0 . extra )
677+ }
678+
667679 /// Obtain the size and alignment of an allocation, even if that allocation has
668680 /// been deallocated.
669681 ///
@@ -688,7 +700,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
688700 // The caller requested no function pointers.
689701 throw_ub ! ( DerefFunctionPointer ( id) )
690702 } else {
691- Ok ( ( Size :: ZERO , Align :: from_bytes ( 1 ) . unwrap ( ) ) )
703+ Ok ( ( Size :: ZERO , Align :: ONE ) )
692704 } ;
693705 }
694706
@@ -930,7 +942,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
930942 ///
931943 /// Performs appropriate bounds checks.
932944 pub fn read_bytes ( & self , sptr : Scalar < M :: PointerTag > , size : Size ) -> InterpResult < ' tcx , & [ u8 ] > {
933- let alloc_ref = match self . get ( sptr, size, Align :: from_bytes ( 1 ) . unwrap ( ) ) ? {
945+ let alloc_ref = match self . get ( sptr, size, Align :: ONE ) ? {
934946 Some ( a) => a,
935947 None => return Ok ( & [ ] ) , // zero-sized access
936948 } ;
@@ -956,7 +968,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
956968 assert_eq ! ( lower, len, "can only write iterators with a precise length" ) ;
957969
958970 let size = Size :: from_bytes ( len) ;
959- let alloc_ref = match self . get_mut ( sptr, size, Align :: from_bytes ( 1 ) . unwrap ( ) ) ? {
971+ let alloc_ref = match self . get_mut ( sptr, size, Align :: ONE ) ? {
960972 Some ( alloc_ref) => alloc_ref,
961973 None => {
962974 // zero-sized access
0 commit comments