@@ -865,24 +865,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
865865        this. sb_retag_reference ( val,  new_perm,  RetagInfo  {  cause,  in_field :  false  } ) 
866866    } 
867867
868-     fn  sb_retag_box_to_raw ( 
869-         & mut  self , 
870-         val :  & ImmTy < ' tcx ,  Provenance > , 
871-         alloc_ty :  Ty < ' tcx > , 
872-     )  -> InterpResult < ' tcx ,  ImmTy < ' tcx ,  Provenance > >  { 
873-         let  this = self . eval_context_mut ( ) ; 
874-         let  is_global_alloc = alloc_ty. ty_adt_def ( ) . is_some_and ( |adt| { 
875-             let  global_alloc = this. tcx . require_lang_item ( rustc_hir:: LangItem :: GlobalAlloc ,  None ) ; 
876-             adt. did ( )  == global_alloc
877-         } ) ; 
878-         if  is_global_alloc { 
879-             // Retag this as-if it was a mutable reference. 
880-             this. sb_retag_ptr_value ( RetagKind :: Raw ,  val) 
881-         }  else  { 
882-             Ok ( val. clone ( ) ) 
883-         } 
884-     } 
885- 
886868    fn  sb_retag_place_contents ( 
887869        & mut  self , 
888870        kind :  RetagKind , 
@@ -891,9 +873,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
891873        let  this = self . eval_context_mut ( ) ; 
892874        let  retag_fields = this. machine . borrow_tracker . as_mut ( ) . unwrap ( ) . get_mut ( ) . retag_fields ; 
893875        let  retag_cause = match  kind { 
894-             RetagKind :: Raw  |  RetagKind :: TwoPhase  {  .. }  => unreachable ! ( ) ,  // these  can only happen in `retag_ptr_value` 
876+             RetagKind :: TwoPhase  {  .. }  => unreachable ! ( ) ,  // can only happen in `retag_ptr_value` 
895877            RetagKind :: FnEntry  => RetagCause :: FnEntry , 
896-             RetagKind :: Default  => RetagCause :: Normal , 
878+             RetagKind :: Default  |  RetagKind :: Raw   => RetagCause :: Normal , 
897879        } ; 
898880        let  mut  visitor =
899881            RetagVisitor  {  ecx :  this,  kind,  retag_cause,  retag_fields,  in_field :  false  } ; 
@@ -959,14 +941,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
959941
960942                // Check the type of this value to see what to do with it (retag, or recurse). 
961943                match  place. layout . ty . kind ( )  { 
962-                     ty:: Ref ( ..)  => { 
963-                         let  new_perm = 
964-                             NewPermission :: from_ref_ty ( place . layout . ty ,  self . kind ,   self . ecx ) ; 
965-                         self . retag_ptr_inplace ( place ,  new_perm ) ? ; 
966-                     } 
967-                     ty :: RawPtr ( .. )  =>  { 
968-                         // We do *not* want to recurse into raw pointers -- wide raw pointers have 
969-                         // fields, and for dyn Trait pointees those can have reference type! 
944+                     ty:: Ref ( ..)  | ty :: RawPtr ( .. )   => { 
945+                         if   matches ! ( place . layout . ty . kind ( ) ,  ty :: Ref ( .. ) ) 
946+                             ||  self . kind  ==  RetagKind :: Raw 
947+                         { 
948+                              let  new_perm = 
949+                                  NewPermission :: from_ref_ty ( place . layout . ty ,   self . kind ,   self . ecx ) ; 
950+                              self . retag_ptr_inplace ( place ,  new_perm ) ? ; 
951+                         } 
970952                    } 
971953                    ty:: Adt ( adt,  _)  if  adt. is_box ( )  => { 
972954                        // Recurse for boxes, they require some tricky handling and will end up in `visit_box` above. 
0 commit comments