@@ -28,10 +28,10 @@ pub enum ErrorHandled {
2828 TooGeneric ( Span ) ,
2929}
3030
31- impl From < ErrorGuaranteed > for ErrorHandled {
31+ impl From < ReportedErrorInfo > for ErrorHandled {
3232 #[ 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 )
3535 }
3636}
3737
@@ -64,6 +64,20 @@ pub struct ReportedErrorInfo {
6464}
6565
6666impl 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).
6781 #[ inline]
6882 pub fn allowed_in_infallible ( error : ErrorGuaranteed ) -> ReportedErrorInfo {
6983 ReportedErrorInfo { allowed_in_infallible : true , error }
@@ -74,13 +88,6 @@ impl ReportedErrorInfo {
7488 }
7589}
7690
77- impl From < ErrorGuaranteed > for ReportedErrorInfo {
78- #[ inline]
79- fn from ( error : ErrorGuaranteed ) -> ReportedErrorInfo {
80- ReportedErrorInfo { allowed_in_infallible : false , error }
81- }
82- }
83-
8491impl Into < ErrorGuaranteed > for ReportedErrorInfo {
8592 #[ inline]
8693 fn into ( self ) -> ErrorGuaranteed {
@@ -180,11 +187,11 @@ fn print_backtrace(backtrace: &Backtrace) {
180187 eprintln ! ( "\n \n An error occurred in the MIR interpreter:\n {backtrace}" ) ;
181188}
182189
183- impl From < ErrorGuaranteed > for InterpErrorInfo < ' _ > {
190+ /* impl From<ErrorGuaranteed> for InterpErrorInfo<'_> {
184191 fn from(err: ErrorGuaranteed) -> Self {
185192 InterpErrorKind::InvalidProgram(InvalidProgramInfo::AlreadyReported(err.into())).into()
186193 }
187- }
194+ }*/
188195
189196impl From < ErrorHandled > for InterpErrorInfo < ' _ > {
190197 fn from ( err : ErrorHandled ) -> Self {
0 commit comments