Skip to content

do not prefer trivially true candidates with -Znext-solver - #163928

Open
lcnr wants to merge 1 commit into
rust-lang:mainfrom
lcnr:only-merge-eq-modulo-regions
Open

lcnr wants to merge 1 commit into
rust-lang:mainfrom
lcnr:only-merge-eq-modulo-regions

Conversation

@lcnr

@lcnr lcnr commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

This is for the sake future compatibility, see https://rust-lang.zulipchat.com/#narrow/channel/144729-t-types/topic/resolving.20equal.20regions/near/623504310 for more background. Integrated changes to make this not cause any crater regression, see #133502 (comment) where we did an accidental crater run only for this change.

I would generally like us to not be region dependent at all. For this we need the following:

  • stalled_on shouldn't have to track region variables
  • my hope is that we can yeet region uniquification once we have OR constraints

For this to work candidate merging has to always merge the region constraints of all candidates and can't rely on there being no region constraints. This in turn means that as long as there's an ambiguous candidate, we can't use another candidate which is known to hold, as the ambiguous candidate may end up resulting in fewer region constraints than the existing options.

This change does prevent us from discarding HeadUsages of other where-bounds if one where-bound holds without any constraints. This will cause hangs if we allow using a non-rigid ParamEnv for normalization in rust-lang/trait-system-refactor-initiative#210.

This also has annoying interactions with weakening impl shadowing. I am really unsure about the long-term plan here. We may revert this change in the future because the tradeoff isn't worth it, unsure. By doing it for now we're future compatible with whatever we want to do.

The cycle handling tests are better tested by https://github.com/lcnr/search_graph_fuzz, having subtle cycle handling tests as ui tests is very brittle and very easily stops testing the right thing.

cc rust-lang/trait-system-refactor-initiative#305, see the added test

r? types

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Oct 7, 2026
@lcnr
lcnr force-pushed the only-merge-eq-modulo-regions branch 2 times, most recently from 037ac33 to 06ec1ca Compare October 7, 2026 10:03
@lcnr
lcnr force-pushed the only-merge-eq-modulo-regions branch from 06ec1ca to 0cdc858 Compare October 7, 2026 10:53
@lcnr lcnr changed the title Next-solver do not prefer trivially true candidates do not prefer trivially true candidates with -Znext-solver Oct 7, 2026
Comment thread compiler/rustc_next_trait_solver/src/solve/mod.rs Outdated
@lcnr
lcnr force-pushed the only-merge-eq-modulo-regions branch from 0cdc858 to 232b0ff Compare October 8, 2026 07:31
@rustbot

rustbot commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants