@@ -9,6 +9,7 @@ use rand::rngs::StdRng;
9
9
use rand:: SeedableRng ;
10
10
11
11
use rustc_ast:: ast:: Mutability ;
12
+ use rustc_const_eval:: const_eval:: CheckAlignment ;
12
13
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
13
14
#[ allow( unused) ]
14
15
use rustc_data_structures:: static_assert_size;
@@ -22,7 +23,7 @@ use rustc_middle::{
22
23
} ;
23
24
use rustc_span:: def_id:: { CrateNum , DefId } ;
24
25
use rustc_span:: Symbol ;
25
- use rustc_target:: abi:: Size ;
26
+ use rustc_target:: abi:: { Align , Size } ;
26
27
use rustc_target:: spec:: abi:: Abi ;
27
28
28
29
use crate :: {
@@ -781,15 +782,28 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
781
782
const PANIC_ON_ALLOC_FAIL : bool = false ;
782
783
783
784
#[ 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
+ }
786
791
}
787
792
788
793
#[ inline( always) ]
789
794
fn use_addr_for_alignment_check ( ecx : & MiriInterpCx < ' mir , ' tcx > ) -> bool {
790
795
ecx. machine . check_alignment == AlignmentCheck :: Int
791
796
}
792
797
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
+
793
807
#[ inline( always) ]
794
808
fn enforce_validity ( ecx : & MiriInterpCx < ' mir , ' tcx > ) -> bool {
795
809
ecx. machine . validate
0 commit comments