diff options
| author | Michael Goulet <michael@errs.io> | 2024-06-12 11:15:57 -0400 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-06-13 08:52:35 -0400 |
| commit | 93ee07c75603ad5492cf789eee89fd61ecc9d3ad (patch) | |
| tree | d3ef2bb519d125c5b39fad79ade30a7be3ef1d5a /compiler/rustc_trait_selection/src/solve | |
| parent | 921645c737f1d6d107a0a10ca5ee129d364dcd7a (diff) | |
| download | rust-93ee07c75603ad5492cf789eee89fd61ecc9d3ad.tar.gz rust-93ee07c75603ad5492cf789eee89fd61ecc9d3ad.zip | |
Check that alias-relate terms are WF if reporting an error in alias-relate
Diffstat (limited to 'compiler/rustc_trait_selection/src/solve')
| -rw-r--r-- | compiler/rustc_trait_selection/src/solve/fulfill.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/fulfill.rs b/compiler/rustc_trait_selection/src/solve/fulfill.rs index 3c3d5dfe79c..519a24f6975 100644 --- a/compiler/rustc_trait_selection/src/solve/fulfill.rs +++ b/compiler/rustc_trait_selection/src/solve/fulfill.rs @@ -515,6 +515,30 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> { self.with_derived_obligation(obligation, |this| nested_goal.visit_with(this))?; } + // alias-relate may fail because the lhs or rhs can't be normalized, + // and therefore is treated as rigid. + if let Some(ty::PredicateKind::AliasRelate(lhs, rhs, _)) = pred_kind.no_bound_vars() { + if let Some(obligation) = goal + .infcx() + .visit_proof_tree( + goal.goal().with(goal.infcx().tcx, ty::ClauseKind::WellFormed(lhs.into())), + self, + ) + .break_value() + { + return ControlFlow::Break(obligation); + } else if let Some(obligation) = goal + .infcx() + .visit_proof_tree( + goal.goal().with(goal.infcx().tcx, ty::ClauseKind::WellFormed(rhs.into())), + self, + ) + .break_value() + { + return ControlFlow::Break(obligation); + } + } + ControlFlow::Break(self.obligation.clone()) } } |
