@@ -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,
@@ -143,11 +143,18 @@ pub trait Machine<'mir, 'tcx: 'mir>: Sized {
143143 /// Whether memory accesses should be alignment-checked.
144144 fn enforce_alignment ( ecx : & InterpCx < ' mir , ' tcx , Self > ) -> bool ;
145145
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+ }
151158
152159 /// Whether to enforce the validity invariant for a specific layout.
153160 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>) {
519526 type FrameExtra = ( ) ;
520527 type Bytes = Box < [ u8 ] > ;
521528
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-
528529 #[ inline( always) ]
529530 fn ignore_optional_overflow_checks ( _ecx : & InterpCx < $mir, $tcx, Self > ) -> bool {
530531 false
0 commit comments