diff options
| author | Scott McMurray <scottmcm@users.noreply.github.com> | 2024-12-13 02:00:20 -0800 |
|---|---|---|
| committer | Scott McMurray <scottmcm@users.noreply.github.com> | 2024-12-13 02:00:20 -0800 |
| commit | 38249be509101e87ea4ac10951b1b4ce554f1cc0 (patch) | |
| tree | 9e090fcb0ebad1290811af2cc560604c3cdbb80d /compiler/rustc_const_eval/src/interpret/step.rs | |
| parent | 612adbb6bf88ecf549fb93cb1f4edcf793bca88e (diff) | |
| download | rust-38249be509101e87ea4ac10951b1b4ce554f1cc0.tar.gz rust-38249be509101e87ea4ac10951b1b4ce554f1cc0.zip | |
Don't retag the `PtrMetadata(&raw const *_n)` in slice indexing
Diffstat (limited to 'compiler/rustc_const_eval/src/interpret/step.rs')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/step.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/step.rs b/compiler/rustc_const_eval/src/interpret/step.rs index b61865be667..f6d2e476738 100644 --- a/compiler/rustc_const_eval/src/interpret/step.rs +++ b/compiler/rustc_const_eval/src/interpret/step.rs @@ -9,6 +9,7 @@ use rustc_middle::ty::layout::FnAbiOf; use rustc_middle::ty::{self, Instance, Ty}; use rustc_middle::{bug, mir, span_bug}; use rustc_span::source_map::Spanned; +use rustc_span::{DesugaringKind, Span}; use rustc_target::callconv::FnAbi; use tracing::{info, instrument, trace}; @@ -80,7 +81,9 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { use rustc_middle::mir::StatementKind::*; match &stmt.kind { - Assign(box (place, rvalue)) => self.eval_rvalue_into_place(rvalue, *place)?, + Assign(box (place, rvalue)) => { + self.eval_rvalue_into_place(rvalue, *place, stmt.source_info.span)? + } SetDiscriminant { place, variant_index } => { let dest = self.eval_place(**place)?; @@ -159,6 +162,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { &mut self, rvalue: &mir::Rvalue<'tcx>, place: mir::Place<'tcx>, + span: Span, ) -> InterpResult<'tcx> { let dest = self.eval_place(place)?; // FIXME: ensure some kind of non-aliasing between LHS and RHS? @@ -250,8 +254,11 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { let src = self.eval_place(place)?; let place = self.force_allocation(&src)?; let mut val = ImmTy::from_immediate(place.to_ref(self), dest.layout); - if !place_base_raw { + if !place_base_raw + && span.desugaring_kind() != Some(DesugaringKind::IndexBoundsCheckReborrow) + { // If this was not already raw, it needs retagging. + // Unless it's the `PtrMetadata(&raw const *_n)` from indexing. val = M::retag_ptr_value(self, mir::RetagKind::Raw, &val)?; } self.write_immediate(*val, &dest)?; |
