Skip to content

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

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

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

This comment has been minimized.


if let Some((i, candidate)) = always_applicable {
return Some((candidate.result, MergeCandidateInfo::AlwaysApplicable(i)));
if rest.iter().any(|candidate| {

@BoxyUwU BoxyUwU Oct 12, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

comment about what the behaviour of this fn is supposed to be, rn its kinda hard to figure it out imo

View changes since the review

}
}

fn response_only_references_shared_vars_outside_of_region_constraints<I: Interner>(

@BoxyUwU BoxyUwU Oct 12, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i dont understand the mental model behind what ur doing here xd slash in general somewhat confused by the concept of comparing canonical responses with different vars

that combined with it apparently just being wrong in the presence of opaque types and nested goals?

View changes since the review

@BoxyUwU

BoxyUwU commented Oct 12, 2026

Copy link
Copy Markdown
Member

r? me

@rust-bors

This comment has been minimized.

@lcnr
lcnr force-pushed the only-merge-eq-modulo-regions branch from 232b0ff to df707e1 Compare October 13, 2026 10:49
@rustbot

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

@rustbot

rustbot commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

⚠️ Warning ⚠️

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job test-tidy failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
fmt: checked 7357 files
tidy check
x.py completions check
tidy [rustdoc_json (src)]: `rustdoc-json-types` modified, checking format version
tidy [gcc_submodule]: Commit SHA of the src/gcc submodule (`c86ad8032df732309fe949ea68da1874fbb76f5c`) does not match the required GCC version of the GCC codegen backend (`37ea7cd851f04ee6a313c5067c9fde9328f876aa`).
Make sure to set the src/gcc submodule to commit 37ea7cd851f04ee6a313c5067c9fde9328f876aa.
The GCC codegen backend commit is configured at /checkout/compiler/rustc_codegen_gcc/libgccjit.version.
tidy [gcc_submodule]: FAIL
tidy: Skipping binary file check, read-only filesystem
removing old virtual environment
creating virtual environment at '/checkout/obj/build/venv' using 'python3.12' and 'venv'
Requirement already satisfied: pip in ./build/venv/lib/python3.12/site-packages (24.0)
---
typechecking javascript files
tidy: The following check failed: gcc_submodule
Bootstrap failed while executing `test src/tools/tidy tidyselftest --extra-checks=py,cpp,js,spellcheck`
Currently active steps:
test::Tidy {  } at src/bootstrap/src/core/build_steps/test.rs:1743
Command `/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools-bin/rust-tidy --root-path=/checkout --cargo-path=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo --output-dir=/checkout/obj/build --concurrency=4 --npm-path=/node/bin/yarn --ci=true --extra-checks=py,cpp,js,spellcheck` failed with exit code 1
Created at: src/bootstrap/src/core/build_steps/tool.rs:1627:23
Executed at: src/bootstrap/src/core/build_steps/test.rs:1828:24

Command has failed. Rerun with -v to see more details.
Build completed unsuccessfully in 0:01:58
  local time: Tue Oct 13 10:56:28 UTC 2026
  network time: Tue, 13 Oct 2026 10:56:28 GMT
##[error]Process completed with exit code 1.
##[group]Run echo "disk usage:"

@lcnr

lcnr commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

gonna try instead actually instantiating the canonical response and recanonicalizing modulo region constraints which is more trivially correct

@lcnr
lcnr marked this pull request as draft October 13, 2026 11:21
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 13, 2026

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-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

6 participants