11use super :: { AllocId , AllocRange , ConstAlloc , Pointer , Scalar } ;
22
3+ use crate :: error;
34use crate :: mir:: interpret:: ConstValue ;
45use crate :: query:: TyCtxtAt ;
5- use crate :: ty:: { layout, tls, Ty , ValTree } ;
6+ use crate :: ty:: { layout, tls, Ty , TyCtxt , ValTree } ;
67
78use rustc_data_structures:: sync:: Lock ;
89use rustc_errors:: {
@@ -41,6 +42,32 @@ impl ErrorHandled {
4142 ErrorHandled :: TooGeneric ( _span) => ErrorHandled :: TooGeneric ( span) ,
4243 }
4344 }
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+ }
4471}
4572
4673#[ derive( Debug , Copy , Clone , PartialEq , Eq , HashStable , TyEncodable , TyDecodable ) ]
@@ -54,12 +81,6 @@ impl ReportedErrorInfo {
5481 pub fn tainted_by_errors ( error : ErrorGuaranteed ) -> ReportedErrorInfo {
5582 ReportedErrorInfo { is_tainted_by_errors : true , error }
5683 }
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- }
6384}
6485
6586impl From < ErrorGuaranteed > for ReportedErrorInfo {
0 commit comments