Skip to content

Commit 3e971eb

Browse files
committed
Revert "change skolemizations to use universe index"
This reverts commit 755bdaa.
1 parent 55e1104 commit 3e971eb

File tree

1 file changed

+18
-18
lines changed
  • src/librustc/infer/region_constraints

1 file changed

+18
-18
lines changed

src/librustc/infer/region_constraints/mod.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub struct RegionConstraintCollector<'tcx> {
4848
glbs: CombineMap<'tcx>,
4949

5050
/// Number of skolemized variables currently active.
51-
skolemization_count: ty::UniverseIndex,
51+
skolemization_count: u32,
5252

5353
/// Global counter used during the GLB algorithm to create unique
5454
/// names for fresh bound regions
@@ -233,7 +233,7 @@ type CombineMap<'tcx> = FxHashMap<TwoRegions<'tcx>, RegionVid>;
233233
pub struct RegionSnapshot {
234234
length: usize,
235235
region_snapshot: ut::Snapshot<ut::InPlace<ty::RegionVid>>,
236-
skolemization_count: ty::UniverseIndex,
236+
skolemization_count: u32,
237237
}
238238

239239
/// When working with skolemized regions, we often wish to find all of
@@ -277,7 +277,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
277277
data: RegionConstraintData::default(),
278278
lubs: FxHashMap(),
279279
glbs: FxHashMap(),
280-
skolemization_count: ty::UniverseIndex::ROOT,
280+
skolemization_count: 0,
281281
bound_count: 0,
282282
undo_log: Vec::new(),
283283
unification_table: ut::UnificationTable::new(),
@@ -329,7 +329,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
329329
unification_table,
330330
} = self;
331331

332-
assert_eq!(skolemization_count.as_usize(), 0);
332+
assert_eq!(*skolemization_count, 0);
333333

334334
// Clear the tables of (lubs, glbs), so that we will create
335335
// fresh regions if we do a LUB operation. As it happens,
@@ -375,7 +375,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
375375
assert!(self.undo_log[snapshot.length] == OpenSnapshot);
376376
assert!(
377377
self.skolemization_count == snapshot.skolemization_count,
378-
"failed to pop skolemized regions: {:?} now vs {:?} at start",
378+
"failed to pop skolemized regions: {} now vs {} at start",
379379
self.skolemization_count,
380380
snapshot.skolemization_count
381381
);
@@ -485,9 +485,9 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
485485
assert!(self.in_snapshot());
486486
assert!(self.undo_log[snapshot.length] == OpenSnapshot);
487487

488-
let universe = self.skolemization_count.subuniverse();
489-
self.skolemization_count = universe;
490-
tcx.mk_region(ReSkolemized(universe, br))
488+
let sc = self.skolemization_count;
489+
self.skolemization_count = sc + 1;
490+
tcx.mk_region(ReSkolemized(ty::SkolemizedRegionVid { index: sc }, br))
491491
}
492492

493493
/// Removes all the edges to/from the skolemized regions that are
@@ -505,34 +505,34 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
505505
assert!(self.in_snapshot());
506506
assert!(self.undo_log[snapshot.length] == OpenSnapshot);
507507
assert!(
508-
self.skolemization_count.as_usize() >= skols.len(),
508+
self.skolemization_count as usize >= skols.len(),
509509
"popping more skolemized variables than actually exist, \
510510
sc now = {}, skols.len = {}",
511-
self.skolemization_count.as_usize(),
511+
self.skolemization_count,
512512
skols.len()
513513
);
514514

515-
let last_to_pop = self.skolemization_count.subuniverse();
516-
let first_to_pop = ty::UniverseIndex::from(last_to_pop.as_u32() - (skols.len() as u32));
515+
let last_to_pop = self.skolemization_count;
516+
let first_to_pop = last_to_pop - (skols.len() as u32);
517517

518518
assert!(
519519
first_to_pop >= snapshot.skolemization_count,
520520
"popping more regions than snapshot contains, \
521-
sc now = {:?}, sc then = {:?}, skols.len = {}",
521+
sc now = {}, sc then = {}, skols.len = {}",
522522
self.skolemization_count,
523523
snapshot.skolemization_count,
524524
skols.len()
525525
);
526526
debug_assert! {
527527
skols.iter()
528528
.all(|&k| match *k {
529-
ty::ReSkolemized(universe, _) =>
530-
universe >= first_to_pop &&
531-
universe < last_to_pop,
529+
ty::ReSkolemized(index, _) =>
530+
index.index >= first_to_pop &&
531+
index.index < last_to_pop,
532532
_ =>
533533
false
534534
}),
535-
"invalid skolemization keys or keys out of range ({:?}..{:?}): {:?}",
535+
"invalid skolemization keys or keys out of range ({}..{}): {:?}",
536536
snapshot.skolemization_count,
537537
self.skolemization_count,
538538
skols
@@ -867,7 +867,7 @@ impl fmt::Debug for RegionSnapshot {
867867
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
868868
write!(
869869
f,
870-
"RegionSnapshot(length={},skolemization={:?})",
870+
"RegionSnapshot(length={},skolemization={})",
871871
self.length,
872872
self.skolemization_count
873873
)

0 commit comments

Comments
 (0)