@@ -9,6 +9,7 @@ pub enum TerminationInfo {
99 Exit ( i64 ) ,
1010 Abort ( Option < String > ) ,
1111 UnsupportedInIsolation ( String ) ,
12+ ExperimentalUb { msg : String , url : String }
1213}
1314
1415/// Miri specific diagnostics
@@ -25,7 +26,7 @@ pub fn report_error<'tcx, 'mir>(
2526 use InterpError :: * ;
2627
2728 e. print_backtrace ( ) ;
28- let ( title, msg, help ) = match e. kind {
29+ let ( title, msg, helps ) = match e. kind {
2930 MachineStop ( info) => {
3031 let info = info. downcast_ref :: < TerminationInfo > ( ) . expect ( "invalid MachineStop payload" ) ;
3132 use TerminationInfo :: * ;
@@ -37,13 +38,20 @@ pub fn report_error<'tcx, 'mir>(
3738 ( "abnormal termination" , format ! ( "the evaluated program aborted execution: {}" , msg) ) ,
3839 UnsupportedInIsolation ( msg) =>
3940 ( "unsupported operation" , format ! ( "{}" , msg) ) ,
41+ ExperimentalUb { msg, .. } =>
42+ ( "Undefined Behavior" , format ! ( "{}" , msg) ) ,
4043 } ;
41- let help = match info {
44+ let helps = match info {
4245 UnsupportedInIsolation ( _) =>
43- Some ( "pass the flag `-Zmiri-disable-isolation` to disable isolation" ) ,
44- _ => None ,
46+ vec ! [ format!( "pass the flag `-Zmiri-disable-isolation` to disable isolation" ) ] ,
47+ ExperimentalUb { url, .. } =>
48+ vec ! [
49+ format!( "this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental" ) ,
50+ format!( "see {} for further information" , url) ,
51+ ] ,
52+ _ => vec ! [ ] ,
4553 } ;
46- ( title, msg, help )
54+ ( title, msg, helps )
4755 }
4856 _ => {
4957 let ( title, msg) = match e. kind {
@@ -56,21 +64,22 @@ pub fn report_error<'tcx, 'mir>(
5664 _ =>
5765 bug ! ( "This error should be impossible in Miri: {}" , e) ,
5866 } ;
59- let help = match e. kind {
67+ let helps = match e. kind {
6068 Unsupported ( UnsupportedOpInfo :: NoMirFor ( ..) ) =>
61- Some ( "make sure to use a Miri sysroot, which you can prepare with `cargo miri setup`" ) ,
69+ vec ! [ format! ( "make sure to use a Miri sysroot, which you can prepare with `cargo miri setup`" ) ] ,
6270 Unsupported ( _) =>
63- Some ( "this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support" ) ,
64- UndefinedBehavior ( UndefinedBehaviorInfo :: UbExperimental ( _) ) =>
65- Some ( "this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental" ) ,
71+ vec ! [ format!( "this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support" ) ] ,
6672 UndefinedBehavior ( _) =>
67- Some ( "this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior" ) ,
68- _ => None ,
73+ vec ! [
74+ format!( "this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior" ) ,
75+ format!( "see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information" ) ,
76+ ] ,
77+ _ => vec ! [ ] ,
6978 } ;
70- ( title, msg, help )
79+ ( title, msg, helps )
7180 }
7281 } ;
73- report_msg ( ecx, & format ! ( "{}: {}" , title, msg) , msg, help , true )
82+ report_msg ( ecx, & format ! ( "{}: {}" , title, msg) , msg, & helps , true )
7483}
7584
7685/// Report an error or note (depending on the `error` argument) at the current frame's current statement.
@@ -79,7 +88,7 @@ fn report_msg<'tcx, 'mir>(
7988 ecx : & InterpCx < ' mir , ' tcx , Evaluator < ' tcx > > ,
8089 title : & str ,
8190 span_msg : String ,
82- help : Option < & str > ,
91+ helps : & [ String ] ,
8392 error : bool ,
8493) -> Option < i64 > {
8594 let span = if let Some ( frame) = ecx. stack ( ) . last ( ) {
@@ -93,7 +102,7 @@ fn report_msg<'tcx, 'mir>(
93102 ecx. tcx . sess . diagnostic ( ) . span_note_diag ( span, title)
94103 } ;
95104 err. span_label ( span, span_msg) ;
96- if let Some ( help) = help {
105+ for help in helps {
97106 err. help ( help) ;
98107 }
99108 // Add backtrace
@@ -149,7 +158,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
149158 CreatedAlloc ( AllocId ( id) ) =>
150159 format ! ( "created allocation with id {}" , id) ,
151160 } ;
152- report_msg ( this, "tracking was triggered" , msg, None , false ) ;
161+ report_msg ( this, "tracking was triggered" , msg, & [ ] , false ) ;
153162 }
154163 } ) ;
155164 }
0 commit comments