diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-04-02 14:54:34 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-04-17 09:50:44 +0000 |
| commit | d87e9636d5e1d16845f3b11c3a3f1e0443679cd2 (patch) | |
| tree | 640d1e69940d9a1192fb46c7fffa5ec7ab04752b /compiler/rustc_const_eval | |
| parent | 8c9cba2be7c6c61ef91d722d27a55abb5eef371c (diff) | |
| download | rust-d87e9636d5e1d16845f3b11c3a3f1e0443679cd2.tar.gz rust-d87e9636d5e1d16845f3b11c3a3f1e0443679cd2.zip | |
Run the "is this static mutable" logic the same way as in `in_mutable_memory`
Diffstat (limited to 'compiler/rustc_const_eval')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/validity.rs | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/validity.rs b/compiler/rustc_const_eval/src/interpret/validity.rs index 920cf68aa62..194781f3dd3 100644 --- a/compiler/rustc_const_eval/src/interpret/validity.rs +++ b/compiler/rustc_const_eval/src/interpret/validity.rs @@ -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 // mutability; for nested statics we have no type and directly use the annotated mutability. - match (mutability, nested) { - (Mutability::Mut, _) => Mutability::Mut, - (Mutability::Not, true) => Mutability::Not, - (Mutability::Not, false) - if !self - .ecx - .tcx - .type_of(did) - .no_bound_vars() - .expect("statics should not have generic parameters") - .is_freeze(*self.ecx.tcx, ty::ParamEnv::reveal_all()) => - { - Mutability::Mut + if nested { + mutability + } else { + match mutability { + Mutability::Not + if !self + .ecx + .tcx + .type_of(did) + .no_bound_vars() + .expect("statics should not have generic parameters") + .is_freeze(*self.ecx.tcx, ty::ParamEnv::reveal_all()) => + { + Mutability::Mut + } + _ => mutability, } - (Mutability::Not, false) => Mutability::Not, } } GlobalAlloc::Memory(alloc) => alloc.inner().mutability, |
