1
1
use rustc_mir:: interpret:: InterpErrorInfo ;
2
+ use std:: cell:: RefCell ;
2
3
3
4
use crate :: * ;
4
5
6
+ pub enum NonHaltingDiagnostic {
7
+ PoppedTrackedPointerTag ( Item ) ,
8
+ }
9
+
5
10
pub fn report_err < ' tcx , ' mir > (
6
11
ecx : & InterpCx < ' mir , ' tcx , Evaluator < ' tcx > > ,
7
12
mut e : InterpErrorInfo < ' tcx > ,
@@ -12,8 +17,6 @@ pub fn report_err<'tcx, 'mir>(
12
17
let info = info. downcast_ref :: < TerminationInfo > ( ) . expect ( "invalid MachineStop payload" ) ;
13
18
match info {
14
19
TerminationInfo :: Exit ( code) => return Some ( * code) ,
15
- TerminationInfo :: PoppedTrackedPointerTag ( item) =>
16
- format ! ( "popped tracked tag for item {:?}" , item) ,
17
20
TerminationInfo :: Abort => format ! ( "the evaluated program aborted execution" ) ,
18
21
}
19
22
}
@@ -25,11 +28,23 @@ pub fn report_err<'tcx, 'mir>(
25
28
_ => e. to_string ( ) ,
26
29
} ;
27
30
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 > {
28
39
if let Some ( frame) = ecx. stack ( ) . last ( ) {
29
40
let span = frame. current_source_info ( ) . unwrap ( ) . span ;
30
41
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
+ } ;
33
48
let frames = ecx. generate_stacktrace ( None ) ;
34
49
err. span_label ( span, msg) ;
35
50
// 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>(
61
76
return None ;
62
77
}
63
78
64
- use std:: cell:: RefCell ;
65
79
thread_local ! {
66
- static ECX : RefCell <Vec <InterpErrorInfo < ' static > >> = RefCell :: new( Vec :: new( ) ) ;
80
+ static ECX : RefCell <Vec <NonHaltingDiagnostic >> = RefCell :: new( Vec :: new( ) ) ;
67
81
}
68
82
69
- pub fn register_err ( e : InterpErrorInfo < ' static > ) {
83
+ pub fn register_err ( e : NonHaltingDiagnostic ) {
70
84
ECX . with ( |ecx| ecx. borrow_mut ( ) . push ( e) ) ;
71
85
}
72
86
@@ -76,7 +90,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
76
90
let this = self . eval_context_ref ( ) ;
77
91
ECX . with ( |ecx| {
78
92
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 ) ;
80
98
}
81
99
} ) ;
82
100
}
0 commit comments