@@ -462,7 +462,7 @@ impl Stacks {
462
462
size : Size ,
463
463
extra : MemoryExtra ,
464
464
kind : MemoryKind < MiriMemoryKind > ,
465
- ) -> ( Self , Tag ) {
465
+ ) -> Self {
466
466
let ( tag, perm) = match kind {
467
467
MemoryKind :: Stack =>
468
468
// New unique borrow. This tag is not accessible by the program,
@@ -472,12 +472,15 @@ impl Stacks {
472
472
// and in particular, *all* raw pointers.
473
473
( Tag :: Tagged ( extra. borrow_mut ( ) . new_ptr ( ) ) , Permission :: Unique ) ,
474
474
MemoryKind :: Machine ( MiriMemoryKind :: Static ) =>
475
+ // Statics are inherently shared, so we do not derive any uniqueness assumptions
476
+ // from direct accesses to a static. Thus, the base permission is `SharedReadWrite`.
475
477
( extra. borrow_mut ( ) . static_base_ptr ( id) , Permission :: SharedReadWrite ) ,
476
478
_ =>
479
+ // Everything else we handle entirely untagged for now.
480
+ // FIXME: experiment with more precise tracking.
477
481
( Tag :: Untagged , Permission :: SharedReadWrite ) ,
478
482
} ;
479
- let stack = Stacks :: new ( size, perm, tag, extra) ;
480
- ( stack, tag)
483
+ Stacks :: new ( size, perm, tag, extra)
481
484
}
482
485
483
486
#[ inline( always) ]
@@ -591,7 +594,12 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
591
594
592
595
// Compute new borrow.
593
596
let new_tag = match kind {
597
+ // Give up tracking for raw pointers.
598
+ // FIXME: Experiment with more precise tracking. Blocked on `&raw`
599
+ // because `Rc::into_raw` currently creates intermediate references,
600
+ // breaking `Rc::from_raw`.
594
601
RefKind :: Raw { .. } => Tag :: Untagged ,
602
+ // All other pointesr are properly tracked.
595
603
_ => Tag :: Tagged ( this. memory . extra . stacked_borrows . borrow_mut ( ) . new_ptr ( ) ) ,
596
604
} ;
597
605
0 commit comments