diff --git a/rust-version b/rust-version index 5f1a4428febc1..e6c238023e407 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -e1c91213ff80af5b87a197b784b40bcbc8cf3add +a803f313fdf8f6eb2d674d7dfb3694a2b437ee1e diff --git a/src/machine.rs b/src/machine.rs index a7a61a1f44c7d..e5a748453e881 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -9,6 +9,7 @@ use rand::rngs::StdRng; use rand::SeedableRng; use rustc_ast::ast::Mutability; +use rustc_const_eval::const_eval::CheckAlignment; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; #[allow(unused)] use rustc_data_structures::static_assert_size; @@ -22,7 +23,7 @@ use rustc_middle::{ }; use rustc_span::def_id::{CrateNum, DefId}; use rustc_span::Symbol; -use rustc_target::abi::Size; +use rustc_target::abi::{Align, Size}; use rustc_target::spec::abi::Abi; use crate::{ @@ -781,8 +782,12 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> { const PANIC_ON_ALLOC_FAIL: bool = false; #[inline(always)] - fn enforce_alignment(ecx: &MiriInterpCx<'mir, 'tcx>) -> bool { - ecx.machine.check_alignment != AlignmentCheck::None + fn enforce_alignment(ecx: &MiriInterpCx<'mir, 'tcx>) -> CheckAlignment { + if ecx.machine.check_alignment == AlignmentCheck::None { + CheckAlignment::No + } else { + CheckAlignment::Error + } } #[inline(always)] @@ -790,6 +795,15 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> { ecx.machine.check_alignment == AlignmentCheck::Int } + fn alignment_check_failed( + _ecx: &InterpCx<'mir, 'tcx, Self>, + has: Align, + required: Align, + _check: CheckAlignment, + ) -> InterpResult<'tcx, ()> { + throw_ub!(AlignmentCheckFailed { has, required }) + } + #[inline(always)] fn enforce_validity(ecx: &MiriInterpCx<'mir, 'tcx>) -> bool { ecx.machine.validate