review
This commit is contained in:
parent
bbd581c583
commit
c6c0d17c8d
@ -11,36 +11,22 @@ pub fn anonymize_predicate<'tcx>(
|
||||
pred: ty::Predicate<'tcx>,
|
||||
) -> ty::Predicate<'tcx> {
|
||||
let kind = pred.kind();
|
||||
let new = match kind {
|
||||
match kind {
|
||||
ty::PredicateKind::ForAll(binder) => {
|
||||
ty::PredicateKind::ForAll(tcx.anonymize_late_bound_regions(binder))
|
||||
let new = ty::PredicateKind::ForAll(tcx.anonymize_late_bound_regions(binder));
|
||||
if new != *kind { new.to_predicate(tcx) } else { pred }
|
||||
}
|
||||
&ty::PredicateKind::Trait(data, constness) => ty::PredicateKind::Trait(data, constness),
|
||||
|
||||
&ty::PredicateKind::RegionOutlives(data) => ty::PredicateKind::RegionOutlives(data),
|
||||
|
||||
&ty::PredicateKind::TypeOutlives(data) => ty::PredicateKind::TypeOutlives(data),
|
||||
|
||||
&ty::PredicateKind::Projection(data) => ty::PredicateKind::Projection(data),
|
||||
|
||||
&ty::PredicateKind::WellFormed(data) => ty::PredicateKind::WellFormed(data),
|
||||
|
||||
&ty::PredicateKind::ObjectSafe(data) => ty::PredicateKind::ObjectSafe(data),
|
||||
|
||||
&ty::PredicateKind::ClosureKind(closure_def_id, closure_substs, kind) => {
|
||||
ty::PredicateKind::ClosureKind(closure_def_id, closure_substs, kind)
|
||||
}
|
||||
|
||||
&ty::PredicateKind::Subtype(data) => ty::PredicateKind::Subtype(data),
|
||||
|
||||
&ty::PredicateKind::ConstEvaluatable(def_id, substs) => {
|
||||
ty::PredicateKind::ConstEvaluatable(def_id, substs)
|
||||
}
|
||||
|
||||
&ty::PredicateKind::ConstEquate(c1, c2) => ty::PredicateKind::ConstEquate(c1, c2),
|
||||
};
|
||||
|
||||
if new != *kind { new.to_predicate(tcx) } else { pred }
|
||||
ty::PredicateKind::Trait(_, _)
|
||||
| ty::PredicateKind::RegionOutlives(_)
|
||||
| ty::PredicateKind::TypeOutlives(_)
|
||||
| ty::PredicateKind::Projection(_)
|
||||
| ty::PredicateKind::WellFormed(_)
|
||||
| ty::PredicateKind::ObjectSafe(_)
|
||||
| ty::PredicateKind::ClosureKind(_, _, _)
|
||||
| ty::PredicateKind::Subtype(_)
|
||||
| ty::PredicateKind::ConstEvaluatable(_, _)
|
||||
| ty::PredicateKind::ConstEquate(_, _) => pred,
|
||||
}
|
||||
}
|
||||
|
||||
struct PredicateSet<'tcx> {
|
||||
|
@ -1225,20 +1225,10 @@ impl<'tcx> Predicate<'tcx> {
|
||||
// substitution code expects equal binding levels in the values
|
||||
// from the substitution and the value being substituted into, and
|
||||
// this trick achieves that).
|
||||
|
||||
let substs = trait_ref.skip_binder().substs;
|
||||
let kind = match self.kind() {
|
||||
PredicateKind::ForAll(binder) => binder.skip_binder().kind(),
|
||||
kind => kind,
|
||||
};
|
||||
|
||||
let new = kind.subst(tcx, substs);
|
||||
|
||||
if new != *kind {
|
||||
new.to_predicate(tcx).potentially_qualified(tcx, PredicateKind::ForAll)
|
||||
} else {
|
||||
self
|
||||
}
|
||||
let pred = *self.ignore_qualifiers(tcx).skip_binder();
|
||||
let new = pred.subst(tcx, substs);
|
||||
if new != pred { new.potentially_qualified(tcx, PredicateKind::ForAll) } else { self }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,6 @@ pub fn is_min_const_fn(tcx: TyCtxt<'tcx>, def_id: DefId, body: &'a Body<'tcx>) -
|
||||
loop {
|
||||
let predicates = tcx.predicates_of(current);
|
||||
for (predicate, _) in predicates.predicates {
|
||||
// TODO: forall
|
||||
match predicate.ignore_qualifiers(tcx).skip_binder().kind() {
|
||||
ty::PredicateKind::ForAll(_) => bug!("unexpected predicate: {:?}", predicate),
|
||||
ty::PredicateKind::RegionOutlives(_)
|
||||
|
@ -639,7 +639,6 @@ impl AutoTraitFinder<'tcx> {
|
||||
// We check this by calling is_of_param on the relevant types
|
||||
// from the various possible predicates
|
||||
|
||||
// TODO: forall
|
||||
match predicate.ignore_qualifiers(self.tcx).skip_binder().kind() {
|
||||
&ty::PredicateKind::Trait(p, _) => {
|
||||
if self.is_param_no_infer(p.trait_ref.substs)
|
||||
|
@ -256,7 +256,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: forall
|
||||
match obligation.predicate.ignore_qualifiers(tcx).skip_binder().kind() {
|
||||
ty::PredicateKind::ForAll(_) => {
|
||||
bug!("unexpected predicate: {:?}", obligation.predicate)
|
||||
@ -1481,7 +1480,6 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: forall
|
||||
let mut err = match predicate.ignore_qualifiers(self.tcx).skip_binder().kind() {
|
||||
&ty::PredicateKind::Trait(data, _) => {
|
||||
let trait_ref = ty::Binder::bind(data.trait_ref);
|
||||
@ -1583,8 +1581,6 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
}
|
||||
|
||||
ty::PredicateKind::WellFormed(arg) => {
|
||||
// TODO: forall
|
||||
|
||||
// Same hacky approach as above to avoid deluging user
|
||||
// with error messages.
|
||||
if arg.references_error() || self.tcx.sess.has_errors() {
|
||||
@ -1604,7 +1600,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
ty::PredicateKind::Subtype(ref data) => {
|
||||
ty::PredicateKind::Subtype(data) => {
|
||||
if data.references_error() || self.tcx.sess.has_errors() {
|
||||
// no need to overload user in such cases
|
||||
return;
|
||||
@ -1737,14 +1733,16 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
err: &mut DiagnosticBuilder<'tcx>,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
) {
|
||||
let (pred, item_def_id, span) =
|
||||
match (obligation.predicate.ignore_qualifiers(self.tcx).skip_binder().kind(), obligation.cause.code.peel_derives()) {
|
||||
(
|
||||
ty::PredicateKind::Trait(pred, _),
|
||||
&ObligationCauseCode::BindingObligation(item_def_id, span),
|
||||
) => (pred, item_def_id, span),
|
||||
_ => return,
|
||||
};
|
||||
let (pred, item_def_id, span) = match (
|
||||
obligation.predicate.ignore_qualifiers(self.tcx).skip_binder().kind(),
|
||||
obligation.cause.code.peel_derives(),
|
||||
) {
|
||||
(
|
||||
ty::PredicateKind::Trait(pred, _),
|
||||
&ObligationCauseCode::BindingObligation(item_def_id, span),
|
||||
) => (pred, item_def_id, span),
|
||||
_ => return,
|
||||
};
|
||||
|
||||
let node = match (
|
||||
self.tcx.hir().get_if_local(item_def_id),
|
||||
|
@ -245,7 +245,6 @@ fn predicates_reference_self(
|
||||
.iter()
|
||||
.map(|(predicate, sp)| (predicate.subst_supertrait(tcx, &trait_ref), sp))
|
||||
.filter_map(|(predicate, &sp)| {
|
||||
// TODO: forall
|
||||
match predicate.ignore_qualifiers(tcx).skip_binder().kind() {
|
||||
ty::PredicateKind::Trait(ref data, _) => {
|
||||
// In the case of a trait predicate, we can skip the "self" type.
|
||||
@ -300,7 +299,6 @@ fn generics_require_sized_self(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
|
||||
let predicates = tcx.predicates_of(def_id);
|
||||
let predicates = predicates.instantiate_identity(tcx).predicates;
|
||||
elaborate_predicates(tcx, predicates.into_iter()).any(|obligation| {
|
||||
// TODO: forall
|
||||
match obligation.predicate.ignore_qualifiers(tcx).skip_binder().kind() {
|
||||
ty::PredicateKind::Trait(ref trait_pred, _) => {
|
||||
trait_pred.def_id() == sized_def_id && trait_pred.self_ty().is_param(0)
|
||||
|
@ -933,7 +933,6 @@ fn assemble_candidates_from_predicates<'cx, 'tcx>(
|
||||
let infcx = selcx.infcx();
|
||||
for predicate in env_predicates {
|
||||
debug!("assemble_candidates_from_predicates: predicate={:?}", predicate);
|
||||
// TODO: forall
|
||||
if let &ty::PredicateKind::Projection(data) =
|
||||
predicate.ignore_qualifiers(infcx.tcx).skip_binder().kind()
|
||||
{
|
||||
@ -1228,7 +1227,6 @@ fn confirm_object_candidate<'cx, 'tcx>(
|
||||
// select only those projections that are actually projecting an
|
||||
// item with the correct name
|
||||
|
||||
// TODO: forall
|
||||
let env_predicates = env_predicates.filter_map(|o| {
|
||||
match o.predicate.ignore_qualifiers(selcx.tcx()).skip_binder().kind() {
|
||||
&ty::PredicateKind::Projection(data)
|
||||
|
@ -408,7 +408,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
None => self.check_recursion_limit(&obligation, &obligation)?,
|
||||
}
|
||||
|
||||
// TODO: forall
|
||||
match obligation.predicate.ignore_qualifiers(self.tcx()).skip_binder().kind() {
|
||||
ty::PredicateKind::ForAll(_) => {
|
||||
bug!("unexpected predicate: {:?}", obligation.predicate)
|
||||
|
@ -223,9 +223,21 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predi
|
||||
// the environment.
|
||||
ty::Placeholder(..) => chalk_ir::GoalData::All(chalk_ir::Goals::new(interner)),
|
||||
|
||||
_ => chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::WellFormed(
|
||||
chalk_ir::WellFormed::Ty(ty.lower_into(interner)),
|
||||
)),
|
||||
_ => {
|
||||
let (ty, binders, _named_regions) =
|
||||
collect_bound_vars(interner, interner.tcx, &ty::Binder::bind(ty));
|
||||
|
||||
chalk_ir::GoalData::Quantified(
|
||||
chalk_ir::QuantifierKind::ForAll,
|
||||
chalk_ir::Binders::new(
|
||||
binders,
|
||||
chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::WellFormed(
|
||||
chalk_ir::WellFormed::Ty(ty.lower_into(interner)),
|
||||
))
|
||||
.intern(interner),
|
||||
),
|
||||
)
|
||||
}
|
||||
},
|
||||
// FIXME(chalk): handle well formed consts
|
||||
GenericArgKind::Const(..) => {
|
||||
|
@ -42,7 +42,6 @@ fn normalize_generic_arg_after_erasing_regions<'tcx>(
|
||||
}
|
||||
|
||||
fn not_outlives_predicate(tcx: TyCtxt<'tcx>, p: &ty::Predicate<'tcx>) -> bool {
|
||||
// TODO: forall
|
||||
match p.ignore_qualifiers(tcx).skip_binder().kind() {
|
||||
ty::PredicateKind::RegionOutlives(..) | ty::PredicateKind::TypeOutlives(..) => false,
|
||||
ty::PredicateKind::ForAll(_) => bug!("unexpected predicate: {:?}", p),
|
||||
|
@ -1706,7 +1706,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
obligation.predicate
|
||||
);
|
||||
|
||||
// TODO: forall
|
||||
match obligation.predicate.ignore_qualifiers(tcx).skip_binder().kind() {
|
||||
&ty::PredicateKind::Trait(pred, _) => {
|
||||
let pred = ty::Binder::bind(pred);
|
||||
|
@ -631,7 +631,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
}
|
||||
};
|
||||
let mut format_pred = |pred: ty::Predicate<'tcx>| {
|
||||
// TODO: forall
|
||||
match pred.ignore_qualifiers(tcx).skip_binder().kind() {
|
||||
&ty::PredicateKind::Projection(pred) => {
|
||||
let pred = ty::Binder::bind(pred);
|
||||
|
@ -2400,8 +2400,6 @@ fn bounds_from_generic_predicates<'tcx>(
|
||||
let mut projections = vec![];
|
||||
for (predicate, _) in predicates.predicates {
|
||||
debug!("predicate {:?}", predicate);
|
||||
// TODO: forall (we could keep the current behavior and just skip binders eagerly,
|
||||
// not sure if we want to though)
|
||||
match predicate.ignore_qualifiers(tcx).skip_binder().kind() {
|
||||
ty::PredicateKind::Trait(trait_predicate, _) => {
|
||||
let entry = types.entry(trait_predicate.self_ty()).or_default();
|
||||
@ -3895,7 +3893,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
.borrow()
|
||||
.pending_obligations()
|
||||
.into_iter()
|
||||
// TODO: forall
|
||||
.filter_map(move |obligation| {
|
||||
match obligation.predicate.ignore_qualifiers(self.tcx).skip_binder().kind() {
|
||||
ty::PredicateKind::ForAll(_) => {
|
||||
|
@ -29,12 +29,10 @@ impl<'tcx> ExplicitPredicatesMap<'tcx> {
|
||||
|
||||
// process predicates and convert to `RequiredPredicates` entry, see below
|
||||
for &(predicate, span) in predicates.predicates {
|
||||
// TODO: forall
|
||||
match predicate.ignore_qualifiers(tcx).skip_binder().kind() {
|
||||
ty::PredicateKind::ForAll(_) => bug!("unepected predicate: {:?}", predicate),
|
||||
|
||||
ty::PredicateKind::TypeOutlives(predicate) => {
|
||||
let OutlivesPredicate(ref ty, ref reg) = predicate;
|
||||
ty::PredicateKind::TypeOutlives(OutlivesPredicate(ref ty, ref reg)) => {
|
||||
insert_outlives_predicate(
|
||||
tcx,
|
||||
(*ty).into(),
|
||||
@ -44,8 +42,7 @@ impl<'tcx> ExplicitPredicatesMap<'tcx> {
|
||||
)
|
||||
}
|
||||
|
||||
ty::PredicateKind::RegionOutlives(predicate) => {
|
||||
let OutlivesPredicate(ref reg1, ref reg2) = predicate;
|
||||
ty::PredicateKind::RegionOutlives(OutlivesPredicate(ref reg1, ref reg2)) => {
|
||||
insert_outlives_predicate(
|
||||
tcx,
|
||||
(*reg1).into(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user