@@ -199,6 +199,7 @@ pub fn report_error<'tcx, 'mir>(
199199 e : InterpErrorInfo < ' tcx > ,
200200) -> Option < ( i64 , bool ) > {
201201 use InterpError :: * ;
202+ use UndefinedBehaviorInfo :: * ;
202203
203204 let mut msg = vec ! [ ] ;
204205
@@ -271,7 +272,7 @@ pub fn report_error<'tcx, 'mir>(
271272 ( title, helps)
272273 } else {
273274 let title = match e. kind ( ) {
274- UndefinedBehavior ( UndefinedBehaviorInfo :: ValidationError ( validation_err) )
275+ UndefinedBehavior ( ValidationError ( validation_err) )
275276 if matches ! (
276277 validation_err. kind,
277278 ValidationErrorKind :: PointerAsInt { .. } | ValidationErrorKind :: PartialPointer
@@ -299,7 +300,7 @@ pub fn report_error<'tcx, 'mir>(
299300 let helps = match e. kind ( ) {
300301 Unsupported ( _) =>
301302 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 { .. } )
303304 if ecx. machine . check_alignment == AlignmentCheck :: Symbolic
304305 =>
305306 vec ! [
@@ -311,13 +312,20 @@ pub fn report_error<'tcx, 'mir>(
311312 ( None , format!( "this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior" ) ) ,
312313 ( None , format!( "see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information" ) ) ,
313314 ] ;
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+ }
317323 }
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" ) ) ) ;
320327 }
328+ _ => { } ,
321329 }
322330 helps
323331 }
@@ -339,7 +347,7 @@ pub fn report_error<'tcx, 'mir>(
339347 // We want to dump the allocation if this is `InvalidUninitBytes`. Since `format_error` consumes `e`, we compute the outut early.
340348 let mut extra = String :: new ( ) ;
341349 match e. kind ( ) {
342- UndefinedBehavior ( UndefinedBehaviorInfo :: InvalidUninitBytes ( Some ( ( alloc_id, access) ) ) ) => {
350+ UndefinedBehavior ( InvalidUninitBytes ( Some ( ( alloc_id, access) ) ) ) => {
343351 writeln ! (
344352 extra,
345353 "Uninitialized memory occurred at {alloc_id:?}{range:?}, in this allocation:" ,
0 commit comments