@@ -330,7 +330,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
330
330
* self . tcx ,
331
331
& mut self . machine ,
332
332
& mut alloc. extra ,
333
- tag,
333
+ ( alloc_id , tag) ,
334
334
alloc_range ( Size :: ZERO , size) ,
335
335
) ?;
336
336
@@ -350,7 +350,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
350
350
ptr : Pointer < Option < M :: PointerTag > > ,
351
351
size : Size ,
352
352
align : Align ,
353
- ) -> InterpResult < ' tcx , Option < ( AllocId , Size , M :: PointerTag ) > > {
353
+ ) -> InterpResult < ' tcx , Option < ( AllocId , Size , M :: TagExtra ) > > {
354
354
let align = M :: enforce_alignment ( & self ) . then_some ( align) ;
355
355
self . check_and_deref_ptr (
356
356
ptr,
@@ -401,11 +401,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
401
401
size : Size ,
402
402
align : Option < Align > ,
403
403
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 ) > ,
409
405
) -> InterpResult < ' tcx , Option < T > > {
410
406
fn check_offset_align ( offset : u64 , align : Align ) -> InterpResult < ' static > {
411
407
if offset % align. bytes ( ) == 0 {
@@ -450,7 +446,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
450
446
// we want the error to be about the bounds.
451
447
if let Some ( align) = align {
452
448
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
+ ) ;
454
453
let ( _, addr) = ptr. into_parts ( ) ; // we checked that offset is absolute
455
454
check_offset_align ( addr. bytes ( ) , align) ?;
456
455
} else {
@@ -575,7 +574,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
575
574
) ?;
576
575
if let Some ( ( alloc_id, offset, tag, alloc) ) = ptr_and_alloc {
577
576
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) ?;
579
578
Ok ( Some ( AllocRef { alloc, range, tcx : * self . tcx , alloc_id } ) )
580
579
} else {
581
580
// 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> {
636
635
// We cannot call `get_raw_mut` inside `check_and_deref_ptr` as that would duplicate `&mut self`.
637
636
let ( alloc, machine) = self . get_alloc_raw_mut ( alloc_id) ?;
638
637
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) ?;
640
639
Ok ( Some ( AllocRefMut { alloc, range, tcx, alloc_id } ) )
641
640
} else {
642
641
Ok ( None )
@@ -1014,7 +1013,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
1014
1013
} ;
1015
1014
let src_alloc = self . get_alloc_raw ( src_alloc_id) ?;
1016
1015
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) ?;
1018
1017
// We need the `dest` ptr for the next operation, so we get it now.
1019
1018
// We already did the source checks and called the hooks so we are good to return early.
1020
1019
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> {
1039
1038
// Destination alloc preparations and access hooks.
1040
1039
let ( dest_alloc, extra) = self . get_alloc_raw_mut ( dest_alloc_id) ?;
1041
1040
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
+ ) ?;
1043
1048
let dest_bytes = dest_alloc
1044
1049
. get_bytes_mut_ptr ( & tcx, dest_range)
1045
1050
. 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> {
1158
1163
pub fn ptr_try_get_alloc_id (
1159
1164
& self ,
1160
1165
ptr : Pointer < Option < M :: PointerTag > > ,
1161
- ) -> Result < ( AllocId , Size , M :: PointerTag ) , u64 > {
1166
+ ) -> Result < ( AllocId , Size , M :: TagExtra ) , u64 > {
1162
1167
match ptr. into_pointer_or_addr ( ) {
1163
1168
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 ) )
1166
1171
}
1167
1172
Err ( addr) => Err ( addr. bytes ( ) ) ,
1168
1173
}
@@ -1173,7 +1178,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
1173
1178
pub fn ptr_get_alloc_id (
1174
1179
& self ,
1175
1180
ptr : Pointer < Option < M :: PointerTag > > ,
1176
- ) -> InterpResult < ' tcx , ( AllocId , Size , M :: PointerTag ) > {
1181
+ ) -> InterpResult < ' tcx , ( AllocId , Size , M :: TagExtra ) > {
1177
1182
self . ptr_try_get_alloc_id ( ptr) . map_err ( |offset| {
1178
1183
err_ub ! ( DanglingIntPointer ( offset, CheckInAllocMsg :: InboundsTest ) ) . into ( )
1179
1184
} )
0 commit comments