@@ -5,15 +5,14 @@ use either::Either;
5
5
use rustc_abi:: WrappingRange ;
6
6
use rustc_errors:: codes:: * ;
7
7
use rustc_errors:: {
8
- Diag , DiagArgValue , DiagCtxtHandle , DiagMessage , Diagnostic , EmissionGuarantee , Level ,
9
- MultiSpan , Subdiagnostic ,
8
+ Diag , DiagArgValue , DiagMessage , Diagnostic , EmissionGuarantee , Level , MultiSpan , Subdiagnostic ,
10
9
} ;
11
10
use rustc_hir:: ConstContext ;
12
11
use rustc_macros:: { Diagnostic , LintDiagnostic , Subdiagnostic } ;
13
12
use rustc_middle:: mir:: interpret:: {
14
- CheckInAllocMsg , CtfeProvenance , ExpectedKind , InterpErrorKind , InvalidMetaKind ,
15
- InvalidProgramInfo , Misalignment , Pointer , PointerKind , ResourceExhaustionInfo ,
16
- UndefinedBehaviorInfo , UnsupportedOpInfo , ValidationErrorInfo ,
13
+ CtfeProvenance , ExpectedKind , InterpErrorKind , InvalidMetaKind , InvalidProgramInfo ,
14
+ Misalignment , Pointer , PointerKind , ResourceExhaustionInfo , UndefinedBehaviorInfo ,
15
+ UnsupportedOpInfo , ValidationErrorInfo ,
17
16
} ;
18
17
use rustc_middle:: ty:: { self , Mutability , Ty } ;
19
18
use rustc_span:: { Span , Symbol } ;
@@ -498,19 +497,6 @@ pub trait ReportErrorExt {
498
497
}
499
498
}
500
499
501
- fn bad_pointer_message ( msg : CheckInAllocMsg , dcx : DiagCtxtHandle < ' _ > ) -> String {
502
- use crate :: fluent_generated:: * ;
503
-
504
- let msg = match msg {
505
- CheckInAllocMsg :: MemoryAccessTest => const_eval_memory_access_test,
506
- CheckInAllocMsg :: PointerArithmeticTest => const_eval_pointer_arithmetic_test,
507
- CheckInAllocMsg :: OffsetFromTest => const_eval_offset_from_test,
508
- CheckInAllocMsg :: InboundsTest => const_eval_in_bounds_test,
509
- } ;
510
-
511
- dcx. eagerly_translate_to_string ( msg, [ ] . into_iter ( ) )
512
- }
513
-
514
500
impl < ' a > ReportErrorExt for UndefinedBehaviorInfo < ' a > {
515
501
fn diagnostic_message ( & self ) -> DiagMessage {
516
502
use UndefinedBehaviorInfo :: * ;
@@ -564,7 +550,6 @@ impl<'a> ReportErrorExt for UndefinedBehaviorInfo<'a> {
564
550
565
551
fn add_args < G : EmissionGuarantee > ( self , diag : & mut Diag < ' _ , G > ) {
566
552
use UndefinedBehaviorInfo :: * ;
567
- let dcx = diag. dcx ;
568
553
match self {
569
554
Ub ( _) => { }
570
555
Custom ( custom) => {
@@ -612,12 +597,10 @@ impl<'a> ReportErrorExt for UndefinedBehaviorInfo<'a> {
612
597
diag. arg ( "vtable_dyn_type" , vtable_dyn_type. to_string ( ) ) ;
613
598
}
614
599
PointerUseAfterFree ( alloc_id, msg) => {
615
- diag. arg ( "alloc_id" , alloc_id)
616
- . arg ( "bad_pointer_message" , bad_pointer_message ( msg, dcx) ) ;
600
+ diag. arg ( "alloc_id" , alloc_id) . arg ( "operation" , format ! ( "{:?}" , msg) ) ;
617
601
}
618
602
PointerOutOfBounds { alloc_id, alloc_size, ptr_offset, inbounds_size, msg } => {
619
603
diag. arg ( "alloc_size" , alloc_size. bytes ( ) ) ;
620
- diag. arg ( "bad_pointer_message" , bad_pointer_message ( msg, dcx) ) ;
621
604
diag. arg ( "pointer" , {
622
605
let mut out = format ! ( "{:?}" , alloc_id) ;
623
606
if ptr_offset > 0 {
@@ -627,14 +610,17 @@ impl<'a> ReportErrorExt for UndefinedBehaviorInfo<'a> {
627
610
}
628
611
out
629
612
} ) ;
613
+ diag. arg ( "inbounds_size" , inbounds_size) ;
630
614
diag. arg ( "inbounds_size_is_neg" , inbounds_size < 0 ) ;
631
615
diag. arg ( "inbounds_size_abs" , inbounds_size. unsigned_abs ( ) ) ;
616
+ diag. arg ( "ptr_offset" , ptr_offset) ;
632
617
diag. arg ( "ptr_offset_is_neg" , ptr_offset < 0 ) ;
633
618
diag. arg ( "ptr_offset_abs" , ptr_offset. unsigned_abs ( ) ) ;
634
619
diag. arg (
635
620
"alloc_size_minus_ptr_offset" ,
636
621
alloc_size. bytes ( ) . saturating_sub ( ptr_offset as u64 ) ,
637
622
) ;
623
+ diag. arg ( "operation" , format ! ( "{:?}" , msg) ) ;
638
624
}
639
625
DanglingIntPointer { addr, inbounds_size, msg } => {
640
626
if addr != 0 {
@@ -644,9 +630,10 @@ impl<'a> ReportErrorExt for UndefinedBehaviorInfo<'a> {
644
630
) ;
645
631
}
646
632
633
+ diag. arg ( "inbounds_size" , inbounds_size) ;
647
634
diag. arg ( "inbounds_size_is_neg" , inbounds_size < 0 ) ;
648
635
diag. arg ( "inbounds_size_abs" , inbounds_size. unsigned_abs ( ) ) ;
649
- diag. arg ( "bad_pointer_message " , bad_pointer_message ( msg , dcx ) ) ;
636
+ diag. arg ( "operation " , format ! ( "{:?}" , msg ) ) ;
650
637
}
651
638
AlignmentCheckFailed ( Misalignment { required, has } , msg) => {
652
639
diag. arg ( "required" , required. bytes ( ) ) ;
0 commit comments