Skip to content

trait_solver: Preserve concrete candidates in ambiguous ORs - #162442

Open
Dnreikronos wants to merge 8 commits into
rust-lang:mainfrom
Dnreikronos:trait_solver/preserve_binder_or_candidates
Open

trait_solver: Preserve concrete candidates in ambiguous ORs#162442
Dnreikronos wants to merge 8 commits into
rust-lang:mainfrom
Dnreikronos:trait_solver/preserve_binder_or_candidates

Conversation

@Dnreikronos

@Dnreikronos Dnreikronos commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Stacked on #161988. That PR contains the first six commits in this branch, covering reflexive region constraints and the canonicalization needed around them. The only new work here is the final mixed-OR fix. Once #161988 lands, that is all that remains.

propagate_ambiguity used to collapse an entire OR when one alternative was ambiguous. That could throw away a concrete candidate before the root assumptions got a chance to check it. Now ambiguity propagates only when every alternative is ambiguous. A mixed OR keeps its concrete candidates, but still stays ambiguous if none of those candidates can be proved.

I kept the dependency visible because these fixes are related, but they are easier to review separately. The regression test covers both OR orders and the AND case where ambiguity is required. I like this split because it keeps the evaluator from turning a candidate that might work into Ambig just because another branch is unclear.

This is the follow-up Boxy asked to split out in this comment. cc @BoxyUwU

@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. labels Sep 7, 2026
@rustbot

rustbot commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

r? @jieyouxu

rustbot has assigned @jieyouxu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 75 candidates
  • Random selection from 21 candidates

@rust-log-analyzer

This comment has been minimized.

A reflexive `'a: 'a` leaf is always satisfied, so filter it out in
`And::new` instead of pattern matching for it in the places which
happen to build such a constraint. An AND which ends up empty is
trivially true, which makes the OR containing it true.

This is how a reflexive candidate discharges a root type outlives
constraint, so `destructure_type_outlives_constraints_in_root` no
longer has to look at region outlives leaves at all.
@Dnreikronos
Dnreikronos force-pushed the trait_solver/preserve_binder_or_candidates branch from 70b6e52 to da7324e Compare September 7, 2026 18:56
@rustbot

rustbot commented Sep 7, 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.

@jieyouxu

jieyouxu commented Sep 8, 2026

Copy link
Copy Markdown
Member

r? types

@rustbot rustbot added the T-types Relevant to the types team, which will review and decide on the PR/issue. label Sep 8, 2026
@rustbot rustbot assigned lcnr and unassigned jieyouxu Sep 8, 2026
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. T-types Relevant to the types team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants