Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the "leak check" in favor of "universes" #48407

Closed
wants to merge 22 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
48df576
Revert "change skolemizations to use universe index"
sgrif Mar 6, 2018
50bd71c
Revert "fix tests in `librustc_driver`"
sgrif Mar 6, 2018
5dad682
Revert "fix tidy error"
sgrif Mar 6, 2018
2a94f30
Revert "change skolemizations to use universe index"
sgrif Mar 6, 2018
f6e6d23
Revert "introduce `UniverseIndex` into `ParamEnv`"
sgrif Mar 6, 2018
26d1fc7
Revert "add universes to type inference variables"
sgrif Mar 6, 2018
3d4791b
introduce `UniverseIndex` into `InferCtxt`
sgrif Feb 7, 2018
ff17bd7
add universes to type inference variables
sgrif Feb 7, 2018
66520ff
change skolemizations to use universe index
sgrif Feb 7, 2018
534d5d1
store RegionVariableInfo and not just RegionVariableOrigin
sgrif Feb 7, 2018
59f3b20
give a universe to region variables
sgrif Feb 7, 2018
ad9e9d9
make solving "universe aware", in a simplistic way
sgrif Feb 7, 2018
24478c4
kill higher_ranked_lub and higher_ranked_glb
sgrif Feb 7, 2018
367be87
remove `hr_match` -- no longer needed
nikomatsakis Aug 23, 2017
5aca3b9
move param-env from CombineFields into the individual operations
nikomatsakis Aug 21, 2017
afb4010
Wrap `InferCtxt::universe` in a cell
sgrif Feb 8, 2018
3b8008f
track skol levels in the InferCtxt rather than via counter
sgrif Feb 8, 2018
0bc324a
remove pop_skolemized and friends
sgrif Feb 8, 2018
17e0577
DO NOT MERGE THIS COMMIT
sgrif Mar 6, 2018
bd90fb5
Fix rustdoc breakage
sgrif Mar 6, 2018
725eeb0
[DO NOT MERGE THIS COMMIT] Remove more failing tests
sgrif Mar 7, 2018
3f599ad
Fix rebase issues
sgrif Mar 19, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "introduce UniverseIndex into ParamEnv"
This reverts commit d4df52c.
sgrif committed Mar 14, 2018
commit f6e6d230589a4d90477718f85ecf86f96f223a32
10 changes: 0 additions & 10 deletions src/librustc/ich/impls_ty.rs
Original file line number Diff line number Diff line change
@@ -1066,7 +1066,6 @@ for ty::steal::Steal<T>

impl_stable_hash_for!(struct ty::ParamEnv<'tcx> {
caller_bounds,
universe,
reveal
});

@@ -1237,15 +1236,6 @@ for traits::VtableGeneratorData<'gcx, N> where N: HashStable<StableHashingContex
}
}

impl<'a> HashStable<StableHashingContext<'a>>
for ty::UniverseIndex {
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'a>,
hasher: &mut StableHasher<W>) {
self.depth().hash_stable(hcx, hasher);
}
}

impl_stable_hash_for!(
impl<'tcx, V> for struct infer::canonical::Canonical<'tcx, V> {
variables, value
7 changes: 2 additions & 5 deletions src/librustc/traits/mod.rs
Original file line number Diff line number Diff line change
@@ -546,8 +546,7 @@ pub fn normalize_param_env_or_error<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
predicates);

let elaborated_env = ty::ParamEnv::new(tcx.intern_predicates(&predicates),
unnormalized_env.reveal,
unnormalized_env.universe);
unnormalized_env.reveal);

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

ty::ParamEnv::new(tcx.intern_predicates(&predicates),
unnormalized_env.reveal,
unnormalized_env.universe)
ty::ParamEnv::new(tcx.intern_predicates(&predicates), unnormalized_env.reveal)
})
}

