@@ -17,8 +17,8 @@ use rustc_hir as hir;
17
17
use rustc_middle:: bug;
18
18
use rustc_middle:: mir:: interpret:: ValidationErrorKind :: { self , * } ;
19
19
use 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,
22
22
} ;
23
23
use rustc_middle:: ty:: layout:: { LayoutCx , LayoutOf , TyAndLayout } ;
24
24
use rustc_middle:: ty:: { self , Ty } ;
@@ -37,8 +37,8 @@ use super::{
37
37
38
38
// for the validation errors
39
39
#[ 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 ;
42
42
use super :: UndefinedBehaviorInfo :: * ;
43
43
use super :: UnsupportedOpInfo :: * ;
44
44
@@ -97,20 +97,19 @@ macro_rules! try_validation {
97
97
( $e: expr, $where: expr,
98
98
$( $( $p: pat_param ) |+ => $kind: expr ) ,+ $( , ) ?
99
99
) => { {
100
- $e. map_err ( |e| {
100
+ $e. map_err_kind ( |e| {
101
101
// We catch the error and turn it into a validation failure. We are okay with
102
102
// 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 {
105
104
$(
106
105
$( $p) |+ => {
107
106
err_validation_failure!(
108
107
$where,
109
108
$kind
110
- ) . into ( )
109
+ )
111
110
}
112
111
) ,+,
113
- _ => InterpErrorInfo :: from_parts ( kind , backtrace ) ,
112
+ e => e ,
114
113
}
115
114
} ) ?
116
115
} } ;
@@ -1230,11 +1229,10 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValueVisitor<'tcx, M> for ValidityVisitor<'rt,
1230
1229
// No need for an alignment check here, this is not an actual memory access.
1231
1230
let alloc = self . ecx . get_ptr_alloc ( mplace. ptr ( ) , size) ?. expect ( "we already excluded size 0" ) ;
1232
1231
1233
- alloc. get_bytes_strip_provenance ( ) . map_err ( |err | {
1232
+ alloc. get_bytes_strip_provenance ( ) . map_err_kind ( |kind | {
1234
1233
// Some error happened, try to provide a more detailed description.
1235
1234
// For some errors we might be able to provide extra information.
1236
1235
// (This custom logic does not fit the `try_validation!` macro.)
1237
- let ( kind, backtrace) = err. into_parts ( ) ;
1238
1236
match kind {
1239
1237
Ub ( InvalidUninitBytes ( Some ( ( _alloc_id, access) ) ) ) | Unsup ( ReadPointerAsInt ( Some ( ( _alloc_id, access) ) ) ) => {
1240
1238
// Some byte was uninitialized, determine which
@@ -1247,14 +1245,14 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValueVisitor<'tcx, M> for ValidityVisitor<'rt,
1247
1245
self . path . push ( PathElem :: ArrayElem ( i) ) ;
1248
1246
1249
1247
if matches ! ( kind, Ub ( InvalidUninitBytes ( _) ) ) {
1250
- err_validation_failure ! ( self . path, Uninit { expected } ) . into ( )
1248
+ err_validation_failure ! ( self . path, Uninit { expected } )
1251
1249
} else {
1252
- err_validation_failure ! ( self . path, PointerAsInt { expected } ) . into ( )
1250
+ err_validation_failure ! ( self . path, PointerAsInt { expected } )
1253
1251
}
1254
1252
}
1255
1253
1256
1254
// Propagate upwards (that will also check for unexpected errors).
1257
- _ => return InterpErrorInfo :: from_parts ( kind , backtrace ) ,
1255
+ err => err ,
1258
1256
}
1259
1257
} ) ?;
1260
1258
@@ -1368,12 +1366,12 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
1368
1366
v. reset_padding ( val) ?;
1369
1367
interp_ok ( ( ) )
1370
1368
} )
1371
- . map_err ( |err| {
1369
+ . map_err_info ( |err| {
1372
1370
if !matches ! (
1373
1371
err. kind( ) ,
1374
1372
err_ub!( ValidationError { .. } )
1375
- | InterpError :: InvalidProgram ( _)
1376
- | InterpError :: Unsupported ( UnsupportedOpInfo :: ExternTypeField )
1373
+ | InterpErrorKind :: InvalidProgram ( _)
1374
+ | InterpErrorKind :: Unsupported ( UnsupportedOpInfo :: ExternTypeField )
1377
1375
) {
1378
1376
bug ! (
1379
1377
"Unexpected error during validation: {}" ,
0 commit comments