Skip to content

Commit 2169cdd

Browse files
committed
Merge from rustc
2 parents 4458009 + 5b39367 commit 2169cdd

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/machine.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ use rustc_middle::{
2222
};
2323
use rustc_span::def_id::{CrateNum, DefId};
2424
use rustc_span::Symbol;
25-
use rustc_target::abi::Size;
25+
use rustc_target::abi::{Size, Align};
2626
use rustc_target::spec::abi::Abi;
27+
use rustc_const_eval::const_eval::CheckAlignment;
2728

2829
use crate::{
2930
concurrency::{data_race, weak_memory},
@@ -781,15 +782,28 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
781782
const PANIC_ON_ALLOC_FAIL: bool = false;
782783

783784
#[inline(always)]
784-
fn enforce_alignment(ecx: &MiriInterpCx<'mir, 'tcx>) -> bool {
785-
ecx.machine.check_alignment != AlignmentCheck::None
785+
fn enforce_alignment(ecx: &MiriInterpCx<'mir, 'tcx>) -> CheckAlignment {
786+
if ecx.machine.check_alignment == AlignmentCheck::None {
787+
CheckAlignment::No
788+
} else {
789+
CheckAlignment::Error
790+
}
786791
}
787792

788793
#[inline(always)]
789794
fn use_addr_for_alignment_check(ecx: &MiriInterpCx<'mir, 'tcx>) -> bool {
790795
ecx.machine.check_alignment == AlignmentCheck::Int
791796
}
792797

798+
fn alignment_check_failed(
799+
_ecx: &InterpCx<'mir, 'tcx, Self>,
800+
has: Align,
801+
required: Align,
802+
_check: CheckAlignment,
803+
) -> InterpResult<'tcx, ()> {
804+
throw_ub!(AlignmentCheckFailed { has, required })
805+
}
806+
793807
#[inline(always)]
794808
fn enforce_validity(ecx: &MiriInterpCx<'mir, 'tcx>) -> bool {
795809
ecx.machine.validate

0 commit comments

Comments
 (0)