Run the "is this static mutable" logic the same way as in in_mutable_memory
This commit is contained in:
parent
8c9cba2be7
commit
d87e9636d5
1 changed files with 16 additions and 14 deletions
|
@ -491,21 +491,23 @@ 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 {
|
||||||
if !self
|
Mutability::Not
|
||||||
.ecx
|
if !self
|
||||||
.tcx
|
.ecx
|
||||||
.type_of(did)
|
.tcx
|
||||||
.no_bound_vars()
|
.type_of(did)
|
||||||
.expect("statics should not have generic parameters")
|
.no_bound_vars()
|
||||||
.is_freeze(*self.ecx.tcx, ty::ParamEnv::reveal_all()) =>
|
.expect("statics should not have generic parameters")
|
||||||
{
|
.is_freeze(*self.ecx.tcx, ty::ParamEnv::reveal_all()) =>
|
||||||
Mutability::Mut
|
{
|
||||||
|
Mutability::Mut
|
||||||
|
}
|
||||||
|
_ => mutability,
|
||||||
}
|
}
|
||||||
(Mutability::Not, false) => Mutability::Not,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GlobalAlloc::Memory(alloc) => alloc.inner().mutability,
|
GlobalAlloc::Memory(alloc) => alloc.inner().mutability,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue