Skip to content

Commit 1171ebf

Browse files
committed
Revert "introduce UniverseIndex into ParamEnv"
This reverts commit d4df52c.
1 parent 26cebda commit 1171ebf

File tree

5 files changed

+9
-62
lines changed

5 files changed

+9
-62
lines changed

src/librustc/ich/impls_ty.rs

-10
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,6 @@ for ty::steal::Steal<T>
11111111

11121112
impl_stable_hash_for!(struct ty::ParamEnv<'tcx> {
11131113
caller_bounds,
1114-
universe,
11151114
reveal
11161115
});
11171116

@@ -1282,15 +1281,6 @@ for traits::VtableGeneratorData<'gcx, N> where N: HashStable<StableHashingContex
12821281
}
12831282
}
12841283

1285-
impl<'a> HashStable<StableHashingContext<'a>>
1286-
for ty::UniverseIndex {
1287-
fn hash_stable<W: StableHasherResult>(&self,
1288-
hcx: &mut StableHashingContext<'a>,
1289-
hasher: &mut StableHasher<W>) {
1290-
self.depth().hash_stable(hcx, hasher);
1291-
}
1292-
}
1293-
12941284
impl_stable_hash_for!(
12951285
impl<'tcx, V> for struct infer::canonical::Canonical<'tcx, V> {
12961286
variables, value

src/librustc/traits/mod.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -610,8 +610,7 @@ pub fn normalize_param_env_or_error<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
610610
predicates);
611611

612612
let elaborated_env = ty::ParamEnv::new(tcx.intern_predicates(&predicates),
613-
unnormalized_env.reveal,
614-
unnormalized_env.universe);
613+
unnormalized_env.reveal);
615614

616615
tcx.infer_ctxt().enter(|infcx| {
617616
// FIXME. We should really... do something with these region
@@ -685,9 +684,7 @@ pub fn normalize_param_env_or_error<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
685684
debug!("normalize_param_env_or_error: resolved predicates={:?}",
686685
predicates);
687686

688-
ty::ParamEnv::new(tcx.intern_predicates(&predicates),
689-
unnormalized_env.reveal,
690-
unnormalized_env.universe)
687+
ty::ParamEnv::new(tcx.intern_predicates(&predicates), unnormalized_env.reveal)
691688
})
692689
}
693690

src/librustc/ty/mod.rs

+4-21
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,9 @@ pub struct UniverseIndex(u32);
13381338
impl UniverseIndex {
13391339
/// The root universe, where things that the user defined are
13401340
/// visible.
1341-
pub const ROOT: UniverseIndex = UniverseIndex(0);
1341+
pub fn root() -> UniverseIndex {
1342+
UniverseIndex(0)
1343+
}
13421344

13431345
/// A "subuniverse" corresponds to being inside a `forall` quantifier.
13441346
/// So, for example, suppose we have this type in universe `U`:
@@ -1354,13 +1356,6 @@ impl UniverseIndex {
13541356
pub fn subuniverse(self) -> UniverseIndex {
13551357
UniverseIndex(self.0 + 1)
13561358
}
1357-
1358-
/// Gets the "depth" of this universe in the universe tree. This
1359-
/// is not really useful except for e.g. the `HashStable`
1360-
/// implementation
1361-
pub fn depth(&self) -> u32 {
1362-
self.0
1363-
}
13641359
}
13651360

13661361
/// When type checking, we use the `ParamEnv` to track
@@ -1377,17 +1372,6 @@ pub struct ParamEnv<'tcx> {
13771372
/// want `Reveal::All` -- note that this is always paired with an
13781373
/// empty environment. To get that, use `ParamEnv::reveal()`.
13791374
pub reveal: traits::Reveal,
1380-
1381-
/// What is the innermost universe we have created? Starts out as
1382-
/// `UniverseIndex::root()` but grows from there as we enter
1383-
/// universal quantifiers.
1384-
///
1385-
/// NB: At present, we exclude the universal quantifiers on the
1386-
/// item we are type-checking, and just consider those names as
1387-
/// part of the root universe. So this would only get incremented
1388-
/// when we enter into a higher-ranked (`for<..>`) type or trait
1389-
/// bound.
1390-
pub universe: UniverseIndex,
13911375
}
13921376

13931377
impl<'tcx> ParamEnv<'tcx> {
@@ -2707,8 +2691,7 @@ fn param_env<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
27072691
// sure that this will succeed without errors anyway.
27082692

27092693
let unnormalized_env = ty::ParamEnv::new(tcx.intern_predicates(&predicates),
2710-
traits::Reveal::UserFacing,
2711-
ty::UniverseIndex::ROOT);
2694+
traits::Reveal::UserFacing);
27122695

27132696
let body_id = tcx.hir.as_local_node_id(def_id).map_or(DUMMY_NODE_ID, |id| {
27142697
tcx.hir.maybe_body_owned_by(id).map_or(id, |body| body.node_id)

src/librustc/ty/structural_impls.rs

+2-24
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ impl<'a, 'tcx> Lift<'tcx> for ty::ParamEnv<'a> {
279279
tcx.lift(&self.caller_bounds).map(|caller_bounds| {
280280
ty::ParamEnv {
281281
reveal: self.reveal,
282-
universe: self.universe,
283282
caller_bounds,
284283
}
285284
})
@@ -737,29 +736,8 @@ impl<'tcx, T:TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder<T> {
737736
}
738737
}
739738

740-
impl<'tcx> TypeFoldable<'tcx> for ty::ParamEnv<'tcx> {
741-
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
742-
ty::ParamEnv {
743-
reveal: self.reveal,
744-
caller_bounds: self.caller_bounds.fold_with(folder),
745-
universe: self.universe.fold_with(folder),
746-
}
747-
}
748-
749-
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
750-
let &ty::ParamEnv { reveal: _, ref universe, ref caller_bounds } = self;
751-
universe.super_visit_with(visitor) || caller_bounds.super_visit_with(visitor)
752-
}
753-
}
754-
755-
impl<'tcx> TypeFoldable<'tcx> for ty::UniverseIndex {
756-
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, _folder: &mut F) -> Self {
757-
*self
758-
}
759-
760-
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _visitor: &mut V) -> bool {
761-
false
762-
}
739+
BraceStructTypeFoldableImpl! {
740+
impl<'tcx> TypeFoldable<'tcx> for ty::ParamEnv<'tcx> { reveal, caller_bounds }
763741
}
764742

765743
impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Slice<ty::ExistentialPredicate<'tcx>> {

src/librustc_typeck/check/compare_method.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,7 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
218218
// the new hybrid bounds we computed.
219219
let normalize_cause = traits::ObligationCause::misc(impl_m_span, impl_m_node_id);
220220
let param_env = ty::ParamEnv::new(tcx.intern_predicates(&hybrid_preds.predicates),
221-
Reveal::UserFacing,
222-
ty::UniverseIndex::ROOT);
221+
Reveal::UserFacing);
223222
let param_env = traits::normalize_param_env_or_error(tcx,
224223
impl_m.def_id,
225224
param_env,

0 commit comments

Comments
 (0)