@@ -199,6 +199,7 @@ pub fn report_error<'tcx, 'mir>(
199
199
e : InterpErrorInfo < ' tcx > ,
200
200
) -> Option < ( i64 , bool ) > {
201
201
use InterpError :: * ;
202
+ use UndefinedBehaviorInfo :: * ;
202
203
203
204
let mut msg = vec ! [ ] ;
204
205
@@ -271,7 +272,7 @@ pub fn report_error<'tcx, 'mir>(
271
272
( title, helps)
272
273
} else {
273
274
let title = match e. kind ( ) {
274
- UndefinedBehavior ( UndefinedBehaviorInfo :: ValidationError ( validation_err) )
275
+ UndefinedBehavior ( ValidationError ( validation_err) )
275
276
if matches ! (
276
277
validation_err. kind,
277
278
ValidationErrorKind :: PointerAsInt { .. } | ValidationErrorKind :: PartialPointer
@@ -299,7 +300,7 @@ pub fn report_error<'tcx, 'mir>(
299
300
let helps = match e. kind ( ) {
300
301
Unsupported ( _) =>
301
302
vec ! [ ( None , format!( "this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support" ) ) ] ,
302
- UndefinedBehavior ( UndefinedBehaviorInfo :: AlignmentCheckFailed { .. } )
303
+ UndefinedBehavior ( AlignmentCheckFailed { .. } )
303
304
if ecx. machine . check_alignment == AlignmentCheck :: Symbolic
304
305
=>
305
306
vec ! [
@@ -311,13 +312,20 @@ pub fn report_error<'tcx, 'mir>(
311
312
( None , format!( "this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior" ) ) ,
312
313
( None , format!( "see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information" ) ) ,
313
314
] ;
314
- if let UndefinedBehaviorInfo :: PointerUseAfterFree ( alloc_id, _) | UndefinedBehaviorInfo :: PointerOutOfBounds { alloc_id, .. } = info {
315
- if let Some ( span) = ecx. machine . allocated_span ( * alloc_id) {
316
- helps. push ( ( Some ( span) , format ! ( "{:?} was allocated here:" , alloc_id) ) ) ;
315
+ match info {
316
+ PointerUseAfterFree ( alloc_id, _) | PointerOutOfBounds { alloc_id, .. } => {
317
+ if let Some ( span) = ecx. machine . allocated_span ( * alloc_id) {
318
+ helps. push ( ( Some ( span) , format ! ( "{:?} was allocated here:" , alloc_id) ) ) ;
319
+ }
320
+ if let Some ( span) = ecx. machine . deallocated_span ( * alloc_id) {
321
+ helps. push ( ( Some ( span) , format ! ( "{:?} was deallocated here:" , alloc_id) ) ) ;
322
+ }
317
323
}
318
- if let Some ( span) = ecx. machine . deallocated_span ( * alloc_id) {
319
- helps. push ( ( Some ( span) , format ! ( "{:?} was deallocated here:" , alloc_id) ) ) ;
324
+ AbiMismatchArgument { .. } | AbiMismatchReturn { .. } => {
325
+ helps. push ( ( None , format ! ( "this means these two types are not *guaranteed* to be ABI-compatible across all targets" ) ) ) ;
326
+ helps. push ( ( None , format ! ( "if you think this code should be accepted anyway, please report an issue" ) ) ) ;
320
327
}
328
+ _ => { } ,
321
329
}
322
330
helps
323
331
}
@@ -339,7 +347,7 @@ pub fn report_error<'tcx, 'mir>(
339
347
// We want to dump the allocation if this is `InvalidUninitBytes`. Since `format_error` consumes `e`, we compute the outut early.
340
348
let mut extra = String :: new ( ) ;
341
349
match e. kind ( ) {
342
- UndefinedBehavior ( UndefinedBehaviorInfo :: InvalidUninitBytes ( Some ( ( alloc_id, access) ) ) ) => {
350
+ UndefinedBehavior ( InvalidUninitBytes ( Some ( ( alloc_id, access) ) ) ) => {
343
351
writeln ! (
344
352
extra,
345
353
"Uninitialized memory occurred at {alloc_id:?}{range:?}, in this allocation:" ,
0 commit comments