Exhaustively match on the mutability and nestedness
This commit is contained in:
parent
bbbf06d5e9
commit
bbedde835e
@ -483,12 +483,14 @@ 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 self.ecx.tcx.def_kind(did) {
|
let DefKind::Static { mutability, nested } = self.ecx.tcx.def_kind(did)
|
||||||
DefKind::Static { mutability: Mutability::Mut, .. } => Mutability::Mut,
|
else {
|
||||||
DefKind::Static { mutability: Mutability::Not, nested: true } => {
|
bug!()
|
||||||
Mutability::Not
|
};
|
||||||
}
|
match (mutability, nested) {
|
||||||
DefKind::Static { mutability: Mutability::Not, nested: false }
|
(Mutability::Mut, _) => Mutability::Mut,
|
||||||
|
(Mutability::Not, true) => Mutability::Not,
|
||||||
|
(Mutability::Not, false)
|
||||||
if !self
|
if !self
|
||||||
.ecx
|
.ecx
|
||||||
.tcx
|
.tcx
|
||||||
@ -499,7 +501,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
|
|||||||
{
|
{
|
||||||
Mutability::Mut
|
Mutability::Mut
|
||||||
}
|
}
|
||||||
_ => Mutability::Not,
|
(Mutability::Not, false) => Mutability::Not,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GlobalAlloc::Memory(alloc) => alloc.inner().mutability,
|
GlobalAlloc::Memory(alloc) => alloc.inner().mutability,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user