@@ -223,7 +223,9 @@ pub struct CommonTypes<'tcx> {
223
223
/// a trait object, and which gets removed in `ExistentialTraitRef`.
224
224
/// This type must not appear anywhere in other converted types.
225
225
pub trait_object_dummy_self : Ty < ' tcx > ,
226
+ }
226
227
228
+ pub struct CommonLifetimes < ' tcx > {
227
229
pub re_empty : Region < ' tcx > ,
228
230
pub re_static : Region < ' tcx > ,
229
231
pub re_erased : Region < ' tcx > ,
@@ -933,11 +935,6 @@ EnumLiftImpl! {
933
935
impl < ' tcx > CommonTypes < ' tcx > {
934
936
fn new ( interners : & CtxtInterners < ' tcx > ) -> CommonTypes < ' tcx > {
935
937
let mk = |sty| CtxtInterners :: intern_ty ( interners, interners, sty) ;
936
- let mk_region = |r| {
937
- interners. region . borrow_mut ( ) . intern ( r, |r| {
938
- Interned ( interners. arena . alloc ( r) )
939
- } ) . 0
940
- } ;
941
938
942
939
CommonTypes {
943
940
unit : mk ( Tuple ( List :: empty ( ) ) ) ,
@@ -961,10 +958,22 @@ impl<'tcx> CommonTypes<'tcx> {
961
958
f64 : mk ( Float ( ast:: FloatTy :: F64 ) ) ,
962
959
963
960
trait_object_dummy_self : mk ( Infer ( ty:: FreshTy ( 0 ) ) ) ,
961
+ }
962
+ }
963
+ }
964
964
965
- re_empty : mk_region ( RegionKind :: ReEmpty ) ,
966
- re_static : mk_region ( RegionKind :: ReStatic ) ,
967
- re_erased : mk_region ( RegionKind :: ReErased ) ,
965
+ impl < ' tcx > CommonLifetimes < ' tcx > {
966
+ fn new ( interners : & CtxtInterners < ' tcx > ) -> CommonLifetimes < ' tcx > {
967
+ let mk = |r| {
968
+ interners. region . borrow_mut ( ) . intern ( r, |r| {
969
+ Interned ( interners. arena . alloc ( r) )
970
+ } ) . 0
971
+ } ;
972
+
973
+ CommonLifetimes {
974
+ re_empty : mk ( RegionKind :: ReEmpty ) ,
975
+ re_static : mk ( RegionKind :: ReStatic ) ,
976
+ re_erased : mk ( RegionKind :: ReErased ) ,
968
977
}
969
978
}
970
979
}
@@ -1016,6 +1025,9 @@ pub struct GlobalCtxt<'tcx> {
1016
1025
/// Common types, pre-interned for your convenience.
1017
1026
pub types : CommonTypes < ' tcx > ,
1018
1027
1028
+ /// Common lifetimes, pre-interned for your convenience.
1029
+ pub lifetimes : CommonLifetimes < ' tcx > ,
1030
+
1019
1031
/// Map indicating what traits are in scope for places where this
1020
1032
/// is relevant; generated by resolve.
1021
1033
trait_map : FxHashMap < DefIndex ,
@@ -1214,6 +1226,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1214
1226
} ) ;
1215
1227
let interners = CtxtInterners :: new ( & arenas. interner ) ;
1216
1228
let common_types = CommonTypes :: new ( & interners) ;
1229
+ let common_lifetimes = CommonLifetimes :: new ( & interners) ;
1217
1230
let dep_graph = hir. dep_graph . clone ( ) ;
1218
1231
let max_cnum = cstore. crates_untracked ( ) . iter ( ) . map ( |c| c. as_usize ( ) ) . max ( ) . unwrap_or ( 0 ) ;
1219
1232
let mut providers = IndexVec :: from_elem_n ( extern_providers, max_cnum + 1 ) ;
@@ -1268,6 +1281,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1268
1281
global_interners : interners,
1269
1282
dep_graph,
1270
1283
types : common_types,
1284
+ lifetimes : common_lifetimes,
1271
1285
trait_map,
1272
1286
export_map : resolutions. export_map . into_iter ( ) . map ( |( k, v) | {
1273
1287
let exports: Vec < _ > = v. into_iter ( ) . map ( |e| {
@@ -2486,7 +2500,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
2486
2500
2487
2501
#[ inline]
2488
2502
pub fn mk_static_str ( self ) -> Ty < ' tcx > {
2489
- self . mk_imm_ref ( self . types . re_static , self . mk_str ( ) )
2503
+ self . mk_imm_ref ( self . lifetimes . re_static , self . mk_str ( ) )
2490
2504
}
2491
2505
2492
2506
#[ inline]
0 commit comments