Split some logic from a loop into a separate function
This commit is contained in:
parent
340e708634
commit
14da30e3e6
1 changed files with 27 additions and 18 deletions
|
@ -547,6 +547,16 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
|
||||||
) -> impl Iterator<Item = PredicateObligation<'tcx>> + 'a + Captures<'tcx> {
|
) -> impl Iterator<Item = PredicateObligation<'tcx>> + 'a + Captures<'tcx> {
|
||||||
unsubstituted_region_constraints.iter().map(move |&constraint| {
|
unsubstituted_region_constraints.iter().map(move |&constraint| {
|
||||||
let predicate = substitute_value(self.tcx, result_subst, constraint);
|
let predicate = substitute_value(self.tcx, result_subst, constraint);
|
||||||
|
self.query_outlives_constraint_to_obligation(predicate, cause.clone(), param_env)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn query_outlives_constraint_to_obligation(
|
||||||
|
&self,
|
||||||
|
predicate: QueryOutlivesConstraint<'tcx>,
|
||||||
|
cause: ObligationCause<'tcx>,
|
||||||
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
|
) -> Obligation<'tcx, ty::Predicate<'tcx>> {
|
||||||
let ty::OutlivesPredicate(k1, r2) = predicate.skip_binder();
|
let ty::OutlivesPredicate(k1, r2) = predicate.skip_binder();
|
||||||
|
|
||||||
let atom = match k1.unpack() {
|
let atom = match k1.unpack() {
|
||||||
|
@ -559,13 +569,12 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
|
||||||
GenericArgKind::Const(..) => {
|
GenericArgKind::Const(..) => {
|
||||||
// Consts cannot outlive one another, so we don't expect to
|
// Consts cannot outlive one another, so we don't expect to
|
||||||
// encounter this branch.
|
// encounter this branch.
|
||||||
span_bug!(cause.span, "unexpected const outlives {:?}", constraint);
|
span_bug!(cause.span, "unexpected const outlives {:?}", predicate);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let predicate = predicate.rebind(atom).to_predicate(self.tcx);
|
let predicate = predicate.rebind(atom).to_predicate(self.tcx);
|
||||||
|
|
||||||
Obligation::new(cause.clone(), param_env, predicate)
|
Obligation::new(cause, param_env, predicate)
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Given two sets of values for the same set of canonical variables, unify them.
|
/// Given two sets of values for the same set of canonical variables, unify them.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue