Skip to content

Commit

Permalink
do not prefer substs relate during coherence
Browse files Browse the repository at this point in the history
  • Loading branch information
lcnr committed May 26, 2023
1 parent c86212f commit e7fa993
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions compiler/rustc_trait_selection/src/solve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,18 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {

if let Some(merged) = self.try_merge_responses(&candidates) {
Ok(merged)
} else if let Ok(subst_relate_response) = subst_relate_response {
Ok(subst_relate_response)
} 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)
}
}
}
}
}
Expand Down

0 comments on commit e7fa993

Please sign in to comment.