elaborate
This commit is contained in:
parent
7f39b0c9ab
commit
4c3b1e89cf
@ -151,14 +151,22 @@ impl Elaborator<'tcx> {
|
|||||||
|
|
||||||
fn elaborate(&mut self, obligation: &PredicateObligation<'tcx>) {
|
fn elaborate(&mut self, obligation: &PredicateObligation<'tcx>) {
|
||||||
let tcx = self.visited.tcx;
|
let tcx = self.visited.tcx;
|
||||||
match obligation.predicate.kind() {
|
let pred = match obligation.predicate.kint(tcx) {
|
||||||
ty::PredicateKind::Trait(ref data, _) => {
|
// We have to be careful and rebind this whenever
|
||||||
|
// dealing with a predicate further down.
|
||||||
|
ty::PredicateKint::ForAll(binder) => binder.skip_binder(),
|
||||||
|
pred => pred,
|
||||||
|
};
|
||||||
|
|
||||||
|
match pred {
|
||||||
|
ty::PredicateKint::ForAll(_) => bug!("unexpected predicate: {:?}", pred),
|
||||||
|
ty::PredicateKint::Trait(ref data, _) => {
|
||||||
// Get predicates declared on the trait.
|
// Get predicates declared on the trait.
|
||||||
let predicates = tcx.super_predicates_of(data.def_id());
|
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(
|
predicate_obligation(
|
||||||
pred.subst_supertrait(tcx, &data.to_poly_trait_ref()),
|
pred.subst_supertrait(tcx, &ty::Binder::bind(data.trait_ref)),
|
||||||
Some(span),
|
Some(span),
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
@ -173,36 +181,36 @@ impl Elaborator<'tcx> {
|
|||||||
|
|
||||||
self.stack.extend(obligations);
|
self.stack.extend(obligations);
|
||||||
}
|
}
|
||||||
ty::PredicateKind::WellFormed(..) => {
|
ty::PredicateKint::WellFormed(..) => {
|
||||||
// Currently, we do not elaborate WF predicates,
|
// Currently, we do not elaborate WF predicates,
|
||||||
// although we easily could.
|
// although we easily could.
|
||||||
}
|
}
|
||||||
ty::PredicateKind::ObjectSafe(..) => {
|
ty::PredicateKint::ObjectSafe(..) => {
|
||||||
// Currently, we do not elaborate object-safe
|
// Currently, we do not elaborate object-safe
|
||||||
// predicates.
|
// predicates.
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Subtype(..) => {
|
ty::PredicateKint::Subtype(..) => {
|
||||||
// Currently, we do not "elaborate" predicates like `X <: Y`,
|
// Currently, we do not "elaborate" predicates like `X <: Y`,
|
||||||
// though conceivably we might.
|
// though conceivably we might.
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Projection(..) => {
|
ty::PredicateKint::Projection(..) => {
|
||||||
// Nothing to elaborate in a projection predicate.
|
// Nothing to elaborate in a projection predicate.
|
||||||
}
|
}
|
||||||
ty::PredicateKind::ClosureKind(..) => {
|
ty::PredicateKint::ClosureKind(..) => {
|
||||||
// Nothing to elaborate when waiting for a closure's kind to be inferred.
|
// Nothing to elaborate when waiting for a closure's kind to be inferred.
|
||||||
}
|
}
|
||||||
ty::PredicateKind::ConstEvaluatable(..) => {
|
ty::PredicateKint::ConstEvaluatable(..) => {
|
||||||
// Currently, we do not elaborate const-evaluatable
|
// Currently, we do not elaborate const-evaluatable
|
||||||
// predicates.
|
// predicates.
|
||||||
}
|
}
|
||||||
ty::PredicateKind::ConstEquate(..) => {
|
ty::PredicateKint::ConstEquate(..) => {
|
||||||
// Currently, we do not elaborate const-equate
|
// Currently, we do not elaborate const-equate
|
||||||
// predicates.
|
// predicates.
|
||||||
}
|
}
|
||||||
ty::PredicateKind::RegionOutlives(..) => {
|
ty::PredicateKint::RegionOutlives(..) => {
|
||||||
// Nothing to elaborate from `'a: 'b`.
|
// Nothing to elaborate from `'a: 'b`.
|
||||||
}
|
}
|
||||||
ty::PredicateKind::TypeOutlives(ref data) => {
|
ty::PredicateKint::TypeOutlives(ty::OutlivesPredicate(ty_max, r_min)) => {
|
||||||
// We know that `T: 'a` for some type `T`. We can
|
// We know that `T: 'a` for some type `T`. We can
|
||||||
// often elaborate this. For example, if we know that
|
// often elaborate this. For example, if we know that
|
||||||
// `[U]: 'a`, that implies that `U: 'a`. Similarly, if
|
// `[U]: 'a`, that implies that `U: 'a`. Similarly, if
|
||||||
@ -217,8 +225,6 @@ impl Elaborator<'tcx> {
|
|||||||
// consider this as evidence that `T: 'static`, but
|
// consider this as evidence that `T: 'static`, but
|
||||||
// I'm a bit wary of such constructions and so for now
|
// I'm a bit wary of such constructions and so for now
|
||||||
// I want to be conservative. --nmatsakis
|
// I want to be conservative. --nmatsakis
|
||||||
let ty_max = data.skip_binder().0;
|
|
||||||
let r_min = data.skip_binder().1;
|
|
||||||
if r_min.is_late_bound() {
|
if r_min.is_late_bound() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -397,7 +397,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
|||||||
self.out.push(traits::Obligation::new(
|
self.out.push(traits::Obligation::new(
|
||||||
cause,
|
cause,
|
||||||
self.param_env,
|
self.param_env,
|
||||||
ty::PredicateKind::WellFormed(resolved_constant.into())
|
ty::PredicateKint::WellFormed(resolved_constant.into())
|
||||||
.to_predicate(self.tcx()),
|
.to_predicate(self.tcx()),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -483,10 +483,8 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
|||||||
self.out.push(traits::Obligation::new(
|
self.out.push(traits::Obligation::new(
|
||||||
cause,
|
cause,
|
||||||
param_env,
|
param_env,
|
||||||
ty::PredicateKind::TypeOutlives(ty::Binder::dummy(
|
ty::PredicateKint::TypeOutlives(ty::OutlivesPredicate(rty, r))
|
||||||
ty::OutlivesPredicate(rty, r),
|
.to_predicate(self.tcx()),
|
||||||
))
|
|
||||||
.to_predicate(self.tcx()),
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user