@@ -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,
@@ -143,11 +143,18 @@ pub trait Machine<'mir, 'tcx: 'mir>: Sized {
143
143
/// Whether memory accesses should be alignment-checked.
144
144
fn enforce_alignment ( ecx : & InterpCx < ' mir , ' tcx , Self > ) -> bool ;
145
145
146
- /// Whether, when checking alignment, we should look at the actual address and thus support
147
- /// custom alignment logic based on whatever the integer address happens to be.
148
- ///
149
- /// If this returns true, Provenance::OFFSET_IS_ADDR must be true.
150
- fn use_addr_for_alignment_check ( ecx : & InterpCx < ' mir , ' tcx , Self > ) -> bool ;
146
+ /// Gives the machine a chance to detect more misalignment than the built-in checks would catch.
147
+ #[ inline( always) ]
148
+ fn alignment_check (
149
+ _ecx : & InterpCx < ' mir , ' tcx , Self > ,
150
+ _alloc_id : AllocId ,
151
+ _alloc_align : Align ,
152
+ _alloc_kind : AllocKind ,
153
+ _offset : Size ,
154
+ _align : Align ,
155
+ ) -> Option < Misalignment > {
156
+ None
157
+ }
151
158
152
159
/// Whether to enforce the validity invariant for a specific layout.
153
160
fn enforce_validity ( ecx : & InterpCx < ' mir , ' tcx , Self > , layout : TyAndLayout < ' tcx > ) -> bool ;
@@ -519,12 +526,6 @@ pub macro compile_time_machine(<$mir: lifetime, $tcx: lifetime>) {
519
526
type FrameExtra = ( ) ;
520
527
type Bytes = Box < [ u8 ] > ;
521
528
522
- #[ inline( always) ]
523
- fn use_addr_for_alignment_check ( _ecx : & InterpCx < $mir, $tcx, Self > ) -> bool {
524
- // We do not support `use_addr`.
525
- false
526
- }
527
-
528
529
#[ inline( always) ]
529
530
fn ignore_optional_overflow_checks ( _ecx : & InterpCx < $mir, $tcx, Self > ) -> bool {
530
531
false
0 commit comments