@@ -9,6 +9,7 @@ pub enum TerminationInfo {
9
9
Exit ( i64 ) ,
10
10
Abort ( Option < String > ) ,
11
11
UnsupportedInIsolation ( String ) ,
12
+ ExperimentalUb { msg : String , url : String }
12
13
}
13
14
14
15
/// Miri specific diagnostics
@@ -25,7 +26,7 @@ pub fn report_error<'tcx, 'mir>(
25
26
use InterpError :: * ;
26
27
27
28
e. print_backtrace ( ) ;
28
- let ( title, msg, help ) = match e. kind {
29
+ let ( title, msg, helps ) = match e. kind {
29
30
MachineStop ( info) => {
30
31
let info = info. downcast_ref :: < TerminationInfo > ( ) . expect ( "invalid MachineStop payload" ) ;
31
32
use TerminationInfo :: * ;
@@ -37,13 +38,20 @@ pub fn report_error<'tcx, 'mir>(
37
38
( "abnormal termination" , format ! ( "the evaluated program aborted execution: {}" , msg) ) ,
38
39
UnsupportedInIsolation ( msg) =>
39
40
( "unsupported operation" , format ! ( "{}" , msg) ) ,
41
+ ExperimentalUb { msg, .. } =>
42
+ ( "Undefined Behavior" , format ! ( "{}" , msg) ) ,
40
43
} ;
41
- let help = match info {
44
+ let helps = match info {
42
45
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 ! [ ] ,
45
53
} ;
46
- ( title, msg, help )
54
+ ( title, msg, helps )
47
55
}
48
56
_ => {
49
57
let ( title, msg) = match e. kind {
@@ -56,21 +64,22 @@ pub fn report_error<'tcx, 'mir>(
56
64
_ =>
57
65
bug ! ( "This error should be impossible in Miri: {}" , e) ,
58
66
} ;
59
- let help = match e. kind {
67
+ let helps = match e. kind {
60
68
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`" ) ] ,
62
70
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" ) ] ,
66
72
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 ! [ ] ,
69
78
} ;
70
- ( title, msg, help )
79
+ ( title, msg, helps )
71
80
}
72
81
} ;
73
- report_msg ( ecx, & format ! ( "{}: {}" , title, msg) , msg, help , true )
82
+ report_msg ( ecx, & format ! ( "{}: {}" , title, msg) , msg, & helps , true )
74
83
}
75
84
76
85
/// 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>(
79
88
ecx : & InterpCx < ' mir , ' tcx , Evaluator < ' tcx > > ,
80
89
title : & str ,
81
90
span_msg : String ,
82
- help : Option < & str > ,
91
+ helps : & [ String ] ,
83
92
error : bool ,
84
93
) -> Option < i64 > {
85
94
let span = if let Some ( frame) = ecx. stack ( ) . last ( ) {
@@ -93,7 +102,7 @@ fn report_msg<'tcx, 'mir>(
93
102
ecx. tcx . sess . diagnostic ( ) . span_note_diag ( span, title)
94
103
} ;
95
104
err. span_label ( span, span_msg) ;
96
- if let Some ( help) = help {
105
+ for help in helps {
97
106
err. help ( help) ;
98
107
}
99
108
// Add backtrace
@@ -149,7 +158,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
149
158
CreatedAlloc ( AllocId ( id) ) =>
150
159
format ! ( "created allocation with id {}" , id) ,
151
160
} ;
152
- report_msg ( this, "tracking was triggered" , msg, None , false ) ;
161
+ report_msg ( this, "tracking was triggered" , msg, & [ ] , false ) ;
153
162
}
154
163
} ) ;
155
164
}
0 commit comments