@@ -161,22 +161,14 @@ impl<'mir: 'ecx, 'tcx: 'mir, 'ecx> EvalContextPrivExt<'mir, 'tcx, 'ecx>
161
161
{
162
162
}
163
163
trait EvalContextPrivExt < ' mir : ' ecx , ' tcx : ' mir , ' ecx > : crate :: MiriInterpCxExt < ' mir , ' tcx > {
164
- /// Returns the `AllocId` the reborrow was done in, if there is some actual
165
- /// memory associated with this pointer. Returns `None` if there is no actual
166
- /// memory allocated. Also checks that the reborrow of size `ptr_size` is
167
- /// within bounds of the allocation.
168
- ///
169
- /// Also returns the tag that the pointer should get, which is essentially
170
- /// `if new_perm.is_some() { new_tag } else { parent_tag }` along with
171
- /// some logging (always) and fake reads (if `new_perm` is
172
- /// `Some(NewPermission { perform_read_access: true }`).
164
+ /// Returns the provenance that should be used henceforth.
173
165
fn tb_reborrow (
174
166
& mut self ,
175
167
place : & MPlaceTy < ' tcx , Provenance > , // parent tag extracted from here
176
168
ptr_size : Size ,
177
169
new_perm : NewPermission ,
178
170
new_tag : BorTag ,
179
- ) -> InterpResult < ' tcx , Option < ( AllocId , BorTag ) > > {
171
+ ) -> InterpResult < ' tcx , Option < Provenance > > {
180
172
let this = self . eval_context_mut ( ) ;
181
173
// Ensure we bail out if the pointer goes out-of-bounds (see miri#1050).
182
174
this. check_ptr_access_align (
@@ -222,13 +214,14 @@ trait EvalContextPrivExt<'mir: 'ecx, 'tcx: 'mir, 'ecx>: crate::MiriInterpCxExt<'
222
214
place. layout. ty,
223
215
) ;
224
216
log_creation ( this, None ) ?;
225
- return Ok ( None ) ;
217
+ // Keep original provenance.
218
+ return Ok ( place. ptr . provenance ) ;
226
219
}
227
220
} ;
228
221
log_creation ( this, Some ( ( alloc_id, base_offset, parent_prov) ) ) ?;
229
222
230
223
let orig_tag = match parent_prov {
231
- ProvenanceExtra :: Wildcard => return Ok ( None ) , // TODO: handle wildcard pointers
224
+ ProvenanceExtra :: Wildcard => return Ok ( place . ptr . provenance ) , // TODO: handle wildcard pointers
232
225
ProvenanceExtra :: Concrete ( tag) => tag,
233
226
} ;
234
227
@@ -279,7 +272,7 @@ trait EvalContextPrivExt<'mir: 'ecx, 'tcx: 'mir, 'ecx>: crate::MiriInterpCxExt<'
279
272
280
273
// Record the parent-child pair in the tree.
281
274
tree_borrows. new_child ( orig_tag, new_tag, new_perm. initial_state , range, span) ?;
282
- Ok ( Some ( ( alloc_id, new_tag) ) )
275
+ Ok ( Some ( Provenance :: Concrete { alloc_id, tag : new_tag } ) )
283
276
}
284
277
285
278
/// Retags an individual pointer, returning the retagged version.
@@ -315,25 +308,10 @@ trait EvalContextPrivExt<'mir: 'ecx, 'tcx: 'mir, 'ecx>: crate::MiriInterpCxExt<'
315
308
let new_tag = this. machine . borrow_tracker . as_mut ( ) . unwrap ( ) . get_mut ( ) . new_ptr ( ) ;
316
309
317
310
// Compute the actual reborrow.
318
- let reborrowed = this. tb_reborrow ( & place, reborrow_size, new_perm, new_tag) ?;
311
+ let new_prov = this. tb_reborrow ( & place, reborrow_size, new_perm, new_tag) ?;
319
312
320
313
// Adjust pointer.
321
- let new_place = place. map_provenance ( |p| {
322
- p. map ( |prov| {
323
- match reborrowed {
324
- Some ( ( alloc_id, actual_tag) ) => {
325
- // If `reborrow` could figure out the AllocId of this ptr, hard-code it into the new one.
326
- // Even if we started out with a wildcard, this newly retagged pointer is tied to that allocation.
327
- Provenance :: Concrete { alloc_id, tag : actual_tag }
328
- }
329
- None => {
330
- // Looks like this has to stay a wildcard pointer.
331
- assert ! ( matches!( prov, Provenance :: Wildcard ) ) ;
332
- Provenance :: Wildcard
333
- }
334
- }
335
- } )
336
- } ) ;
314
+ let new_place = place. map_provenance ( |_| new_prov) ;
337
315
338
316
// Return new pointer.
339
317
Ok ( ImmTy :: from_immediate ( new_place. to_ref ( this) , val. layout ) )
0 commit comments