-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cleanup candidate_should_be_dropped_in_favor_of
#124592
base: master
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
5b84662
to
2634b4b
Compare
2634b4b
to
7891306
Compare
This comment was marked as outdated.
This comment was marked as outdated.
7891306
to
a0359c8
Compare
@bors try |
cleaning `candidate_should_be_dropped_in_favor_of` and make sure it's actually a partial ordering :< - non-global where-bounds are preferred over impls - impls are preferred over global where-bound - non-global where-bounds and global where-bounds are considered equal The new solver currently does not implement thelowered priority of global `ParamEnv` candidates, so the divergence between it and the old solver in the added tests will be resolved in favor of the old solver behavior after this PR. r? `@compiler-errors`
candidate_should_be_dropped_in_favor_of
candidate_should_be_dropped_in_favor_of
☀️ Try build successful - checks-actions |
@craterbot check |
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
🚧 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
🎉 Experiment
|
Minimizations:
|
@lcnr, I just went through the crater reports of all 47 “unknown” regressions. Some of them were spurious (no space left on device), all of the the remaining ones are type mismatches of the expected kind as well as secondary regressions only (except for redst4r/bustools_cli-rs / bustools_cli-0.2.1) with the primary regression being As discussed, this is ready for an FCP. I will open “incoming breakage” PRs for the relevant crates if/once this PR gets accepted. |
This PR changes the rule to candidate winnowing during selection. We prefer candidates over others, both to guide inference and to avoid ambiguity in case there are multipe applicable candidates. The current preference rules aren't a proper order, making candidate selection order-dependent. The issue arrises for "global This current preference rules are as follows
I propose to change these rules to a proper ordering:
This avoids order-dependence and is easier to support in the next-generation trait solver. The current behavior is also unintuitive. This change adds additional incomplete inference guidance in cases with
With this setup, we previously did not use the impls to drop the global If there were more than 2 or 3 impl candidates, we ended dropping the global rust/compiler/rustc_trait_selection/src/traits/select/mod.rs Lines 498 to 508 in cf2baaa
This causes the following patterns to change behavior
while keeping the behavior of the patterns in
The new solver currently does not implement the lowered priority of global There are multiple existing crates which break due to inference changes, see #124592 (comment). All breakage should be fixable by adding explicit type annotations and we intend to open PRs doing so once this is in FCP. Thank you @fmease for minimizing them. @rfcbot fcp merge |
Team member @lcnr has proposed to merge this. The next step is review by the rest of the tagged team members: Concerns:
Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
is imgui not a relatively significant crate to be breaking? I would expect that to be being used by a lot of projects 🤔 |
I still think we should go ahead with it. The fix to it will be local. I don't mind if we have to keep this regression on nightly for 1 or 2 versions |
@rfcbot concern could we instead prioritize trivial where-bounds over impls without preventing impls in normalization somehow? |
As I've said a few times, I hope that in the new solver we can convert this to more of a "guidance" setup, but regardless we will need some kind of ordering to give that guidance, and in that vein... @rfcbot reviewed ...I think this ordering makes intuitive sense. It would be good to work with the regressions (especially imgui) to ensure they update their where-clauses up front, if that is needed, and/or issue point releases. |
rework winnowing to sensibly handle global where-bounds this is somewhat weird, but it at least allows us to mirror this behavior in the new solver: - trivial builtin-impls - non-global where-bounds, bailing with ambiguity if at least one global where-bound exists - object ☠️ + alias-bound candidates - merge candidates ignoring global where-bounds This is a different approach from rust-lang#124592 which maintains the "if there are global where-bounds, don't guide type inference using non-global where-bounds" behavior, hopefully avoiding the breakage and means we use guidance from non-global where-bounds in fewer, instead of in more cases. r? `@compiler-errors`
and make sure it's actually a partial ordering :< the previous ordering was:
The new solver currently does not implement the lowered priority of global
ParamEnv
candidates, so the divergence between it and the old solver in the added tests will be resolved in favor of the old solver behavior after this PR.r? @compiler-errors