dropck
This commit is contained in:
parent
7f3dc04644
commit
b1d14ef08f
2 changed files with 31 additions and 4 deletions
|
@ -217,10 +217,10 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
|
||||||
// repeated `.iter().any(..)` calls.
|
// repeated `.iter().any(..)` calls.
|
||||||
|
|
||||||
// This closure is a more robust way to check `Predicate` equality
|
// This closure is a more robust way to check `Predicate` equality
|
||||||
// than simple `==` checks (which were the previous implementation).
|
// than simple `==` checks (which were the previous implementation). It relies on
|
||||||
// It relies on `ty::relate` for `TraitPredicate` and `ProjectionPredicate`
|
// `ty::relate` for `TraitPredicate`, `ProjectionPredicate`, `ConstEvaluatable`
|
||||||
// (which implement the Relate trait), while delegating on simple equality
|
// `TypeOutlives` and `TypeWellFormedFromEnv` (which implement the Relate trait),
|
||||||
// for the other `Predicate`.
|
// while delegating on simple equality for the other `Predicate`.
|
||||||
// This implementation solves (Issue #59497) and (Issue #58311).
|
// This implementation solves (Issue #59497) and (Issue #58311).
|
||||||
// It is unclear to me at the moment whether the approach based on `relate`
|
// It is unclear to me at the moment whether the approach based on `relate`
|
||||||
// could be extended easily also to the other `Predicate`.
|
// could be extended easily also to the other `Predicate`.
|
||||||
|
@ -235,6 +235,17 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
|
||||||
(ty::PredicateKind::Projection(a), ty::PredicateKind::Projection(b)) => {
|
(ty::PredicateKind::Projection(a), ty::PredicateKind::Projection(b)) => {
|
||||||
relator.relate(predicate.rebind(a), p.rebind(b)).is_ok()
|
relator.relate(predicate.rebind(a), p.rebind(b)).is_ok()
|
||||||
}
|
}
|
||||||
|
(
|
||||||
|
ty::PredicateKind::ConstEvaluatable(def_a, substs_a),
|
||||||
|
ty::PredicateKind::ConstEvaluatable(def_b, substs_b),
|
||||||
|
) => tcx.try_unify_abstract_consts(((def_a, substs_a), (def_b, substs_b))),
|
||||||
|
(ty::PredicateKind::TypeOutlives(a), ty::PredicateKind::TypeOutlives(b)) => {
|
||||||
|
relator.relate(predicate.rebind(a.0), p.rebind(b.0)).is_ok()
|
||||||
|
}
|
||||||
|
(
|
||||||
|
ty::PredicateKind::TypeWellFormedFromEnv(a),
|
||||||
|
ty::PredicateKind::TypeWellFormedFromEnv(b),
|
||||||
|
) => relator.relate(predicate.rebind(a), p.rebind(b)).is_ok(),
|
||||||
_ => predicate == p,
|
_ => predicate == p,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
//check-pass
|
||||||
|
#![feature(const_generics, const_evaluatable_checked)]
|
||||||
|
#![allow(incomplete_features)]
|
||||||
|
|
||||||
|
struct Foo<const N: usize>
|
||||||
|
where
|
||||||
|
[(); N + 1]: ;
|
||||||
|
|
||||||
|
impl<const N: usize> Drop for Foo<N>
|
||||||
|
where
|
||||||
|
[(); N + 1]: ,
|
||||||
|
{
|
||||||
|
fn drop(&mut self) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
Loading…
Add table
Add a link
Reference in a new issue