@@ -330,7 +330,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
330330 * self . tcx ,
331331 & mut self . machine ,
332332 & mut alloc. extra ,
333- tag,
333+ ( alloc_id , tag) ,
334334 alloc_range ( Size :: ZERO , size) ,
335335 ) ?;
336336
@@ -350,7 +350,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
350350 ptr : Pointer < Option < M :: PointerTag > > ,
351351 size : Size ,
352352 align : Align ,
353- ) -> InterpResult < ' tcx , Option < ( AllocId , Size , M :: PointerTag ) > > {
353+ ) -> InterpResult < ' tcx , Option < ( AllocId , Size , M :: TagExtra ) > > {
354354 let align = M :: enforce_alignment ( & self ) . then_some ( align) ;
355355 self . check_and_deref_ptr (
356356 ptr,
@@ -401,11 +401,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
401401 size : Size ,
402402 align : Option < Align > ,
403403 msg : CheckInAllocMsg ,
404- alloc_size : impl FnOnce (
405- AllocId ,
406- Size ,
407- M :: PointerTag ,
408- ) -> InterpResult < ' tcx , ( Size , Align , T ) > ,
404+ alloc_size : impl FnOnce ( AllocId , Size , M :: TagExtra ) -> InterpResult < ' tcx , ( Size , Align , T ) > ,
409405 ) -> InterpResult < ' tcx , Option < T > > {
410406 fn check_offset_align ( offset : u64 , align : Align ) -> InterpResult < ' static > {
411407 if offset % align. bytes ( ) == 0 {
@@ -450,7 +446,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
450446 // we want the error to be about the bounds.
451447 if let Some ( align) = align {
452448 if M :: force_int_for_alignment_check ( self ) {
453- assert ! ( M :: PointerTag :: OFFSET_IS_ADDR , "ptr-to-int cast for align check should never fail" ) ;
449+ assert ! (
450+ M :: PointerTag :: OFFSET_IS_ADDR ,
451+ "ptr-to-int cast for align check should never fail"
452+ ) ;
454453 let ( _, addr) = ptr. into_parts ( ) ; // we checked that offset is absolute
455454 check_offset_align ( addr. bytes ( ) , align) ?;
456455 } else {
@@ -575,7 +574,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
575574 ) ?;
576575 if let Some ( ( alloc_id, offset, tag, alloc) ) = ptr_and_alloc {
577576 let range = alloc_range ( offset, size) ;
578- M :: memory_read ( * self . tcx , & self . machine , & alloc. extra , tag, range) ?;
577+ M :: memory_read ( * self . tcx , & self . machine , & alloc. extra , ( alloc_id , tag) , range) ?;
579578 Ok ( Some ( AllocRef { alloc, range, tcx : * self . tcx , alloc_id } ) )
580579 } else {
581580 // Even in this branch we have to be sure that we actually access the allocation, in
@@ -636,7 +635,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
636635 // We cannot call `get_raw_mut` inside `check_and_deref_ptr` as that would duplicate `&mut self`.
637636 let ( alloc, machine) = self . get_alloc_raw_mut ( alloc_id) ?;
638637 let range = alloc_range ( offset, size) ;
639- M :: memory_written ( tcx, machine, & mut alloc. extra , tag, range) ?;
638+ M :: memory_written ( tcx, machine, & mut alloc. extra , ( alloc_id , tag) , range) ?;
640639 Ok ( Some ( AllocRefMut { alloc, range, tcx, alloc_id } ) )
641640 } else {
642641 Ok ( None )
@@ -1014,7 +1013,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
10141013 } ;
10151014 let src_alloc = self . get_alloc_raw ( src_alloc_id) ?;
10161015 let src_range = alloc_range ( src_offset, size) ;
1017- M :: memory_read ( * tcx, & self . machine , & src_alloc. extra , src_tag, src_range) ?;
1016+ M :: memory_read ( * tcx, & self . machine , & src_alloc. extra , ( src_alloc_id , src_tag) , src_range) ?;
10181017 // We need the `dest` ptr for the next operation, so we get it now.
10191018 // We already did the source checks and called the hooks so we are good to return early.
10201019 let Some ( ( dest_alloc_id, dest_offset, dest_tag) ) = dest_parts else {
@@ -1039,7 +1038,13 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
10391038 // Destination alloc preparations and access hooks.
10401039 let ( dest_alloc, extra) = self . get_alloc_raw_mut ( dest_alloc_id) ?;
10411040 let dest_range = alloc_range ( dest_offset, size * num_copies) ;
1042- M :: memory_written ( * tcx, extra, & mut dest_alloc. extra , dest_tag, dest_range) ?;
1041+ M :: memory_written (
1042+ * tcx,
1043+ extra,
1044+ & mut dest_alloc. extra ,
1045+ ( dest_alloc_id, dest_tag) ,
1046+ dest_range,
1047+ ) ?;
10431048 let dest_bytes = dest_alloc
10441049 . get_bytes_mut_ptr ( & tcx, dest_range)
10451050 . map_err ( |e| e. to_interp_error ( dest_alloc_id) ) ?
@@ -1158,11 +1163,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
11581163 pub fn ptr_try_get_alloc_id (
11591164 & self ,
11601165 ptr : Pointer < Option < M :: PointerTag > > ,
1161- ) -> Result < ( AllocId , Size , M :: PointerTag ) , u64 > {
1166+ ) -> Result < ( AllocId , Size , M :: TagExtra ) , u64 > {
11621167 match ptr. into_pointer_or_addr ( ) {
11631168 Ok ( ptr) => {
1164- let ( alloc_id, offset) = M :: ptr_get_alloc ( self , ptr) ;
1165- Ok ( ( alloc_id, offset, ptr . provenance ) )
1169+ let ( alloc_id, offset, extra ) = M :: ptr_get_alloc ( self , ptr) ;
1170+ Ok ( ( alloc_id, offset, extra ) )
11661171 }
11671172 Err ( addr) => Err ( addr. bytes ( ) ) ,
11681173 }
@@ -1173,7 +1178,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
11731178 pub fn ptr_get_alloc_id (
11741179 & self ,
11751180 ptr : Pointer < Option < M :: PointerTag > > ,
1176- ) -> InterpResult < ' tcx , ( AllocId , Size , M :: PointerTag ) > {
1181+ ) -> InterpResult < ' tcx , ( AllocId , Size , M :: TagExtra ) > {
11771182 self . ptr_try_get_alloc_id ( ptr) . map_err ( |offset| {
11781183 err_ub ! ( DanglingIntPointer ( offset, CheckInAllocMsg :: InboundsTest ) ) . into ( )
11791184 } )
0 commit comments