Skip to content

Commit 35e78b5

Browse files
nikomatsakissgrif
authored andcommitted
change skolemizations to use universe index
1 parent 13efaf0 commit 35e78b5

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

src/librustc/ty/mod.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub use self::sty::{ExistentialTraitRef, PolyExistentialTraitRef};
6969
pub use self::sty::{ExistentialProjection, PolyExistentialProjection, Const};
7070
pub use self::sty::{BoundRegion, EarlyBoundRegion, FreeRegion, Region};
7171
pub use self::sty::RegionKind;
72-
pub use self::sty::{TyVid, IntVid, FloatVid, RegionVid, SkolemizedRegionVid};
72+
pub use self::sty::{TyVid, IntVid, FloatVid, RegionVid};
7373
pub use self::sty::BoundRegion::*;
7474
pub use self::sty::InferTy::*;
7575
pub use self::sty::RegionKind::*;
@@ -1345,7 +1345,7 @@ impl<'tcx> InstantiatedPredicates<'tcx> {
13451345
/// type name in a non-zero universe is a skolemized type -- an
13461346
/// idealized representative of "types in general" that we use for
13471347
/// checking generic functions.
1348-
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
1348+
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
13491349
pub struct UniverseIndex(u32);
13501350

13511351
impl UniverseIndex {
@@ -1365,7 +1365,19 @@ impl UniverseIndex {
13651365
/// region `'a`, but that region was not nameable from `U` because
13661366
/// it was not in scope there.
13671367
pub fn subuniverse(self) -> UniverseIndex {
1368-
UniverseIndex(self.0 + 1)
1368+
UniverseIndex(self.0.checked_add(1).unwrap())
1369+
}
1370+
1371+
pub fn from(v: u32) -> UniverseIndex {
1372+
UniverseIndex(v)
1373+
}
1374+
1375+
pub fn as_u32(&self) -> u32 {
1376+
self.0
1377+
}
1378+
1379+
pub fn as_usize(&self) -> usize {
1380+
self.0 as usize
13691381
}
13701382

13711383
/// Gets the "depth" of this universe in the universe tree. This

src/librustc/ty/sty.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ pub enum RegionKind {
10281028

10291029
/// A skolemized region - basically the higher-ranked version of ReFree.
10301030
/// Should not exist after typeck.
1031-
ReSkolemized(SkolemizedRegionVid, BoundRegion),
1031+
ReSkolemized(ty::UniverseIndex, BoundRegion),
10321032

10331033
/// Empty lifetime is for data that is never accessed.
10341034
/// Bottom in the region lattice. We treat ReEmpty somewhat
@@ -1079,11 +1079,6 @@ newtype_index!(RegionVid
10791079
DEBUG_FORMAT = custom,
10801080
});
10811081

1082-
#[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, PartialOrd, Ord)]
1083-
pub struct SkolemizedRegionVid {
1084-
pub index: u32,
1085-
}
1086-
10871082
#[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
10881083
pub enum InferTy {
10891084
TyVar(TyVid),

src/librustc/util/ppaux.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ define_print! {
786786
}
787787

788788
ty::ReSkolemized(id, ref bound_region) => {
789-
write!(f, "ReSkolemized({}, {:?})", id.index, bound_region)
789+
write!(f, "ReSkolemized({:?}, {:?})", id, bound_region)
790790
}
791791

792792
ty::ReEmpty => write!(f, "ReEmpty"),

0 commit comments

Comments
 (0)