From 2c20c44c922d548381bc4199be44c0b4f3e0c5af Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 25 Apr 2019 22:04:51 +0100 Subject: [PATCH] Split `CommonTypes` into `CommonTypes` and `CommonLifetimes` --- src/librustc/ty/context.rs | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index ed500d1ac33..6756c50e7dd 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -223,7 +223,9 @@ pub struct CommonTypes<'tcx> { /// a trait object, and which gets removed in `ExistentialTraitRef`. /// This type must not appear anywhere in other converted types. pub trait_object_dummy_self: Ty<'tcx>, +} +pub struct CommonLifetimes<'tcx> { pub re_empty: Region<'tcx>, pub re_static: Region<'tcx>, pub re_erased: Region<'tcx>, @@ -933,11 +935,6 @@ impl<'a, 'tcx> Lift<'tcx> for UserType<'a> { impl<'tcx> CommonTypes<'tcx> { fn new(interners: &CtxtInterners<'tcx>) -> CommonTypes<'tcx> { let mk = |sty| CtxtInterners::intern_ty(interners, interners, sty); - let mk_region = |r| { - interners.region.borrow_mut().intern(r, |r| { - Interned(interners.arena.alloc(r)) - }).0 - }; CommonTypes { unit: mk(Tuple(List::empty())), @@ -961,10 +958,22 @@ fn new(interners: &CtxtInterners<'tcx>) -> CommonTypes<'tcx> { f64: mk(Float(ast::FloatTy::F64)), trait_object_dummy_self: mk(Infer(ty::FreshTy(0))), + } + } +} - re_empty: mk_region(RegionKind::ReEmpty), - re_static: mk_region(RegionKind::ReStatic), - re_erased: mk_region(RegionKind::ReErased), +impl<'tcx> CommonLifetimes<'tcx> { + fn new(interners: &CtxtInterners<'tcx>) -> CommonLifetimes<'tcx> { + let mk = |r| { + interners.region.borrow_mut().intern(r, |r| { + Interned(interners.arena.alloc(r)) + }).0 + }; + + CommonLifetimes { + re_empty: mk(RegionKind::ReEmpty), + re_static: mk(RegionKind::ReStatic), + re_erased: mk(RegionKind::ReErased), } } } @@ -1016,6 +1025,9 @@ pub struct GlobalCtxt<'tcx> { /// Common types, pre-interned for your convenience. pub types: CommonTypes<'tcx>, + /// Common lifetimes, pre-interned for your convenience. + pub lifetimes: CommonLifetimes<'tcx>, + /// Map indicating what traits are in scope for places where this /// is relevant; generated by resolve. trait_map: FxHashMap = v.into_iter().map(|e| { @@ -2486,7 +2500,7 @@ pub fn mk_str(self) -> Ty<'tcx> { #[inline] pub fn mk_static_str(self) -> Ty<'tcx> { - self.mk_imm_ref(self.types.re_static, self.mk_str()) + self.mk_imm_ref(self.lifetimes.re_static, self.mk_str()) } #[inline] -- 2.44.0