@@ -28,10 +28,10 @@ pub enum ErrorHandled {
28
28
TooGeneric ( Span ) ,
29
29
}
30
30
31
- impl From < ErrorGuaranteed > for ErrorHandled {
31
+ impl From < ReportedErrorInfo > for ErrorHandled {
32
32
#[ inline]
33
- fn from ( error : ErrorGuaranteed ) -> ErrorHandled {
34
- ErrorHandled :: Reported ( error. into ( ) , DUMMY_SP )
33
+ fn from ( error : ReportedErrorInfo ) -> ErrorHandled {
34
+ ErrorHandled :: Reported ( error, DUMMY_SP )
35
35
}
36
36
}
37
37
@@ -64,6 +64,20 @@ pub struct ReportedErrorInfo {
64
64
}
65
65
66
66
impl ReportedErrorInfo {
67
+ #[ inline]
68
+ pub fn const_eval_error ( error : ErrorGuaranteed ) -> ReportedErrorInfo {
69
+ ReportedErrorInfo { allowed_in_infallible : false , error }
70
+ }
71
+
72
+ /// Use this when the error that led to this is *not* a const-eval error
73
+ /// (e.g., a layout or type checking error).
74
+ #[ inline]
75
+ pub fn non_const_eval_error ( error : ErrorGuaranteed ) -> ReportedErrorInfo {
76
+ ReportedErrorInfo { allowed_in_infallible : true , error }
77
+ }
78
+
79
+ /// Use this when the error that led to this *is* a const-eval error, but
80
+ /// we do allow it to occur in infallible constants (e.g., resource exhaustion).
67
81
#[ inline]
68
82
pub fn allowed_in_infallible ( error : ErrorGuaranteed ) -> ReportedErrorInfo {
69
83
ReportedErrorInfo { allowed_in_infallible : true , error }
@@ -74,13 +88,6 @@ impl ReportedErrorInfo {
74
88
}
75
89
}
76
90
77
- impl From < ErrorGuaranteed > for ReportedErrorInfo {
78
- #[ inline]
79
- fn from ( error : ErrorGuaranteed ) -> ReportedErrorInfo {
80
- ReportedErrorInfo { allowed_in_infallible : false , error }
81
- }
82
- }
83
-
84
91
impl Into < ErrorGuaranteed > for ReportedErrorInfo {
85
92
#[ inline]
86
93
fn into ( self ) -> ErrorGuaranteed {
@@ -180,12 +187,6 @@ fn print_backtrace(backtrace: &Backtrace) {
180
187
eprintln ! ( "\n \n An error occurred in the MIR interpreter:\n {backtrace}" ) ;
181
188
}
182
189
183
- impl From < ErrorGuaranteed > for InterpErrorInfo < ' _ > {
184
- fn from ( err : ErrorGuaranteed ) -> Self {
185
- InterpErrorKind :: InvalidProgram ( InvalidProgramInfo :: AlreadyReported ( err. into ( ) ) ) . into ( )
186
- }
187
- }
188
-
189
190
impl From < ErrorHandled > for InterpErrorInfo < ' _ > {
190
191
fn from ( err : ErrorHandled ) -> Self {
191
192
InterpErrorKind :: InvalidProgram ( match err {
0 commit comments