@@ -264,13 +264,12 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
264
264
Some ( ( size, _align) ) => size,
265
265
None => self . get_raw ( ptr. alloc_id ) ?. size ( ) ,
266
266
} ;
267
- let align = Align :: from_bytes ( 1 ) . unwrap ( ) ;
268
267
// This will also call the access hooks.
269
268
self . copy (
270
269
ptr. into ( ) ,
271
- align ,
270
+ Align :: ONE ,
272
271
new_ptr. into ( ) ,
273
- align ,
272
+ Align :: ONE ,
274
273
old_size. min ( new_size) ,
275
274
/*nonoverlapping*/ true ,
276
275
) ?;
@@ -379,10 +378,10 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
379
378
& self ,
380
379
sptr : Scalar < M :: PointerTag > ,
381
380
size : Size ,
382
- align : Option < Align > ,
381
+ align : Align ,
383
382
msg : CheckInAllocMsg ,
384
383
) -> 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| {
386
385
let ( size, align) =
387
386
self . get_size_and_align ( ptr. alloc_id , AllocCheck :: Dereferenceable ) ?;
388
387
Ok ( ( size, align, ( ) ) )
@@ -604,6 +603,11 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
604
603
}
605
604
}
606
605
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
+
607
611
/// Gives raw mutable access to the `Allocation`, without bounds or alignment checks.
608
612
/// The caller is responsible for calling the access hooks!
609
613
///
@@ -664,6 +668,14 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
664
668
}
665
669
}
666
670
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
+
667
679
/// Obtain the size and alignment of an allocation, even if that allocation has
668
680
/// been deallocated.
669
681
///
@@ -688,7 +700,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
688
700
// The caller requested no function pointers.
689
701
throw_ub ! ( DerefFunctionPointer ( id) )
690
702
} else {
691
- Ok ( ( Size :: ZERO , Align :: from_bytes ( 1 ) . unwrap ( ) ) )
703
+ Ok ( ( Size :: ZERO , Align :: ONE ) )
692
704
} ;
693
705
}
694
706
@@ -930,7 +942,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
930
942
///
931
943
/// Performs appropriate bounds checks.
932
944
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 ) ? {
934
946
Some ( a) => a,
935
947
None => return Ok ( & [ ] ) , // zero-sized access
936
948
} ;
@@ -956,7 +968,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
956
968
assert_eq ! ( lower, len, "can only write iterators with a precise length" ) ;
957
969
958
970
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 ) ? {
960
972
Some ( alloc_ref) => alloc_ref,
961
973
None => {
962
974
// zero-sized access
0 commit comments