@@ -55,6 +55,7 @@ use std::{fmt, str};
55
55
56
56
pub use crate :: ty:: diagnostics:: * ;
57
57
pub use rustc_type_ir:: InferTy :: * ;
58
+ pub use rustc_type_ir:: RegionKind :: * ;
58
59
pub use rustc_type_ir:: TyKind :: * ;
59
60
pub use rustc_type_ir:: * ;
60
61
@@ -80,7 +81,6 @@ pub use self::list::List;
80
81
pub use self :: parameterized:: ParameterizedOverTcx ;
81
82
pub use self :: rvalue_scopes:: RvalueScopes ;
82
83
pub use self :: sty:: BoundRegionKind :: * ;
83
- pub use self :: sty:: RegionKind :: * ;
84
84
pub use self :: sty:: {
85
85
Article , Binder , BoundRegion , BoundRegionKind , BoundTy , BoundTyKind , BoundVar ,
86
86
BoundVariableKind , CanonicalPolyFnSig , ClosureSubsts , ClosureSubstsParts , ConstVid ,
@@ -1161,83 +1161,6 @@ impl<'tcx> OpaqueHiddenType<'tcx> {
1161
1161
}
1162
1162
}
1163
1163
1164
- rustc_index:: newtype_index! {
1165
- /// "Universes" are used during type- and trait-checking in the
1166
- /// presence of `for<..>` binders to control what sets of names are
1167
- /// visible. Universes are arranged into a tree: the root universe
1168
- /// contains names that are always visible. Each child then adds a new
1169
- /// set of names that are visible, in addition to those of its parent.
1170
- /// We say that the child universe "extends" the parent universe with
1171
- /// new names.
1172
- ///
1173
- /// To make this more concrete, consider this program:
1174
- ///
1175
- /// ```ignore (illustrative)
1176
- /// struct Foo { }
1177
- /// fn bar<T>(x: T) {
1178
- /// let y: for<'a> fn(&'a u8, Foo) = ...;
1179
- /// }
1180
- /// ```
1181
- ///
1182
- /// The struct name `Foo` is in the root universe U0. But the type
1183
- /// parameter `T`, introduced on `bar`, is in an extended universe U1
1184
- /// -- i.e., within `bar`, we can name both `T` and `Foo`, but outside
1185
- /// of `bar`, we cannot name `T`. Then, within the type of `y`, the
1186
- /// region `'a` is in a universe U2 that extends U1, because we can
1187
- /// name it inside the fn type but not outside.
1188
- ///
1189
- /// Universes are used to do type- and trait-checking around these
1190
- /// "forall" binders (also called **universal quantification**). The
1191
- /// idea is that when, in the body of `bar`, we refer to `T` as a
1192
- /// type, we aren't referring to any type in particular, but rather a
1193
- /// kind of "fresh" type that is distinct from all other types we have
1194
- /// actually declared. This is called a **placeholder** type, and we
1195
- /// use universes to talk about this. In other words, a type name in
1196
- /// universe 0 always corresponds to some "ground" type that the user
1197
- /// declared, but a type name in a non-zero universe is a placeholder
1198
- /// type -- an idealized representative of "types in general" that we
1199
- /// use for checking generic functions.
1200
- pub struct UniverseIndex {
1201
- derive [ HashStable ]
1202
- DEBUG_FORMAT = "U{}" ,
1203
- }
1204
- }
1205
-
1206
- impl UniverseIndex {
1207
- pub const ROOT : UniverseIndex = UniverseIndex :: from_u32 ( 0 ) ;
1208
-
1209
- /// Returns the "next" universe index in order -- this new index
1210
- /// is considered to extend all previous universes. This
1211
- /// corresponds to entering a `forall` quantifier. So, for
1212
- /// example, suppose we have this type in universe `U`:
1213
- ///
1214
- /// ```ignore (illustrative)
1215
- /// for<'a> fn(&'a u32)
1216
- /// ```
1217
- ///
1218
- /// Once we "enter" into this `for<'a>` quantifier, we are in a
1219
- /// new universe that extends `U` -- in this new universe, we can
1220
- /// name the region `'a`, but that region was not nameable from
1221
- /// `U` because it was not in scope there.
1222
- pub fn next_universe ( self ) -> UniverseIndex {
1223
- UniverseIndex :: from_u32 ( self . private . checked_add ( 1 ) . unwrap ( ) )
1224
- }
1225
-
1226
- /// Returns `true` if `self` can name a name from `other` -- in other words,
1227
- /// if the set of names in `self` is a superset of those in
1228
- /// `other` (`self >= other`).
1229
- pub fn can_name ( self , other : UniverseIndex ) -> bool {
1230
- self . private >= other. private
1231
- }
1232
-
1233
- /// Returns `true` if `self` cannot name some names from `other` -- in other
1234
- /// words, if the set of names in `self` is a strict subset of
1235
- /// those in `other` (`self < other`).
1236
- pub fn cannot_name ( self , other : UniverseIndex ) -> bool {
1237
- self . private < other. private
1238
- }
1239
- }
1240
-
1241
1164
/// The "placeholder index" fully defines a placeholder region, type, or const. Placeholders are
1242
1165
/// identified by both a universe, as well as a name residing within that universe. Distinct bound
1243
1166
/// regions/types/consts within the same universe simply have an unknown relationship to one
0 commit comments