Skip to content

next solver: prefer to select impl candidates over global where-clause candidates - #162655

Open
dianne wants to merge 1 commit into
rust-lang:mainfrom
dianne:drop-paramenv-candidates
Open

next solver: prefer to select impl candidates over global where-clause candidates#162655
dianne wants to merge 1 commit into
rust-lang:mainfrom
dianne:drop-paramenv-candidates

Conversation

@dianne

@dianne dianne commented Sep 11, 2026

Copy link
Copy Markdown
Member

Fixes #162331

Ideally we'd use a more appropriate typing environment when doing const-eval for const-to-pat, which would also fix that (since the problem clauses wouldn't be present to begin with). Being able to do that seems kind of far off, though, so here's a quick fix that (mostly) matches what the old solver does.

@rustbot rustbot added 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) labels Sep 11, 2026
Comment on lines -96 to +97
// Don't winnow until `Certainty::Yes` -- we don't need to winnow until
// codegen, and only on the good path.
// Don't winnow until `Certainty::Yes` -- we don't need to winnow until constant evaluation or
// codegen.

@dianne dianne Sep 11, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

not totally sure what to do with this comment, but seeing as it was wrong before, I'd like to update it in some way

View changes since the review

Comment on lines +144 to +147
(
CandidateSource::ParamEnv(ParamEnvSource::Global),
CandidateSource::Impl(_) | CandidateSource::BuiltinImpl(_),
) => true,

@dianne dianne Sep 11, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

maybe this could be more aggressive? I'm not sure what else would be needed, so I'm treating this as a targeted fix. so far, I haven't been able to find any examples that would still fail without this if const-to-pat resolved and evaluated consts in a clean environment (e.g. as it does when full gca is enabled)

View changes since the review

Comment on lines +7 to +8
#![feature(const_trait_impl)]
#![feature(const_clone)]

@dianne dianne Sep 11, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this is for testing the preference for builtin impls over global where-clause candidates. I haven't found a way to do that without unstable features

View changes since the review

Comment on lines +2 to +4
//@ revisions: current next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[next] compile-flags: -Znext-solver

@dianne dianne Sep 11, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

could maybe get rid of the current-solver revision but I figured I'd include it as a sanity check

View changes since the review

@dianne

dianne commented Sep 11, 2026

Copy link
Copy Markdown
Member Author

r? @lcnr or reassign

@dianne
dianne marked this pull request as ready for review September 11, 2026 18:54
@rustbot

rustbot commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred to the core trait solver

cc @rust-lang/initiative-trait-system-refactor

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 11, 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. 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.

Can't match on associated const on next-solver

3 participants