about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc/infer/higher_ranked/mod.rs4
-rw-r--r--src/librustc/infer/mod.rs11
-rw-r--r--src/librustc/ty/mod.rs40
-rw-r--r--src/librustc_mir/borrow_check/nll/region_infer/mod.rs10
-rw-r--r--src/librustc_mir/borrow_check/nll/region_infer/values.rs4
-rw-r--r--src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs8
6 files changed, 39 insertions, 38 deletions
diff --git a/src/librustc/infer/higher_ranked/mod.rs b/src/librustc/infer/higher_ranked/mod.rs
index 884aa956556..ae1892caa74 100644
--- a/src/librustc/infer/higher_ranked/mod.rs
+++ b/src/librustc/infer/higher_ranked/mod.rs
@@ -593,11 +593,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
     where
         T : TypeFoldable<'tcx>,
     {
-        let new_universe = self.create_superuniverse();
+        let next_universe = self.create_next_universe();
 
         let (result, map) = self.tcx.replace_late_bound_regions(binder, |br| {
             self.tcx.mk_region(ty::RePlaceholder(ty::Placeholder {
-                universe: new_universe,
+                universe: next_universe,
                 name: br,
             }))
         });
diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs
index 95ecec7d0d5..ef9886e06d4 100644
--- a/src/librustc/infer/mod.rs
+++ b/src/librustc/infer/mod.rs
@@ -1489,13 +1489,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
         self.universe.get()
     }
 
