Skip to content

Commit 318c421

Browse files
committed
Auto merge of #115524 - RalfJung:misalign, r=wesleywiser
const-eval: make misalignment a hard error It's been a future-incompat error (showing up in cargo's reports) since rust-lang/rust#104616, Rust 1.68, released in March. That should be long enough. The question for the lang team is simply -- should we move ahead with this, making const-eval alignment failures a hard error? (It turns out some of them accidentally already were hard errors since #104616. But not all so this is still a breaking change. Crater found no regression.)
2 parents 4b39b63 + aadff30 commit 318c421

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;
@@ -885,28 +884,15 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
885884
const PANIC_ON_ALLOC_FAIL: bool = false;
886885

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

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

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

0 commit comments

Comments
 (0)