@@ -865,24 +865,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
865
865
this. sb_retag_reference ( val, new_perm, RetagInfo { cause, in_field : false } )
866
866
}
867
867
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
-
886
868
fn sb_retag_place_contents (
887
869
& mut self ,
888
870
kind : RetagKind ,
@@ -891,9 +873,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
891
873
let this = self . eval_context_mut ( ) ;
892
874
let retag_fields = this. machine . borrow_tracker . as_mut ( ) . unwrap ( ) . get_mut ( ) . retag_fields ;
893
875
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`
895
877
RetagKind :: FnEntry => RetagCause :: FnEntry ,
896
- RetagKind :: Default => RetagCause :: Normal ,
878
+ RetagKind :: Default | RetagKind :: Raw => RetagCause :: Normal ,
897
879
} ;
898
880
let mut visitor =
899
881
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> {
959
941
960
942
// Check the type of this value to see what to do with it (retag, or recurse).
961
943
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
+ }
970
952
}
971
953
ty:: Adt ( adt, _) if adt. is_box ( ) => {
972
954
// Recurse for boxes, they require some tricky handling and will end up in `visit_box` above.
0 commit comments