Skip to content
Next Next commit
introduce UniverseIndex into InferCtxt
Always using root environment for now.
  • Loading branch information
sgrif committed May 2, 2018
commit df8f5375a6b246a4ffee3b074ec749ad95a1f430
12 changes: 12 additions & 0 deletions src/librustc/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -455,6 +466,7 @@ impl<'a, 'gcx, 'tcx> InferCtxtBuilder<'a, 'gcx, 'tcx> {
err_count_on_creation: tcx.sess.err_count(),
in_snapshot: Cell::new(false),
region_obligations: RefCell::new(vec![]),
universe: ty::UniverseIndex::ROOT,
}))
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1376,9 +1376,7 @@ pub struct UniverseIndex(u32);
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`:
Expand Down