@@ -45,7 +45,9 @@ pub struct Stacks {
45
45
/// new pointer.
46
46
#[ derive( Copy , Clone , Hash , PartialEq , Eq ) ]
47
47
enum RefKind {
48
- /// `&mut` and `Box`.
48
+ /// `Box`.
49
+ Box ,
50
+ /// `&mut`.
49
51
Unique { two_phase : bool } ,
50
52
/// `&` with or without interior mutability.
51
53
Shared ,
@@ -56,6 +58,7 @@ enum RefKind {
56
58
impl fmt:: Display for RefKind {
57
59
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
58
60
match self {
61
+ RefKind :: Box => write ! ( f, "Box" ) ,
59
62
RefKind :: Unique { two_phase : false } => write ! ( f, "unique reference" ) ,
60
63
RefKind :: Unique { two_phase : true } => write ! ( f, "unique reference (two-phase)" ) ,
61
64
RefKind :: Shared => write ! ( f, "shared reference" ) ,
@@ -654,15 +657,17 @@ trait EvalContextPrivExt<'mir: 'ecx, 'tcx: 'mir, 'ecx>: crate::MiriInterpCxExt<'
654
657
let ( perm, access) = match kind {
655
658
RefKind :: Unique { two_phase } => {
656
659
// Permission is Unique only if the type is `Unpin` and this is not twophase
657
- let perm = if !two_phase && place. layout . ty . is_unpin ( * this. tcx , this. param_env ( ) ) {
658
- Permission :: Unique
660
+ if !two_phase && place. layout . ty . is_unpin ( * this. tcx , this. param_env ( ) ) {
661
+ ( Permission :: Unique , Some ( AccessKind :: Write ) )
659
662
} else {
660
- Permission :: SharedReadWrite
661
- } ;
662
- // We do an access for all full borrows, even if `!Unpin`.
663
- let access = if !two_phase { Some ( AccessKind :: Write ) } else { None } ;
664
- ( perm, access)
663
+ // FIXME: We emit `dereferenceable` for `!Unpin` mutable references, so we
664
+ // should do fake accesses here. But then we run into
665
+ // <https://github.com/rust-lang/unsafe-code-guidelines/issues/381>, so for now
666
+ // we don't do that.
667
+ ( Permission :: SharedReadWrite , None )
668
+ }
665
669
}
670
+ RefKind :: Box => ( Permission :: Unique , Some ( AccessKind :: Write ) ) ,
666
671
RefKind :: Raw { mutable : true } => {
667
672
// Creating a raw ptr does not count as an access
668
673
( Permission :: SharedReadWrite , None )
@@ -853,7 +858,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
853
858
// Boxes get a weak protectors, since they may be deallocated.
854
859
self . retag_place (
855
860
place,
856
- RefKind :: Unique { two_phase : false } ,
861
+ RefKind :: Box ,
857
862
self . retag_cause ,
858
863
/*protector*/
859
864
( self . kind == RetagKind :: FnEntry ) . then_some ( ProtectorKind :: WeakProtector ) ,
0 commit comments