Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of subst-relate incompleteness in new solver #113901

Merged
merged 1 commit into from
Jul 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions compiler/rustc_trait_selection/src/solve/alias_relate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,27 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
Invert::Yes,
));
// Relate via args
let subst_relate_response = self
.assemble_subst_relate_candidate(param_env, alias_lhs, alias_rhs, direction);
candidates.extend(subst_relate_response);
candidates.extend(
self.assemble_subst_relate_candidate(
param_env, alias_lhs, alias_rhs, direction,
),
);
debug!(?candidates);

if let Some(merged) = self.try_merge_responses(&candidates) {
Ok(merged)
} else {
// 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.
// When relating two aliases and we have ambiguity, if both
// aliases can be normalized to something, we prefer
// "bidirectionally normalizing" both of them within the same
// candidate.
//
// See <https://github.com/rust-lang/trait-system-refactor-initiative/issues/25>.
//
// As this is incomplete, we must not do so during coherence.
match self.solver_mode() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment is wrong, please also link to rust-lang/trait-system-refactor-initiative#25

SolverMode::Normal => {
if let Ok(subst_relate_response) = subst_relate_response {
Ok(subst_relate_response)
} else if let Ok(bidirectional_normalizes_to_response) = self
if let Ok(bidirectional_normalizes_to_response) = self
.assemble_bidirectional_normalizes_to_candidate(
param_env, lhs, rhs, direction,
)
Expand Down
Loading