introduce UniverseIndex into InferCtxt

Always using root environment for now.
This commit is contained in:
Sean Griffin 2018-02-07 10:16:44 -07:00
parent 6a87289fa4
commit df8f5375a6
2 changed files with 13 additions and 3 deletions

View File

@ -183,6 +183,17 @@ pub struct InferCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
// obligations within. This is expected to be done 'late enough'
// that all type inference variables have been bound and so forth.
pub region_obligations: RefCell<Vec<(ast::NodeId, RegionObligation<'tcx>)>>,
/// What is the innermost universe we have created? Starts out as
/// `UniverseIndex::root()` but grows from there as we enter
/// universal quantifiers.
///
/// NB: At present, we exclude the universal quantifiers on the
/// item we are type-checking, and just consider those names as
/// part of the root universe. So this would only get incremented
/// when we enter into a higher-ranked (`for<..>`) type or trait
/// bound.
pub universe: ty::UniverseIndex,
}
/// A map returned by `skolemize_late_bound_regions()` indicating the skolemized
@ -455,6 +466,7 @@ pub fn enter<F, R>(&'tcx mut self, f: F) -> R
err_count_on_creation: tcx.sess.err_count(),
in_snapshot: Cell::new(false),
region_obligations: RefCell::new(vec![]),
universe: ty::UniverseIndex::ROOT,
}))
}
}

View File

@ -1376,9 +1376,7 @@ pub fn is_empty(&self) -> bool {
impl UniverseIndex {
/// The root universe, where things that the user defined are
/// visible.
pub fn root() -> UniverseIndex {
UniverseIndex(0)
}
pub const ROOT: Self = UniverseIndex(0);
/// A "subuniverse" corresponds to being inside a `forall` quantifier.
/// So, for example, suppose we have this type in universe `U`: