Skip to content

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

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
dianne:drop-paramenv-candidates
Sep 29, 2026
Merged

rust-bors[bot] merged 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

seems good enough.

select is slightly weird in general rn and will clean this up post next-solver stabilization https://github.com/rust-lang/trait-system-refactor-initiative/blob/main/notes/stabilization-report/proof-tree-visitors.md#select

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

want to split this out into a separate test given that the other one doesn't rely on unstable features?

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.

sounds good to me, yeah

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

@lcnr lcnr left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

single nit, then r=me

thanks for working on this 😊

View changes since this review

@dianne
dianne force-pushed the drop-paramenv-candidates branch from 79010d2 to e10ae86 Compare September 28, 2026 13:26
@dianne
dianne force-pushed the drop-paramenv-candidates branch from e10ae86 to b6d0fb1 Compare September 28, 2026 15:36
@dianne

dianne commented Sep 28, 2026

Copy link
Copy Markdown
Member Author

nit addressed! I needed to come up with new test names and tweak the comments on the split-out test a bit to make up for missing context, but I'm going to assume that's minor enough to @bors r=lcnr

@rust-bors

rust-bors Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

📌 Commit b6d0fb1 has been tentatively approved by lcnr

It will be put into the queue for this repository once PR CI succeeds.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 28, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 28, 2026
…=lcnr

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

Fixes rust-lang#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.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 28, 2026
…=lcnr

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

Fixes rust-lang#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.
rust-bors Bot pushed a commit that referenced this pull request Sep 28, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - #158936 (Add `std::fs::{Home|Media}Dirs`)
 - #129036 (Additional NonZero conversions)
 - #158997 (Avoid recording unnameable `extern crate` aliases in diagnostic metadata)
 - #161015 (Stabilize `funnel_shifts` (including `const`))
 - #161712 (Stabilize `Result::into_{ok,err}`)
 - #162493 (Add support for -Zsanitizer-cfi-minimal-runtime)
 - #162655 (next solver: prefer to select impl candidates over global where-clause candidates)
 - #162862 (Fix intra doc link resolution when a doc comment is composed of both inner and outer doc comment)
 - #163200 (make `RustaceansAreAwesome` satisfy trait bounds)
 - #163331 (Move `Arc` and `Rc` into `rcs` mod)
 - #163427 (implement #![feature(gca_adts)])
 - #163428 (do not complain about unstable target features on nightly)
 - #163444 (Add `stable_rustc` helper in `run-make-support`)
 - #163447 (Allow using different index types when reading and writing to tables)
 - #163450 (Force the correct type variable to never for method resolution on an adjusted never type)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 29, 2026
…=lcnr

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

Fixes rust-lang#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.
rust-bors Bot pushed a commit that referenced this pull request Sep 29, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - #162655 (next solver: prefer to select impl candidates over global where-clause candidates)
 - #162832 (add `Div` and `Mul` for `Complex<{float}>`)
 - #162862 (Fix intra doc link resolution when a doc comment is composed of both inner and outer doc comment)
 - #163024 (Add `Dir` equivalents of `fs::metadata` & `fs::symlink_metadata`)
 - #163200 (make `RustaceansAreAwesome` satisfy trait bounds)
 - #163210 (std: split stack overflow module)
 - #163331 (Move `Arc` and `Rc` into `rcs` mod)
 - #163183 (Add .seek_read_buf_exact() to std::os::windows::fs::FileExt)
 - #163450 (Force the correct type variable to never for method resolution on an adjusted never type)
rust-bors Bot pushed a commit that referenced this pull request Sep 29, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - #158997 (Avoid recording unnameable `extern crate` aliases in diagnostic metadata)
 - #162655 (next solver: prefer to select impl candidates over global where-clause candidates)
 - #162832 (add `Div` and `Mul` for `Complex<{float}>`)
 - #162862 (Fix intra doc link resolution when a doc comment is composed of both inner and outer doc comment)
 - #163200 (make `RustaceansAreAwesome` satisfy trait bounds)
 - #163210 (std: split stack overflow module)
 - #163331 (Move `Arc` and `Rc` into `rcs` mod)
 - #163183 (Add .seek_read_buf_exact() to std::os::windows::fs::FileExt)
 - #163450 (Force the correct type variable to never for method resolution on an adjusted never type)
@rust-bors
rust-bors Bot merged commit 31ee28f into rust-lang:main Sep 29, 2026
13 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Sep 29, 2026
rust-bors Bot pushed a commit that referenced this pull request Sep 29, 2026
Rollup merge of #162655 - dianne:drop-paramenv-candidates, r=lcnr

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

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.
@dianne
dianne deleted the drop-paramenv-candidates branch September 29, 2026 12:32
pull Bot pushed a commit to LeeeeeeM/miri that referenced this pull request Sep 30, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#158997 (Avoid recording unnameable `extern crate` aliases in diagnostic metadata)
 - rust-lang/rust#162655 (next solver: prefer to select impl candidates over global where-clause candidates)
 - rust-lang/rust#162832 (add `Div` and `Mul` for `Complex<{float}>`)
 - rust-lang/rust#162862 (Fix intra doc link resolution when a doc comment is composed of both inner and outer doc comment)
 - rust-lang/rust#163200 (make `RustaceansAreAwesome` satisfy trait bounds)
 - rust-lang/rust#163210 (std: split stack overflow module)
 - rust-lang/rust#163331 (Move `Arc` and `Rc` into `rcs` mod)
 - rust-lang/rust#163183 (Add .seek_read_buf_exact() to std::os::windows::fs::FileExt)
 - rust-lang/rust#163450 (Force the correct type variable to never for method resolution on an adjusted never type)
bjorn3 pushed a commit to rust-lang/rustc_codegen_cranelift that referenced this pull request Sep 30, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#158997 (Avoid recording unnameable `extern crate` aliases in diagnostic metadata)
 - rust-lang/rust#162655 (next solver: prefer to select impl candidates over global where-clause candidates)
 - rust-lang/rust#162832 (add `Div` and `Mul` for `Complex<{float}>`)
 - rust-lang/rust#162862 (Fix intra doc link resolution when a doc comment is composed of both inner and outer doc comment)
 - rust-lang/rust#163200 (make `RustaceansAreAwesome` satisfy trait bounds)
 - rust-lang/rust#163210 (std: split stack overflow module)
 - rust-lang/rust#163331 (Move `Arc` and `Rc` into `rcs` mod)
 - rust-lang/rust#163183 (Add .seek_read_buf_exact() to std::os::windows::fs::FileExt)
 - rust-lang/rust#163450 (Force the correct type variable to never for method resolution on an adjusted never type)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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