@@ -231,8 +231,10 @@ pub struct CommonLifetimes<'tcx> {
231
231
pub re_empty : Region < ' tcx > ,
232
232
pub re_static : Region < ' tcx > ,
233
233
pub re_erased : Region < ' tcx > ,
234
+ }
234
235
235
- pub ct_err : & ' tcx Const < ' tcx > ,
236
+ pub struct CommonConsts < ' tcx > {
237
+ pub err : & ' tcx Const < ' tcx > ,
236
238
}
237
239
238
240
pub struct LocalTableInContext < ' a , V : ' a > {
@@ -945,7 +947,7 @@ impl<'tcx> CommonTypes<'tcx> {
945
947
bool : mk ( Bool ) ,
946
948
char : mk ( Char ) ,
947
949
never : mk ( Never ) ,
948
- err,
950
+ err : mk ( Error ) ,
949
951
isize : mk ( Int ( ast:: IntTy :: Isize ) ) ,
950
952
i8 : mk ( Int ( ast:: IntTy :: I8 ) ) ,
951
953
i16 : mk ( Int ( ast:: IntTy :: I16 ) ) ,
@@ -982,6 +984,20 @@ impl<'tcx> CommonLifetimes<'tcx> {
982
984
}
983
985
}
984
986
987
+ impl < ' tcx > CommonConsts < ' tcx > {
988
+ fn new ( interners : & CtxtInterners < ' tcx > , types : & CommonTypes < ' tcx > ) -> CommonConsts < ' tcx > {
989
+ let mk_const = |c| {
990
+ interners. const_ . borrow_mut ( ) . intern ( c, |c| {
991
+ Interned ( interners. arena . alloc ( c) )
992
+ } ) . 0
993
+ } ;
994
+
995
+ CommonConsts {
996
+ err : mk_const ( ty:: Const :: zero_sized ( types. err ) ) ,
997
+ }
998
+ }
999
+ }
1000
+
985
1001
// This struct contains information regarding the `ReFree(FreeRegion)` corresponding to a lifetime
986
1002
// conflict.
987
1003
#[ derive( Debug ) ]
@@ -1032,6 +1048,9 @@ pub struct GlobalCtxt<'tcx> {
1032
1048
/// Common lifetimes, pre-interned for your convenience.
1033
1049
pub lifetimes : CommonLifetimes < ' tcx > ,
1034
1050
1051
+ /// Common consts, pre-interned for your convenience.
1052
+ pub consts : CommonConsts < ' tcx > ,
1053
+
1035
1054
/// Map indicating what traits are in scope for places where this
1036
1055
/// is relevant; generated by resolve.
1037
1056
trait_map : FxHashMap < DefIndex ,
@@ -1231,6 +1250,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1231
1250
let interners = CtxtInterners :: new ( & arenas. interner ) ;
1232
1251
let common_types = CommonTypes :: new ( & interners) ;
1233
1252
let common_lifetimes = CommonLifetimes :: new ( & interners) ;
1253
+ let common_consts = CommonConsts :: new ( & interners, & common_types) ;
1234
1254
let dep_graph = hir. dep_graph . clone ( ) ;
1235
1255
let max_cnum = cstore. crates_untracked ( ) . iter ( ) . map ( |c| c. as_usize ( ) ) . max ( ) . unwrap_or ( 0 ) ;
1236
1256
let mut providers = IndexVec :: from_elem_n ( extern_providers, max_cnum + 1 ) ;
@@ -1286,6 +1306,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1286
1306
dep_graph,
1287
1307
types : common_types,
1288
1308
lifetimes : common_lifetimes,
1309
+ consts : common_consts,
1289
1310
trait_map,
1290
1311
export_map : resolutions. export_map . into_iter ( ) . map ( |( k, v) | {
1291
1312
let exports: Vec < _ > = v. into_iter ( ) . map ( |e| {
0 commit comments