@@ -3,11 +3,13 @@ use std::cell::RefCell;
3
3
4
4
use crate :: * ;
5
5
6
+ /// Miri specific diagnostics
6
7
pub enum NonHaltingDiagnostic {
7
8
PoppedTrackedPointerTag ( Item ) ,
8
9
}
9
10
10
- pub fn report_err < ' tcx , ' mir > (
11
+ /// Emit a custom diagnostic without going through the miri-engine machinery
12
+ pub fn report_diagnostic < ' tcx , ' mir > (
11
13
ecx : & InterpCx < ' mir , ' tcx , Evaluator < ' tcx > > ,
12
14
mut e : InterpErrorInfo < ' tcx > ,
13
15
) -> Option < i64 > {
@@ -31,6 +33,8 @@ pub fn report_err<'tcx, 'mir>(
31
33
report_msg ( ecx, msg, true )
32
34
}
33
35
36
+ /// Report an error or note (depending on the `error` argument) at the current frame's current statement.
37
+ /// Also emits a full stacktrace of the interpreter stack.
34
38
pub fn report_msg < ' tcx , ' mir > (
35
39
ecx : & InterpCx < ' mir , ' tcx , Evaluator < ' tcx > > ,
36
40
msg : String ,
@@ -80,12 +84,15 @@ thread_local! {
80
84
static DIAGNOSTICS : RefCell <Vec <NonHaltingDiagnostic >> = RefCell :: new( Vec :: new( ) ) ;
81
85
}
82
86
87
+ /// Schedule a diagnostic for emitting. This function works even if you have no `InterpCx` available.
88
+ /// The diagnostic will be emitted after the current interpreter step is finished.
83
89
pub fn register_diagnostic ( e : NonHaltingDiagnostic ) {
84
90
DIAGNOSTICS . with ( |diagnostics| diagnostics. borrow_mut ( ) . push ( e) ) ;
85
91
}
86
92
87
93
impl < ' mir , ' tcx > EvalContextExt < ' mir , ' tcx > for crate :: MiriEvalContext < ' mir , ' tcx > { }
88
94
pub trait EvalContextExt < ' mir , ' tcx : ' mir > : crate :: MiriEvalContextExt < ' mir , ' tcx > {
95
+ /// Emit all diagnostics that were registed with `register_diagnostics`
89
96
fn process_diagnostics ( & self ) {
90
97
let this = self . eval_context_ref ( ) ;
91
98
DIAGNOSTICS . with ( |diagnostics| {
0 commit comments