@@ -12,12 +12,12 @@ use rustc_middle::mir;
12
12
use rustc_middle:: ty:: layout:: TyAndLayout ;
13
13
use rustc_middle:: ty:: { self , TyCtxt } ;
14
14
use rustc_span:: def_id:: DefId ;
15
- use rustc_target:: abi:: Size ;
15
+ use rustc_target:: abi:: { Align , Size } ;
16
16
use rustc_target:: spec:: abi:: Abi as CallAbi ;
17
17
18
18
use super :: {
19
- AllocBytes , AllocId , AllocRange , Allocation , ConstAllocation , FnArg , Frame , ImmTy , InterpCx ,
20
- InterpResult , MPlaceTy , MemoryKind , OpTy , PlaceTy , Pointer , Provenance ,
19
+ AllocBytes , AllocId , AllocKind , AllocRange , Allocation , ConstAllocation , FnArg , Frame , ImmTy ,
20
+ InterpCx , InterpResult , MPlaceTy , MemoryKind , Misalignment , OpTy , PlaceTy , Pointer , Provenance ,
21
21
} ;
22
22
23
23
/// Data returned by Machine::stack_pop,
@@ -135,11 +135,18 @@ pub trait Machine<'mir, 'tcx: 'mir>: Sized {
135
135
/// Whether memory accesses should be alignment-checked.
136
136
fn enforce_alignment ( ecx : & InterpCx < ' mir , ' tcx , Self > ) -> bool ;
137
137
138
- /// Whether, when checking alignment, we should look at the actual address and thus support
139
- /// custom alignment logic based on whatever the integer address happens to be.
140
- ///
141
- /// If this returns true, Provenance::OFFSET_IS_ADDR must be true.
142
- fn use_addr_for_alignment_check ( ecx : & InterpCx < ' mir , ' tcx , Self > ) -> bool ;
138
+ /// Gives the machine a chance to detect more misalignment than the built-in checks would catch.
139
+ #[ inline( always) ]
140
+ fn alignment_check (
141
+ _ecx : & InterpCx < ' mir , ' tcx , Self > ,
142
+ _alloc_id : AllocId ,
143
+ _alloc_align : Align ,
144
+ _alloc_kind : AllocKind ,
145
+ _offset : Size ,
146
+ _align : Align ,
147
+ ) -> Option < Misalignment > {
148
+ None
149
+ }
143
150
144
151
/// Whether to enforce the validity invariant for a specific layout.
145
152
fn enforce_validity ( ecx : & InterpCx < ' mir , ' tcx , Self > , layout : TyAndLayout < ' tcx > ) -> bool ;
@@ -511,12 +518,6 @@ pub macro compile_time_machine(<$mir: lifetime, $tcx: lifetime>) {
511
518
type FrameExtra = ( ) ;
512
519
type Bytes = Box < [ u8 ] > ;
513
520
514
- #[ inline( always) ]
515
- fn use_addr_for_alignment_check ( _ecx : & InterpCx < $mir, $tcx, Self > ) -> bool {
516
- // We do not support `use_addr`.
517
- false
518
- }
519
-
520
521
#[ inline( always) ]
521
522
fn ignore_optional_overflow_checks ( _ecx : & InterpCx < $mir, $tcx, Self > ) -> bool {
522
523
false
0 commit comments