@@ -1457,7 +1457,7 @@ impl<'tcx> InstantiatedPredicates<'tcx> {
14571457/// presence of `for<..>` binders to control what sets of names are
14581458/// visible. Universes are arranged into a tree: the root universe
14591459/// contains names that are always visible. But when you enter into
1460- /// some subuniverse , then it may add names that are only visible
1460+ /// some superuniverse , then it may add names that are only visible
14611461/// within that subtree (but it can still name the names of its
14621462/// ancestor universes).
14631463///
@@ -1471,10 +1471,10 @@ impl<'tcx> InstantiatedPredicates<'tcx> {
14711471/// ```
14721472///
14731473/// The struct name `Foo` is in the root universe U0. But the type
1474- /// parameter `T`, introduced on `bar`, is in a subuniverse U1 --
1474+ /// parameter `T`, introduced on `bar`, is in a superuniverse U1 --
14751475/// i.e., within `bar`, we can name both `T` and `Foo`, but outside of
14761476/// `bar`, we cannot name `T`. Then, within the type of `y`, the
1477- /// region `'a` is in a subuniverse U2 of U1, because we can name it
1477+ /// region `'a` is in a superuniverse U2 of U1, because we can name it
14781478/// inside the fn type but not outside.
14791479///
14801480/// Universes are used to do type- and trait-checking around these
@@ -1489,52 +1489,54 @@ impl<'tcx> InstantiatedPredicates<'tcx> {
14891489/// type -- an idealized representative of "types in general" that we
14901490/// use for checking generic functions.
14911491#[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Hash , RustcEncodable , RustcDecodable ) ]
1492- pub struct UniverseIndex ( u32 ) ;
1492+ pub struct UniverseIndex { private : u32 }
1493+
1494+ impl_stable_hash_for ! ( struct UniverseIndex { private } ) ;
14931495
14941496impl UniverseIndex {
14951497 /// The root universe, where things that the user defined are
14961498 /// visible.
1497- pub const ROOT : Self = UniverseIndex ( 0 ) ;
1499+ pub const ROOT : Self = UniverseIndex { private : 0 } ;
14981500
14991501 /// The "max universe" -- this isn't really a valid universe, but
15001502 /// it's useful sometimes as a "starting value" when you are
15011503 /// taking the minimum of a (non-empty!) set of universes.
1502- pub const MAX : Self = UniverseIndex ( :: std:: u32:: MAX ) ;
1504+ pub const MAX : Self = UniverseIndex { private : :: std:: u32:: MAX } ;
15031505
15041506 /// Creates a universe index from the given integer. Not to be
15051507 /// used lightly lest you pick a bad value. But sometimes we
15061508 /// convert universe indices into integers and back for various
15071509 /// reasons.
15081510 pub fn from_u32 ( index : u32 ) -> Self {
1509- UniverseIndex ( index)
1511+ UniverseIndex { private : index }
15101512 }
15111513
1512- /// A "subuniverse " corresponds to being inside a `forall` quantifier.
1514+ /// A "superuniverse " corresponds to being inside a `forall` quantifier.
15131515 /// So, for example, suppose we have this type in universe `U`:
15141516 ///
15151517 /// ```
15161518 /// for<'a> fn(&'a u32)
15171519 /// ```
15181520 ///
15191521 /// Once we "enter" into this `for<'a>` quantifier, we are in a
1520- /// subuniverse of `U` -- in this new universe, we can name the
1522+ /// superuniverse of `U` -- in this new universe, we can name the
15211523 /// region `'a`, but that region was not nameable from `U` because
15221524 /// it was not in scope there.
1523- pub fn subuniverse ( self ) -> UniverseIndex {
1524- UniverseIndex ( self . 0 . checked_add ( 1 ) . unwrap ( ) )
1525+ pub fn superuniverse ( self ) -> UniverseIndex {
1526+ UniverseIndex :: from_u32 ( self . private . checked_add ( 1 ) . unwrap ( ) )
15251527 }
15261528
15271529 /// True if the names in this universe are a subset of the names in `other`.
15281530 pub fn is_subset_of ( self , other : UniverseIndex ) -> bool {
1529- self . 0 <= other. 0
1531+ self . private <= other. private
15301532 }
15311533
15321534 pub fn as_u32 ( & self ) -> u32 {
1533- self . 0
1535+ self . private
15341536 }
15351537
15361538 pub fn as_usize ( & self ) -> usize {
1537- self . 0 as usize
1539+ self . private as usize
15381540 }
15391541}
15401542
@@ -1546,7 +1548,7 @@ impl fmt::Debug for UniverseIndex {
15461548
15471549impl From < u32 > for UniverseIndex {
15481550 fn from ( index : u32 ) -> Self {
1549- UniverseIndex ( index)
1551+ UniverseIndex :: from_u32 ( index)
15501552 }
15511553}
15521554
0 commit comments