1
1
use super :: { AllocId , AllocRange , ConstAlloc , Pointer , Scalar } ;
2
2
3
+ use crate :: error;
3
4
use crate :: mir:: interpret:: ConstValue ;
4
5
use crate :: query:: TyCtxtAt ;
5
- use crate :: ty:: { layout, tls, Ty , ValTree } ;
6
+ use crate :: ty:: { layout, tls, Ty , TyCtxt , ValTree } ;
6
7
7
8
use rustc_data_structures:: sync:: Lock ;
8
9
use rustc_errors:: {
@@ -41,6 +42,32 @@ impl ErrorHandled {
41
42
ErrorHandled :: TooGeneric ( _span) => ErrorHandled :: TooGeneric ( span) ,
42
43
}
43
44
}
45
+
46
+ pub fn emit_err ( & self , tcx : TyCtxt < ' _ > ) -> ErrorGuaranteed {
47
+ match self {
48
+ & ErrorHandled :: Reported ( err, span) => {
49
+ if !err. is_tainted_by_errors && !span. is_dummy ( ) {
50
+ tcx. sess . emit_err ( error:: ErroneousConstant { span } ) ;
51
+ }
52
+ err. error
53
+ }
54
+ & ErrorHandled :: TooGeneric ( span) => tcx. sess . delay_span_bug (
55
+ span,
56
+ "encountered TooGeneric error when monomorphic data was expected" ,
57
+ ) ,
58
+ }
59
+ }
60
+
61
+ pub fn emit_note ( & self , tcx : TyCtxt < ' _ > ) {
62
+ match self {
63
+ & ErrorHandled :: Reported ( err, span) => {
64
+ if !err. is_tainted_by_errors && !span. is_dummy ( ) {
65
+ tcx. sess . emit_note ( error:: ErroneousConstant { span } ) ;
66
+ }
67
+ }
68
+ & ErrorHandled :: TooGeneric ( _) => { }
69
+ }
70
+ }
44
71
}
45
72
46
73
#[ derive( Debug , Copy , Clone , PartialEq , Eq , HashStable , TyEncodable , TyDecodable ) ]
@@ -54,12 +81,6 @@ impl ReportedErrorInfo {
54
81
pub fn tainted_by_errors ( error : ErrorGuaranteed ) -> ReportedErrorInfo {
55
82
ReportedErrorInfo { is_tainted_by_errors : true , error }
56
83
}
57
-
58
- /// Returns true if evaluation failed because MIR was tainted by errors.
59
- #[ inline]
60
- pub fn is_tainted_by_errors ( self ) -> bool {
61
- self . is_tainted_by_errors
62
- }
63
84
}
64
85
65
86
impl From < ErrorGuaranteed > for ReportedErrorInfo {
0 commit comments