@@ -231,8 +231,10 @@ pub struct CommonLifetimes<'tcx> {
231231 pub re_empty : Region < ' tcx > ,
232232 pub re_static : Region < ' tcx > ,
233233 pub re_erased : Region < ' tcx > ,
234+ }
234235
235- pub ct_err : & ' tcx Const < ' tcx > ,
236+ pub struct CommonConsts < ' tcx > {
237+ pub err : & ' tcx Const < ' tcx > ,
236238}
237239
238240pub struct LocalTableInContext < ' a , V : ' a > {
@@ -945,7 +947,7 @@ impl<'tcx> CommonTypes<'tcx> {
945947 bool : mk ( Bool ) ,
946948 char : mk ( Char ) ,
947949 never : mk ( Never ) ,
948- err,
950+ err : mk ( Error ) ,
949951 isize : mk ( Int ( ast:: IntTy :: Isize ) ) ,
950952 i8 : mk ( Int ( ast:: IntTy :: I8 ) ) ,
951953 i16 : mk ( Int ( ast:: IntTy :: I16 ) ) ,
@@ -982,6 +984,20 @@ impl<'tcx> CommonLifetimes<'tcx> {
982984 }
983985}
984986
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+
9851001// This struct contains information regarding the `ReFree(FreeRegion)` corresponding to a lifetime
9861002// conflict.
9871003#[ derive( Debug ) ]
@@ -1032,6 +1048,9 @@ pub struct GlobalCtxt<'tcx> {
10321048 /// Common lifetimes, pre-interned for your convenience.
10331049 pub lifetimes : CommonLifetimes < ' tcx > ,
10341050
1051+ /// Common consts, pre-interned for your convenience.
1052+ pub consts : CommonConsts < ' tcx > ,
1053+
10351054 /// Map indicating what traits are in scope for places where this
10361055 /// is relevant; generated by resolve.
10371056 trait_map : FxHashMap < DefIndex ,
@@ -1231,6 +1250,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
12311250 let interners = CtxtInterners :: new ( & arenas. interner ) ;
12321251 let common_types = CommonTypes :: new ( & interners) ;
12331252 let common_lifetimes = CommonLifetimes :: new ( & interners) ;
1253+ let common_consts = CommonConsts :: new ( & interners, & common_types) ;
12341254 let dep_graph = hir. dep_graph . clone ( ) ;
12351255 let max_cnum = cstore. crates_untracked ( ) . iter ( ) . map ( |c| c. as_usize ( ) ) . max ( ) . unwrap_or ( 0 ) ;
12361256 let mut providers = IndexVec :: from_elem_n ( extern_providers, max_cnum + 1 ) ;
@@ -1286,6 +1306,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
12861306 dep_graph,
12871307 types : common_types,
12881308 lifetimes : common_lifetimes,
1309+ consts : common_consts,
12891310 trait_map,
12901311 export_map : resolutions. export_map . into_iter ( ) . map ( |( k, v) | {
12911312 let exports: Vec < _ > = v. into_iter ( ) . map ( |e| {
0 commit comments