@@ -9,6 +9,7 @@ use rand::rngs::StdRng;
99use rand:: SeedableRng ;
1010
1111use rustc_ast:: ast:: Mutability ;
12+ use rustc_const_eval:: const_eval:: CheckAlignment ;
1213use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
1314#[ allow( unused) ]
1415use rustc_data_structures:: static_assert_size;
@@ -22,7 +23,7 @@ use rustc_middle::{
2223} ;
2324use rustc_span:: def_id:: { CrateNum , DefId } ;
2425use rustc_span:: Symbol ;
25- use rustc_target:: abi:: Size ;
26+ use rustc_target:: abi:: { Align , Size } ;
2627use rustc_target:: spec:: abi:: Abi ;
2728
2829use crate :: {
@@ -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