Skip to content

Commit e7fa993

Browse files
committed
do not prefer substs relate during coherence
1 parent c86212f commit e7fa993

File tree

1 file changed

+11
-3
lines changed
  • compiler/rustc_trait_selection/src/solve

1 file changed

+11
-3
lines changed

compiler/rustc_trait_selection/src/solve/mod.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,18 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
265265

266266
if let Some(merged) = self.try_merge_responses(&candidates) {
267267
Ok(merged)
268-
} else if let Ok(subst_relate_response) = subst_relate_response {
269-
Ok(subst_relate_response)
270268
} else {
271-
self.flounder(&candidates)
269+
// When relating two aliases and we have ambiguity, we prefer
270+
// relating the generic arguments of the aliases over normalizing
271+
// them. This is necessary for inference during typeck.
272+
//
273+
// As this is incomplete, we must not do so during coherence.
274+
match (self.solver_mode(), subst_relate_response) {
275+
(SolverMode::Normal, Ok(response)) => Ok(response),
276+
(SolverMode::Normal, Err(NoSolution)) | (SolverMode::Coherence, _) => {
277+
self.flounder(&candidates)
278+
}
279+
}
272280
}
273281
}
274282
}

0 commit comments

Comments
 (0)