@@ -134,7 +134,7 @@ pub fn report_error<'tcx, 'mir>(
134
134
) -> Option < i64 > {
135
135
use InterpError :: * ;
136
136
137
- let ( title, helps) = match & e. kind ( ) {
137
+ let ( title, labels , helps) = match & e. kind ( ) {
138
138
MachineStop ( info) => {
139
139
let info = info. downcast_ref :: < TerminationInfo > ( ) . expect ( "invalid MachineStop payload" ) ;
140
140
use TerminationInfo :: * ;
@@ -146,6 +146,7 @@ pub fn report_error<'tcx, 'mir>(
146
146
Deadlock => Some ( "deadlock" ) ,
147
147
MultipleSymbolDefinitions { .. } | SymbolShimClashing { .. } => None ,
148
148
} ;
149
+ let mut labels = vec ! [ ] ;
149
150
#[ rustfmt:: skip]
150
151
let helps = match info {
151
152
UnsupportedInIsolation ( _) =>
@@ -154,17 +155,13 @@ pub fn report_error<'tcx, 'mir>(
154
155
( None , format!( "or pass `-Zmiri-isolation-error=warn to configure Miri to return an error code from isolated operations (if supported for that operation) and continue with a warning" ) ) ,
155
156
] ,
156
157
ExperimentalUb { url, help, .. } => {
157
- let mut helps = Vec :: new ( ) ;
158
158
if let Some ( help) = help {
159
- helps . push ( ( Some ( ecx . cur_span ( ) . data ( ) ) , help. clone ( ) ) ) ;
159
+ labels . push ( help. clone ( ) ) ;
160
160
}
161
- helps. push (
162
- ( None , format ! ( "this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental" ) )
163
- ) ;
164
- helps. push (
161
+ vec ! [
162
+ ( None , format!( "this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental" ) ) ,
165
163
( None , format!( "see {} for further information" , url) )
166
- ) ;
167
- helps
164
+ ]
168
165
}
169
166
MultipleSymbolDefinitions { first, first_crate, second, second_crate, .. } =>
170
167
vec ! [
@@ -175,7 +172,7 @@ pub fn report_error<'tcx, 'mir>(
175
172
vec ! [ ( Some ( * span) , format!( "the `{}` symbol is defined here" , link_name) ) ] ,
176
173
_ => vec ! [ ] ,
177
174
} ;
178
- ( title, helps)
175
+ ( title, labels , helps)
179
176
}
180
177
_ => {
181
178
#[ rustfmt:: skip]
@@ -213,7 +210,7 @@ pub fn report_error<'tcx, 'mir>(
213
210
] ,
214
211
_ => vec ! [ ] ,
215
212
} ;
216
- ( Some ( title) , helps)
213
+ ( Some ( title) , vec ! [ ] , helps)
217
214
}
218
215
} ;
219
216
@@ -226,6 +223,7 @@ pub fn report_error<'tcx, 'mir>(
226
223
DiagLevel :: Error ,
227
224
& if let Some ( title) = title { format ! ( "{}: {}" , title, msg) } else { msg. clone ( ) } ,
228
225
msg,
226
+ labels,
229
227
helps,
230
228
& stacktrace,
231
229
) ;
@@ -270,6 +268,7 @@ fn report_msg<'tcx>(
270
268
diag_level : DiagLevel ,
271
269
title : & str ,
272
270
span_msg : String ,
271
+ labels : Vec < String > ,
273
272
mut helps : Vec < ( Option < SpanData > , String ) > ,
274
273
stacktrace : & [ FrameInfo < ' tcx > ] ,
275
274
) {
@@ -288,6 +287,12 @@ fn report_msg<'tcx>(
288
287
err. note ( & span_msg) ;
289
288
err. note ( "(no span available)" ) ;
290
289
}
290
+
291
+ // Add extra labels to the primary span.
292
+ for label in labels {
293
+ err. span_label ( span, label) ;
294
+ }
295
+
291
296
// Show help messages.
292
297
if !helps. is_empty ( ) {
293
298
// Add visual separator before backtrace.
@@ -422,7 +427,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
422
427
_ => ( "tracking was triggered" , DiagLevel :: Note ) ,
423
428
} ;
424
429
425
- report_msg ( * this. tcx , diag_level, title, msg, vec ! [ ] , & stacktrace) ;
430
+ report_msg ( * this. tcx , diag_level, title, msg, vec ! [ ] , vec ! [ ] , & stacktrace) ;
426
431
}
427
432
} ) ;
428
433
}
0 commit comments