diff options
| author | Ralf Jung <post@ralfj.de> | 2024-09-15 13:11:05 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-09-15 22:53:04 +0200 |
| commit | 7dfffe7e70b49777cfc4bf394eeafc27c1a36c18 (patch) | |
| tree | e6afdc3d54f0010d001446c752821d42d3433b25 /compiler/rustc_const_eval | |
| parent | 8c2c9a9ef527edb453bcee638d34beb0e7b4616b (diff) | |
| download | rust-7dfffe7e70b49777cfc4bf394eeafc27c1a36c18.tar.gz rust-7dfffe7e70b49777cfc4bf394eeafc27c1a36c18.zip | |
const: don't ICE when encountering a mutable ref to immutable memory
Diffstat (limited to 'compiler/rustc_const_eval')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/validity.rs | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/validity.rs b/compiler/rustc_const_eval/src/interpret/validity.rs index 469af35ec1b..ca38f779256 100644 --- a/compiler/rustc_const_eval/src/interpret/validity.rs +++ b/compiler/rustc_const_eval/src/interpret/validity.rs @@ -14,6 +14,7 @@ use hir::def::DefKind; use rustc_ast::Mutability; use rustc_data_structures::fx::FxHashSet; use rustc_hir as hir; +use rustc_middle::bug; use rustc_middle::mir::interpret::ValidationErrorKind::{self, *}; use rustc_middle::mir::interpret::{ alloc_range, ExpectedKind, InterpError, InvalidMetaKind, Misalignment, PointerKind, Provenance, @@ -21,7 +22,6 @@ use rustc_middle::mir::interpret::{ }; use rustc_middle::ty::layout::{LayoutCx, LayoutOf, TyAndLayout}; use rustc_middle::ty::{self, Ty, TyCtxt}; -use rustc_middle::{bug, span_bug}; use rustc_span::symbol::{sym, Symbol}; use rustc_target::abi::{ Abi, FieldIdx, FieldsShape, Scalar as ScalarAbi, Size, VariantIdx, Variants, WrappingRange, @@ -617,13 +617,7 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValidityVisitor<'rt, 'tcx, M> { if ptr_expected_mutbl == Mutability::Mut && alloc_actual_mutbl == Mutability::Not { - if !self.ecx.tcx.sess.opts.unstable_opts.unleash_the_miri_inside_of_you - { - span_bug!( - self.ecx.tcx.span, - "the static const safety checks accepted mutable references they should not have accepted" - ); - } + // This can actually occur with transmutes. throw_validation_failure!(self.path, MutableRefToImmutable); } // In a const, everything must be completely immutable. |
