Skip to content

Commit 3d4791b

Browse files
committed
introduce UniverseIndex into InferCtxt
Always using root environment for now.
1 parent 26d1fc7 commit 3d4791b

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/librustc/infer/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,17 @@ pub struct InferCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
182182
// obligations within. This is expected to be done 'late enough'
183183
// that all type inference variables have been bound and so forth.
184184
pub region_obligations: RefCell<Vec<(ast::NodeId, RegionObligation<'tcx>)>>,
185+
186+
/// What is the innermost universe we have created? Starts out as
187+
/// `UniverseIndex::root()` but grows from there as we enter
188+
/// universal quantifiers.
189+
///
190+
/// NB: At present, we exclude the universal quantifiers on the
191+
/// item we are type-checking, and just consider those names as
192+
/// part of the root universe. So this would only get incremented
193+
/// when we enter into a higher-ranked (`for<..>`) type or trait
194+
/// bound.
195+
pub universe: ty::UniverseIndex,
185196
}
186197

187198
/// A map returned by `skolemize_late_bound_regions()` indicating the skolemized
@@ -454,6 +465,7 @@ impl<'a, 'gcx, 'tcx> InferCtxtBuilder<'a, 'gcx, 'tcx> {
454465
err_count_on_creation: tcx.sess.err_count(),
455466
in_snapshot: Cell::new(false),
456467
region_obligations: RefCell::new(vec![]),
468+
universe: ty::UniverseIndex::ROOT,
457469
}))
458470
}
459471
}

src/librustc/ty/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,9 +1334,7 @@ pub struct UniverseIndex(u32);
13341334
impl UniverseIndex {
13351335
/// The root universe, where things that the user defined are
13361336
/// visible.
1337-
pub fn root() -> UniverseIndex {
1338-
UniverseIndex(0)
1339-
}
1337+
pub const ROOT: Self = UniverseIndex(0);
13401338

13411339
/// A "subuniverse" corresponds to being inside a `forall` quantifier.
13421340
/// So, for example, suppose we have this type in universe `U`:

0 commit comments

Comments
 (0)