@@ -164,7 +164,6 @@ pub struct CommonTypes<'tcx> {
164164 pub f64 : Ty < ' tcx > ,
165165 pub never : Ty < ' tcx > ,
166166 pub self_param : Ty < ' tcx > ,
167- pub err : Ty < ' tcx > ,
168167
169168 /// Dummy type used for the `Self` of a `TraitRef` created for converting
170169 /// a trait object, and which gets removed in `ExistentialTraitRef`.
@@ -183,10 +182,6 @@ pub struct CommonLifetimes<'tcx> {
183182 pub re_erased : Region < ' tcx > ,
184183}
185184
186- pub struct CommonConsts < ' tcx > {
187- pub err : & ' tcx Const < ' tcx > ,
188- }
189-
190185pub struct LocalTableInContext < ' a , V > {
191186 hir_owner : Option < LocalDefId > ,
192187 data : & ' a ItemLocalMap < V > ,
@@ -821,7 +816,6 @@ impl<'tcx> CommonTypes<'tcx> {
821816 bool : mk ( Bool ) ,
822817 char : mk ( Char ) ,
823818 never : mk ( Never ) ,
824- err : mk ( Error ) ,
825819 isize : mk ( Int ( ast:: IntTy :: Isize ) ) ,
826820 i8 : mk ( Int ( ast:: IntTy :: I8 ) ) ,
827821 i16 : mk ( Int ( ast:: IntTy :: I16 ) ) ,
@@ -855,19 +849,6 @@ impl<'tcx> CommonLifetimes<'tcx> {
855849 }
856850}
857851
858- impl < ' tcx > CommonConsts < ' tcx > {
859- fn new ( interners : & CtxtInterners < ' tcx > , types : & CommonTypes < ' tcx > ) -> CommonConsts < ' tcx > {
860- let mk_const = |c| interners. const_ . intern ( c, |c| Interned ( interners. arena . alloc ( c) ) ) . 0 ;
861-
862- CommonConsts {
863- err : mk_const ( ty:: Const {
864- val : ty:: ConstKind :: Value ( ConstValue :: Scalar ( Scalar :: zst ( ) ) ) ,
865- ty : types. err ,
866- } ) ,
867- }
868- }
869- }
870-
871852// This struct contains information regarding the `ReFree(FreeRegion)` corresponding to a lifetime
872853// conflict.
873854#[ derive( Debug ) ]
@@ -925,9 +906,6 @@ pub struct GlobalCtxt<'tcx> {
925906 /// Common lifetimes, pre-interned for your convenience.
926907 pub lifetimes : CommonLifetimes < ' tcx > ,
927908
928- /// Common consts, pre-interned for your convenience.
929- pub consts : CommonConsts < ' tcx > ,
930-
931909 /// Resolutions of `extern crate` items produced by resolver.
932910 extern_crate_map : NodeMap < CrateNum > ,
933911
@@ -992,6 +970,34 @@ pub struct GlobalCtxt<'tcx> {
992970}
993971
994972impl < ' tcx > TyCtxt < ' tcx > {
973+ /// Construct an `Error` type. This requires proof that an error has already been emited or
974+ /// will be emited.
975+ #[ track_caller]
976+ #[ inline]
977+ pub fn err ( self , proof : rustc_errors:: ErrorProof ) -> Ty < ' tcx > {
978+ self . sess . diagnostic ( ) . delay_span_bug (
979+ rustc_span:: DUMMY_SP ,
980+ & format ! ( "Error constructed but not emited {}" , std:: panic:: Location :: caller( ) ) ,
981+ ) ;
982+ self . mk_ty ( Error ( proof) )
983+ }
984+
985+ /// Construct an error `const`. This requires proof that an error has already been emited or
986+ /// will be emited.
987+ #[ track_caller]
988+ #[ inline]
989+ pub fn const_err ( self , proof : rustc_errors:: ErrorProof ) -> Const < ' tcx > {
990+ self . sess . diagnostic ( ) . delay_span_bug (
991+ rustc_span:: DUMMY_SP ,
992+ & format ! ( "Error `const` constructed but not emited {}" , std:: panic:: Location :: caller( ) ) ,
993+ ) ;
994+
995+ * self . mk_const ( ty:: Const {
996+ val : ty:: ConstKind :: Value ( ConstValue :: Scalar ( Scalar :: zst ( ) ) ) ,
997+ ty : self . err ( proof) ,
998+ } )
999+ }
1000+
9951001 pub fn alloc_steal_mir ( self , mir : BodyAndCache < ' tcx > ) -> & ' tcx Steal < BodyAndCache < ' tcx > > {
9961002 self . arena . alloc ( Steal :: new ( mir) )
9971003 }
@@ -1096,7 +1102,6 @@ impl<'tcx> TyCtxt<'tcx> {
10961102 let interners = CtxtInterners :: new ( arena) ;
10971103 let common_types = CommonTypes :: new ( & interners) ;
10981104 let common_lifetimes = CommonLifetimes :: new ( & interners) ;
1099- let common_consts = CommonConsts :: new ( & interners, & common_types) ;
11001105 let cstore = resolutions. cstore ;
11011106 let crates = cstore. crates_untracked ( ) ;
11021107 let max_cnum = crates. iter ( ) . map ( |c| c. as_usize ( ) ) . max ( ) . unwrap_or ( 0 ) ;
@@ -1146,7 +1151,6 @@ impl<'tcx> TyCtxt<'tcx> {
11461151 prof : s. prof . clone ( ) ,
11471152 types : common_types,
11481153 lifetimes : common_lifetimes,
1149- consts : common_consts,
11501154 extern_crate_map : resolutions. extern_crate_map ,
11511155 trait_map,
11521156 export_map : resolutions
@@ -1840,7 +1844,7 @@ macro_rules! sty_debug_print {
18401844 let variant = match t. kind {
18411845 ty:: Bool | ty:: Char | ty:: Int ( ..) | ty:: Uint ( ..) |
18421846 ty:: Float ( ..) | ty:: Str | ty:: Never => continue ,
1843- ty:: Error => /* unimportant */ continue ,
1847+ ty:: Error ( .. ) => /* unimportant */ continue ,
18441848 $( ty:: $variant( ..) => & mut $variant, ) *
18451849 } ;
18461850 let lt = t. flags. intersects( ty:: TypeFlags :: HAS_RE_INFER ) ;
0 commit comments