@@ -12,12 +12,12 @@ use rustc_middle::mir;
1212use rustc_middle:: ty:: layout:: TyAndLayout ;
1313use rustc_middle:: ty:: { self , TyCtxt } ;
1414use rustc_span:: def_id:: DefId ;
15- use rustc_target:: abi:: Size ;
15+ use rustc_target:: abi:: { Align , Size } ;
1616use rustc_target:: spec:: abi:: Abi as CallAbi ;
1717
1818use 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 ,
2121} ;
2222
2323/// Data returned by Machine::stack_pop,
@@ -135,11 +135,18 @@ pub trait Machine<'mir, 'tcx: 'mir>: Sized {
135135 /// Whether memory accesses should be alignment-checked.
136136 fn enforce_alignment ( ecx : & InterpCx < ' mir , ' tcx , Self > ) -> bool ;
137137
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+ }
143150
144151 /// Whether to enforce the validity invariant for a specific layout.
145152 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>) {
511518 type FrameExtra = ( ) ;
512519 type Bytes = Box < [ u8 ] > ;
513520
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-
520521 #[ inline( always) ]
521522 fn ignore_optional_overflow_checks ( _ecx : & InterpCx < $mir, $tcx, Self > ) -> bool {
522523 false
0 commit comments