@@ -1457,10 +1457,10 @@ impl<'tcx> InstantiatedPredicates<'tcx> {
14571457/// "Universes" are used during type- and trait-checking in the
14581458/// presence of `for<..>` binders to control what sets of names are
14591459/// visible. Universes are arranged into a tree: the root universe
1460- /// contains names that are always visible. But when you enter into
1461- /// some superuniverse, then it may add names that are only visible
1462- /// within that subtree (but it can still name the names of its
1463- /// ancestor universes) .
1460+ /// contains names that are always visible. Each child then adds a new
1461+ /// set of names that are visible, in addition to those of its parent.
1462+ /// We say that the child universe "extends" the parent universe with
1463+ /// new names .
14641464///
14651465/// To make this more concrete, consider this program:
14661466///
@@ -1472,11 +1472,11 @@ impl<'tcx> InstantiatedPredicates<'tcx> {
14721472/// ```
14731473///
14741474/// The struct name `Foo` is in the root universe U0. But the type
1475- /// parameter `T`, introduced on `bar`, is in a superuniverse U1 --
1476- /// i.e., within `bar`, we can name both `T` and `Foo`, but outside of
1477- /// `bar`, we cannot name `T`. Then, within the type of `y`, the
1478- /// region `'a` is in a superuniverse U2 of U1, because we can name it
1479- /// inside the fn type but not outside.
1475+ /// parameter `T`, introduced on `bar`, is in an extended universe U1
1476+ /// -- i.e., within `bar`, we can name both `T` and `Foo`, but outside
1477+ /// of `bar`, we cannot name `T`. Then, within the type of `y`, the
1478+ /// region `'a` is in a universe U2 that extends U1, because we can
1479+ /// name it inside the fn type but not outside.
14801480///
14811481/// Universes are used to do type- and trait-checking around these
14821482/// "forall" binders (also called **universal quantification**). The
@@ -1500,24 +1500,28 @@ impl_stable_hash_for!(struct UniverseIndex { private });
15001500impl UniverseIndex {
15011501 pub const ROOT : UniverseIndex = UniverseIndex :: from_u32_const ( 0 ) ;
15021502
1503- /// A "superuniverse" corresponds to being inside a `forall` quantifier.
1504- /// So, for example, suppose we have this type in universe `U`:
1503+ /// Returns the "next" universe index in order -- this new index
1504+ /// is considered to extend all previous universes. This
1505+ /// corresponds to entering a `forall` quantifier. So, for
1506+ /// example, suppose we have this type in universe `U`:
15051507 ///
15061508 /// ```
15071509 /// for<'a> fn(&'a u32)
15081510 /// ```
15091511 ///
15101512 /// Once we "enter" into this `for<'a>` quantifier, we are in a
1511- /// superuniverse of `U` -- in this new universe, we can name the
1512- /// region `'a`, but that region was not nameable from `U` because
1513- /// it was not in scope there.
1514- pub fn superuniverse ( self ) -> UniverseIndex {
1513+ /// new universe that extends `U` -- in this new universe, we can
1514+ /// name the region `'a`, but that region was not nameable from
1515+ /// `U` because it was not in scope there.
1516+ pub fn next_universe ( self ) -> UniverseIndex {
15151517 UniverseIndex :: from_u32 ( self . private . checked_add ( 1 ) . unwrap ( ) )
15161518 }
15171519
1518- /// True if the names in this universe are a subset of the names in `other`.
1519- pub fn is_subset_of ( self , other : UniverseIndex ) -> bool {
1520- self . private <= other. private
1520+ /// True if `self` can name a name from `other` -- in other words,
1521+ /// if the set of names in `self` is a superset of those in
1522+ /// `other`.
1523+ pub fn can_name ( self , other : UniverseIndex ) -> bool {
1524+ self . private >= other. private
15211525 }
15221526}
15231527
0 commit comments