@@ -37,8 +37,9 @@ impl ProvenanceMap {
3737 /// indeed that is how codegen treats them).
3838 ///
3939 /// Only exposed with `AllocId` provenance, since it panics if there is bytewise provenance.
40+ #[ inline]
4041 pub fn ptrs ( & self ) -> & SortedMap < Size , AllocId > {
41- assert ! ( self . bytes. is_empty( ) ) ;
42+ debug_assert ! ( self . bytes. is_empty( ) ) ;
4243 & self . ptrs
4344 }
4445}
@@ -106,7 +107,11 @@ impl<Prov: Provenance> ProvenanceMap<Prov> {
106107 let start = range. start ;
107108 let end = range. end ( ) ;
108109 // Clear the bytewise part -- this is easy.
109- self . bytes . remove_range ( start..end) ;
110+ if Prov :: OFFSET_IS_ADDR {
111+ self . bytes . remove_range ( start..end) ;
112+ } else {
113+ debug_assert ! ( self . bytes. is_empty( ) ) ;
114+ }
110115
111116 // For the ptr-sized part, find the first (inclusive) and last (exclusive) byte of
112117 // provenance that overlaps with the given range.
@@ -167,7 +172,6 @@ pub struct ProvenanceCopy<Prov> {
167172}
168173
169174impl < Prov : Provenance > ProvenanceMap < Prov > {
170- #[ instrument( skip( self , cx) , level = "debug" ) ]
171175 pub fn prepare_copy (
172176 & self ,
173177 src : AllocRange ,
@@ -225,7 +229,11 @@ impl<Prov: Provenance> ProvenanceMap<Prov> {
225229 trace ! ( "no start overlapping entry" ) ;
226230 }
227231 // Then the main part, bytewise provenance from `self.bytes`.
228- bytes. extend ( self . bytes . range ( src. start ..src. end ( ) ) ) ;
232+ if Prov :: OFFSET_IS_ADDR {
233+ bytes. extend ( self . bytes . range ( src. start ..src. end ( ) ) ) ;
234+ } else {
235+ debug_assert ! ( self . bytes. is_empty( ) ) ;
236+ }
229237 // And finally possibly parts of a pointer at the end.
230238 if let Some ( entry) = self . range_get_ptrs ( alloc_range ( src. end ( ) , Size :: ZERO ) , cx) . first ( ) {
231239 if !Prov :: OFFSET_IS_ADDR {
@@ -266,6 +274,10 @@ impl<Prov: Provenance> ProvenanceMap<Prov> {
266274 /// to be clear of provenance.
267275 pub fn apply_copy ( & mut self , copy : ProvenanceCopy < Prov > ) {
268276 self . ptrs . insert_presorted ( copy. dest_ptrs ) ;
269- self . bytes . insert_presorted ( copy. dest_bytes ) ;
277+ if Prov :: OFFSET_IS_ADDR {
278+ self . bytes . insert_presorted ( copy. dest_bytes ) ;
279+ } else {
280+ debug_assert ! ( copy. dest_bytes. is_empty( ) ) ;
281+ }
270282 }
271283}
0 commit comments