@@ -17,8 +17,8 @@ use rustc_hir as hir;
1717use rustc_middle:: bug;
1818use rustc_middle:: mir:: interpret:: ValidationErrorKind :: { self , * } ;
1919use rustc_middle:: mir:: interpret:: {
20- ExpectedKind , InterpError , InterpErrorInfo , InvalidMetaKind , Misalignment , PointerKind ,
21- Provenance , UnsupportedOpInfo , ValidationErrorInfo , alloc_range, interp_ok,
20+ ExpectedKind , InterpErrorKind , InvalidMetaKind , Misalignment , PointerKind , Provenance ,
21+ UnsupportedOpInfo , ValidationErrorInfo , alloc_range, interp_ok,
2222} ;
2323use rustc_middle:: ty:: layout:: { LayoutCx , LayoutOf , TyAndLayout } ;
2424use rustc_middle:: ty:: { self , Ty } ;
@@ -37,8 +37,8 @@ use super::{
3737
3838// for the validation errors
3939#[ rustfmt:: skip]
40- use super :: InterpError :: UndefinedBehavior as Ub ;
41- use super :: InterpError :: Unsupported as Unsup ;
40+ use super :: InterpErrorKind :: UndefinedBehavior as Ub ;
41+ use super :: InterpErrorKind :: Unsupported as Unsup ;
4242use super :: UndefinedBehaviorInfo :: * ;
4343use super :: UnsupportedOpInfo :: * ;
4444
@@ -97,20 +97,19 @@ macro_rules! try_validation {
9797 ( $e: expr, $where: expr,
9898 $( $( $p: pat_param ) |+ => $kind: expr ) ,+ $( , ) ?
9999 ) => { {
100- $e. map_err ( |e| {
100+ $e. map_err_kind ( |e| {
101101 // We catch the error and turn it into a validation failure. We are okay with
102102 // allocation here as this can only slow down builds that fail anyway.
103- let ( kind, backtrace) = e. into_parts( ) ;
104- match kind {
103+ match e {
105104 $(
106105 $( $p) |+ => {
107106 err_validation_failure!(
108107 $where,
109108 $kind
110- ) . into ( )
109+ )
111110 }
112111 ) ,+,
113- _ => InterpErrorInfo :: from_parts ( kind , backtrace ) ,
112+ e => e ,
114113 }
115114 } ) ?
116115 } } ;
@@ -1230,11 +1229,10 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValueVisitor<'tcx, M> for ValidityVisitor<'rt,
12301229 // No need for an alignment check here, this is not an actual memory access.
12311230 let alloc = self . ecx . get_ptr_alloc ( mplace. ptr ( ) , size) ?. expect ( "we already excluded size 0" ) ;
12321231
1233- alloc. get_bytes_strip_provenance ( ) . map_err ( |err | {
1232+ alloc. get_bytes_strip_provenance ( ) . map_err_kind ( |kind | {
12341233 // Some error happened, try to provide a more detailed description.
12351234 // For some errors we might be able to provide extra information.
12361235 // (This custom logic does not fit the `try_validation!` macro.)
1237- let ( kind, backtrace) = err. into_parts ( ) ;
12381236 match kind {
12391237 Ub ( InvalidUninitBytes ( Some ( ( _alloc_id, access) ) ) ) | Unsup ( ReadPointerAsInt ( Some ( ( _alloc_id, access) ) ) ) => {
12401238 // Some byte was uninitialized, determine which
@@ -1247,14 +1245,14 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValueVisitor<'tcx, M> for ValidityVisitor<'rt,
12471245 self . path . push ( PathElem :: ArrayElem ( i) ) ;
12481246
12491247 if matches ! ( kind, Ub ( InvalidUninitBytes ( _) ) ) {
1250- err_validation_failure ! ( self . path, Uninit { expected } ) . into ( )
1248+ err_validation_failure ! ( self . path, Uninit { expected } )
12511249 } else {
1252- err_validation_failure ! ( self . path, PointerAsInt { expected } ) . into ( )
1250+ err_validation_failure ! ( self . path, PointerAsInt { expected } )
12531251 }
12541252 }
12551253
12561254 // Propagate upwards (that will also check for unexpected errors).
1257- _ => return InterpErrorInfo :: from_parts ( kind , backtrace ) ,
1255+ err => err ,
12581256 }
12591257 } ) ?;
12601258
@@ -1368,12 +1366,12 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
13681366 v. reset_padding ( val) ?;
13691367 interp_ok ( ( ) )
13701368 } )
1371- . map_err ( |err| {
1369+ . map_err_info ( |err| {
13721370 if !matches ! (
13731371 err. kind( ) ,
13741372 err_ub!( ValidationError { .. } )
1375- | InterpError :: InvalidProgram ( _)
1376- | InterpError :: Unsupported ( UnsupportedOpInfo :: ExternTypeField )
1373+ | InterpErrorKind :: InvalidProgram ( _)
1374+ | InterpErrorKind :: Unsupported ( UnsupportedOpInfo :: ExternTypeField )
13771375 ) {
13781376 bug ! (
13791377 "Unexpected error during validation: {}" ,
0 commit comments