@@ -256,7 +256,10 @@ pub enum UndefinedBehaviorInfo<'tcx> {
256
256
/// The value validity check found a problem.
257
257
/// Should only be thrown by `validity.rs` and always point out which part of the value
258
258
/// is the problem.
259
- ValidationFailure ( String ) ,
259
+ ValidationFailure {
260
+ path : Option < String > ,
261
+ msg : String ,
262
+ } ,
260
263
/// Using a non-boolean `u8` as bool.
261
264
InvalidBool ( u8 ) ,
262
265
/// Using a non-character `u32` as character.
@@ -331,7 +334,10 @@ impl fmt::Display for UndefinedBehaviorInfo<'_> {
331
334
) ,
332
335
WriteToReadOnly ( a) => write ! ( f, "writing to {} which is read-only" , a) ,
333
336
DerefFunctionPointer ( a) => write ! ( f, "accessing {} which contains a function" , a) ,
334
- ValidationFailure ( ref err) => write ! ( f, "type validation failed: {}" , err) ,
337
+ ValidationFailure { path : None , msg } => write ! ( f, "type validation failed: {}" , msg) ,
338
+ ValidationFailure { path : Some ( path) , msg } => {
339
+ write ! ( f, "type validation failed at {}: {}" , path, msg)
340
+ }
335
341
InvalidBool ( b) => {
336
342
write ! ( f, "interpreting an invalid 8-bit value as a bool: 0x{:02x}" , b)
337
343
}
@@ -499,13 +505,13 @@ impl fmt::Debug for InterpError<'_> {
499
505
}
500
506
501
507
impl InterpError < ' _ > {
502
- /// Some errors to string formatting even if the error is never printed.
508
+ /// Some errors do string formatting even if the error is never printed.
503
509
/// To avoid performance issues, there are places where we want to be sure to never raise these formatting errors,
504
510
/// so this method lets us detect them and `bug!` on unexpected errors.
505
511
pub fn formatted_string ( & self ) -> bool {
506
512
match self {
507
513
InterpError :: Unsupported ( UnsupportedOpInfo :: Unsupported ( _) )
508
- | InterpError :: UndefinedBehavior ( UndefinedBehaviorInfo :: ValidationFailure ( _ ) )
514
+ | InterpError :: UndefinedBehavior ( UndefinedBehaviorInfo :: ValidationFailure { .. } )
509
515
| InterpError :: UndefinedBehavior ( UndefinedBehaviorInfo :: Ub ( _) ) => true ,
510
516
_ => false ,
511
517
}
0 commit comments