@@ -21,8 +21,8 @@ use rustc_target::abi::{Align, HasDataLayout, Size};
21
21
use crate :: fluent_generated as fluent;
22
22
23
23
use 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 ,
26
26
PointerArithmetic , Provenance , Scalar ,
27
27
} ;
28
28
@@ -425,7 +425,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
425
425
}
426
426
// Must be aligned.
427
427
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
+ ) ?;
429
432
}
430
433
None
431
434
}
@@ -449,7 +452,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
449
452
// Test align. Check this last; if both bounds and alignment are violated
450
453
// we want the error to be about the bounds.
451
454
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
+ ) ?;
453
459
}
454
460
455
461
// 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> {
460
466
}
461
467
462
468
#[ 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 > {
464
474
if let Some ( misaligned) = misaligned {
465
- throw_ub ! ( AlignmentCheckFailed ( misaligned) )
475
+ throw_ub ! ( AlignmentCheckFailed ( misaligned, msg ) )
466
476
}
467
477
Ok ( ( ) )
468
478
}
0 commit comments