25 changes: 4 additions & 21 deletions src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
@@ -1334,7 +1334,9 @@ pub struct UniverseIndex(u32);
impl UniverseIndex {
/// The root universe, where things that the user defined are
/// visible.
pub const ROOT: UniverseIndex = UniverseIndex(0);
pub fn root() -> UniverseIndex {
UniverseIndex(0)
}

/// A "subuniverse" corresponds to being inside a `forall` quantifier.
/// So, for example, suppose we have this type in universe `U`:
@@ -1350,13 +1352,6 @@ impl UniverseIndex {
pub fn subuniverse(self) -> UniverseIndex {
UniverseIndex(self.0 + 1)
}

/// Gets the "depth" of this universe in the universe tree. This
/// is not really useful except for e.g. the `HashStable`
/// implementation
pub fn depth(&self) -> u32 {
self.0
}
}

/// When type checking, we use the `ParamEnv` to track
@@ -1373,17 +1368,6 @@ pub struct ParamEnv<'tcx> {
/// want `Reveal::All` -- note that this is always paired with an
/// empty environment. To get that, use `ParamEnv::reveal()`.
pub reveal: traits::Reveal,

/// What is the innermost universe we have created? Starts out as
/// `UniverseIndex::root()` but grows from there as we enter
/// universal quantifiers.
///
/// NB: At present, we exclude the universal quantifiers on the
/// item we are type-checking, and just consider those names as
/// part of the root universe. So this would only get incremented
/// when we enter into a higher-ranked (`for<..>`) type or trait
/// bound.
pub universe: UniverseIndex,
}

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

let unnormalized_env = ty::ParamEnv::new(tcx.intern_predicates(&predicates),
traits::Reveal::UserFacing,
ty::UniverseIndex::ROOT);
traits::Reveal::UserFacing);

let body_id = tcx.hir.as_local_node_id(def_id).map_or(DUMMY_NODE_ID, |id| {
tcx.hir.maybe_body_owned_by(id).map_or(id, |body| body.node_id)
26 changes: 2 additions & 24 deletions src/librustc/ty/structural_impls.rs
Original file line number Diff line number Diff line change
@@ -279,7 +279,6 @@ impl<'a, 'tcx> Lift<'tcx> for ty::ParamEnv<'a> {
tcx.lift(&self.caller_bounds).map(|caller_bounds| {
ty::ParamEnv {
reveal: self.reveal,
universe: self.universe,
caller_bounds,
}
})
@@ -737,29 +736,8 @@ impl<'tcx, T:TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder<T> {
}
}

impl<'tcx> TypeFoldable<'tcx> for ty::ParamEnv<'tcx> {
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
ty::ParamEnv {
reveal: self.reveal,
caller_bounds: self.caller_bounds.fold_with(folder),
universe: self.universe.fold_with(folder),
}
}

fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
let &ty::ParamEnv { reveal: _, ref universe, ref caller_bounds } = self;
universe.super_visit_with(visitor) || caller_bounds.super_visit_with(visitor)
}
}

impl<'tcx> TypeFoldable<'tcx> for ty::UniverseIndex {
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, _folder: &mut F) -> Self {
*self
}

fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _visitor: &mut V) -> bool {
false
}
BraceStructTypeFoldableImpl! {
impl<'tcx> TypeFoldable<'tcx> for ty::ParamEnv<'tcx> { reveal, caller_bounds }
}

impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Slice<ty::ExistentialPredicate<'tcx>> {
3 changes: 1 addition & 2 deletions src/librustc_typeck/check/compare_method.rs
Original file line number Diff line number Diff line change
@@ -218,8 +218,7 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// the new hybrid bounds we computed.
let normalize_cause = traits::ObligationCause::misc(impl_m_span, impl_m_node_id);
let param_env = ty::ParamEnv::new(tcx.intern_predicates(&hybrid_preds.predicates),
Reveal::UserFacing,
ty::UniverseIndex::ROOT);
Reveal::UserFacing);
let param_env = traits::normalize_param_env_or_error(tcx,
impl_m.def_id,
param_env,