11use rustc_mir:: interpret:: InterpErrorInfo ;
2+ use std:: cell:: RefCell ;
23
34use crate :: * ;
45
6+ pub enum NonHaltingDiagnostic {
7+ PoppedTrackedPointerTag ( Item ) ,
8+ }
9+
510pub fn report_err < ' tcx , ' mir > (
611 ecx : & InterpCx < ' mir , ' tcx , Evaluator < ' tcx > > ,
712 mut e : InterpErrorInfo < ' tcx > ,
@@ -12,8 +17,6 @@ pub fn report_err<'tcx, 'mir>(
1217 let info = info. downcast_ref :: < TerminationInfo > ( ) . expect ( "invalid MachineStop payload" ) ;
1318 match info {
1419 TerminationInfo :: Exit ( code) => return Some ( * code) ,
15- TerminationInfo :: PoppedTrackedPointerTag ( item) =>
16- format ! ( "popped tracked tag for item {:?}" , item) ,
1720 TerminationInfo :: Abort => format ! ( "the evaluated program aborted execution" ) ,
1821 }
1922 }
@@ -25,11 +28,23 @@ pub fn report_err<'tcx, 'mir>(
2528 _ => e. to_string ( ) ,
2629 } ;
2730 e. print_backtrace ( ) ;
31+ report_msg ( ecx, msg, true )
32+ }
33+
34+ pub fn report_msg < ' tcx , ' mir > (
35+ ecx : & InterpCx < ' mir , ' tcx , Evaluator < ' tcx > > ,
36+ msg : String ,
37+ error : bool ,
38+ ) -> Option < i64 > {
2839 if let Some ( frame) = ecx. stack ( ) . last ( ) {
2940 let span = frame. current_source_info ( ) . unwrap ( ) . span ;
3041
31- let msg = format ! ( "Miri evaluation error: {}" , msg) ;
32- let mut err = ecx. tcx . sess . struct_span_err ( span, msg. as_str ( ) ) ;
42+ let mut err = if error {
43+ let msg = format ! ( "Miri evaluation error: {}" , msg) ;
44+ ecx. tcx . sess . struct_span_err ( span, msg. as_str ( ) )
45+ } else {
46+ ecx. tcx . sess . diagnostic ( ) . span_note_diag ( span, msg. as_str ( ) )
47+ } ;
3348 let frames = ecx. generate_stacktrace ( None ) ;
3449 err. span_label ( span, msg) ;
3550 // We iterate with indices because we need to look at the next frame (the caller).
@@ -61,12 +76,11 @@ pub fn report_err<'tcx, 'mir>(
6176 return None ;
6277}
6378
64- use std:: cell:: RefCell ;
6579thread_local ! {
66- static ECX : RefCell <Vec <InterpErrorInfo < ' static > >> = RefCell :: new( Vec :: new( ) ) ;
80+ static ECX : RefCell <Vec <NonHaltingDiagnostic >> = RefCell :: new( Vec :: new( ) ) ;
6781}
6882
69- pub fn register_err ( e : InterpErrorInfo < ' static > ) {
83+ pub fn register_err ( e : NonHaltingDiagnostic ) {
7084 ECX . with ( |ecx| ecx. borrow_mut ( ) . push ( e) ) ;
7185}
7286
@@ -76,7 +90,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
7690 let this = self . eval_context_ref ( ) ;
7791 ECX . with ( |ecx| {
7892 for e in ecx. borrow_mut ( ) . drain ( ..) {
79- report_err ( this, e) ;
93+ let msg = match e {
94+ NonHaltingDiagnostic :: PoppedTrackedPointerTag ( item) =>
95+ format ! ( "popped tracked tag for item {:?}" , item) ,
96+ } ;
97+ report_msg ( this, msg, false ) ;
8098 }
8199 } ) ;
82100 }
0 commit comments