@@ -648,32 +648,27 @@ trait EvalContextPrivExt<'mir: 'ecx, 'tcx: 'mir, 'ecx>: crate::MiriInterpCxExt<'
648648 } ;
649649
650650 let ( _size, _align, alloc_kind) = this. get_alloc_info ( alloc_id) ;
651- match alloc_kind {
652- AllocKind :: LiveData => {
653- // This should have alloc_extra data, but `get_alloc_extra` can still fail
654- // if converting this alloc_id from a global to a local one
655- // uncovers a non-supported `extern static`.
656- let extra = this. get_alloc_extra ( alloc_id) ?;
657- let mut stacked_borrows = extra
658- . borrow_tracker_sb ( )
659- . borrow_mut ( ) ;
660- // Note that we create a *second* `DiagnosticCxBuilder` below for the actual retag.
661- // FIXME: can this be done cleaner?
662- let dcx = DiagnosticCxBuilder :: retag (
663- & this. machine ,
664- retag_info,
665- new_tag,
666- orig_tag,
667- alloc_range ( base_offset, size) ,
668- ) ;
669- let mut dcx = dcx. build ( & mut stacked_borrows. history , base_offset) ;
670- dcx. log_creation ( ) ;
671- if new_perm. protector ( ) . is_some ( ) {
672- dcx. log_protector ( ) ;
673- }
674- } ,
675- AllocKind :: Function | AllocKind :: VTable | AllocKind :: Dead => {
676- // No stacked borrows on these allocations.
651+ if alloc_kind. is_live_data ( ) {
652+ // This should have alloc_extra data, but `get_alloc_extra` can still fail
653+ // if converting this alloc_id from a global to a local one
654+ // uncovers a non-supported `extern static`.
655+ let extra = this. get_alloc_extra ( alloc_id) ?;
656+ let mut stacked_borrows = extra
657+ . borrow_tracker_sb ( )
658+ . borrow_mut ( ) ;
659+ // Note that we create a *second* `DiagnosticCxBuilder` below for the actual retag.
660+ // FIXME: can this be done cleaner?
661+ let dcx = DiagnosticCxBuilder :: retag (
662+ & this. machine ,
663+ retag_info,
664+ new_tag,
665+ orig_tag,
666+ alloc_range ( base_offset, size) ,
667+ ) ;
668+ let mut dcx = dcx. build ( & mut stacked_borrows. history , base_offset) ;
669+ dcx. log_creation ( ) ;
670+ if new_perm. protector ( ) . is_some ( ) {
671+ dcx. log_protector ( ) ;
677672 }
678673 }
679674 Ok ( ( ) )
@@ -1012,18 +1007,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
10121007 // This is okay because accessing them is UB anyway, no need for any Stacked Borrows checks.
10131008 // NOT using `get_alloc_extra_mut` since this might be a read-only allocation!
10141009 let ( _size, _align, kind) = this. get_alloc_info ( alloc_id) ;
1015- match kind {
1016- AllocKind :: LiveData => {
1017- // This should have alloc_extra data, but `get_alloc_extra` can still fail
1018- // if converting this alloc_id from a global to a local one
1019- // uncovers a non-supported `extern static`.
1020- let alloc_extra = this. get_alloc_extra ( alloc_id) ?;
1021- trace ! ( "Stacked Borrows tag {tag:?} exposed in {alloc_id:?}" ) ;
1022- alloc_extra. borrow_tracker_sb ( ) . borrow_mut ( ) . exposed_tags . insert ( tag) ;
1023- }
1024- AllocKind :: Function | AllocKind :: VTable | AllocKind :: Dead => {
1025- // No stacked borrows on these allocations.
1026- }
1010+ if kind. is_live_data ( ) {
1011+ // This should have alloc_extra data, but `get_alloc_extra` can still fail
1012+ // if converting this alloc_id from a global to a local one
1013+ // uncovers a non-supported `extern static`.
1014+ let alloc_extra = this. get_alloc_extra ( alloc_id) ?;
1015+ trace ! ( "Stacked Borrows tag {tag:?} exposed in {alloc_id:?}" ) ;
1016+ alloc_extra. borrow_tracker_sb ( ) . borrow_mut ( ) . exposed_tags . insert ( tag) ;
10271017 }
10281018 Ok ( ( ) )
10291019 }
0 commit comments