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
|
||||
// mutability; for nested statics we have no type and directly use the annotated mutability.
|
||||
match self.ecx.tcx.def_kind(did) {
|
||||
DefKind::Static { mutability: Mutability::Mut, .. } => Mutability::Mut,
|
||||
DefKind::Static { mutability: Mutability::Not, nested: true } => {
|
||||
Mutability::Not
|
||||
}
|
||||
DefKind::Static { mutability: Mutability::Not, nested: false }
|
||||
let DefKind::Static { mutability, nested } = self.ecx.tcx.def_kind(did)
|
||||
else {
|
||||
bug!()
|
||||
};
|
||||
match (mutability, nested) {
|
||||
(Mutability::Mut, _) => Mutability::Mut,
|
||||
(Mutability::Not, true) => Mutability::Not,
|
||||
(Mutability::Not, false)
|
||||
if !self
|
||||
.ecx
|
||||
.tcx
|
||||
@ -499,7 +501,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
|
||||
{
|
||||
Mutability::Mut
|
||||
}
|
||||
_ => Mutability::Not,
|
||||
(Mutability::Not, false) => Mutability::Not,
|
||||
}
|
||||
}
|
||||
GlobalAlloc::Memory(alloc) => alloc.inner().mutability,
|
||||
|
Loading…
x
Reference in New Issue
Block a user