@@ -164,7 +164,6 @@ pub struct CommonTypes<'tcx> {
164
164
pub f64 : Ty < ' tcx > ,
165
165
pub never : Ty < ' tcx > ,
166
166
pub self_param : Ty < ' tcx > ,
167
- pub err : Ty < ' tcx > ,
168
167
169
168
/// Dummy type used for the `Self` of a `TraitRef` created for converting
170
169
/// a trait object, and which gets removed in `ExistentialTraitRef`.
@@ -183,10 +182,6 @@ pub struct CommonLifetimes<'tcx> {
183
182
pub re_erased : Region < ' tcx > ,
184
183
}
185
184
186
- pub struct CommonConsts < ' tcx > {
187
- pub err : & ' tcx Const < ' tcx > ,
188
- }
189
-
190
185
pub struct LocalTableInContext < ' a , V > {
191
186
hir_owner : Option < LocalDefId > ,
192
187
data : & ' a ItemLocalMap < V > ,
@@ -821,7 +816,6 @@ impl<'tcx> CommonTypes<'tcx> {
821
816
bool : mk ( Bool ) ,
822
817
char : mk ( Char ) ,
823
818
never : mk ( Never ) ,
824
- err : mk ( Error ) ,
825
819
isize : mk ( Int ( ast:: IntTy :: Isize ) ) ,
826
820
i8 : mk ( Int ( ast:: IntTy :: I8 ) ) ,
827
821
i16 : mk ( Int ( ast:: IntTy :: I16 ) ) ,
@@ -855,19 +849,6 @@ impl<'tcx> CommonLifetimes<'tcx> {
855
849
}
856
850
}
857
851
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
-
871
852
// This struct contains information regarding the `ReFree(FreeRegion)` corresponding to a lifetime
872
853
// conflict.
873
854
#[ derive( Debug ) ]
@@ -925,9 +906,6 @@ pub struct GlobalCtxt<'tcx> {
925
906
/// Common lifetimes, pre-interned for your convenience.
926
907
pub lifetimes : CommonLifetimes < ' tcx > ,
927
908
928
- /// Common consts, pre-interned for your convenience.
929
- pub consts : CommonConsts < ' tcx > ,
930
-
931
909
/// Resolutions of `extern crate` items produced by resolver.
932
910
extern_crate_map : NodeMap < CrateNum > ,
933
911
@@ -992,6 +970,34 @@ pub struct GlobalCtxt<'tcx> {
992
970
}
993
971
994
972
impl < ' 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
+
995
1001
pub fn alloc_steal_mir ( self , mir : BodyAndCache < ' tcx > ) -> & ' tcx Steal < BodyAndCache < ' tcx > > {
996
1002
self . arena . alloc ( Steal :: new ( mir) )
997
1003
}
@@ -1096,7 +1102,6 @@ impl<'tcx> TyCtxt<'tcx> {
1096
1102
let interners = CtxtInterners :: new ( arena) ;
1097
1103
let common_types = CommonTypes :: new ( & interners) ;
1098
1104
let common_lifetimes = CommonLifetimes :: new ( & interners) ;
1099
- let common_consts = CommonConsts :: new ( & interners, & common_types) ;
1100
1105
let cstore = resolutions. cstore ;
1101
1106
let crates = cstore. crates_untracked ( ) ;
1102
1107
let max_cnum = crates. iter ( ) . map ( |c| c. as_usize ( ) ) . max ( ) . unwrap_or ( 0 ) ;
@@ -1146,7 +1151,6 @@ impl<'tcx> TyCtxt<'tcx> {
1146
1151
prof : s. prof . clone ( ) ,
1147
1152
types : common_types,
1148
1153
lifetimes : common_lifetimes,
1149
- consts : common_consts,
1150
1154
extern_crate_map : resolutions. extern_crate_map ,
1151
1155
trait_map,
1152
1156
export_map : resolutions
@@ -1840,7 +1844,7 @@ macro_rules! sty_debug_print {
1840
1844
let variant = match t. kind {
1841
1845
ty:: Bool | ty:: Char | ty:: Int ( ..) | ty:: Uint ( ..) |
1842
1846
ty:: Float ( ..) | ty:: Str | ty:: Never => continue ,
1843
- ty:: Error => /* unimportant */ continue ,
1847
+ ty:: Error ( .. ) => /* unimportant */ continue ,
1844
1848
$( ty:: $variant( ..) => & mut $variant, ) *
1845
1849
} ;
1846
1850
let lt = t. flags. intersects( ty:: TypeFlags :: HAS_RE_INFER ) ;
0 commit comments