@@ -256,7 +256,10 @@ pub enum UndefinedBehaviorInfo<'tcx> {
256256 /// The value validity check found a problem.
257257 /// Should only be thrown by `validity.rs` and always point out which part of the value
258258 /// is the problem.
259- ValidationFailure ( String ) ,
259+ ValidationFailure {
260+ path : Option < String > ,
261+ msg : String ,
262+ } ,
260263 /// Using a non-boolean `u8` as bool.
261264 InvalidBool ( u8 ) ,
262265 /// Using a non-character `u32` as character.
@@ -331,7 +334,10 @@ impl fmt::Display for UndefinedBehaviorInfo<'_> {
331334 ) ,
332335 WriteToReadOnly ( a) => write ! ( f, "writing to {} which is read-only" , a) ,
333336 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+ }
335341 InvalidBool ( b) => {
336342 write ! ( f, "interpreting an invalid 8-bit value as a bool: 0x{:02x}" , b)
337343 }
@@ -499,13 +505,13 @@ impl fmt::Debug for InterpError<'_> {
499505}
500506
501507impl 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.
503509 /// To avoid performance issues, there are places where we want to be sure to never raise these formatting errors,
504510 /// so this method lets us detect them and `bug!` on unexpected errors.
505511 pub fn formatted_string ( & self ) -> bool {
506512 match self {
507513 InterpError :: Unsupported ( UnsupportedOpInfo :: Unsupported ( _) )
508- | InterpError :: UndefinedBehavior ( UndefinedBehaviorInfo :: ValidationFailure ( _ ) )
514+ | InterpError :: UndefinedBehavior ( UndefinedBehaviorInfo :: ValidationFailure { .. } )
509515 | InterpError :: UndefinedBehavior ( UndefinedBehaviorInfo :: Ub ( _) ) => true ,
510516 _ => false ,
511517 }
0 commit comments