subst_supertrait
This commit is contained in:
parent
1fda8c207e
commit
7f39b0c9ab
2 changed files with 14 additions and 31 deletions
|
@ -156,10 +156,10 @@ impl Elaborator<'tcx> {
|
|||
// Get predicates declared on the trait.
|
||||
let predicates = tcx.super_predicates_of(data.def_id());
|
||||
|
||||
let obligations = predicates.predicates.iter().map(|(pred, span)| {
|
||||
let obligations = predicates.predicates.iter().map(|&(pred, span)| {
|
||||
predicate_obligation(
|
||||
pred.subst_supertrait(tcx, &data.to_poly_trait_ref()),
|
||||
Some(*span),
|
||||
Some(span),
|
||||
)
|
||||
});
|
||||
debug!("super_predicates: data={:?}", data);
|
||||
|
|
|
@ -1303,37 +1303,20 @@ impl<'tcx> Predicate<'tcx> {
|
|||
// this trick achieves that).
|
||||
|
||||
let substs = trait_ref.skip_binder().substs;
|
||||
let kind = self.kind();
|
||||
let new = match kind {
|
||||
&PredicateKind::Trait(ref binder, constness) => {
|
||||
PredicateKind::Trait(binder.map_bound(|data| data.subst(tcx, substs)), constness)
|
||||
}
|
||||
PredicateKind::Subtype(binder) => {
|
||||
PredicateKind::Subtype(binder.map_bound(|data| data.subst(tcx, substs)))
|
||||
}
|
||||
PredicateKind::RegionOutlives(binder) => {
|
||||
PredicateKind::RegionOutlives(binder.map_bound(|data| data.subst(tcx, substs)))
|
||||
}
|
||||
PredicateKind::TypeOutlives(binder) => {
|
||||
PredicateKind::TypeOutlives(binder.map_bound(|data| data.subst(tcx, substs)))
|
||||
}
|
||||
PredicateKind::Projection(binder) => {
|
||||
PredicateKind::Projection(binder.map_bound(|data| data.subst(tcx, substs)))
|
||||
}
|
||||
&PredicateKind::WellFormed(data) => PredicateKind::WellFormed(data.subst(tcx, substs)),
|
||||
&PredicateKind::ObjectSafe(trait_def_id) => PredicateKind::ObjectSafe(trait_def_id),
|
||||
&PredicateKind::ClosureKind(closure_def_id, closure_substs, kind) => {
|
||||
PredicateKind::ClosureKind(closure_def_id, closure_substs.subst(tcx, substs), kind)
|
||||
}
|
||||
&PredicateKind::ConstEvaluatable(def_id, const_substs) => {
|
||||
PredicateKind::ConstEvaluatable(def_id, const_substs.subst(tcx, substs))
|
||||
}
|
||||
PredicateKind::ConstEquate(c1, c2) => {
|
||||
PredicateKind::ConstEquate(c1.subst(tcx, substs), c2.subst(tcx, substs))
|
||||
}
|
||||
let kind = match self.kint(tcx) {
|
||||
PredicateKint::ForAll(binder) => *binder.skip_binder(),
|
||||
kind => kind,
|
||||
};
|
||||
|
||||
if new != *kind { new.to_predicate(tcx) } else { self }
|
||||
let new = kind.subst(tcx, substs);
|
||||
|
||||
let rebound = if new.has_escaping_bound_vars() {
|
||||
PredicateKint::ForAll(Binder::bind(tcx.intern_predicate_kint(new)))
|
||||
} else {
|
||||
new
|
||||
};
|
||||
|
||||
if rebound != *kind { rebound.to_predicate(tcx) } else { self }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue