Skip to content

Commit 8f4b81b

Browse files
authored
Rollup merge of #113901 - compiler-errors:only-bidi-norm, r=lcnr
Get rid of subst-relate incompleteness in new solver We shouldn't need subst-relate if we have bidirectional-normalizes-to in the new solver. The only potential issue may happen if we have an unconstrained projection like `<Wrapper<?0> as Trait>::Assoc == <Wrapper<T> as Trait>::Assoc` where they both normalize to something that doesn't mention any substs, which would possibly prefer `?0 = T` if we fall back to subst-relate. But I'd prefer if we remove incompleteness until we can determine some case where we need them, and the bidirectional-normalizes-to seems better to have in general. I can update rust-lang/trait-system-refactor-initiative#26 and rust-lang/trait-system-refactor-initiative#25 once this lands. r? `@lcnr`
2 parents 0ed5f09 + e320112 commit 8f4b81b

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

compiler/rustc_trait_selection/src/solve/alias_relate.rs

+12-9
Original file line numberDiff line numberDiff line change
@@ -66,24 +66,27 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
6666
Invert::Yes,
6767
));
6868
// Relate via args
69-
let subst_relate_response = self
70-
.assemble_subst_relate_candidate(param_env, alias_lhs, alias_rhs, direction);
71-
candidates.extend(subst_relate_response);
69+
candidates.extend(
70+
self.assemble_subst_relate_candidate(
71+
param_env, alias_lhs, alias_rhs, direction,
72+
),
73+
);
7274
debug!(?candidates);
7375

7476
if let Some(merged) = self.try_merge_responses(&candidates) {
7577
Ok(merged)
7678
} else {
77-
// When relating two aliases and we have ambiguity, we prefer
78-
// relating the generic arguments of the aliases over normalizing
79-
// them. This is necessary for inference during typeck.
79+
// When relating two aliases and we have ambiguity, if both
80+
// aliases can be normalized to something, we prefer
81+
// "bidirectionally normalizing" both of them within the same
82+
// candidate.
83+
//
84+
// See <https://github.com/rust-lang/trait-system-refactor-initiative/issues/25>.
8085
//
8186
// As this is incomplete, we must not do so during coherence.
8287
match self.solver_mode() {
8388
SolverMode::Normal => {
84-
if let Ok(subst_relate_response) = subst_relate_response {
85-
Ok(subst_relate_response)
86-
} else if let Ok(bidirectional_normalizes_to_response) = self
89+
if let Ok(bidirectional_normalizes_to_response) = self
8790
.assemble_bidirectional_normalizes_to_candidate(
8891
param_env, lhs, rhs, direction,
8992
)

0 commit comments

Comments
 (0)