@@ -462,7 +462,7 @@ impl Stacks {
462462 size : Size ,
463463 extra : MemoryExtra ,
464464 kind : MemoryKind < MiriMemoryKind > ,
465- ) -> ( Self , Tag ) {
465+ ) -> Self {
466466 let ( tag, perm) = match kind {
467467 MemoryKind :: Stack =>
468468 // New unique borrow. This tag is not accessible by the program,
@@ -472,12 +472,15 @@ impl Stacks {
472472 // and in particular, *all* raw pointers.
473473 ( Tag :: Tagged ( extra. borrow_mut ( ) . new_ptr ( ) ) , Permission :: Unique ) ,
474474 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`.
475477 ( extra. borrow_mut ( ) . static_base_ptr ( id) , Permission :: SharedReadWrite ) ,
476478 _ =>
479+ // Everything else we handle entirely untagged for now.
480+ // FIXME: experiment with more precise tracking.
477481 ( Tag :: Untagged , Permission :: SharedReadWrite ) ,
478482 } ;
479- let stack = Stacks :: new ( size, perm, tag, extra) ;
480- ( stack, tag)
483+ Stacks :: new ( size, perm, tag, extra)
481484 }
482485
483486 #[ inline( always) ]
@@ -591,7 +594,12 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
591594
592595 // Compute new borrow.
593596 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`.
594601 RefKind :: Raw { .. } => Tag :: Untagged ,
602+ // All other pointesr are properly tracked.
595603 _ => Tag :: Tagged ( this. memory . extra . stacked_borrows . borrow_mut ( ) . new_ptr ( ) ) ,
596604 } ;
597605
0 commit comments