@@ -225,7 +225,9 @@ pub struct CommonTypes<'tcx> {
225225 /// a trait object, and which gets removed in `ExistentialTraitRef`.
226226 /// This type must not appear anywhere in other converted types.
227227 pub trait_object_dummy_self : Ty < ' tcx > ,
228+ }
228229
230+ pub struct CommonLifetimes < ' tcx > {
229231 pub re_empty : Region < ' tcx > ,
230232 pub re_static : Region < ' tcx > ,
231233 pub re_erased : Region < ' tcx > ,
@@ -935,11 +937,6 @@ EnumLiftImpl! {
935937impl < ' tcx > CommonTypes < ' tcx > {
936938 fn new ( interners : & CtxtInterners < ' tcx > ) -> CommonTypes < ' tcx > {
937939 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- } ;
943940
944941 CommonTypes {
945942 unit : mk ( Tuple ( List :: empty ( ) ) ) ,
@@ -963,10 +960,22 @@ impl<'tcx> CommonTypes<'tcx> {
963960 f64 : mk ( Float ( ast:: FloatTy :: F64 ) ) ,
964961
965962 trait_object_dummy_self : mk ( Infer ( ty:: FreshTy ( 0 ) ) ) ,
963+ }
964+ }
965+ }
966966
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 ) ,
970979 }
971980 }
972981}
@@ -1018,6 +1027,9 @@ pub struct GlobalCtxt<'tcx> {
10181027 /// Common types, pre-interned for your convenience.
10191028 pub types : CommonTypes < ' tcx > ,
10201029
1030+ /// Common lifetimes, pre-interned for your convenience.
1031+ pub lifetimes : CommonLifetimes < ' tcx > ,
1032+
10211033 /// Map indicating what traits are in scope for places where this
10221034 /// is relevant; generated by resolve.
10231035 trait_map : FxHashMap < DefIndex ,
@@ -1216,6 +1228,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
12161228 } ) ;
12171229 let interners = CtxtInterners :: new ( & arenas. interner ) ;
12181230 let common_types = CommonTypes :: new ( & interners) ;
1231+ let common_lifetimes = CommonLifetimes :: new ( & interners) ;
12191232 let dep_graph = hir. dep_graph . clone ( ) ;
12201233 let max_cnum = cstore. crates_untracked ( ) . iter ( ) . map ( |c| c. as_usize ( ) ) . max ( ) . unwrap_or ( 0 ) ;
12211234 let mut providers = IndexVec :: from_elem_n ( extern_providers, max_cnum + 1 ) ;
@@ -1270,6 +1283,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
12701283 global_interners : interners,
12711284 dep_graph,
12721285 types : common_types,
1286+ lifetimes : common_lifetimes,
12731287 trait_map,
12741288 export_map : resolutions. export_map . into_iter ( ) . map ( |( k, v) | {
12751289 let exports: Vec < _ > = v. into_iter ( ) . map ( |e| {
@@ -2468,7 +2482,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
24682482
24692483 #[ inline]
24702484 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 ( ) )
24722486 }
24732487
24742488 #[ inline]
0 commit comments