Skip to content

Commit aadff30

Browse files
committed
const-eval: make misalignment a hard error
1 parent 4c4a2bf commit aadff30

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

src/machine.rs

+2-16
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use rand::rngs::StdRng;
1212
use rand::SeedableRng;
1313

1414
use rustc_ast::ast::Mutability;
15-
use rustc_const_eval::const_eval::CheckAlignment;
1615
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1716
#[allow(unused)]
1817
use rustc_data_structures::static_assert_size;
@@ -886,28 +885,15 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
886885
const PANIC_ON_ALLOC_FAIL: bool = false;
887886

888887
#[inline(always)]
889-
fn enforce_alignment(ecx: &MiriInterpCx<'mir, 'tcx>) -> CheckAlignment {
890-
if ecx.machine.check_alignment == AlignmentCheck::None {
891-
CheckAlignment::No
892-
} else {
893-
CheckAlignment::Error
894-
}
888+
fn enforce_alignment(ecx: &MiriInterpCx<'mir, 'tcx>) -> bool {
889+
ecx.machine.check_alignment != AlignmentCheck::None
895890
}
896891

897892
#[inline(always)]
898893
fn use_addr_for_alignment_check(ecx: &MiriInterpCx<'mir, 'tcx>) -> bool {
899894
ecx.machine.check_alignment == AlignmentCheck::Int
900895
}
901896

902-
fn alignment_check_failed(
903-
_ecx: &InterpCx<'mir, 'tcx, Self>,
904-
has: Align,
905-
required: Align,
906-
_check: CheckAlignment,
907-
) -> InterpResult<'tcx, ()> {
908-
throw_ub!(AlignmentCheckFailed { has, required })
909-
}
910-
911897
#[inline(always)]
912898
fn enforce_validity(ecx: &MiriInterpCx<'mir, 'tcx>, _layout: TyAndLayout<'tcx>) -> bool {
913899
ecx.machine.validate

0 commit comments

Comments
 (0)