@@ -225,7 +225,9 @@ pub struct CommonTypes<'tcx> {
225
225
/// a trait object, and which gets removed in `ExistentialTraitRef`.
226
226
/// This type must not appear anywhere in other converted types.
227
227
pub trait_object_dummy_self : Ty < ' tcx > ,
228
+ }
228
229
230
+ pub struct CommonLifetimes < ' tcx > {
229
231
pub re_empty : Region < ' tcx > ,
230
232
pub re_static : Region < ' tcx > ,
231
233
pub re_erased : Region < ' tcx > ,
@@ -935,11 +937,6 @@ EnumLiftImpl! {
935
937
impl < ' tcx > CommonTypes < ' tcx > {
936
938
fn new ( interners : & CtxtInterners < ' tcx > ) -> CommonTypes < ' tcx > {
937
939
let mk = |sty| CtxtInterners :: intern_ty ( interners, interners, sty) ;
938
- let mk_region = |r| {
939
- interners. region . borrow_mut ( ) . intern ( r, |r| {
940
- Interned ( interners. arena . alloc ( r) )
941
- } ) . 0
942
- } ;
943
940
944
941
CommonTypes {
945
942
unit : mk ( Tuple ( List :: empty ( ) ) ) ,
@@ -963,10 +960,22 @@ impl<'tcx> CommonTypes<'tcx> {
963
960
f64 : mk ( Float ( ast:: FloatTy :: F64 ) ) ,
964
961
965
962
trait_object_dummy_self : mk ( Infer ( ty:: FreshTy ( 0 ) ) ) ,
963
+ }
964
+ }
965
+ }
966
966
967
- re_empty : mk_region ( RegionKind :: ReEmpty ) ,
968
- re_static : mk_region ( RegionKind :: ReStatic ) ,
969
- re_erased : mk_region ( RegionKind :: ReErased ) ,
967
+ impl < ' tcx > CommonLifetimes < ' tcx > {
968
+ fn new ( interners : & CtxtInterners < ' tcx > ) -> CommonLifetimes < ' tcx > {
969
+ let mk = |r| {
970
+ interners. region . borrow_mut ( ) . intern ( r, |r| {
971
+ Interned ( interners. arena . alloc ( r) )
972
+ } ) . 0
973
+ } ;
974
+
975
+ CommonLifetimes {
976
+ re_empty : mk ( RegionKind :: ReEmpty ) ,
977
+ re_static : mk ( RegionKind :: ReStatic ) ,
978
+ re_erased : mk ( RegionKind :: ReErased ) ,
970
979
}
971
980
}
972
981
}
@@ -1018,6 +1027,9 @@ pub struct GlobalCtxt<'tcx> {
1018
1027
/// Common types, pre-interned for your convenience.
1019
1028
pub types : CommonTypes < ' tcx > ,
1020
1029
1030
+ /// Common lifetimes, pre-interned for your convenience.
1031
+ pub lifetimes : CommonLifetimes < ' tcx > ,
1032
+
1021
1033
/// Map indicating what traits are in scope for places where this
1022
1034
/// is relevant; generated by resolve.
1023
1035
trait_map : FxHashMap < DefIndex ,
@@ -1216,6 +1228,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1216
1228
} ) ;
1217
1229
let interners = CtxtInterners :: new ( & arenas. interner ) ;
1218
1230
let common_types = CommonTypes :: new ( & interners) ;
1231
+ let common_lifetimes = CommonLifetimes :: new ( & interners) ;
1219
1232
let dep_graph = hir. dep_graph . clone ( ) ;
1220
1233
let max_cnum = cstore. crates_untracked ( ) . iter ( ) . map ( |c| c. as_usize ( ) ) . max ( ) . unwrap_or ( 0 ) ;
1221
1234
let mut providers = IndexVec :: from_elem_n ( extern_providers, max_cnum + 1 ) ;
@@ -1270,6 +1283,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1270
1283
global_interners : interners,
1271
1284
dep_graph,
1272
1285
types : common_types,
1286
+ lifetimes : common_lifetimes,
1273
1287
trait_map,
1274
1288
export_map : resolutions. export_map . into_iter ( ) . map ( |( k, v) | {
1275
1289
let exports: Vec < _ > = v. into_iter ( ) . map ( |e| {
@@ -2468,7 +2482,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
2468
2482
2469
2483
#[ inline]
2470
2484
pub fn mk_static_str ( self ) -> Ty < ' tcx > {
2471
- self . mk_imm_ref ( self . types . re_static , self . mk_str ( ) )
2485
+ self . mk_imm_ref ( self . lifetimes . re_static , self . mk_str ( ) )
2472
2486
}
2473
2487
2474
2488
#[ inline]
0 commit comments