@@ -14,11 +14,8 @@ use std::ptr;
14
14
15
15
use rustc_ast:: Mutability ;
16
16
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
17
- use rustc_hir:: CRATE_HIR_ID ;
18
17
use rustc_middle:: mir:: display_allocation;
19
- use rustc_middle:: mir:: interpret:: UndefinedBehaviorInfo ;
20
18
use rustc_middle:: ty:: { self , Instance , ParamEnv , Ty , TyCtxt } ;
21
- use rustc_session:: lint:: builtin:: INVALID_ALIGNMENT ;
22
19
use rustc_target:: abi:: { Align , HasDataLayout , Size } ;
23
20
24
21
use crate :: const_eval:: CheckAlignment ;
@@ -448,7 +445,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
448
445
} else {
449
446
// Check allocation alignment and offset alignment.
450
447
if alloc_align. bytes ( ) < align. bytes ( ) {
451
- self . alignment_check_failed ( alloc_align, align, check) ?;
448
+ M :: alignment_check_failed ( self , alloc_align, align, check) ?;
452
449
}
453
450
self . check_offset_align ( offset. bytes ( ) , align, check) ?;
454
451
}
@@ -472,43 +469,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
472
469
} else {
473
470
// The biggest power of two through which `offset` is divisible.
474
471
let offset_pow2 = 1 << offset. trailing_zeros ( ) ;
475
- self . alignment_check_failed ( Align :: from_bytes ( offset_pow2) . unwrap ( ) , align, check)
472
+ M :: alignment_check_failed ( self , Align :: from_bytes ( offset_pow2) . unwrap ( ) , align, check)
476
473
}
477
474
}
478
-
479
- fn alignment_check_failed (
480
- & self ,
481
- has : Align ,
482
- required : Align ,
483
- check : CheckAlignment ,
484
- ) -> InterpResult < ' tcx , ( ) > {
485
- match check {
486
- CheckAlignment :: Error => {
487
- throw_ub ! ( AlignmentCheckFailed { has, required } )
488
- }
489
- CheckAlignment :: No => span_bug ! (
490
- self . cur_span( ) ,
491
- "`alignment_check_failed` called when no alignment check requested"
492
- ) ,
493
- CheckAlignment :: FutureIncompat => self . tcx . struct_span_lint_hir (
494
- INVALID_ALIGNMENT ,
495
- self . stack ( ) . iter ( ) . find_map ( |frame| frame. lint_root ( ) ) . unwrap_or ( CRATE_HIR_ID ) ,
496
- self . cur_span ( ) ,
497
- UndefinedBehaviorInfo :: AlignmentCheckFailed { has, required } . to_string ( ) ,
498
- |db| {
499
- let mut stacktrace = self . generate_stacktrace ( ) ;
500
- // Filter out `requires_caller_location` frames.
501
- stacktrace
502
- . retain ( |frame| !frame. instance . def . requires_caller_location ( * self . tcx ) ) ;
503
- for frame in stacktrace {
504
- db. span_label ( frame. span , format ! ( "inside `{}`" , frame. instance) ) ;
505
- }
506
- db
507
- } ,
508
- ) ,
509
- }
510
- Ok ( ( ) )
511
- }
512
475
}
513
476
514
477
/// Allocation accessors
0 commit comments