diff options
| author | Ralf Jung <post@ralfj.de> | 2024-01-05 12:18:11 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-02-10 16:12:55 +0100 |
| commit | 4e77e368ebc1bf21ae23137c253138c9ffbc3c7f (patch) | |
| tree | 25c8fec03548477f540fc370b2aee475f9f40307 /compiler/rustc_const_eval/src/interpret | |
| parent | 5f40394baa07b6fb50bc70dedd8b780524b20934 (diff) | |
| download | rust-4e77e368ebc1bf21ae23137c253138c9ffbc3c7f.tar.gz rust-4e77e368ebc1bf21ae23137c253138c9ffbc3c7f.zip | |
unstably allow constants to refer to statics and read from immutable statics
Diffstat (limited to 'compiler/rustc_const_eval/src/interpret')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/validity.rs | 15 |
1 files changed, 0 insertions, 15 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/validity.rs b/compiler/rustc_const_eval/src/interpret/validity.rs index 90cde81c018..67665c4aed2 100644 --- a/compiler/rustc_const_eval/src/interpret/validity.rs +++ b/compiler/rustc_const_eval/src/interpret/validity.rs @@ -132,7 +132,6 @@ pub enum CtfeValidationMode { /// `allow_immutable_unsafe_cell` says whether we allow `UnsafeCell` in immutable memory (which is the /// case for the top-level allocation of a `const`, where this is fine because the allocation will be /// copied at each use site). - /// `allow_static_ptrs` says if pointers to statics are permitted (which is the case for promoteds in statics). Const { allow_immutable_unsafe_cell: bool, allow_static_ptrs: bool }, } @@ -146,13 +145,6 @@ impl CtfeValidationMode { } } - fn allow_static_ptrs(self) -> bool { - match self { - CtfeValidationMode::Static { .. } => true, // statics can point to statics - CtfeValidationMode::Const { allow_static_ptrs, .. } => allow_static_ptrs, - } - } - fn may_contain_mutable_ref(self) -> bool { match self { CtfeValidationMode::Static { mutbl } => mutbl == Mutability::Mut, @@ -468,13 +460,6 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, ' // Special handling for pointers to statics (irrespective of their type). assert!(!self.ecx.tcx.is_thread_local_static(did)); assert!(self.ecx.tcx.is_static(did)); - if self.ctfe_mode.is_some_and(|c| !c.allow_static_ptrs()) { - // See const_eval::machine::MemoryExtra::can_access_statics for why - // this check is so important. - // This check is reachable when the const just referenced the static, - // but never read it (so we never entered `before_access_global`). - throw_validation_failure!(self.path, PtrToStatic { ptr_kind }); - } // Mutability check. if ptr_expected_mutbl == Mutability::Mut { if matches!( |
