1
Fork 0

Run the "is this static mutable" logic the same way as in in_mutable_memory

This commit is contained in:
Oli Scherer 2024-04-02 14:54:34 +00:00
parent 8c9cba2be7
commit d87e9636d5

View file

@ -491,10 +491,11 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
} }
// Return alloc mutability. For "root" statics we look at the type to account for interior // Return alloc mutability. For "root" statics we look at the type to account for interior
// mutability; for nested statics we have no type and directly use the annotated mutability. // mutability; for nested statics we have no type and directly use the annotated mutability.
match (mutability, nested) { if nested {
(Mutability::Mut, _) => Mutability::Mut, mutability
(Mutability::Not, true) => Mutability::Not, } else {
(Mutability::Not, false) match mutability {
Mutability::Not
if !self if !self
.ecx .ecx
.tcx .tcx
@ -505,7 +506,8 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
{ {
Mutability::Mut Mutability::Mut
} }
(Mutability::Not, false) => Mutability::Not, _ => mutability,
}
} }
} }
GlobalAlloc::Memory(alloc) => alloc.inner().mutability, GlobalAlloc::Memory(alloc) => alloc.inner().mutability,