@@ -21,8 +21,8 @@ use rustc_target::abi::{Align, HasDataLayout, Size};
2121use crate :: fluent_generated as fluent;
2222
2323use super :: {
24- alloc_range, AllocBytes , AllocId , AllocMap , AllocRange , Allocation , CheckInAllocMsg ,
25- GlobalAlloc , InterpCx , InterpResult , Machine , MayLeak , Misalignment , Pointer ,
24+ alloc_range, AllocBytes , AllocId , AllocMap , AllocRange , Allocation , CheckAlignMsg ,
25+ CheckInAllocMsg , GlobalAlloc , InterpCx , InterpResult , Machine , MayLeak , Misalignment , Pointer ,
2626 PointerArithmetic , Provenance , Scalar ,
2727} ;
2828
@@ -425,7 +425,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
425425 }
426426 // Must be aligned.
427427 if M :: enforce_alignment ( self ) && align. bytes ( ) > 1 {
428- self . check_misalign ( Self :: offset_misalignment ( addr, align) ) ?;
428+ self . check_misalign (
429+ Self :: offset_misalignment ( addr, align) ,
430+ CheckAlignMsg :: AccessedPtr ,
431+ ) ?;
429432 }
430433 None
431434 }
@@ -449,7 +452,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
449452 // Test align. Check this last; if both bounds and alignment are violated
450453 // we want the error to be about the bounds.
451454 if M :: enforce_alignment ( self ) && align. bytes ( ) > 1 {
452- self . check_misalign ( self . alloc_misalignment ( ptr, offset, align, alloc_align) ) ?;
455+ self . check_misalign (
456+ self . alloc_misalignment ( ptr, offset, align, alloc_align) ,
457+ CheckAlignMsg :: AccessedPtr ,
458+ ) ?;
453459 }
454460
455461 // We can still be zero-sized in this branch, in which case we have to
@@ -460,9 +466,13 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
460466 }
461467
462468 #[ inline( always) ]
463- pub ( super ) fn check_misalign ( & self , misaligned : Option < Misalignment > ) -> InterpResult < ' tcx > {
469+ pub ( super ) fn check_misalign (
470+ & self ,
471+ misaligned : Option < Misalignment > ,
472+ msg : CheckAlignMsg ,
473+ ) -> InterpResult < ' tcx > {
464474 if let Some ( misaligned) = misaligned {
465- throw_ub ! ( AlignmentCheckFailed ( misaligned) )
475+ throw_ub ! ( AlignmentCheckFailed ( misaligned, msg ) )
466476 }
467477 Ok ( ( ) )
468478 }
0 commit comments