-    /// Create and return a new subunivese of the current universe;
-    /// update `self.universe` to that new universe. At present,
-    /// used only in the NLL subtyping code, which uses the new
-    /// universe-based scheme instead of the more limited leak-check
-    /// scheme.
-    pub fn create_superuniverse(&self) -> ty::UniverseIndex {
-        let u = self.universe.get().superuniverse();
+    /// Create and return a fresh universe that extends all previous
+    /// universes. Updates `self.universe` to that new universe.
+    pub fn create_next_universe(&self) -> ty::UniverseIndex {
+        let u = self.universe.get().next_universe();
         self.universe.set(u);
         u
     }
diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs
index 853b49098b9..4135d499c58 100644
--- a/src/librustc/ty/mod.rs
+++ b/src/librustc/ty/mod.rs
@@ -1457,10 +1457,10 @@ impl<'tcx> InstantiatedPredicates<'tcx> {
 /// "Universes" are used during type- and trait-checking in the
 /// presence of `for<..>` binders to control what sets of names are
 /// visible. Universes are arranged into a tree: the root universe
-/// contains names that are always visible. But when you enter into
-/// some superuniverse, then it may add names that are only visible
-/// within that subtree (but it can still name the names of its
-/// ancestor universes).
+/// contains names that are always visible. Each child then adds a new
+/// set of names that are visible, in addition to those of its parent.
+/// We say that the child universe "extends" the parent universe with
+/// new names.
 ///
 /// To make this more concrete, consider this program:
 ///
@@ -1472,11 +1472,11 @@ impl<'tcx> InstantiatedPredicates<'tcx> {
 /// ```
 ///
 /// The struct name `Foo` is in the root universe U0. But the type
-/// parameter `T`, introduced on `bar`, is in a superuniverse U1 --
-/// i.e., within `bar`, we can name both `T` and `Foo`, but outside of
-/// `bar`, we cannot name `T`. Then, within the type of `y`, the
-/// region `'a` is in a superuniverse U2 of U1, because we can name it
-/// inside the fn type but not outside.
+/// parameter `T`, introduced on `bar`, is in an extended universe U1
+/// -- i.e., within `bar`, we can name both `T` and `Foo`, but outside
+/// of `bar`, we cannot name `T`. Then, within the type of `y`, the
+/// region `'a` is in a universe U2 that extends U1, because we can
+/// name it inside the fn type but not outside.
 ///
 /// Universes are used to do type- and trait-checking around these
 /// "forall" binders (also called **universal quantification**). The
@@ -1500,24 +1500,28 @@ impl_stable_hash_for!(struct UniverseIndex { private });
 impl UniverseIndex {
     pub const ROOT: UniverseIndex = UniverseIndex::from_u32_const(0);
 
-    /// A "superuniverse" corresponds to being inside a `forall` quantifier.
-    /// So, for example, suppose we have this type in universe `U`:
+    /// Returns the "next" universe index in order -- this new index
+    /// is considered to extend all previous universes. This
+    /// corresponds to entering a `forall` quantifier.  So, for
+    /// example, suppose we have this type in universe `U`:
     ///
     /// ```
     /// for<'a> fn(&'a u32)
     /// ```
     ///
     /// Once we "enter" into this `for<'a>` quantifier, we are in a
-    /// superuniverse of `U` -- in this new universe, we can name the
-    /// region `'a`, but that region was not nameable from `U` because
-    /// it was not in scope there.
-    pub fn superuniverse(self) -> UniverseIndex {
+    /// new universe that extends `U` -- in this new universe, we can
+    /// name the region `'a`, but that region was not nameable from
+    /// `U` because it was not in scope there.
+    pub fn next_universe(self) -> UniverseIndex {
         UniverseIndex::from_u32(self.private.checked_add(1).unwrap())
     }
 
-    /// True if the names in this universe are a subset of the names in `other`.
-    pub fn is_subset_of(self, other: UniverseIndex) -> bool {
-        self.private <= other.private
+    /// True if `self` can name a name from `other` -- in other words,
+    /// if the set of names in `self` is a superset of those in
+    /// `other`.
+    pub fn can_name(self, other: UniverseIndex) -> bool {
+        self.private >= other.private
     }
 }
 
diff --git a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs
index ca5759183c7..dd8a7f19a63 100644
--- a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs
+++ b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs
@@ -112,7 +112,7 @@ struct RegionDefinition<'tcx> {
     /// Which universe is this region variable defined in? This is
     /// most often `ty::UniverseIndex::ROOT`, but when we encounter
     /// forall-quantifiers like `for<'a> { 'a = 'b }`, we would create
-    /// the variable for `'a` in a superuniverse.
+    /// the variable for `'a` in a fresh universe that extends ROOT.
     universe: ty::UniverseIndex,
 
     /// If this is 'static or an early-bound region, then this is
@@ -339,11 +339,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
 
                 NLLRegionVariableOrigin::Placeholder(placeholder) => {
                     // Each placeholder region is only visible from
-                    // its universe `ui` and its superuniverses. So we
+                    // its universe `ui` and its extensions. So we
                     // can't just add it into `scc` unless the
                     // universe of the scc can name this region.
                     let scc_universe = self.scc_universes[scc];
-                    if placeholder.universe.is_subset_of(scc_universe) {
+                    if scc_universe.can_name(placeholder.universe) {
                         self.scc_values.add_element(scc, placeholder);
                     } else {
                         self.add_incompatible_universe(scc);
@@ -541,7 +541,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
         // Quick check: if scc_b's declared universe is a subset of
         // scc_a's declared univese (typically, both are ROOT), then
         // it cannot contain any problematic universe elements.
-        if self.scc_universes[scc_b].is_subset_of(universe_a) {
+        if universe_a.can_name(self.scc_universes[scc_b]) {
             return true;
         }
 
@@ -550,7 +550,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
         // from universe_a
         self.scc_values
             .placeholders_contained_in(scc_b)
-            .all(|p| p.universe.is_subset_of(universe_a))
+            .all(|p| universe_a.can_name(p.universe))
     }
 
     /// Extend `scc` so that it can outlive some placeholder region
diff --git a/src/librustc_mir/borrow_check/nll/region_infer/values.rs b/src/librustc_mir/borrow_check/nll/region_infer/values.rs
index f9c1c11c62a..3607ae4f508 100644
--- a/src/librustc_mir/borrow_check/nll/region_infer/values.rs
+++ b/src/librustc_mir/borrow_check/nll/region_infer/values.rs
@@ -148,8 +148,8 @@ crate enum RegionElement {
     /// a lifetime parameter).
     RootUniversalRegion(RegionVid),
 
-    /// A superuniverse from a superuniverse (e.g., instantiated from a
-    /// `for<'a> fn(&'a u32)` type).
+    /// A placeholder (e.g., instantiated from a `for<'a> fn(&'a u32)`
+    /// type).
     PlaceholderRegion(ty::Placeholder),
 }
 
diff --git a/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs b/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs
index a7657a57451..96cc1c0afec 100644
--- a/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs
+++ b/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs
@@ -159,7 +159,7 @@ trait TypeRelatingDelegate<'tcx> {
     fn push_outlives(&mut self, sup: ty::Region<'tcx>, sub: ty::Region<'tcx>);
 
     /// Creates a new universe index. Used when instantiating placeholders.
-    fn next_superuniverse(&mut self) -> ty::UniverseIndex;
+    fn create_next_universe(&mut self) -> ty::UniverseIndex;
 
     /// Creates a new region variable representing a higher-ranked
     /// region that is instantiated existentially. This creates an
@@ -218,8 +218,8 @@ impl NllTypeRelatingDelegate<'me, 'bccx, 'gcx, 'tcx> {
 }
 
 impl TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, '_, 'tcx> {
-    fn next_superuniverse(&mut self) -> ty::UniverseIndex {
-        self.infcx.create_superuniverse()
+    fn create_next_universe(&mut self) -> ty::UniverseIndex {
+        self.infcx.create_next_universe()
     }
 
     fn next_existential_region_var(&mut self) -> ty::Region<'tcx> {
@@ -324,7 +324,7 @@ where
                     // new universe for the placeholders we will make
                     // from here out.
                     let universe = lazy_universe.unwrap_or_else(|| {
-                        let universe = delegate.next_superuniverse();
+                        let universe = delegate.create_next_universe();
                         lazy_universe = Some(universe);
                         universe
                     });