@@ -3,11 +3,13 @@ use std::cell::RefCell;
33
44use crate :: * ;
55
6+ /// Miri specific diagnostics
67pub enum NonHaltingDiagnostic {
78 PoppedTrackedPointerTag ( Item ) ,
89}
910
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 > (
1113 ecx : & InterpCx < ' mir , ' tcx , Evaluator < ' tcx > > ,
1214 mut e : InterpErrorInfo < ' tcx > ,
1315) -> Option < i64 > {
@@ -31,6 +33,8 @@ pub fn report_err<'tcx, 'mir>(
3133 report_msg ( ecx, msg, true )
3234}
3335
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.
3438pub fn report_msg < ' tcx , ' mir > (
3539 ecx : & InterpCx < ' mir , ' tcx , Evaluator < ' tcx > > ,
3640 msg : String ,
@@ -80,12 +84,15 @@ thread_local! {
8084 static DIAGNOSTICS : RefCell <Vec <NonHaltingDiagnostic >> = RefCell :: new( Vec :: new( ) ) ;
8185}
8286
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.
8389pub fn register_diagnostic ( e : NonHaltingDiagnostic ) {
8490 DIAGNOSTICS . with ( |diagnostics| diagnostics. borrow_mut ( ) . push ( e) ) ;
8591}
8692
8793impl < ' mir , ' tcx > EvalContextExt < ' mir , ' tcx > for crate :: MiriEvalContext < ' mir , ' tcx > { }
8894pub trait EvalContextExt < ' mir , ' tcx : ' mir > : crate :: MiriEvalContextExt < ' mir , ' tcx > {
95+ /// Emit all diagnostics that were registed with `register_diagnostics`
8996 fn process_diagnostics ( & self ) {
9097 let this = self . eval_context_ref ( ) ;
9198 DIAGNOSTICS . with ( |diagnostics| {
0 commit comments