@@ -1457,10 +1457,10 @@ impl<'tcx> InstantiatedPredicates<'tcx> {
1457
1457
/// "Universes" are used during type- and trait-checking in the
1458
1458
/// presence of `for<..>` binders to control what sets of names are
1459
1459
/// 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 .
1464
1464
///
1465
1465
/// To make this more concrete, consider this program:
1466
1466
///
@@ -1472,11 +1472,11 @@ impl<'tcx> InstantiatedPredicates<'tcx> {
1472
1472
/// ```
1473
1473
///
1474
1474
/// 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.
1480
1480
///
1481
1481
/// Universes are used to do type- and trait-checking around these
1482
1482
/// "forall" binders (also called **universal quantification**). The
@@ -1500,24 +1500,28 @@ impl_stable_hash_for!(struct UniverseIndex { private });
1500
1500
impl UniverseIndex {
1501
1501
pub const ROOT : UniverseIndex = UniverseIndex :: from_u32_const ( 0 ) ;
1502
1502
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`:
1505
1507
///
1506
1508
/// ```
1507
1509
/// for<'a> fn(&'a u32)
1508
1510
/// ```
1509
1511
///
1510
1512
/// 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 {
1515
1517
UniverseIndex :: from_u32 ( self . private . checked_add ( 1 ) . unwrap ( ) )
1516
1518
}
1517
1519
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
1521
1525
}
1522
1526
}
1523
1527
0 commit comments