Rollup merge of #111987 - lcnr:alias-relate-coherence, r=BoxyUwU
do not prefer substs relate during coherence r? ```@compiler-errors```
This commit is contained in:
commit
dfdbf1b133
1 changed files with 25 additions and 9 deletions
|
@ -231,13 +231,21 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
let mut candidates = Vec::new();
|
let mut candidates = Vec::new();
|
||||||
// LHS normalizes-to RHS
|
// LHS normalizes-to RHS
|
||||||
candidates.extend(
|
candidates.extend(evaluate_normalizes_to(
|
||||||
evaluate_normalizes_to(self, alias_lhs, rhs, direction, Invert::No).ok(),
|
self,
|
||||||
);
|
alias_lhs,
|
||||||
|
rhs,
|
||||||
|
direction,
|
||||||
|
Invert::No,
|
||||||
|
));
|
||||||
// RHS normalizes-to RHS
|
// RHS normalizes-to RHS
|
||||||
candidates.extend(
|
candidates.extend(evaluate_normalizes_to(
|
||||||
evaluate_normalizes_to(self, alias_rhs, lhs, direction, Invert::Yes).ok(),
|
self,
|
||||||
);
|
alias_rhs,
|
||||||
|
lhs,
|
||||||
|
direction,
|
||||||
|
Invert::Yes,
|
||||||
|
));
|
||||||
// Relate via substs
|
// Relate via substs
|
||||||
let subst_relate_response = self.probe(|ecx| {
|
let subst_relate_response = self.probe(|ecx| {
|
||||||
let span = tracing::span!(
|
let span = tracing::span!(
|
||||||
|
@ -265,10 +273,18 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
if let Some(merged) = self.try_merge_responses(&candidates) {
|
if let Some(merged) = self.try_merge_responses(&candidates) {
|
||||||
Ok(merged)
|
Ok(merged)
|
||||||
} else if let Ok(subst_relate_response) = subst_relate_response {
|
|
||||||
Ok(subst_relate_response)
|
|
||||||
} else {
|
} else {
|
||||||
self.flounder(&candidates)
|
// When relating two aliases and we have ambiguity, we prefer
|
||||||
|
// relating the generic arguments of the aliases over normalizing
|
||||||
|
// them. This is necessary for inference during typeck.
|
||||||
|
//
|
||||||
|
// As this is incomplete, we must not do so during coherence.
|
||||||
|
match (self.solver_mode(), subst_relate_response) {
|
||||||
|
(SolverMode::Normal, Ok(response)) => Ok(response),
|
||||||
|
(SolverMode::Normal, Err(NoSolution)) | (SolverMode::Coherence, _) => {
|
||||||
|
self.flounder(&candidates)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue