From cd30894c2f7113bf79c7f66d30a774f11b315d3f Mon Sep 17 00:00:00 2001 From: Bastian Kauschke Date: Wed, 17 Jun 2020 00:13:00 +0200 Subject: [PATCH] anonymize_predicate --- src/librustc_infer/traits/util.rs | 53 ++++++++++++++----------------- 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/src/librustc_infer/traits/util.rs b/src/librustc_infer/traits/util.rs index 4ae7e417a8f..957c993c4bf 100644 --- a/src/librustc_infer/traits/util.rs +++ b/src/librustc_infer/traits/util.rs @@ -10,41 +10,34 @@ pub fn anonymize_predicate<'tcx>( tcx: TyCtxt<'tcx>, pred: ty::Predicate<'tcx>, ) -> ty::Predicate<'tcx> { - let kind = pred.kind(); + let kind = pred.kint(tcx); let new = match kind { - &ty::PredicateKind::Trait(ref data, constness) => { - ty::PredicateKind::Trait(tcx.anonymize_late_bound_regions(data), constness) + ty::PredicateKint::ForAll(binder) => { + ty::PredicateKint::ForAll(tcx.anonymize_late_bound_regions(binder)) + } + &ty::PredicateKint::Trait(data, constness) => ty::PredicateKint::Trait(data, constness), + + &ty::PredicateKint::RegionOutlives(data) => ty::PredicateKint::RegionOutlives(data), + + &ty::PredicateKint::TypeOutlives(data) => ty::PredicateKint::TypeOutlives(data), + + &ty::PredicateKint::Projection(data) => ty::PredicateKint::Projection(data), + + &ty::PredicateKint::WellFormed(data) => ty::PredicateKint::WellFormed(data), + + &ty::PredicateKint::ObjectSafe(data) => ty::PredicateKint::ObjectSafe(data), + + &ty::PredicateKint::ClosureKind(closure_def_id, closure_substs, kind) => { + ty::PredicateKint::ClosureKind(closure_def_id, closure_substs, kind) } - ty::PredicateKind::RegionOutlives(data) => { - ty::PredicateKind::RegionOutlives(tcx.anonymize_late_bound_regions(data)) + &ty::PredicateKint::Subtype(data) => ty::PredicateKint::Subtype(data), + + &ty::PredicateKint::ConstEvaluatable(def_id, substs) => { + ty::PredicateKint::ConstEvaluatable(def_id, substs) } - ty::PredicateKind::TypeOutlives(data) => { - ty::PredicateKind::TypeOutlives(tcx.anonymize_late_bound_regions(data)) - } - - ty::PredicateKind::Projection(data) => { - ty::PredicateKind::Projection(tcx.anonymize_late_bound_regions(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(tcx.anonymize_late_bound_regions(data)) - } - - &ty::PredicateKind::ConstEvaluatable(def_id, substs) => { - ty::PredicateKind::ConstEvaluatable(def_id, substs) - } - - ty::PredicateKind::ConstEquate(c1, c2) => ty::PredicateKind::ConstEquate(c1, c2), + &ty::PredicateKint::ConstEquate(c1, c2) => ty::PredicateKint::ConstEquate(c1, c2), }; if new != *kind { new.to_predicate(tcx) } else { pred }