Skip to content

Commit df8f537

Browse files
committed
introduce UniverseIndex into InferCtxt
Always using root environment for now.
1 parent 6a87289 commit df8f537

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

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

src/librustc/ty/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,9 +1376,7 @@ pub struct UniverseIndex(u32);
13761376
impl UniverseIndex {
13771377
/// The root universe, where things that the user defined are
13781378
/// visible.
1379-
pub fn root() -> UniverseIndex {
1380-
UniverseIndex(0)
1381-
}
1379+
pub const ROOT: Self = UniverseIndex(0);
13821380

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

0 commit comments

Comments
 (0)