Skip to content

Commit 2c20c44

Browse files
committed
Split CommonTypes into CommonTypes and CommonLifetimes
1 parent bd31c39 commit 2c20c44

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

src/librustc/ty/context.rs

+23-9
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,9 @@ pub struct CommonTypes<'tcx> {
223223
/// a trait object, and which gets removed in `ExistentialTraitRef`.
224224
/// This type must not appear anywhere in other converted types.
225225
pub trait_object_dummy_self: Ty<'tcx>,
226+
}
226227

228+
pub struct CommonLifetimes<'tcx> {
227229
pub re_empty: Region<'tcx>,
228230
pub re_static: Region<'tcx>,
229231
pub re_erased: Region<'tcx>,
@@ -933,11 +935,6 @@ EnumLiftImpl! {
933935
impl<'tcx> CommonTypes<'tcx> {
934936
fn new(interners: &CtxtInterners<'tcx>) -> CommonTypes<'tcx> {
935937
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-
};
941938

942939
CommonTypes {
943940
unit: mk(Tuple(List::empty())),
@@ -961,10 +958,22 @@ impl<'tcx> CommonTypes<'tcx> {
961958
f64: mk(Float(ast::FloatTy::F64)),
962959

963960
trait_object_dummy_self: mk(Infer(ty::FreshTy(0))),
961+
}
962+
}
963+
}
964964

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),
968977
}
969978
}
970979
}
@@ -1016,6 +1025,9 @@ pub struct GlobalCtxt<'tcx> {
10161025
/// Common types, pre-interned for your convenience.
10171026
pub types: CommonTypes<'tcx>,
10181027

1028+
/// Common lifetimes, pre-interned for your convenience.
1029+
pub lifetimes: CommonLifetimes<'tcx>,
1030+
10191031
/// Map indicating what traits are in scope for places where this
10201032
/// is relevant; generated by resolve.
10211033
trait_map: FxHashMap<DefIndex,
@@ -1214,6 +1226,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
12141226
});
12151227
let interners = CtxtInterners::new(&arenas.interner);
12161228
let common_types = CommonTypes::new(&interners);
1229+
let common_lifetimes = CommonLifetimes::new(&interners);
12171230
let dep_graph = hir.dep_graph.clone();
12181231
let max_cnum = cstore.crates_untracked().iter().map(|c| c.as_usize()).max().unwrap_or(0);
12191232
let mut providers = IndexVec::from_elem_n(extern_providers, max_cnum + 1);
@@ -1268,6 +1281,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
12681281
global_interners: interners,
12691282
dep_graph,
12701283
types: common_types,
1284+
lifetimes: common_lifetimes,
12711285
trait_map,
12721286
export_map: resolutions.export_map.into_iter().map(|(k, v)| {
12731287
let exports: Vec<_> = v.into_iter().map(|e| {
@@ -2486,7 +2500,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
24862500

24872501
#[inline]
24882502
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())
24902504
}
24912505

24922506
#[inline]

0 commit comments

Comments
 (0)