Split CommonTypes
into CommonTypes
and CommonLifetimes
This commit is contained in:
parent
bd31c392f2
commit
2c20c44c92
1 changed files with 23 additions and 9 deletions
|
@ -223,7 +223,9 @@ pub struct CommonTypes<'tcx> {
|
||||||
/// a trait object, and which gets removed in `ExistentialTraitRef`.
|
/// a trait object, and which gets removed in `ExistentialTraitRef`.
|
||||||
/// This type must not appear anywhere in other converted types.
|
/// This type must not appear anywhere in other converted types.
|
||||||
pub trait_object_dummy_self: Ty<'tcx>,
|
pub trait_object_dummy_self: Ty<'tcx>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct CommonLifetimes<'tcx> {
|
||||||
pub re_empty: Region<'tcx>,
|
pub re_empty: Region<'tcx>,
|
||||||
pub re_static: Region<'tcx>,
|
pub re_static: Region<'tcx>,
|
||||||
pub re_erased: Region<'tcx>,
|
pub re_erased: Region<'tcx>,
|
||||||
|
@ -933,11 +935,6 @@ EnumLiftImpl! {
|
||||||
impl<'tcx> CommonTypes<'tcx> {
|
impl<'tcx> CommonTypes<'tcx> {
|
||||||
fn new(interners: &CtxtInterners<'tcx>) -> CommonTypes<'tcx> {
|
fn new(interners: &CtxtInterners<'tcx>) -> CommonTypes<'tcx> {
|
||||||
let mk = |sty| CtxtInterners::intern_ty(interners, interners, sty);
|
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 {
|
CommonTypes {
|
||||||
unit: mk(Tuple(List::empty())),
|
unit: mk(Tuple(List::empty())),
|
||||||
|
@ -961,10 +958,22 @@ impl<'tcx> CommonTypes<'tcx> {
|
||||||
f64: mk(Float(ast::FloatTy::F64)),
|
f64: mk(Float(ast::FloatTy::F64)),
|
||||||
|
|
||||||
trait_object_dummy_self: mk(Infer(ty::FreshTy(0))),
|
trait_object_dummy_self: mk(Infer(ty::FreshTy(0))),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
re_empty: mk_region(RegionKind::ReEmpty),
|
impl<'tcx> CommonLifetimes<'tcx> {
|
||||||
re_static: mk_region(RegionKind::ReStatic),
|
fn new(interners: &CtxtInterners<'tcx>) -> CommonLifetimes<'tcx> {
|
||||||
re_erased: mk_region(RegionKind::ReErased),
|
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.
|
/// Common types, pre-interned for your convenience.
|
||||||
pub types: CommonTypes<'tcx>,
|
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
|
/// Map indicating what traits are in scope for places where this
|
||||||
/// is relevant; generated by resolve.
|
/// is relevant; generated by resolve.
|
||||||
trait_map: FxHashMap<DefIndex,
|
trait_map: FxHashMap<DefIndex,
|
||||||
|
@ -1214,6 +1226,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
});
|
});
|
||||||
let interners = CtxtInterners::new(&arenas.interner);
|
let interners = CtxtInterners::new(&arenas.interner);
|
||||||
let common_types = CommonTypes::new(&interners);
|
let common_types = CommonTypes::new(&interners);
|
||||||
|
let common_lifetimes = CommonLifetimes::new(&interners);
|
||||||
let dep_graph = hir.dep_graph.clone();
|
let dep_graph = hir.dep_graph.clone();
|
||||||
let max_cnum = cstore.crates_untracked().iter().map(|c| c.as_usize()).max().unwrap_or(0);
|
let max_cnum = cstore.crates_untracked().iter().map(|c| c.as_usize()).max().unwrap_or(0);
|
||||||
let mut providers = IndexVec::from_elem_n(extern_providers, max_cnum + 1);
|
let mut providers = IndexVec::from_elem_n(extern_providers, max_cnum + 1);
|
||||||
|
@ -1268,6 +1281,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
global_interners: interners,
|
global_interners: interners,
|
||||||
dep_graph,
|
dep_graph,
|
||||||
types: common_types,
|
types: common_types,
|
||||||
|
lifetimes: common_lifetimes,
|
||||||
trait_map,
|
trait_map,
|
||||||
export_map: resolutions.export_map.into_iter().map(|(k, v)| {
|
export_map: resolutions.export_map.into_iter().map(|(k, v)| {
|
||||||
let exports: Vec<_> = v.into_iter().map(|e| {
|
let exports: Vec<_> = v.into_iter().map(|e| {
|
||||||
|
@ -2486,7 +2500,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn mk_static_str(self) -> Ty<'tcx> {
|
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]
|
#[inline]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue