@@ -1348,9 +1348,7 @@ pub struct UniverseIndex(u32);
1348
1348
impl UniverseIndex {
1349
1349
/// The root universe, where things that the user defined are
1350
1350
/// visible.
1351
- pub fn root ( ) -> UniverseIndex {
1352
- UniverseIndex ( 0 )
1353
- }
1351
+ pub const ROOT : UniverseIndex = UniverseIndex ( 0 ) ;
1354
1352
1355
1353
/// A "subuniverse" corresponds to being inside a `forall` quantifier.
1356
1354
/// So, for example, suppose we have this type in universe `U`:
@@ -1366,6 +1364,13 @@ impl UniverseIndex {
1366
1364
pub fn subuniverse ( self ) -> UniverseIndex {
1367
1365
UniverseIndex ( self . 0 + 1 )
1368
1366
}
1367
+
1368
+ /// Gets the "depth" of this universe in the universe tree. This
1369
+ /// is not really useful except for e.g. the `HashStable`
1370
+ /// implementation
1371
+ pub fn depth ( & self ) -> u32 {
1372
+ self . 0
1373
+ }
1369
1374
}
1370
1375
1371
1376
/// When type checking, we use the `ParamEnv` to track
@@ -1382,6 +1387,17 @@ pub struct ParamEnv<'tcx> {
1382
1387
/// want `Reveal::All` -- note that this is always paired with an
1383
1388
/// empty environment. To get that, use `ParamEnv::reveal()`.
1384
1389
pub reveal : traits:: Reveal ,
1390
+
1391
+ /// What is the innermost universe we have created? Starts out as
1392
+ /// `UniverseIndex::root()` but grows from there as we enter
1393
+ /// universal quantifiers.
1394
+ ///
1395
+ /// NB: At present, we exclude the universal quantifiers on the
1396
+ /// item we are type-checking, and just consider those names as
1397
+ /// part of the root universe. So this would only get incremented
1398
+ /// when we enter into a higher-ranked (`for<..>`) type or trait
1399
+ /// bound.
1400
+ pub universe : UniverseIndex ,
1385
1401
}
1386
1402
1387
1403
impl < ' tcx > ParamEnv < ' tcx > {
@@ -2657,7 +2673,8 @@ fn param_env<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
2657
2673
// sure that this will succeed without errors anyway.
2658
2674
2659
2675
let unnormalized_env = ty:: ParamEnv :: new ( tcx. intern_predicates ( & predicates) ,
2660
- traits:: Reveal :: UserFacing ) ;
2676
+ traits:: Reveal :: UserFacing ,
2677
+ ty:: UniverseIndex :: ROOT ) ;
2661
2678
2662
2679
let body_id = tcx. hir . as_local_node_id ( def_id) . map_or ( DUMMY_NODE_ID , |id| {
2663
2680
tcx. hir . maybe_body_owned_by ( id) . map_or ( id, |body| body. node_id )
0 commit comments