@@ -112,15 +112,15 @@ pub struct Memory<'mir, 'tcx, M: Machine<'mir, 'tcx>> {
112112/// A reference to some allocation that was already bounds-checked for the given region
113113/// and had the on-access machine hooks run.
114114#[ derive( Copy , Clone ) ]
115- pub struct AllocRef < ' a , ' tcx , Prov , Extra > {
115+ pub struct AllocRef < ' a , ' tcx , Prov : Provenance , Extra > {
116116 alloc : & ' a Allocation < Prov , Extra > ,
117117 range : AllocRange ,
118118 tcx : TyCtxt < ' tcx > ,
119119 alloc_id : AllocId ,
120120}
121121/// A reference to some allocation that was already bounds-checked for the given region
122122/// and had the on-access machine hooks run.
123- pub struct AllocRefMut < ' a , ' tcx , Prov , Extra > {
123+ pub struct AllocRefMut < ' a , ' tcx , Prov : Provenance , Extra > {
124124 alloc : & ' a mut Allocation < Prov , Extra > ,
125125 range : AllocRange ,
126126 tcx : TyCtxt < ' tcx > ,
@@ -302,8 +302,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
302302 . into ( ) ) ;
303303 } ;
304304
305- debug ! ( ?alloc) ;
306-
307305 if alloc. mutability == Mutability :: Not {
308306 throw_ub_format ! ( "deallocating immutable allocation {alloc_id:?}" ) ;
309307 }
@@ -797,7 +795,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
797795 // This is a new allocation, add the allocation it points to `todo`.
798796 if let Some ( ( _, alloc) ) = self . memory . alloc_map . get ( id) {
799797 todo. extend (
800- alloc. provenance ( ) . values ( ) . filter_map ( |prov| prov. get_alloc_id ( ) ) ,
798+ alloc. provenance ( ) . provenances ( ) . filter_map ( |prov| prov. get_alloc_id ( ) ) ,
801799 ) ;
802800 }
803801 }
@@ -833,7 +831,8 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> std::fmt::Debug for DumpAllocs<'a,
833831 allocs_to_print : & mut VecDeque < AllocId > ,
834832 alloc : & Allocation < Prov , Extra > ,
835833 ) -> std:: fmt:: Result {
836- for alloc_id in alloc. provenance ( ) . values ( ) . filter_map ( |prov| prov. get_alloc_id ( ) ) {
834+ for alloc_id in alloc. provenance ( ) . provenances ( ) . filter_map ( |prov| prov. get_alloc_id ( ) )
835+ {
837836 allocs_to_print. push_back ( alloc_id) ;
838837 }
839838 write ! ( fmt, "{}" , display_allocation( tcx, alloc) )
@@ -962,7 +961,7 @@ impl<'tcx, 'a, Prov: Provenance, Extra> AllocRef<'a, 'tcx, Prov, Extra> {
962961
963962 /// Returns whether the allocation has provenance anywhere in the range of the `AllocRef`.
964963 pub ( crate ) fn has_provenance ( & self ) -> bool {
965- self . alloc . range_has_provenance ( & self . tcx , self . range )
964+ ! self . alloc . provenance ( ) . range_empty ( self . range , & self . tcx )
966965 }
967966}
968967
@@ -1060,7 +1059,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
10601059
10611060 // Source alloc preparations and access hooks.
10621061 let Some ( ( src_alloc_id, src_offset, src_prov) ) = src_parts else {
1063- // Zero-sized *source*, that means dst is also zero-sized and we have nothing to do.
1062+ // Zero-sized *source*, that means dest is also zero-sized and we have nothing to do.
10641063 return Ok ( ( ) ) ;
10651064 } ;
10661065 let src_alloc = self . get_alloc_raw ( src_alloc_id) ?;
@@ -1079,22 +1078,18 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
10791078 return Ok ( ( ) ) ;
10801079 } ;
10811080
1082- // Checks provenance edges on the src, which needs to happen before
1083- // `prepare_provenance_copy`.
1084- if src_alloc. range_has_provenance ( & tcx, alloc_range ( src_range. start , Size :: ZERO ) ) {
1085- throw_unsup ! ( PartialPointerCopy ( Pointer :: new( src_alloc_id, src_range. start) ) ) ;
1086- }
1087- if src_alloc. range_has_provenance ( & tcx, alloc_range ( src_range. end ( ) , Size :: ZERO ) ) {
1088- throw_unsup ! ( PartialPointerCopy ( Pointer :: new( src_alloc_id, src_range. end( ) ) ) ) ;
1089- }
1081+ // Prepare getting source provenance.
10901082 let src_bytes = src_alloc. get_bytes_unchecked ( src_range) . as_ptr ( ) ; // raw ptr, so we can also get a ptr to the destination allocation
10911083 // first copy the provenance to a temporary buffer, because
10921084 // `get_bytes_mut` will clear the provenance, which is correct,
10931085 // since we don't want to keep any provenance at the target.
1094- let provenance =
1095- src_alloc. prepare_provenance_copy ( self , src_range, dest_offset, num_copies) ;
1086+ // This will also error if copying partial provenance is not supported.
1087+ let provenance = src_alloc
1088+ . provenance ( )
1089+ . prepare_copy ( src_range, dest_offset, num_copies, self )
1090+ . map_err ( |e| e. to_interp_error ( dest_alloc_id) ) ?;
10961091 // Prepare a copy of the initialization mask.
1097- let compressed = src_alloc. compress_uninit_range ( src_range) ;
1092+ let init = src_alloc. init_mask ( ) . prepare_copy ( src_range) ;
10981093
10991094 // Destination alloc preparations and access hooks.
11001095 let ( dest_alloc, extra) = self . get_alloc_raw_mut ( dest_alloc_id) ?;
@@ -1111,7 +1106,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
11111106 . map_err ( |e| e. to_interp_error ( dest_alloc_id) ) ?
11121107 . as_mut_ptr ( ) ;
11131108
1114- if compressed . no_bytes_init ( ) {
1109+ if init . no_bytes_init ( ) {
11151110 // Fast path: If all bytes are `uninit` then there is nothing to copy. The target range
11161111 // is marked as uninitialized but we otherwise omit changing the byte representation which may
11171112 // be arbitrary for uninitialized bytes.
@@ -1160,13 +1155,13 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
11601155 }
11611156
11621157 // now fill in all the "init" data
1163- dest_alloc. mark_compressed_init_range (
1164- & compressed ,
1158+ dest_alloc. init_mask_apply_copy (
1159+ init ,
11651160 alloc_range ( dest_offset, size) , // just a single copy (i.e., not full `dest_range`)
11661161 num_copies,
11671162 ) ;
11681163 // copy the provenance to the destination
1169- dest_alloc. mark_provenance_range ( provenance) ;
1164+ dest_alloc. provenance_apply_copy ( provenance) ;
11701165
11711166 Ok ( ( ) )
11721167 }
0 commit comments