Simplify
This commit is contained in:
parent
69b3959afe
commit
62d5fb85ac
1 changed files with 22 additions and 30 deletions
|
@ -388,7 +388,8 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
|
||||||
(true, Ok(Certainty::Maybe(MaybeCause::Ambiguity))) | (false, Err(_)) => {}
|
(true, Ok(Certainty::Maybe(MaybeCause::Ambiguity))) | (false, Err(_)) => {}
|
||||||
_ => return ControlFlow::Continue(()),
|
_ => return ControlFlow::Continue(()),
|
||||||
}
|
}
|
||||||
let pred_kind = goal.goal().predicate.kind();
|
|
||||||
|
let pred = goal.goal().predicate;
|
||||||
|
|
||||||
let candidates = self.non_trivial_candidates(goal);
|
let candidates = self.non_trivial_candidates(goal);
|
||||||
let candidate = match candidates.as_slice() {
|
let candidate = match candidates.as_slice() {
|
||||||
|
@ -410,12 +411,12 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
|
||||||
|
|
||||||
// FIXME: Also, what about considering >1 layer up the stack? May be necessary
|
// FIXME: Also, what about considering >1 layer up the stack? May be necessary
|
||||||
// for normalizes-to.
|
// for normalizes-to.
|
||||||
let child_mode = match pred_kind.skip_binder() {
|
let child_mode = match pred.kind().skip_binder() {
|
||||||
ty::PredicateKind::Clause(ty::ClauseKind::Trait(pred)) => {
|
ty::PredicateKind::Clause(ty::ClauseKind::Trait(trait_pred)) => {
|
||||||
ChildMode::Trait(pred_kind.rebind(pred))
|
ChildMode::Trait(pred.kind().rebind(trait_pred))
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(pred)) => {
|
ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(host_pred)) => {
|
||||||
ChildMode::Host(pred_kind.rebind(pred))
|
ChildMode::Host(pred.kind().rebind(host_pred))
|
||||||
}
|
}
|
||||||
ty::PredicateKind::NormalizesTo(normalizes_to)
|
ty::PredicateKind::NormalizesTo(normalizes_to)
|
||||||
if matches!(
|
if matches!(
|
||||||
|
@ -423,7 +424,7 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
|
||||||
ty::AliasTermKind::ProjectionTy | ty::AliasTermKind::ProjectionConst
|
ty::AliasTermKind::ProjectionTy | ty::AliasTermKind::ProjectionConst
|
||||||
) =>
|
) =>
|
||||||
{
|
{
|
||||||
ChildMode::Trait(pred_kind.rebind(ty::TraitPredicate {
|
ChildMode::Trait(pred.kind().rebind(ty::TraitPredicate {
|
||||||
trait_ref: normalizes_to.alias.trait_ref(tcx),
|
trait_ref: normalizes_to.alias.trait_ref(tcx),
|
||||||
polarity: ty::PredicatePolarity::Positive,
|
polarity: ty::PredicatePolarity::Positive,
|
||||||
}))
|
}))
|
||||||
|
@ -457,10 +458,12 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
|
||||||
for nested_goal in nested_goals {
|
for nested_goal in nested_goals {
|
||||||
trace!(nested_goal = ?(nested_goal.goal(), nested_goal.source(), nested_goal.result()));
|
trace!(nested_goal = ?(nested_goal.goal(), nested_goal.source(), nested_goal.result()));
|
||||||
|
|
||||||
|
let nested_pred = nested_goal.goal().predicate;
|
||||||
|
|
||||||
let make_obligation = |cause| Obligation {
|
let make_obligation = |cause| Obligation {
|
||||||
cause,
|
cause,
|
||||||
param_env: nested_goal.goal().param_env,
|
param_env: nested_goal.goal().param_env,
|
||||||
predicate: nested_goal.goal().predicate,
|
predicate: nested_pred,
|
||||||
recursion_depth: self.obligation.recursion_depth + 1,
|
recursion_depth: self.obligation.recursion_depth + 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -510,28 +513,17 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
|
||||||
|
|
||||||
// alias-relate may fail because the lhs or rhs can't be normalized,
|
// alias-relate may fail because the lhs or rhs can't be normalized,
|
||||||
// and therefore is treated as rigid.
|
// and therefore is treated as rigid.
|
||||||
if let Some(ty::PredicateKind::AliasRelate(lhs, rhs, _)) = pred_kind.no_bound_vars() {
|
if let Some(ty::PredicateKind::AliasRelate(lhs, rhs, _)) = pred.kind().no_bound_vars() {
|
||||||
if let Some(obligation) = goal
|
goal.infcx().visit_proof_tree_at_depth(
|
||||||
.infcx()
|
|
||||||
.visit_proof_tree_at_depth(
|
|
||||||
goal.goal().with(tcx, ty::ClauseKind::WellFormed(lhs.into())),
|
goal.goal().with(tcx, ty::ClauseKind::WellFormed(lhs.into())),
|
||||||
goal.depth() + 1,
|
goal.depth() + 1,
|
||||||
self,
|
self,
|
||||||
)
|
)?;
|
||||||
.break_value()
|
goal.infcx().visit_proof_tree_at_depth(
|
||||||
{
|
|
||||||
return ControlFlow::Break(obligation);
|
|
||||||
} else if let Some(obligation) = goal
|
|
||||||
.infcx()
|
|
||||||
.visit_proof_tree_at_depth(
|
|
||||||
goal.goal().with(tcx, ty::ClauseKind::WellFormed(rhs.into())),
|
goal.goal().with(tcx, ty::ClauseKind::WellFormed(rhs.into())),
|
||||||
goal.depth() + 1,
|
goal.depth() + 1,
|
||||||
self,
|
self,
|
||||||
)
|
)?;
|
||||||
.break_value()
|
|
||||||
{
|
|
||||||
return ControlFlow::Break(obligation);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.detect_error_in_higher_ranked_projection(goal)?;
|
self.detect_error_in_higher_ranked_projection(goal)?;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue