@@ -15,15 +15,49 @@ use std::{any::Any, backtrace::Backtrace, fmt};
15
15
pub enum ErrorHandled {
16
16
/// Already reported an error for this evaluation, and the compilation is
17
17
/// *guaranteed* to fail. Warnings/lints *must not* produce `Reported`.
18
- Reported ( ErrorGuaranteed ) ,
18
+ Reported ( ReportedErrorInfo ) ,
19
19
/// Don't emit an error, the evaluation failed because the MIR was generic
20
20
/// and the substs didn't fully monomorphize it.
21
21
TooGeneric ,
22
22
}
23
23
24
24
impl From < ErrorGuaranteed > for ErrorHandled {
25
- fn from ( err : ErrorGuaranteed ) -> ErrorHandled {
26
- ErrorHandled :: Reported ( err)
25
+ #[ inline]
26
+ fn from ( error : ErrorGuaranteed ) -> ErrorHandled {
27
+ ErrorHandled :: Reported ( error. into ( ) )
28
+ }
29
+ }
30
+
31
+ #[ derive( Debug , Copy , Clone , PartialEq , Eq , HashStable , TyEncodable , TyDecodable ) ]
32
+ pub struct ReportedErrorInfo {
33
+ error : ErrorGuaranteed ,
34
+ is_tainted_by_errors : bool ,
35
+ }
36
+
37
+ impl ReportedErrorInfo {
38
+ #[ inline]
39
+ pub fn tainted_by_errors ( error : ErrorGuaranteed ) -> ReportedErrorInfo {
40
+ ReportedErrorInfo { is_tainted_by_errors : true , error }
41
+ }
42
+
43
+ /// Returns true if evaluation failed because MIR was tainted by errors.
44
+ #[ inline]
45
+ pub fn is_tainted_by_errors ( self ) -> bool {
46
+ self . is_tainted_by_errors
47
+ }
48
+ }
49
+
50
+ impl From < ErrorGuaranteed > for ReportedErrorInfo {
51
+ #[ inline]
52
+ fn from ( error : ErrorGuaranteed ) -> ReportedErrorInfo {
53
+ ReportedErrorInfo { is_tainted_by_errors : false , error }
54
+ }
55
+ }
56
+
57
+ impl Into < ErrorGuaranteed > for ReportedErrorInfo {
58
+ #[ inline]
59
+ fn into ( self ) -> ErrorGuaranteed {
60
+ self . error
27
61
}
28
62
}
29
63
@@ -89,7 +123,7 @@ fn print_backtrace(backtrace: &Backtrace) {
89
123
90
124
impl From < ErrorGuaranteed > for InterpErrorInfo < ' _ > {
91
125
fn from ( err : ErrorGuaranteed ) -> Self {
92
- InterpError :: InvalidProgram ( InvalidProgramInfo :: AlreadyReported ( err) ) . into ( )
126
+ InterpError :: InvalidProgram ( InvalidProgramInfo :: AlreadyReported ( err. into ( ) ) ) . into ( )
93
127
}
94
128
}
95
129
@@ -125,7 +159,7 @@ pub enum InvalidProgramInfo<'tcx> {
125
159
/// Resolution can fail if we are in a too generic context.
126
160
TooGeneric ,
127
161
/// Abort in case errors are already reported.
128
- AlreadyReported ( ErrorGuaranteed ) ,
162
+ AlreadyReported ( ReportedErrorInfo ) ,
129
163
/// An error occurred during layout computation.
130
164
Layout ( layout:: LayoutError < ' tcx > ) ,
131
165
/// An error occurred during FnAbi computation: the passed --target lacks FFI support
@@ -144,7 +178,7 @@ impl fmt::Display for InvalidProgramInfo<'_> {
144
178
use InvalidProgramInfo :: * ;
145
179
match self {
146
180
TooGeneric => write ! ( f, "encountered overly generic constant" ) ,
147
- AlreadyReported ( ErrorGuaranteed { .. } ) => {
181
+ AlreadyReported ( _ ) => {
148
182
write ! (
149
183
f,
150
184
"an error has already been reported elsewhere (this should not usually be printed)"
0 commit comments